Fix NPE when adding new taxon to classification
authorPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 8 Feb 2016 13:08:36 +0000 (14:08 +0100)
committerPatrick Plitzner <p.plitzner@bgbm.org>
Mon, 8 Feb 2016 13:08:36 +0000 (14:08 +0100)
eu.etaxonomy.taxeditor.store/src/main/java/eu/etaxonomy/taxeditor/newWizard/NewTaxonNodeWizard.java

index dbe283bd139a00b7d8af8f2c6accaa200a55b966..2478bf5a125b6429af38ecd63c1312672728065f 100644 (file)
@@ -56,8 +56,15 @@ public class NewTaxonNodeWizard extends AbstractNewEntityWizard<ITaxonTreeNode>{
             Reference sec = taxon.getSec();
             taxon.setSec(null);
             try{
-               UpdateResult result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parent.getUuid(), taxon, parent.getReference(), parent.getMicroReference());
-                       
+               UUID parentNodeUuid;
+               if(parent instanceof Classification){
+                   parentNodeUuid = ((Classification) parent).getRootNode().getUuid();
+               }
+               else{
+                   parentNodeUuid = parent.getUuid();
+               }
+                UpdateResult result = CdmStore.getService(ITaxonNodeService.class).createNewTaxonNode(parentNodeUuid, taxon, parent.getReference(), parent.getMicroReference());
+
                 //TaxonNode taxonNode = parent.addChildTaxon(taxon, parent.getReference(), parent.getMicroReference());
 
               /*  if(CdmStore.getCurrentSessionManager().isRemoting()) {
@@ -79,9 +86,9 @@ public class NewTaxonNodeWizard extends AbstractNewEntityWizard<ITaxonTreeNode>{
                         affectedObjects.add(parentNode);
                     }
                 }
-                
 
-                
+
+
 
                 if(CdmStore.getCurrentSessionManager().isRemoting()) {
                     CdmApplicationState.getCurrentDataChangeService()