From 7e154cb6b0c6245a9f58c5759ff5408d9f378543 Mon Sep 17 00:00:00 2001 From: Katja Luther Date: Wed, 28 May 2014 12:14:18 +0000 Subject: [PATCH] catch NPE #4228 --- .../taxeditor/editor/TaxonEditorInput.java | 62 ++++++++++--------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java index b0428d5bc..2dfc5b7d6 100644 --- a/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java +++ b/eu.etaxonomy.taxeditor.editor/src/main/java/eu/etaxonomy/taxeditor/editor/TaxonEditorInput.java @@ -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 acceptedTaxa = new HashSet(); + Set 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 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 acceptedTaxa = new HashSet(); - Set 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 taxa = synonym.getAcceptedTaxa(); - input = getInputForMultipleTaxa(conversation, taxa); - } - - input.setInitiallySelectedTaxonBase(taxonBase); + return input; } -- 2.34.1