From: Patrick Plitzner
Date: Wed, 21 Jun 2017 07:56:11 +0000 (+0200)
Subject: ref #6694 Use service methods to add and remove features
X-Git-Tag: 4.8.0^2~49^2~4
X-Git-Url: https://dev.e-taxonomy.eu/gitweb/taxeditor.git/commitdiff_plain/17502849a24b87a607b565515dea41a00f3c3e53
ref #6694 Use service methods to add and remove features
---
diff --git a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java
index 6743a3e62..16399d9db 100644
--- a/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java
+++ b/eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/featuretree/e4/FeatureTreeEditor.java
@@ -164,7 +164,7 @@ public class FeatureTreeEditor implements ICdmEntitySessionEnabled,
// commit the conversation and start a new transaction immediately
conversation.commit(true);
- CdmStore.getService(IFeatureTreeService.class).merge(featureTree);
+ CdmStore.getService(IFeatureTreeService.class).saveOrUpdate(featureTree);
this.setDirty(false);
}
@@ -215,17 +215,12 @@ public class FeatureTreeEditor implements ICdmEntitySessionEnabled,
WizardDialog dialog = new WizardDialog(shell, wizard);
if (dialog.open() == IStatus.OK) {
- IStructuredSelection selection = (IStructuredSelection) composite.getViewer()
- .getSelection();
- FeatureNode parent = (FeatureNode) (selection.getFirstElement() != null ? selection
- .getFirstElement() : ((FeatureTree) composite.getViewer().getInput())
- .getRoot());
- Collection additionalFeatures = wizard
- .getAdditionalFeatures();
- for (Feature feature : additionalFeatures) {
- FeatureNode child = FeatureNode.NewInstance(feature);
- parent.addChild(child);
- CdmStore.getService(IFeatureNodeService.class).save(child);
+ IStructuredSelection selection = (IStructuredSelection) composite.getViewer().getSelection();
+ FeatureNode parent = (FeatureNode) (selection.getFirstElement() != null ? selection.getFirstElement()
+ : ((FeatureTree) composite.getViewer().getInput()).getRoot());
+ Collection additionalFeatures = wizard.getAdditionalFeatures();
+ for (Feature feature : additionalFeatures) {
+ CdmStore.getService(IFeatureNodeService.class).addChildFeaturNode(parent, feature);
}
setDirty(true);
composite.getViewer().refresh();
@@ -243,9 +238,6 @@ public class FeatureTreeEditor implements ICdmEntitySessionEnabled,
for (Object selectedObject : selection.toArray()) {
FeatureNode featureNode = (FeatureNode) selectedObject;
- FeatureNode parent = featureNode.getParent();
- parent.removeChild(featureNode);
-
CdmStore.getService(IFeatureNodeService.class).deleteFeatureNode(featureNode.getUuid(), new FeatureNodeDeletionConfigurator());
}