cherry pick from develop
authork.luther <k.luther@BGBM11732.bgbm.fu-berlin.de>
Thu, 4 Feb 2016 12:00:44 +0000 (13:00 +0100)
committerk.luther <k.luther@BGBM11732.bgbm.fu-berlin.de>
Thu, 4 Feb 2016 12:00:44 +0000 (13:00 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java

index bd2588b773c6d2e396a40e2b1144122f46198369..6368cdfeaa57b8723f7c2f6fab942663cf582ac8 100644 (file)
@@ -14,6 +14,7 @@ import eu.etaxonomy.cdm.api.application.CdmChangeEvent;
 import eu.etaxonomy.cdm.api.application.CdmChangeEvent.Action;
 import eu.etaxonomy.cdm.api.service.IClassificationService;
 import eu.etaxonomy.cdm.api.service.ITaxonNodeService;
+import eu.etaxonomy.cdm.api.service.UpdateResult;
 import eu.etaxonomy.cdm.model.common.CdmBase;
 import eu.etaxonomy.cdm.model.taxon.Classification;
 import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode;
@@ -52,25 +53,31 @@ public class NewTaxonNodeWizard extends AbstractNewEntityWizard<ITaxonTreeNode>{
             ITaxonTreeNode parent = getParentTreeNode();
             Taxon taxon = taxonNodePage.getTaxon();
             try{
-                TaxonNode taxonNode = parent.addChildTaxon(taxon, parent.getReference(), parent.getMicroReference());
+               UpdateResult result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, parent.getReference(), parent.getMicroReference());
+                       
+                //TaxonNode taxonNode = parent.addChildTaxon(taxon, parent.getReference(), parent.getMicroReference());
 
-                if(CdmStore.getCurrentSessionManager().isRemoting()) {
+              /*  if(CdmStore.getCurrentSessionManager().isRemoting()) {
                     taxonNode = CdmStore.getService(ITaxonNodeService.class).merge(taxonNode);
                 } else {
                     taxonNode = CdmStore.getService(ITaxonNodeService.class).save(taxonNode);
-                }
-                generatedTaxonNodeUuid = taxonNode.getUuid();
+                }*/
+               generatedTaxonNodeUuid = result.getCdmEntity().getUuid();
+               TaxonNode taxonNode = CdmStore.getService(ITaxonNodeService.class).load(generatedTaxonNodeUuid);
 
                 Set<CdmBase> affectedObjects = new HashSet<CdmBase>();
-
-                TaxonNode parentNode = taxonNode.getParent();
-                if(parentNode.getParent() == null) {
-                    affectedObjects.add(taxonNode.getClassification());
+                if (result.getUpdatedObjects().iterator().hasNext()){
+                       TaxonNode parentNode = (TaxonNode)result.getUpdatedObjects().iterator().next();
+                       if(parentNode.getParent() == null) {
+                        affectedObjects.add(taxonNode.getClassification());
+                    }
+                       if(parentNode instanceof TaxonNode) {
+                        affectedObjects.add(parentNode);
+                    }
                 }
+                
 
-                if(parentNode instanceof TaxonNode) {
-                    affectedObjects.add(parentNode);
-                }
+                
 
                 if(CdmStore.getCurrentSessionManager().isRemoting()) {
                     CdmApplicationState.getCurrentDataChangeService()