Skip to content

Commit ea1d316

Browse files
committed
Web socket messages when nodes are copied
1 parent 6219fba commit ea1d316

File tree

6 files changed

+124
-202
lines changed

6 files changed

+124
-202
lines changed

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/SaveAndRestoreController.java

Lines changed: 11 additions & 59 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,7 @@ public class SaveAndRestoreController extends SaveAndRestoreBaseController
186186
@FXML
187187
private VBox errorPane;
188188

189+
@SuppressWarnings("unused")
189190
@FXML
190191
private Label webSocketTrackerLabel;
191192

@@ -207,14 +208,10 @@ public class SaveAndRestoreController extends SaveAndRestoreBaseController
207208
List<MenuItem> menuItems = Arrays.asList(
208209
new LoginMenuItem(this, selectedItemsProperty,
209210
() -> ApplicationService.createInstance("credentials_management")),
210-
new NewFolderMenuItem(this, selectedItemsProperty,
211-
() -> createNewFolder()),
212-
new NewConfigurationMenuItem(this, selectedItemsProperty,
213-
() -> createNewConfiguration()),
214-
new CreateSnapshotMenuItem(this, selectedItemsProperty,
215-
() -> openConfigurationForSnapshot()),
216-
new NewCompositeSnapshotMenuItem(this, selectedItemsProperty,
217-
() -> createNewCompositeSnapshot()),
211+
new NewFolderMenuItem(this, selectedItemsProperty, this::createNewFolder),
212+
new NewConfigurationMenuItem(this, selectedItemsProperty, this::createNewConfiguration),
213+
new CreateSnapshotMenuItem(this, selectedItemsProperty, this::openConfigurationForSnapshot),
214+
new NewCompositeSnapshotMenuItem(this, selectedItemsProperty, this::createNewCompositeSnapshot),
218215
new RestoreFromClientMenuItem(this, selectedItemsProperty,
219216
() -> {
220217
disabledUi.set(true);
@@ -226,8 +223,8 @@ public class SaveAndRestoreController extends SaveAndRestoreBaseController
226223
RestoreUtil.restore(RestoreMode.SERVICE_RESTORE, saveAndRestoreService, selectedItemsProperty.get(0), () -> disabledUi.set(false));
227224
}),
228225
new SeparatorMenuItem(),
229-
new EditCompositeMenuItem(this, selectedItemsProperty, () -> editCompositeSnapshot()),
230-
new RenameFolderMenuItem(this, selectedItemsProperty, () -> renameNode()),
226+
new EditCompositeMenuItem(this, selectedItemsProperty, this::editCompositeSnapshot),
227+
new RenameFolderMenuItem(this, selectedItemsProperty, this::renameNode),
231228
copyMenuItem,
232229
pasteMenuItem,
233230
deleteNodeMenuItem,
@@ -236,11 +233,10 @@ public class SaveAndRestoreController extends SaveAndRestoreBaseController
236233
new TagGoldenMenuItem(this, selectedItemsProperty),
237234
tagWithComment,
238235
new SeparatorMenuItem(),
239-
new CopyUniqueIdToClipboardMenuItem(this, selectedItemsProperty,
240-
() -> copyUniqueNodeIdToClipboard()),
236+
new CopyUniqueIdToClipboardMenuItem(this, selectedItemsProperty, this::copyUniqueNodeIdToClipboard),
241237
new SeparatorMenuItem(),
242-
new ImportFromCSVMenuItem(this, selectedItemsProperty, () -> importFromCSV()),
243-
new ExportToCSVMenuItem(this, selectedItemsProperty, () -> exportToCSV())
238+
new ImportFromCSVMenuItem(this, selectedItemsProperty, this::importFromCSV),
239+
new ExportToCSVMenuItem(this, selectedItemsProperty, this::exportToCSV)
244240
);
245241

246242
private final SimpleStringProperty webSocketTrackerText = new SimpleStringProperty();
@@ -1041,45 +1037,6 @@ protected void moveNodes(List<Node> sourceNodes, Node targetNode, TransferMode t
10411037
});
10421038
}
10431039

