X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/fcd1daf643c47ede1fab4ba26835ce47917d9f22..fdf9eec2eb7b4806e1a1cdc4020db83ce65345bc:/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java diff --git a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java index e3e72a46e1..d4c1b5942c 100644 --- a/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java +++ b/cdmlib-services/src/main/java/eu/etaxonomy/cdm/api/service/TaxonServiceImpl.java @@ -21,6 +21,8 @@ import java.util.Map; import java.util.Set; import java.util.UUID; +import javax.persistence.EntityNotFoundException; + import org.apache.log4j.Logger; import org.apache.lucene.index.CorruptIndexException; import org.apache.lucene.queryParser.ParseException; @@ -35,6 +37,7 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; +import eu.etaxonomy.cdm.api.service.config.DeleteConfiguratorBase; import eu.etaxonomy.cdm.api.service.config.IFindTaxaAndNamesConfigurator; import eu.etaxonomy.cdm.api.service.config.MatchingTaxonConfigurator; import eu.etaxonomy.cdm.api.service.config.SynonymDeletionConfigurator; @@ -91,13 +94,16 @@ import eu.etaxonomy.cdm.model.molecular.DnaSample; import eu.etaxonomy.cdm.model.molecular.Sequence; import eu.etaxonomy.cdm.model.molecular.SingleRead; import eu.etaxonomy.cdm.model.name.HomotypicalGroup; +import eu.etaxonomy.cdm.model.name.NameRelationship; import eu.etaxonomy.cdm.model.name.Rank; import eu.etaxonomy.cdm.model.name.TaxonNameBase; import eu.etaxonomy.cdm.model.name.ZoologicalName; import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; +import eu.etaxonomy.cdm.model.occurrence.DeterminationEvent; import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase; import eu.etaxonomy.cdm.model.reference.Reference; import eu.etaxonomy.cdm.model.taxon.Classification; +import eu.etaxonomy.cdm.model.taxon.ITaxonTreeNode; import eu.etaxonomy.cdm.model.taxon.Synonym; import eu.etaxonomy.cdm.model.taxon.SynonymRelationship; import eu.etaxonomy.cdm.model.taxon.SynonymRelationshipType; @@ -111,6 +117,7 @@ import eu.etaxonomy.cdm.persistence.dao.common.IOrderedTermVocabularyDao; import eu.etaxonomy.cdm.persistence.dao.initializer.AbstractBeanInitializer; import eu.etaxonomy.cdm.persistence.dao.name.ITaxonNameDao; import eu.etaxonomy.cdm.persistence.dao.occurrence.IOccurrenceDao; +import eu.etaxonomy.cdm.persistence.dao.taxon.IClassificationDao; import eu.etaxonomy.cdm.persistence.dao.taxon.ITaxonDao; import eu.etaxonomy.cdm.persistence.fetch.CdmFetch; import eu.etaxonomy.cdm.persistence.query.MatchMode; @@ -145,7 +152,6 @@ public class TaxonServiceImpl extends IdentifiableServiceBase getAllSynonyms(int limit, int start) { - return dao.getAllSynonyms(limit, start); - } - - /** - * FIXME Candidate for harmonization - * list(Taxon.class, ...) - * (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ITaxonService#getAllTaxa(int, int) - */ - @Override - public List getAllTaxa(int limit, int start) { - return dao.getAllTaxa(limit, start); - } - /** * FIXME Candidate for harmonization * merge with getRootTaxa(Reference sec, ..., ...) @@ -216,18 +203,11 @@ public class TaxonServiceImpl extends IdentifiableServiceBase getRootTaxa(Rank rank, Reference sec, boolean onlyWithChildren,boolean withMisapplications, List propertyPaths) { return dao.getRootTaxa(rank, sec, null, onlyWithChildren, withMisapplications, propertyPaths); } - /* (non-Javadoc) - * @see eu.etaxonomy.cdm.api.service.ITaxonService#getAllRelationships(int, int) - */ @Override public List getAllRelationships(int limit, int start){ return dao.getAllRelationships(limit, start); @@ -294,10 +274,12 @@ public class TaxonServiceImpl extends IdentifiableServiceBase heteroSynonyms = acceptedTaxon.getSynonymsInGroup(synonymHomotypicGroup); + Set basionymsAndReplacedSynonyms = synonymHomotypicGroup.getBasionymAndReplacedSynonymRelations(); for (Synonym heteroSynonym : heteroSynonyms){ if (synonym.equals(heteroSynonym)){ acceptedTaxon.removeSynonym(heteroSynonym, false); + }else{ //move synonyms in same homotypic group to new accepted taxon heteroSynonym.replaceAcceptedTaxon(newAcceptedTaxon, relTypeForGroup, copyCitationInfo, citation, microCitation); @@ -310,7 +292,9 @@ public class TaxonServiceImpl extends IdentifiableServiceBase synonymName = synonym.getName(); - // remove synonym from taxon + /* // remove synonym from taxon toTaxon.removeSynonym(synonym); - +*/ // Create a taxon with synonym name Taxon fromTaxon = Taxon.NewInstance(synonymName, null); @@ -338,7 +322,8 @@ public class TaxonServiceImpl extends IdentifiableServiceBase(pageNumber, numberOfResults, pageSize, results); } + @Override + public List listAcceptedTaxaFor(UUID synonymUuid, UUID classificationUuid, Integer pageSize, Integer pageNumber, + List orderHints, List propertyPaths){ + return pageAcceptedTaxaFor(synonymUuid, classificationUuid, pageSize, pageNumber, orderHints, propertyPaths).getRecords(); + } + + @Override + public Pager pageAcceptedTaxaFor(UUID synonymUuid, UUID classificationUuid, Integer pageSize, Integer pageNumber, + List orderHints, List propertyPaths){ + + List list = new ArrayList(); + Long count = 0l; + + Synonym synonym = null; + + try { + synonym = (Synonym) dao.load(synonymUuid); + } catch (ClassCastException e){ + throw new EntityNotFoundException("The TaxonBase entity referenced by " + synonymUuid + " is not a Synonmy"); + } catch (NullPointerException e){ + throw new EntityNotFoundException("No TaxonBase entity found for " + synonymUuid); + } + + Classification classificationFilter = null; + if(classificationUuid != null){ + try { + classificationFilter = classificationDao.load(classificationUuid); + } catch (NullPointerException e){ + throw new EntityNotFoundException("No Classification entity found for " + classificationUuid); + } + if(classificationFilter == null){ + + } + } + + count = dao.countAcceptedTaxaFor(synonym, classificationFilter) ; + if(count > (pageSize * pageNumber)){ + list = dao.listAcceptedTaxaFor(synonym, classificationFilter, pageSize, pageNumber, orderHints, propertyPaths); + } + + return new DefaultPagerImpl(pageNumber, count.intValue(), pageSize, list); + } + + /** * @param taxon * @param includeRelationships @@ -548,6 +577,10 @@ public class TaxonServiceImpl extends IdentifiableServiceBase(pageNumber, numberOfResults, pageSize, results); } + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.api.service.ITaxonService#getHomotypicSynonymsByHomotypicGroup(eu.etaxonomy.cdm.model.taxon.Taxon, java.util.List) + */ + @Override + public List> getSynonymsByHomotypicGroup(Taxon taxon, List propertyPaths){ + List> result = new ArrayList>(); + Taxon t = (Taxon)dao.load(taxon.getUuid(), propertyPaths); + + //homotypic + result.add(t.getHomotypicSynonymsByHomotypicGroup()); + + //heterotypic + List homotypicalGroups = t.getHeterotypicSynonymyGroups(); + for(HomotypicalGroup homotypicalGroup : homotypicalGroups){ + result.add(t.getSynonymsInGroup(homotypicalGroup)); + } + + return result; + + } + /* (non-Javadoc) * @see eu.etaxonomy.cdm.api.service.ITaxonService#getHomotypicSynonymsByHomotypicGroup(eu.etaxonomy.cdm.model.taxon.Taxon, java.util.List) */ @@ -795,6 +849,8 @@ public class TaxonServiceImpl extends IdentifiableServiceBase propertyPath) { + logger.trace("listMedia() - START"); + Set taxa = new HashSet(); List taxonMedia = new ArrayList(); @@ -803,13 +859,15 @@ public class TaxonServiceImpl extends IdentifiableServiceBase taxonDescriptions = new ArrayList(); // --- TaxonDescriptions for (Taxon t : taxa) { @@ -826,7 +884,9 @@ public class TaxonServiceImpl extends IdentifiableServiceBase specimensOrObservations = new HashSet(); // --- Specimens for (Taxon t : taxa) { @@ -880,6 +940,7 @@ public class TaxonServiceImpl extends IdentifiableServiceBase nameDescriptions = new HashSet(); for (Taxon t : taxa) { @@ -897,7 +958,12 @@ public class TaxonServiceImpl extends IdentifiableServiceBase referencedObjects = isDeletable(taxon, config); + + if (referencedObjects.isEmpty()){ + // --- DeleteSynonymRelations if (config.isDeleteSynonymRelations()){ boolean removeSynonymNameFromHomotypicalGroup = false; + // use tmp Set to avoid concurrent modification Set synRelsToDelete = new HashSet(); synRelsToDelete.addAll(taxon.getSynonymRelations()); for (SynonymRelationship synRel : synRelsToDelete){ Synonym synonym = synRel.getSynonym(); + // taxon.removeSynonymRelation will set the accepted taxon and the synonym to NULL + // this will cause hibernate to delete the relationship since + // the SynonymRelationship field on both is annotated with removeOrphan + // so no further explicit deleting of the relationship should be done here taxon.removeSynonymRelation(synRel, removeSynonymNameFromHomotypicalGroup); + + // --- DeleteSynonymsIfPossible if (config.isDeleteSynonymsIfPossible()){ //TODO which value boolean newHomotypicGroupIfNeeded = true; SynonymDeletionConfigurator synConfig = new SynonymDeletionConfigurator(); - deleteSynonym(synonym, taxon, synConfig); - }else{ - deleteSynonymRelationships(synonym, taxon); } + // relationship will be deleted by hibernate automatically, + // see comment above and http://dev.e-taxonomy.eu/trac/ticket/3797 + // else{ + // deleteSynonymRelationships(synonym, taxon); + // } } } - // TaxonRelationship + // --- DeleteTaxonRelationships if (! config.isDeleteTaxonRelationships()){ if (taxon.getTaxonRelations().size() > 0){ - String message = "Taxon can't be deleted as it is related to another taxon. Remove taxon from all relations to other taxa prior to deletion."; - throw new ReferencedObjectUndeletableException(message); + String message = "Taxon can't be deleted as it is related to another taxon. " + + "Remove taxon from all relations to other taxa prior to deletion."; + // throw new ReferencedObjectUndeletableException(message); } } else{ for (TaxonRelationship taxRel: taxon.getTaxonRelations()){ - - - if (config.isDeleteMisappliedNamesAndInvalidDesignations()){ if (taxRel.getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR()) || taxRel.getType().equals(TaxonRelationshipType.INVALID_DESIGNATION_FOR())){ if (taxon.equals(taxRel.getToTaxon())){ @@ -1002,38 +1078,39 @@ public class TaxonServiceImpl extends IdentifiableServiceBase descriptions = taxon.getDescriptions(); - - for (TaxonDescription desc: descriptions){ - //TODO use description delete configurator ? - //FIXME check if description is ALWAYS deletable - if (desc.getDescribedSpecimenOrObservation() != null){ - String message = "Taxon can't be deleted as it is used in a TaxonDescription" + - " which also describes specimens or abservations"; - throw new ReferencedObjectUndeletableException(message); - } - descriptionService.delete(desc); - taxon.removeDescription(desc); + Set descriptions = taxon.getDescriptions(); + List removeDescriptions = new ArrayList(); + for (TaxonDescription desc: descriptions){ + //TODO use description delete configurator ? + //FIXME check if description is ALWAYS deletable + if (desc.getDescribedSpecimenOrObservation() != null){ + String message = "Taxon can't be deleted as it is used in a TaxonDescription" + + " which also describes specimens or abservations"; + //throw new ReferencedObjectUndeletableException(message); } + removeDescriptions.add(desc); + descriptionService.delete(desc); + + } + for (TaxonDescription desc: removeDescriptions){ + taxon.removeDescription(desc); + } } - //check references with only reverse mapping + /* //check references with only reverse mapping String message = checkForReferences(taxon); if (message != null){ - throw new ReferencedObjectUndeletableException(message.toString()); - } + //throw new ReferencedObjectUndeletableException(message.toString()); + }*/ if (! config.isDeleteTaxonNodes() || (!config.isDeleteInAllClassifications() && classification == null )){ - if (taxon.getTaxonNodes().size() > 0){ - message = "Taxon can't be deleted as it is used in a classification node. Remove taxon from all classifications prior to deletion or define a classification where it should be deleted or adapt the taxon deletion configurator."; - throw new ReferencedObjectUndeletableException(message); - } + //if (taxon.getTaxonNodes().size() > 0){ + // message = "Taxon can't be deleted as it is used in a classification node. Remove taxon from all classifications prior to deletion or define a classification where it should be deleted or adapt the taxon deletion configurator."; + // throw new ReferencedObjectUndeletableException(message); + //} }else{ if (taxon.getTaxonNodes().size() != 0){ Set nodes = taxon.getTaxonNodes(); @@ -1058,16 +1135,18 @@ public class TaxonServiceImpl extends IdentifiableServiceBase nodesList = new ArrayList(); + Set nodesList = new HashSet(); nodesList.addAll(taxon.getTaxonNodes()); - for (TaxonNode taxonNode: nodesList){ - if(deleteChildren){ - Object[] childNodes = taxonNode.getChildNodes().toArray(); + for (ITaxonTreeNode treeNode: nodesList){ + TaxonNode taxonNode = (TaxonNode) treeNode; + if(!deleteChildren){ + /* Object[] childNodes = taxonNode.getChildNodes().toArray(); + //nodesList.addAll(taxonNode.getChildNodes()); for (Object childNode: childNodes){ TaxonNode childNodeCast = (TaxonNode) childNode; deleteTaxon(childNodeCast.getTaxon(), config, classification); @@ -1077,9 +1156,11 @@ public class TaxonServiceImpl extends IdentifiableServiceBase list = genericDao.getCdmBasesByFieldAndClass(PolytomousKeyNode.class, "taxon", taxon); + if (!list.isEmpty()) { + result = true; + } + return result; + } + @Transactional(readOnly = false) public UUID delete(Synonym syn){ UUID result = syn.getUuid(); @@ -1194,8 +1288,8 @@ public class TaxonServiceImpl extends IdentifiableServiceBase taxonSet = new HashSet(); - if (taxon != null){ - taxonSet.add(taxon); + List messages = isDeletable(synonym, config); + if (messages.isEmpty()){ + synonym = CdmBase.deproxy(dao.merge(synonym), Synonym.class); + + //remove synonymRelationship + Set taxonSet = new HashSet(); + if (taxon != null){ + taxonSet.add(taxon); + }else{ + taxonSet.addAll(synonym.getAcceptedTaxa()); + } + for (Taxon relatedTaxon : taxonSet){ + // dao.deleteSynonymRelationships(synonym, relatedTaxon); + relatedTaxon.removeSynonym(synonym, config.isNewHomotypicGroupIfNeeded()); + } + this.saveOrUpdate(synonym); + + //TODO remove name from homotypical group? + + //remove synonym (if necessary) + + UUID uuid = null; + if (synonym.getSynonymRelations().isEmpty()){ + TaxonNameBase name = synonym.getName(); + synonym.setName(null); + uuid = dao.delete(synonym); + + //remove name if possible (and required) + if (name != null && config.isDeleteNameIfPossible()){ + + nameService.delete(name, config.getNameDeletionConfig()); + + } + + }else { + return null; + } + return uuid.toString(); }else{ - taxonSet.addAll(synonym.getAcceptedTaxa()); - } - for (Taxon relatedTaxon : taxonSet){ -// dao.deleteSynonymRelationships(synonym, relatedTaxon); - relatedTaxon.removeSynonym(synonym, config.isNewHomotypicGroupIfNeeded()); - } - this.saveOrUpdate(synonym); - - //TODO remove name from homotypical group? - - //remove synonym (if necessary) - - - if (synonym.getSynonymRelations().isEmpty()){ - TaxonNameBase name = synonym.getName(); - synonym.setName(null); - dao.delete(synonym); - - //remove name if possible (and required) - if (name != null && config.isDeleteNameIfPossible()){ - try{ - nameService.delete(name, config.getNameDeletionConfig()); - }catch (ReferencedObjectUndeletableException ex){ - System.err.println("Name wasn't deleted as it is referenced"); - if (logger.isDebugEnabled()) { - logger.debug("Name wasn't deleted as it is referenced"); - } - } - } + return messages.toString(); } + + } @@ -1547,7 +1648,7 @@ public class TaxonServiceImpl extends IdentifiableServiceBase orderHints, List propertyPaths) throws CorruptIndexException, IOException, ParseException { - LuceneSearch luceneSearch = prepareFindByFullTextSearch(clazz, queryString, classification, languages, highlightFragments); + LuceneSearch luceneSearch = prepareFindByFullTextSearch(clazz, queryString, classification, languages, highlightFragments, null); // --- execute search TopGroupsWithMaxScore topDocsResultSet = luceneSearch.executeSearch(pageSize, pageNumber); @@ -1593,18 +1694,21 @@ public class TaxonServiceImpl extends IdentifiableServiceBase clazz, String queryString, Classification classification, List languages, - boolean highlightFragments) { + boolean highlightFragments, SortField[] sortFields) { BooleanQuery finalQuery = new BooleanQuery(); BooleanQuery textQuery = new BooleanQuery(); LuceneSearch luceneSearch = new LuceneSearch(luceneIndexToolProvider, GroupByTaxonClassBridge.GROUPBY_TAXON_FIELD, TaxonBase.class); QueryFactory taxonBaseQueryFactory = luceneIndexToolProvider.newQueryFactoryFor(TaxonBase.class); - SortField[] sortFields = new SortField[]{SortField.FIELD_SCORE, new SortField("titleCache__sort", SortField.STRING, false)}; + if(sortFields == null){ + sortFields = new SortField[]{SortField.FIELD_SCORE, new SortField("titleCache__sort", SortField.STRING, false)}; + } luceneSearch.setSortFields(sortFields); // ---- search criteria @@ -1637,16 +1741,17 @@ public class TaxonServiceImpl extends IdentifiableServiceBasedirect, everted: {@link Direction.relatedTo}: TaxonRelationShip.relatedTo.id --> Taxon.id *
  • inverse: {@link Direction.relatedFrom}: TaxonRelationShip.relatedFrom.id --> Taxon.id
  • *
      - * * @param queryString * @param classification * @param languages * @param highlightFragments + * @param sortFields TODO + * * @return * @throws IOException */ protected LuceneSearch prepareFindByTaxonRelationFullTextSearch(TaxonRelationshipEdge edge, String queryString, Classification classification, List languages, - boolean highlightFragments) throws IOException { + boolean highlightFragments, SortField[] sortFields) throws IOException { String fromField; String queryTermField; @@ -1675,7 +1780,9 @@ public class TaxonServiceImpl extends IdentifiableServiceBase 0; List luceneSearches = new ArrayList(); @@ -1788,7 +1909,7 @@ public class TaxonServiceImpl extends IdentifiableServiceBase orderHints, List propertyPaths) throws CorruptIndexException, IOException, ParseException, LuceneMultiSearchException { LuceneSearch luceneSearchByDescriptionElement = prepareByDescriptionElementFullTextSearch(null, queryString, classification, null, languages, highlightFragments); - LuceneSearch luceneSearchByTaxonBase = prepareFindByFullTextSearch(null, queryString, classification, languages, highlightFragments); + LuceneSearch luceneSearchByTaxonBase = prepareFindByFullTextSearch(null, queryString, classification, languages, highlightFragments, null); LuceneMultiSearch multiSearch = new LuceneMultiSearch(luceneIndexToolProvider, luceneSearchByDescriptionElement, luceneSearchByTaxonBase); @@ -2237,7 +2361,7 @@ public class TaxonServiceImpl extends IdentifiableServiceBase nodes = taxon.getTaxonNodes(); - List taxonNames = new ArrayList(); + List taxonNames = new ArrayList(); for (TaxonNode node: nodes){ // HashMap synonymsGenus = new HashMap(); // Changed this to be able to store the idInSource to a genusName @@ -2878,9 +3002,126 @@ public class TaxonServiceImpl extends IdentifiableServiceBase synonymName = fromTaxon.getName(); + Synonym synonym = Synonym.NewInstance(synonymName, fromTaxon.getSec()); + + // Remove concept relation from taxon + toTaxon.removeTaxon(fromTaxon, oldRelationshipType); + // Create a new synonym for the taxon + SynonymRelationship synonymRelationship; + if (synonymRelationshipType != null + && synonymRelationshipType.equals(SynonymRelationshipType.HOMOTYPIC_SYNONYM_OF())){ + synonymRelationship = toTaxon.addHomotypicSynonym(synonym, null, null); + } else{ + synonymRelationship = toTaxon.addHeterotypicSynonymName(synonymName); + } + + this.saveOrUpdate(toTaxon); + //TODO: configurator and classification + this.deleteTaxon(fromTaxon, null, null); + return synonymRelationship.getSynonym(); -} + } + @Override + public List isDeletable(TaxonBase taxonBase, DeleteConfiguratorBase config){ + List result = new ArrayList(); + Set references = commonService.getReferencingObjects(taxonBase); + if (taxonBase instanceof Taxon){ + TaxonDeletionConfigurator taxonConfig = (TaxonDeletionConfigurator) config; + result = isDeletableForTaxon(references, taxonConfig); + }else{ + SynonymDeletionConfigurator synonymConfig = (SynonymDeletionConfigurator) config; + result = isDeletableForSynonym(references, synonymConfig); + } + return result; + } + + private List isDeletableForSynonym(Set references, SynonymDeletionConfigurator config){ + String message; + List result = new ArrayList(); + for (CdmBase ref: references){ + if (!(ref instanceof SynonymRelationship || ref instanceof Taxon || ref instanceof TaxonNameBase)){ + message = "The Synonym can't be deleted as long as it is referenced by " + ref.getClass().getSimpleName() + " with id "+ ref.getId(); + result.add(message); + } + } + + return result; + } + private List isDeletableForTaxon(Set references, TaxonDeletionConfigurator config){ + String message; + List result = new ArrayList(); + for (CdmBase ref: references){ + if (!(ref instanceof TaxonNameBase)){ + if (!config.isDeleteSynonymRelations() && (ref instanceof SynonymRelationship)){ + message = "The Taxon can't be deleted as long as it has synonyms."; + result.add(message); + } + if (!config.isDeleteDescriptions() && (ref instanceof DescriptionBase)){ + message = "The Taxon can't be deleted as long as it has factual data."; + result.add(message); + } + + if (!config.isDeleteTaxonNodes() && (ref instanceof TaxonNode)){ + message = "The Taxon can't be deleted as long as it belongs to a taxon node."; + result.add(message); + } + if (!config.isDeleteTaxonRelationships() && (ref instanceof TaxonNode)){ + if (!config.isDeleteMisappliedNamesAndInvalidDesignations() && (((TaxonRelationship)ref).getType().equals(TaxonRelationshipType.MISAPPLIED_NAME_FOR())|| ((TaxonRelationship)ref).getType().equals(TaxonRelationshipType.INVALID_DESIGNATION_FOR()))){ + message = "The Taxon can't be deleted as long as it has misapplied names or invalid designations."; + result.add(message); + } else{ + message = "The Taxon can't be deleted as long as it belongs to a taxon node."; + result.add(message); + } + } + if (ref instanceof PolytomousKeyNode){ + message = "The Taxon can't be deleted as long as it is referenced by a polytomous key node."; + result.add(message); + } + + if (HibernateProxyHelper.isInstanceOf(ref, IIdentificationKey.class)){ + message = "Taxon can't be deleted as it is used in an identification key. Remove from identification key prior to deleting this name"; + result.add(message); + + } + + + /* //PolytomousKeyNode + if (referencingObject.isInstanceOf(PolytomousKeyNode.class)){ + String message = "Taxon" + taxon.getTitleCache() + " can't be deleted as it is used in polytomous key node"; + return message; + }*/ + + //TaxonInteraction + if (ref.isInstanceOf(TaxonInteraction.class)){ + message = "Taxon can't be deleted as it is used in taxonInteraction#taxon2"; + result.add(message); + } + + //TaxonInteraction + if (ref.isInstanceOf(DeterminationEvent.class)){ + message = "Taxon can't be deleted as it is used in a determination event"; + result.add(message); + } + + } + + } + + return result; + } + + + + + + }