ref #6694 Use service methods to add and remove features
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / featuretree / e4 / FeatureTreeEditor.java
index 6743a3e6207318c941451f6fdbbcf42f2c8d7ccf..16399d9dbd8ad034251afbdeeda567975dcfac1d 100644 (file)
@@ -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<Feature> 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<Feature> 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());
 
                        }