1044-
/**
1045-
* Updates the tree view such that moved items are shown in the drop target.
1046-
*
1047-
* @param parentTreeItem The drop target
1048-
* @param nodes List of {@link Node}s that were moved.
1049-
*/
1050-
private void addMovedNodes(TreeItem<Node> parentTreeItem, List<Node> nodes) {
1051-
parentTreeItem.getChildren().addAll(nodes.stream().map(this::createTreeItem).toList());
1052-
parentTreeItem.getChildren().sort(treeNodeComparator);
1053-
TreeItem<Node> nextItemToExpand = parentTreeItem;
1054-
while (nextItemToExpand != null) {
1055-
nextItemToExpand.setExpanded(true);
1056-
nextItemToExpand = nextItemToExpand.getParent();
1057-
}
1058-
1059-
}
1060-
1061-
/**
1062-
* Updates the tree view such that moved items are removed from source nodes' parent.
1063-
*
1064-
* @param parentTreeItem The parent of the {@link Node}s before the move.
1065-
* @param nodes List of {@link Node}s that were moved.
1066-
*/
1067-
private void removeMovedNodes(TreeItem<Node> parentTreeItem, List<Node> nodes) {
1068-
List<TreeItem<Node>> childItems = parentTreeItem.getChildren();
1069-
List<TreeItem<Node>> treeItemsToRemove = new ArrayList<>();
1070-
childItems.forEach(childItem -> {
1071-
if (nodes.contains(childItem.getValue())) {
1072-
treeItemsToRemove.add(childItem);
1073-
}
1074-
});
1075-
parentTreeItem.getChildren().removeAll(treeItemsToRemove);
1076-
TreeItem<Node> nextItemToExpand = parentTreeItem;
1077-
while (nextItemToExpand != null) {
1078-
nextItemToExpand.setExpanded(true);
1079-
nextItemToExpand = nextItemToExpand.getParent();
1080-
}
1081-
}
1082-
10831040
/**
10841041
* Parses the {@link URI} to determine what to do. Supported actions/behavior:
10851042
* <ul>
@@ -1316,20 +1273,15 @@ private void pasteFromClipboard() {
13161273
}
13171274
List<String> selectedNodeIds =
13181275
((List<Node>) selectedNodes).stream().map(Node::getUniqueId).collect(Collectors.toList());
1319-
JobManager.schedule("copy nodes", monitor -> {
1276+
JobManager.schedule("Copy odes", monitor -> {
13201277
try {
13211278
saveAndRestoreService.copyNodes(selectedNodeIds, browserSelectionModel.getSelectedItem().getValue().getUniqueId());
13221279
disabledUi.set(false);
13231280
} catch (Exception e) {
13241281
disabledUi.set(false);
13251282
ExceptionDetailsErrorDialog.openError(Messages.errorGeneric, Messages.failedToPasteObjects, e);
13261283
LOG.log(Level.WARNING, "Failed to paste nodes into target " + browserSelectionModel.getSelectedItem().getValue().getName());
1327-
return;
13281284
}
1329-
Platform.runLater(() -> {
1330-
expandTreeNode(browserSelectionModel.getSelectedItem());
1331-
treeView.refresh();
1332-
});
13331285
});
13341286
}
13351287

services/save-and-restore/src/main/java/org/phoebus/service/saveandrestore/persistence/dao/NodeDAO.java

Lines changed: 21 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,7 @@
3232
import org.phoebus.applications.saveandrestore.model.search.SearchResult;
3333
import org.springframework.util.MultiValueMap;
3434

35-
import java.util.HashMap;
36-
import java.util.HashSet;
3735
import java.util.List;
38-
import java.util.Set;
3936

4037
/**
4138
* @author georgweiss Created 11 Mar 2019
@@ -60,6 +57,7 @@ public interface NodeDAO {
6057

6158
/**
6259
* Retrieve the nodes identified by the list of unique node ids
60+
*
6361
* @param uniqueNodeIds List of unique node ids
6462
* @return List of matching nodes
6563
*/
@@ -75,8 +73,8 @@ public interface NodeDAO {
7573
/**
7674
* Checks that each of the node ids passed to this method exist, and that none of them
7775
* is the root node. If check passes all nodes are deleted.
76+
*
7877
* @param nodeIds List of (existing) node ids.
79-
* @return The collection of unique node id representing the deleted
8078
* {@link Node}s. Client may use this to trigger a refresh of the UI.
8179
*/
8280
void deleteNodes(List<String> nodeIds);
@@ -92,7 +90,6 @@ public interface NodeDAO {
9290

9391

9492
/**
95-
*
9693
* @param uniqueNodeId Valid {@link Node} id.
9794
* @return The parent {@link Node}
9895
*/
@@ -114,9 +111,9 @@ public interface NodeDAO {
114111
* @param nodeIds Non-null and non-empty list of unique node ids subject to move
115112
* @param targetId Non-null and non-empty unique id of target node
116113
* @param userName The (account) name of the user performing the operation.
117-
* @return The target {@link Node} object that is the new parent of the moved source {@link Node}
114+
* @return A list of new {@link Node}s
118115
*/
119-
Node copyNodes(List<String> nodeIds, String targetId, String userName);
116+
List<Node> copyNodes(List<String> nodeIds, String targetId, String userName);
120117

121118

122119
/**
@@ -139,8 +136,9 @@ public interface NodeDAO {
139136

140137
/**
141138
* Saves the {@link org.phoebus.applications.saveandrestore.model.Snapshot} to the persistence layer.
139+
*
142140
* @param parentNodeId The unique id of the parent {@link Node} for the new {@link Snapshot}.
143-
* @param snapshot The {@link Snapshot} data.
141+
* @param snapshot The {@link Snapshot} data.
144142
* @return The persisted {@link Snapshot} data.
145143
*/
146144
Snapshot createSnapshot(String parentNodeId, Snapshot snapshot);
@@ -201,14 +199,16 @@ public interface NodeDAO {
201199

202200
/**
203201
* Saves the {@link org.phoebus.applications.saveandrestore.model.Configuration} to the persistence layer.
204-
* @param parentNodeId The unique id of the parent {@link Node} for the new {@link Configuration}.
202+
*
203+
* @param parentNodeId The unique id of the parent {@link Node} for the new {@link Configuration}.
205204
* @param configuration The {@link Configuration} data.
206205
* @return The persisted {@link Configuration} data.
207206
*/
208207
Configuration createConfiguration(String parentNodeId, Configuration configuration);
209208

210209
/**
211210
* Retrieves the {@link ConfigurationData} for the specified (unique) id.
211+
*
212212
* @param uniqueId Id of the configuration {@link Node}
213213
* @return A {@link ConfigurationData} object.
214214
*/
@@ -226,6 +226,7 @@ public interface NodeDAO {
226226

227227
/**
228228
* Retrieves the {@link SnapshotData} for the specified (unique) id.
229+
*
229230
* @param uniqueId Id of the snapshot {@link Node}
230231
* @return A {@link SnapshotData} object.
231232
*/
@@ -249,7 +250,8 @@ public interface NodeDAO {
249250

250251
/**
251252
* Saves the {@link org.phoebus.applications.saveandrestore.model.CompositeSnapshot} to the persistence layer.
252-
* @param parentNodeId The unique id of the parent {@link Node} for the new {@link CompositeSnapshot}.
253+
*
254+
* @param parentNodeId The unique id of the parent {@link Node} for the new {@link CompositeSnapshot}.
253255
* @param compositeSnapshot The {@link CompositeSnapshot} data.
254256
* @return The persisted {@link CompositeSnapshot} data.
255257
*/
@@ -268,6 +270,7 @@ public interface NodeDAO {
268270

269271
/**
270272
* Checks for duplicate PV names in the specified list of snapshot or composite snapshot {@link Node}s.
273+
*
271274
* @param snapshotIds list of snapshot or composite snapshot {@link Node}s
272275
* @return A list if PV names that occur multiple times in the specified snapshot nodes or snapshot nodes
273276
* referenced in composite snapshots. If no duplicates are found, an empty list is returned.
@@ -288,6 +291,7 @@ public interface NodeDAO {
288291
* Aggregates a list of {@link SnapshotItem}s from a composite snapshot node. Note that since a
289292
* composite snapshot may reference other composite snapshots, the implementation may need to recursively
290293
* locate all referenced single snapshots.
294+
*
291295
* @param compositeSnapshotNodeId The if of an existing composite snapshot {@link Node}
292296
* @return A list of {@link SnapshotItem}s.
293297
*/
@@ -297,21 +301,24 @@ public interface NodeDAO {
297301
* Checks if all the referenced snapshot {@link Node}s in a {@link CompositeSnapshot} are
298302
* of the supported type, i.e. {@link org.phoebus.applications.saveandrestore.model.NodeType#COMPOSITE_SNAPSHOT}
299303
* or {@link org.phoebus.applications.saveandrestore.model.NodeType#SNAPSHOT}
304+
*
300305
* @param compositeSnapshot An existing {@link CompositeSnapshot}.
301306
* @return <code>true</code> if all referenced snapshot {@link Node}s in a {@link CompositeSnapshot} are all
302-
* * of the supported type.
307+
* * of the supported type.
303308
*/
304309
boolean checkCompositeSnapshotReferencedNodeTypes(CompositeSnapshot compositeSnapshot);
305310

306311
/**
307312
* Performs a search based on the provided search parameters.
313+
*
308314
* @param searchParameters Map of keyword/value pairs defining the search criteria.
309315
* @return A {@link SearchResult} object with a potentially empty list of {@link Node}s.
310316
*/
311317
SearchResult search(MultiValueMap<String, String> searchParameters);
312318

313319
/**
314320
* Save a new or updated {@link Filter}
321+
*
315322
* @param filter The {@link Filter} to save
316323
* @return The saved {@link Filter}
317324
*/
@@ -324,6 +331,7 @@ public interface NodeDAO {
324331

325332
/**
326333
* Deletes a {@link Filter} based on its name.
334+
*
327335
* @param name Unique name of the {@link Filter}
328336
*/
329337
void deleteFilter(String name);
@@ -335,13 +343,15 @@ public interface NodeDAO {
335343

336344
/**
337345
* Adds a {@link Tag} to specified list of target {@link Node}s
346+
*
338347
* @param tagData See {@link TagData}
339348
* @return The list of updated {@link Node}s
340349
*/
341350
List<Node> addTag(TagData tagData);
342351

343352
/**
344353
* Removes a {@link Tag} from specified list of target {@link Node}s
354+
*
345355
* @param tagData See {@link TagData}
346356
* @return The list of updated {@link Node}s
347357
*/

0 commit comments

Comments
 (0)