catch NPE #4228
authorKatja Luther <k.luther@bgbm.org>
Wed, 28 May 2014 12:14:18 +0000 (12:14 +0000)
committerKatja Luther <k.luther@bgbm.org>
Wed, 28 May 2014 12:14:18 +0000 (12:14 +0000)
eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java

index b0428d5bc511cf107fe2896d9aa8a14e82725e6e..2dfc5b7d6391e90d7f770b4a7a24a51e1aa7b94d 100644 (file)
@@ -109,36 +109,40 @@ public class TaxonEditorInput implements IEditorInput, IConversationEnabled, IPe
        TaxonEditorInput input = null;
 
        TaxonBase taxonBase = CdmStore.getService(ITaxonService.class).find(taxonBaseUuid);
-       if(taxonBase.isOrphaned()) {
-               EditorUtil.warningDialog("Orphaned Taxon", TaxonEditorInput.class, "This is an orphaned taxon i.e. a taxon that is not connected to a classification and not having any taxonomic relationships. Editing of orphaned taxon is currently not supported.");
+       if (taxonBase != null){
+               if(taxonBase.isOrphaned()) {
+                       EditorUtil.warningDialog("Orphaned Taxon", TaxonEditorInput.class, "This is an orphaned taxon i.e. a taxon that is not connected to a classification and not having any taxonomic relationships. Editing of orphaned taxon is currently not supported.");
+               }
+               else if(taxonBase.isInstanceOf(Taxon.class)){
+                       Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
+       
+                       if (taxon.getTaxonNodes().size() == 0 && taxon.isMisapplication()){
+                               // TODO get accepted taxon
+                               EditorUtil.info("trying to open Mispplied Name ");
+       
+                               Set<Taxon> acceptedTaxa = new HashSet<Taxon>();
+                               Set<TaxonRelationship> relations = taxon.getRelationsFromThisTaxon();
+                               for(TaxonRelationship relation : relations){
+                                       if(relation.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
+                                               acceptedTaxa.add(relation.getToTaxon());
+                                       }
+                               }
+                               input =  getInputForMultipleTaxa(conversation, acceptedTaxa);
+       
+                       }else{
+                               input = getInputForMultipleNodes(conversation, taxon.getTaxonNodes());
+                       }
+               }else if(taxonBase instanceof Synonym){
+                       Synonym synonym = (Synonym) taxonBase;
+       
+                       Set<Taxon> taxa = synonym.getAcceptedTaxa();
+                       input = getInputForMultipleTaxa(conversation, taxa);
+               }
+               if (input != null){
+                       input.setInitiallySelectedTaxonBase(taxonBase);
+               }
        }
-       else if(taxonBase.isInstanceOf(Taxon.class)){
-               Taxon taxon = CdmBase.deproxy(taxonBase, Taxon.class);
-
-               if (taxon.getTaxonNodes().size() == 0 && taxon.isMisapplication()){
-                       // TODO get accepted taxon
-                       EditorUtil.info("trying to open Mispplied Name ");
-
-                       Set<Taxon> acceptedTaxa = new HashSet<Taxon>();
-                       Set<TaxonRelationship> relations = taxon.getRelationsFromThisTaxon();
-                       for(TaxonRelationship relation : relations){
-                               if(relation.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())){
-                                       acceptedTaxa.add(relation.getToTaxon());
-                               }
-                       }
-                       input =  getInputForMultipleTaxa(conversation, acceptedTaxa);
-
-               }else{
-                       input = getInputForMultipleNodes(conversation, taxon.getTaxonNodes());
-               }
-       }else if(taxonBase instanceof Synonym){
-               Synonym synonym = (Synonym) taxonBase;
-
-               Set<Taxon> taxa = synonym.getAcceptedTaxa();
-               input = getInputForMultipleTaxa(conversation, taxa);
-       }
-
-       input.setInitiallySelectedTaxonBase(taxonBase);
+       
 
        return input;
     }