From c683d6af7867fbe7534f864e8eb74b05dfa2a31f Mon Sep 17 00:00:00 2001 From: Andreas Kohlbecker Date: Wed, 25 Jan 2017 12:54:44 +0100 Subject: [PATCH] Revert "Revert "ref #6369 Add interfaces for TaxonNameBase and NonViralName"" This reverts commit 949c09b142f2806539e3fb399bef980d3e17e293. --- .../cdm/model/name/INonViralName.java | 503 +++++++++++ .../cdm/model/name/ITaxonNameBase.java | 798 ++++++++++++++++++ .../cdm/model/name/NonViralName.java | 5 +- .../cdm/model/name/TaxonNameBase.java | 77 +- 4 files changed, 1381 insertions(+), 2 deletions(-) create mode 100644 cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/INonViralName.java create mode 100644 cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/ITaxonNameBase.java diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/INonViralName.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/INonViralName.java new file mode 100644 index 0000000000..9b1fc98f71 --- /dev/null +++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/INonViralName.java @@ -0,0 +1,503 @@ +/** +* Copyright (C) 2017 EDIT +* European Distributed Institute of Taxonomy +* http://www.e-taxonomy.eu +* +* The contents of this file are subject to the Mozilla Public License Version 1.1 +* See LICENSE.TXT at the top of this package for the full license terms. +*/ +package eu.etaxonomy.cdm.model.name; + +import java.util.List; +import java.util.Set; + +import javax.persistence.Transient; + +import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; + +/** + * @author a.mueller + * @date 21.01.2017 + * + */ +public interface INonViralName extends ITaxonNameBase{ + + /** + * Creates a new {@link HybridRelationship#HybridRelationship(TaxonNameBase, TaxonNameBase, HybridRelationshipType, String) hybrid relationship} + * to this non viral name. A HybridRelationship may be of type + * "is first/second parent" or "is male/female parent". By invoking this + * method this non viral name becomes a parent of the hybrid child + * non viral name. + * + * @param childName the non viral name of the child for this new hybrid name relationship + * @param type the type of this new name relationship + * @param ruleConsidered the string which specifies the rule on which this name relationship is based + * @return + * @see #addHybridParent(TaxonNameBase, HybridRelationshipType,String ) + * @see #getRelationsToThisName() + * @see #getNameRelations() + * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) + * @see #addNameRelationship(NameRelationship) + */ + public HybridRelationship addHybridChild(NonViralName childName, HybridRelationshipType type, String ruleConsidered); + + /** + * Creates a new {@link HybridRelationship#HybridRelationship(TaxonNameBase, TaxonNameBase, HybridRelationshipType, String) hybrid relationship} + * to this non viral name. A HybridRelationship may be of type + * "is first/second parent" or "is male/female parent". By invoking this + * method this non viral name becomes a hybrid child of the parent + * non viral name. + * + * @param parentName the non viral name of the parent for this new hybrid name relationship + * @param type the type of this new name relationship + * @param ruleConsidered the string which specifies the rule on which this name relationship is based + * @return + * @see #addHybridChild(TaxonNameBase, HybridRelationshipType,String ) + * @see #getRelationsToThisName() + * @see #getNameRelations() + * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) + * @see #addNameRelationship(NameRelationship) + */ + public HybridRelationship addHybridParent(NonViralName parentName, HybridRelationshipType type, String ruleConsidered); + + /** + * Shortcut. Returns the basionym authors title cache. Returns null if no basionym author exists. + * @return + */ + public String computeBasionymAuthorNomenclaturalTitle() ; + + /** + * Shortcut. Returns the combination authors title cache. Returns null if no combination author exists. + * @return + */ + public String computeCombinationAuthorNomenclaturalTitle(); + + /** + * Shortcut. Returns the ex-basionym authors title cache. Returns null if no exbasionym author exists. + * @return + */ + public String computeExBasionymAuthorNomenclaturalTitle(); + + /** + * Shortcut. Returns the ex-combination authors title cache. Returns null if no ex-combination author exists. + * @return + */ + public String computeExCombinationAuthorNomenclaturalTitle(); + + /** + * Generates and returns a concatenated and formatted author teams string + * including basionym and combination authors of this non viral taxon name + * according to the strategy defined in + * {@link eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy#getAuthorshipCache(NonViralName) INonViralNameCacheStrategy}. + * + * @return the string with the concatenated and formated author teams for this non viral taxon name + * @see eu.etaxonomy.cdm.strategy.cache.name.INonViralNameCacheStrategy#getAuthorshipCache(NonViralName) + */ + public String generateAuthorship(); + + + /** + * Returns the concatenated and formatted author teams string including + * basionym and combination authors of this non viral taxon name. + * If the protectedAuthorshipCache flag is set this method returns the + * string stored in the the authorshipCache attribute, otherwise it + * generates the complete authorship string, returns it and stores it in + * the authorshipCache attribute. + * + * @return the string with the concatenated and formated author teams for this non viral taxon name + * @see #generateAuthorship() + */ + @Transient + public String getAuthorshipCache(); + + /** + * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} that published the original combination + * on which this non viral taxon name is nomenclaturally based. Such an + * author (team) can only exist if this non viral taxon name is a new + * combination due to a taxonomical revision. + * + * @return the nomenclatural basionym author (team) of this non viral taxon name + * @see #getCombinationAuthorship() + * @see eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor + * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getNomenclaturalTitle() + */ + public TeamOrPersonBase getBasionymAuthorship(); + + /** + * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} that published this non viral + * taxon name. + * + * @return the nomenclatural author (team) of this non viral taxon name + * @see eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor + * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getNomenclaturalTitle() + */ + public TeamOrPersonBase getCombinationAuthorship(); + + + /** + * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} that contributed to + * the publication of the original combination this non viral taxon name is + * based on. This should have been generally stated by + * the {@link #getBasionymAuthorship() basionym author (team)} itself. + * The presence of a basionym author (team) of this non viral taxon name is a + * condition for the existence of an ex basionym author (team) + * for this same name. + * + * @return the nomenclatural ex basionym author (team) of this non viral taxon name + * @see #getBasionymAuthorship() + * @see #getExCombinationAuthorship() + * @see #getCombinationAuthorship() + * @see eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor + * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getNomenclaturalTitle() + */ + public TeamOrPersonBase getExBasionymAuthorship(); + + /** + * Returns the {@link eu.etaxonomy.cdm.model.agent.TeamOrPersonBase author (team)} that contributed to + * the publication of this non viral taxon name as generally stated by + * the {@link #getCombinationAuthorship() combination author (team)} itself.
+ * An ex-author(-team) is an author(-team) to whom a taxon name was ascribed + * although it is not the author(-team) of a valid publication (for instance + * without the validating description or diagnosis in case of a name for a + * new taxon). The name of this ascribed authorship, followed by "ex", may + * be inserted before the name(s) of the publishing author(s) of the validly + * published name:
+ * Lilium tianschanicum was described by Grubov (1977) as a new species and + * its name was ascribed to Ivanova; since there is no indication that + * Ivanova provided the validating description, the name may be cited as + * Lilium tianschanicum N. A. Ivanova ex Grubov or Lilium tianschanicum Grubov. + *

+ * The presence of an author (team) of this non viral taxon name is a + * condition for the existence of an ex author (team) for this same name. + * + * @return the nomenclatural ex author (team) of this non viral taxon name + * @see #getCombinationAuthorship() + * @see eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor + * @see eu.etaxonomy.cdm.model.agent.TeamOrPersonBase#getNomenclaturalTitle() + */ + public TeamOrPersonBase getExCombinationAuthorship(); + + /** + * Returns either the scientific name string (without authorship) for this + * non viral taxon name if its rank is genus or higher (monomial) or the string for + * the genus part of it if its {@link Rank rank} is lower than genus (bi- or trinomial). + * Genus or uninomial strings begin with an upper case letter. + * + * @return the string containing the suprageneric name, the genus name or the genus part of this non viral taxon name + * @see #getNameCache() + */ + public String getGenusOrUninomial(); + + /** + * Returns the set of all {@link HybridRelationship hybrid relationships} + * in which this taxon name is involved as a {@link common.RelationshipBase#getRelatedTo() child}. + * + * @see #getHybridRelationships() + * @see #getParentRelationships() + * @see HybridRelationshipType + */ + public Set getHybridChildRelations(); + + /** + * Returns the set of all {@link HybridRelationship hybrid relationships} + * in which this taxon name is involved as a {@link common.RelationshipBase#getRelatedFrom() parent}. + * + * @see #getHybridRelationships() + * @see #getChildRelationships() + * @see HybridRelationshipType + */ + public Set getHybridParentRelations(); + + /** + * Returns the genus subdivision epithet string (infrageneric part) for + * this non viral taxon name if its {@link Rank rank} is infrageneric (lower than genus and + * higher than species aggregate: binomial). Genus subdivision epithet + * strings begin with an upper case letter. + * + * @return the string containing the infrageneric part of this non viral taxon name + * @see #getNameCache() + */ + public String getInfraGenericEpithet(); + + /** + * Returns the species epithet string for this non viral taxon name if its {@link Rank rank} is + * species aggregate or lower (bi- or trinomial). Species epithet strings + * begin with a lower case letter. + * + * @return the string containing the species epithet of this non viral taxon name + * @see #getNameCache() + */ + public String getSpecificEpithet(); + + /** + * Returns the species subdivision epithet string (infraspecific part) for + * this non viral taxon name if its {@link Rank rank} is infraspecific + * (lower than species: trinomial). Species subdivision epithet strings + * begin with a lower case letter. + * + * @return the string containing the infraspecific part of this non viral taxon name + * @see #getNameCache() + */ + public String getInfraSpecificEpithet(); + + + /** + * Defines the last part of the name. + * This is for infraspecific taxa, the infraspecific epithet, + * for species the specific epithet, for infageneric taxa the infrageneric epithet + * else the genusOrUninomial. + * However, the result does not depend on the rank (which may be not correctly set + * in case of dirty data) but returns the first name part which is not blank + * considering the above order. + * @return the first not blank name part in reverse order + */ + public String getLastNamePart(); + + /** + * Returns or generates the nameCache (scientific name + * without author strings and year) string for this non viral taxon name. If the + * {@link #isProtectedNameCache() protectedNameCache} flag is not set (False) + * the string will be generated according to a defined strategy, + * otherwise the value of the actual nameCache string will be returned. + * + * @return the string which identifies this non viral taxon name (without authors or year) + * @see #generateNameCache() + */ + @Transient + public String getNameCache() ; + + /** + * Returns the hybrid child relationships ordered by relationship type, or if equal + * by title cache of the related names. + * @see #getHybridParentRelations() + */ + @Transient + public List getOrderedChildRelationships(); + + /** + * Tests if the given name has any authors. + * @return false if no author ((ex)combination or (ex)basionym) exists, true otherwise + */ + public boolean hasAuthors(); + + /** + * Needs to be implemented by those classes that handle autonyms (e.g. botanical names). + **/ + @Transient + public boolean isAutonym(); + + + /** + * Returns the boolean value of the flag indicating whether the name of this + * botanical taxon name is a hybrid formula (true) or not (false). A hybrid + * named by a hybrid formula (composed with its parent names by placing the + * multiplication sign between them) does not have an own published name + * and therefore has neither an {@link NonViralName#getAuthorshipCache() autorship} + * nor other name components. If this flag is set no other hybrid flags may + * be set. + * + * @return the boolean value of the isHybridFormula flag + * @see #isMonomHybrid() + * @see #isBinomHybrid() + * @see #isTrinomHybrid() + */ + public boolean isHybridFormula(); + + /** + * Returns the boolean value of the flag indicating whether this botanical + * taxon name is the name of an intergeneric hybrid (true) or not (false). + * In this case the multiplication sign is placed before the scientific + * name. If this flag is set no other hybrid flags may be set. + * + * @return the boolean value of the isMonomHybrid flag + * @see #isHybridFormula() + * @see #isBinomHybrid() + * @see #isTrinomHybrid() + */ + public boolean isMonomHybrid(); + + /** + * Returns the boolean value of the flag indicating whether this botanical + * taxon name is the name of an interspecific hybrid (true) or not (false). + * In this case the multiplication sign is placed before the species + * epithet. If this flag is set no other hybrid flags may be set. + * + * @return the boolean value of the isBinomHybrid flag + * @see #isHybridFormula() + * @see #isMonomHybrid() + * @see #isTrinomHybrid() + */ + public boolean isBinomHybrid(); + + /** + * Returns the boolean value of the flag indicating whether this botanical + * taxon name is the name of an infraspecific hybrid (true) or not (false). + * In this case the term "notho-" (optionally abbreviated "n-") is used as + * a prefix to the term denoting the infraspecific rank of this botanical + * taxon name. If this flag is set no other hybrid flags may be set. + * + * @return the boolean value of the isTrinomHybrid flag + * @see #isHybridFormula() + * @see #isMonomHybrid() + * @see #isBinomHybrid() + */ + public boolean isTrinomHybrid(); + + + /** + * Returns the boolean value of the flag intended to protect (true) + * or not (false) the {@link #getAuthorshipCache() authorshipCache} (complete authorship string) + * of this non viral taxon name. + * + * @return the boolean value of the protectedAuthorshipCache flag + * @see #getAuthorshipCache() + */ + public boolean isProtectedAuthorshipCache(); + + + /** + * Returns the boolean value of the flag intended to protect (true) + * or not (false) the {@link #getNameCache() nameCache} (scientific name without author strings and year) + * string of this non viral taxon name. + * + * @return the boolean value of the protectedNameCache flag + * @see #getNameCache() + */ + public boolean isProtectedNameCache(); + + public void removeHybridChild(NonViralName child); + + public void removeHybridParent(NonViralName parent); + + /** + * Removes one {@link HybridRelationship hybrid relationship} from the set of + * {@link #getHybridRelationships() hybrid relationships} in which this botanical taxon name + * is involved. The hybrid relationship will also be removed from the set + * belonging to the second botanical taxon name involved. + * + * @param relationship the hybrid relationship which should be deleted from the corresponding sets + * @see #getHybridRelationships() + */ + public void removeHybridRelationship(HybridRelationship hybridRelation); + + /** + * Assigns an authorshipCache string to this non viral taxon name. Sets the isProtectedAuthorshipCache + * flag to true. + * + * @param authorshipCache the string which identifies the complete authorship of this non viral taxon name + * @see #getAuthorshipCache() + */ + public void setAuthorshipCache(String authorshipCache); + + + /** + * Assigns an authorshipCache string to this non viral taxon name. + * + * @param authorshipCache the string which identifies the complete authorship of this non viral taxon name + * @param protectedAuthorshipCache if true the isProtectedAuthorshipCache flag is set to true, otherwise + * the flag is set to false. + * @see #getAuthorshipCache() + */ + public void setAuthorshipCache(String authorshipCache, boolean protectedAuthorshipCache); + + /** + * @see #getBasionymAuthorship() + */ + public void setBasionymAuthorship(TeamOrPersonBase basionymAuthorship); + + /** + * @see #isBinomHybrid() + * @see #isMonomHybrid() + * @see #isTrinomHybrid() + */ + public void setBinomHybrid(boolean binomHybrid); + + + /** + * @see #getCombinationAuthorship() + */ + public void setCombinationAuthorship(TeamOrPersonBase combinationAuthorship); + + /** + * @see #getExBasionymAuthorship() + */ + public void setExBasionymAuthorship(TeamOrPersonBase exBasionymAuthorship); + + + /** + * @see #getExCombinationAuthorship() + */ + public void setExCombinationAuthorship(TeamOrPersonBase exCombinationAuthorship); + + /** + * @see #getGenusOrUninomial() + */ + public void setGenusOrUninomial(String genusOrUninomial); + + /** + * @see #isHybridFormula() + */ + public void setHybridFormula(boolean hybridFormula); + + /** + * @see #getInfraGenericEpithet() + */ + public void setInfraGenericEpithet(String infraGenericEpithet); + + /** + * @see #getInfraSpecificEpithet() + */ + public void setInfraSpecificEpithet(String infraSpecificEpithet); + + /** + * @see #isMonomHybrid() + * @see #isBinomHybrid() + * @see #isTrinomHybrid() + */ + public void setMonomHybrid(boolean monomHybrid); + + /** + * Assigns a nameCache string to this non viral taxon name and protects it from being overwritten. + * Sets the protectedNameCache flag to true. + * + * @param nameCache the string which identifies this non viral taxon name (without authors or year) + * @see #getNameCache() + */ + public void setNameCache(String nameCache); + + /** + * Assigns a nameCache string to this non viral taxon name and protects it from being overwritten. + * Sets the protectedNameCache flag to true. + * + * @param nameCache the string which identifies this non viral taxon name (without authors or year) + * @param protectedNameCache if true teh protectedNameCache is set to true or otherwise set to + * false + * @see #getNameCache() + */ + public void setNameCache(String nameCache, boolean protectedNameCache); + + /** + * @see #isProtectedAuthorshipCache() + * @see #getAuthorshipCache() + */ + public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache); + + /** + * @see #isProtectedNameCache() + */ + public void setProtectedNameCache(boolean protectedNameCache); + + /** + * @see #getSpecificEpithet() + */ + public void setSpecificEpithet(String specificEpithet); + + /** + * @see #isTrinomHybrid() + * @see #isBinomHybrid() + * @see #isMonomHybrid() + */ + public void setTrinomHybrid(boolean trinomHybrid); + + +} diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/ITaxonNameBase.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/ITaxonNameBase.java new file mode 100644 index 0000000000..20ec26dd72 --- /dev/null +++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/ITaxonNameBase.java @@ -0,0 +1,798 @@ +/** +* Copyright (C) 2017 EDIT +* European Distributed Institute of Taxonomy +* http://www.e-taxonomy.eu +* +* The contents of this file are subject to the Mozilla Public License Version 1.1 +* See LICENSE.TXT at the top of this package for the full license terms. +*/ +package eu.etaxonomy.cdm.model.name; + +import java.util.List; +import java.util.Set; + +import javax.persistence.Transient; + +import eu.etaxonomy.cdm.model.common.IIdentifiableEntity; +import eu.etaxonomy.cdm.model.common.IParsable; +import eu.etaxonomy.cdm.model.common.IRelated; +import eu.etaxonomy.cdm.model.description.TaxonNameDescription; +import eu.etaxonomy.cdm.model.occurrence.DerivedUnit; +import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; +import eu.etaxonomy.cdm.model.reference.Reference; +import eu.etaxonomy.cdm.model.taxon.Synonym; +import eu.etaxonomy.cdm.model.taxon.Taxon; +import eu.etaxonomy.cdm.model.taxon.TaxonBase; +import eu.etaxonomy.cdm.strategy.cache.TaggedText; +import eu.etaxonomy.cdm.strategy.match.IMatchable; + +/** + * + * The upmost interface for taxon names. + *

+ * This class corresponds partially to:

    + *
  • TaxonName according to the TDWG ontology + *
  • ScientificName and CanonicalName according to the TCS + *
  • ScientificName according to the ABCD schema + *
+ * + * @author a.mueller + * @date 21.01.2017 + * + */ +public interface ITaxonNameBase> + extends IIdentifiableEntity, IParsable, IRelated, IMatchable, Cloneable{ + + public String generateFullTitle(); + + @Transient + public String getFullTitleCache(); + + @Transient + public NomenclaturalCode getNomenclaturalCode(); + + + /** + * Returns the boolean value "false" since the components of this taxon name + * cannot follow the rules of a corresponding {@link NomenclaturalCode nomenclatural code} + * which is not defined for this class. The nomenclature code depends on + * the concrete name subclass ({@link BacterialName BacterialName}, + * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName}, + * {@link ZoologicalName ZoologicalName} or {@link ViralName ViralName}) + * to which a taxon name belongs. + * + * @return false + */ + @Transient + public boolean isCodeCompliant(); + + public List getTaggedName(); + + public void setFullTitleCache(String fullTitleCache); + + public void setFullTitleCache(String fullTitleCache, boolean protectCache); + + public boolean isProtectedFullTitleCache(); + + void setProtectedFullTitleCache(boolean protectedFullTitleCache); + + /** + * Returns the set of all {@link NameRelationship name relationships} + * in which this taxon name is involved. A taxon name can be both source + * in some name relationships or target in some others. + * + * @see #getRelationsToThisName() + * @see #getRelationsFromThisName() + * @see #addNameRelationship(NameRelationship) + * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String) + * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) + */ + public Set getNameRelations(); + + /** + * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from this taxon name to another taxon name + * and adds it both to the set of {@link #getRelationsFromThisName() relations from this taxon name} and + * to the set of {@link #getRelationsToThisName() relations to the other taxon name}. + * + * @param toName the taxon name of the target for this new name relationship + * @param type the type of this new name relationship + * @param ruleConsidered the string which specifies the rule on which this name relationship is based + * @see #getRelationsToThisName() + * @see #getNameRelations() + * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) + * @see #addNameRelationship(NameRelationship) + */ + public void addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, String ruleConsidered); + + /** + * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from this taxon name to another taxon name + * and adds it both to the set of {@link #getRelationsFromThisName() relations from this taxon name} and + * to the set of {@link #getRelationsToThisName() relations to the other taxon name}. + * + * @param toName the taxon name of the target for this new name relationship + * @param type the type of this new name relationship + * @param ruleConsidered the string which specifies the rule on which this name relationship is based + * @return + * @see #getRelationsToThisName() + * @see #getNameRelations() + * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) + * @see #addNameRelationship(NameRelationship) + */ + public NameRelationship addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, Reference citation, + String microCitation, String ruleConsidered); + + /** + * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from another taxon name to this taxon name + * and adds it both to the set of {@link #getRelationsToThisName() relations to this taxon name} and + * to the set of {@link #getRelationsFromThisName() relations from the other taxon name}. + * + * @param fromName the taxon name of the source for this new name relationship + * @param type the type of this new name relationship + * @param ruleConsidered the string which specifies the rule on which this name relationship is based + * @param citation the reference in which this relation was described + * @param microCitation the reference detail for this relation (e.g. page) + * @see #getRelationsFromThisName() + * @see #getNameRelations() + * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String) + * @see #addNameRelationship(NameRelationship) + */ + public NameRelationship addRelationshipFromName(TaxonNameBase fromName, NameRelationshipType type, String ruleConsidered); + + /** + * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from another taxon name to this taxon name + * and adds it both to the set of {@link #getRelationsToThisName() relations to this taxon name} and + * to the set of {@link #getRelationsFromThisName() relations from the other taxon name}. + * + * @param fromName the taxon name of the source for this new name relationship + * @param type the type of this new name relationship + * @param ruleConsidered the string which specifies the rule on which this name relationship is based + * @param citation the reference in which this relation was described + * @param microCitation the reference detail for this relation (e.g. page) + * @see #getRelationsFromThisName() + * @see #getNameRelations() + * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String) + * @see #addNameRelationship(NameRelationship) + */ + public NameRelationship addRelationshipFromName(TaxonNameBase fromName, NameRelationshipType type, Reference citation, + String microCitation, String ruleConsidered); + + /** + * Removes one {@link NameRelationship name relationship} from one of both sets of + * {@link #getNameRelations() name relationships} in which this taxon name is involved. + * The name relationship will also be removed from one of both sets belonging + * to the second taxon name involved. Furthermore the fromName and toName + * attributes of the name relationship object will be nullified. + * + * @param nameRelation the name relationship which should be deleted from one of both sets + * @see #getNameRelations() + */ + public void removeNameRelationship(NameRelationship nameRelation); + + public void removeRelationToTaxonName(TaxonNameBase toTaxonName); + + /** + * Returns the set of all {@link NameRelationship name relationships} + * in which this taxon name is involved as a source ("from"-side). + * + * @see #getNameRelations() + * @see #getRelationsToThisName() + * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) + */ + public Set getRelationsFromThisName(); + + /** + * Returns the set of all {@link NameRelationship name relationships} + * in which this taxon name is involved as a target ("to"-side). + * + * @see #getNameRelations() + * @see #getRelationsFromThisName() + * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String) + */ + public Set getRelationsToThisName(); + + /** + * Returns the set of {@link NomenclaturalStatus nomenclatural status} assigned + * to this taxon name according to its corresponding nomenclature code. + * This includes the {@link NomenclaturalStatusType type} of the nomenclatural status + * and the nomenclatural code rule considered. + * + * @see NomenclaturalStatus + * @see NomenclaturalStatusType + */ + public Set getStatus(); + + /** + * Adds a new {@link NomenclaturalStatus nomenclatural status} + * to this taxon name's set of nomenclatural status. + * + * @param nomStatus the nomenclatural status to be added + * @see #getStatus() + */ + public void addStatus(NomenclaturalStatus nomStatus); + + public NomenclaturalStatus addStatus(NomenclaturalStatusType statusType, Reference citation, String microCitation); + + /** + * Removes one element from the set of nomenclatural status of this taxon name. + * Type and ruleConsidered attributes of the nomenclatural status object + * will be nullified. + * + * @param nomStatus the nomenclatural status of this taxon name which should be deleted + * @see #getStatus() + */ + public void removeStatus(NomenclaturalStatus nomStatus); + + /** + * Indicates whether this taxon name is a {@link NameRelationshipType#BASIONYM() basionym} + * or a {@link NameRelationshipType#REPLACED_SYNONYM() replaced synonym} + * of any other taxon name. Returns "true", if a basionym or a replaced + * synonym {@link NameRelationship relationship} from this taxon name to another taxon name exists, + * false otherwise (also in case this taxon name is the only one in the + * homotypical group). + */ + public boolean isOriginalCombination(); + + /** + * Indicates this taxon name is a {@link NameRelationshipType#REPLACED_SYNONYM() replaced synonym} + * of any other taxon name. Returns "true", if a replaced + * synonym {@link NameRelationship relationship} from this taxon name to another taxon name exists, + * false otherwise (also in case this taxon name is the only one in the + * homotypical group). + */ + public boolean isReplacedSynonym(); + + /** + * Returns the taxon name which is the {@link NameRelationshipType#BASIONYM() basionym} of this taxon name. + * The basionym of a taxon name is its epithet-bringing synonym. + * For instance Pinus abies L. was published by Linnaeus and the botanist + * Karsten transferred later this taxon to the genus Picea. Therefore, + * Pinus abies L. is the basionym of the new combination Picea abies (L.) H. Karst. + * + * If more than one basionym exists one is choosen at radom. + * + * If no basionym exists null is returned. + */ + public TaxonNameBase getBasionym(); + + /** + * Returns the set of taxon names which are the {@link NameRelationshipType#BASIONYM() basionyms} of this taxon name. + * The basionym of a taxon name is its epithet-bringing synonym. + * For instance Pinus abies L. was published by Linnaeus and the botanist + * Karsten transferred later this taxon to the genus Picea. Therefore, + * Pinus abies L. is the basionym of the new combination Picea abies (L.) H. Karst. + */ + public Set getBasionyms(); + + /** + * Assigns a taxon name as {@link NameRelationshipType#BASIONYM() basionym} of this taxon name. + * The basionym {@link NameRelationship relationship} will be added to this taxon name + * and to the basionym. The basionym cannot have itself a basionym. + * The {@link HomotypicalGroup homotypical groups} of this taxon name and of the basionym + * will be {@link HomotypicalGroup#merge(HomotypicalGroup) merged}. + * + * @param basionym the taxon name to be set as the basionym of this taxon name + * @see #getBasionym() + * @see #addBasionym(TaxonNameBase, String) + */ + public void addBasionym(T basionym); + + /** + * Assigns a taxon name as {@link NameRelationshipType#BASIONYM() basionym} of this taxon name + * and keeps the nomenclatural rule considered for it. The basionym + * {@link NameRelationship relationship} will be added to this taxon name and to the basionym. + * The basionym cannot have itself a basionym. + * The {@link HomotypicalGroup homotypical groups} of this taxon name and of the basionym + * will be {@link HomotypicalGroup#merge(HomotypicalGroup) merged}. + * + * @param basionym the taxon name to be set as the basionym of this taxon name + * @param ruleConsidered the string identifying the nomenclatural rule + * @return + * @see #getBasionym() + * @see #addBasionym(TaxonNameBase) + */ + public NameRelationship addBasionym(T basionym, Reference citation, String microcitation, String ruleConsidered); + + /** + * Returns the set of taxon names which are the {@link NameRelationshipType#REPLACED_SYNONYM() replaced synonyms} of this taxon name. + * + */ + public Set getReplacedSynonyms(); + + /** + * Assigns a taxon name as {@link NameRelationshipType#REPLACED_SYNONYM() replaced synonym} of this taxon name + * and keeps the nomenclatural rule considered for it. The replaced synonym + * {@link NameRelationship relationship} will be added to this taxon name and to the replaced synonym. + * The {@link HomotypicalGroup homotypical groups} of this taxon name and of the replaced synonym + * will be {@link HomotypicalGroup#merge(HomotypicalGroup) merged}. + * + * @param basionym the taxon name to be set as the basionym of this taxon name + * @param ruleConsidered the string identifying the nomenclatural rule + * @see #getBasionym() + * @see #addBasionym(TaxonNameBase) + */ + //TODO: Check if true: The replaced synonym cannot have itself a replaced synonym (?). + public void addReplacedSynonym(T replacedSynonym, Reference citation, String microcitation, String ruleConsidered); + + /** + * Removes the {@link NameRelationshipType#BASIONYM() basionym} {@link NameRelationship relationship} from the set of + * {@link #getRelationsToThisName() name relationships to} this taxon name. The same relationhip will be + * removed from the set of {@link #getRelationsFromThisName() name relationships from} the taxon name + * previously used as basionym. + * + * @see #getBasionym() + * @see #addBasionym(TaxonNameBase) + */ + public void removeBasionyms(); + + /** + * Returns the taxonomic {@link Rank rank} of this taxon name. + * + * @see Rank + */ + public Rank getRank(); + + /** + * @see #getRank() + */ + public void setRank(Rank rank); + + /** + * Returns the {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} of this taxon name. + * The nomenclatural reference is here meant to be the one publication + * this taxon name was originally published in while fulfilling the formal + * requirements as specified by the corresponding {@link NomenclaturalCode nomenclatural code}. + * + * @see eu.etaxonomy.cdm.model.reference.INomenclaturalReference + * @see eu.etaxonomy.cdm.model.reference.Reference + */ + public INomenclaturalReference getNomenclaturalReference(); + + /** + * Assigns a {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference nomenclatural reference} to this taxon name. + * The corresponding {@link eu.etaxonomy.cdm.model.reference.Reference.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true + * as it is obviously used for nomenclatural purposes. + * + * @throws IllegalArgumentException if parameter nomenclaturalReference is not assignable from {@link INomenclaturalReference} + * @see #getNomenclaturalReference() + */ + public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference); + + /** + * Returns the appended phrase string assigned to this taxon name. + * The appended phrase is a non-atomised addition to a name. It is + * not ruled by a nomenclatural code. + */ + public String getAppendedPhrase(); + + /** + * @see #getAppendedPhrase() + */ + public void setAppendedPhrase(String appendedPhrase); + + /** + * Returns the details string of the {@link #getNomenclaturalReference() nomenclatural reference} assigned + * to this taxon name. The details describe the exact localisation within + * the publication used as nomenclature reference. These are mostly + * (implicitly) pages but can also be figures or tables or any other + * element of a publication. A nomenclatural micro reference (details) + * requires the existence of a nomenclatural reference. + */ + //Details of the nomenclatural reference (protologue). + public String getNomenclaturalMicroReference(); + + /** + * @see #getNomenclaturalMicroReference() + */ + public void setNomenclaturalMicroReference(String nomenclaturalMicroReference); + + /** + * @param warnings + */ + public void addParsingProblems(int problems); + + /** + * Returns the set of {@link TypeDesignationBase type designations} assigned + * to this taxon name. + * @see NameTypeDesignation + * @see SpecimenTypeDesignation + */ + public Set getTypeDesignations(); + + /** + * Removes one element from the set of {@link TypeDesignationBase type designations} assigned to + * this taxon name. The type designation itself will be nullified. + * + * @param typeDesignation the type designation which should be deleted + */ + public void removeTypeDesignation(TypeDesignationBase typeDesignation); + + /** + * Returns the set of {@link SpecimenTypeDesignation specimen type designations} assigned + * to this taxon name. The {@link Rank rank} of this taxon name is generally + * "species" or below. The specimen type designations include all the + * specimens on which the typification of this name is based (which are + * exclusively used to typify taxon names belonging to the same + * {@link HomotypicalGroup homotypical group} to which this taxon name + * belongs) and eventually the status of these designations. + * + * @see SpecimenTypeDesignation + * @see NameTypeDesignation + * @see HomotypicalGroup + */ + public Set getSpecimenTypeDesignationsOfHomotypicalGroup(); + + /** + * Returns the set of {@link NameTypeDesignation name type designations} assigned + * to this taxon name the rank of which must be above "species". + * The name type designations include all the taxon names used to typify + * this taxon name and eventually the rejected or conserved status + * of these designations. + * + * @see NameTypeDesignation + * @see SpecimenTypeDesignation + */ + public Set getNameTypeDesignations(); + + /** + * Creates and adds a new {@link NameTypeDesignation name type designation} + * to this taxon name's set of type designations. + * + * @param typeSpecies the taxon name to be used as type of this taxon name + * @param citation the reference for this new designation + * @param citationMicroReference the string with the details (generally pages) within the reference + * @param originalNameString the taxon name string used in the reference to assert this designation + * @param isRejectedType the boolean status for a rejected name type designation + * @param isConservedType the boolean status for a conserved name type designation + * @param isLectoType the boolean status for a lectotype name type designation + * @param isNotDesignated the boolean status for a name type designation without name type + * @param addToAllHomotypicNames the boolean indicating whether the name type designation should be + * added to all taxon names of the homotypical group this taxon name belongs to + * @return + * @see #getNameTypeDesignations() + * @see NameTypeDesignation + * @see TypeDesignationBase#isNotDesignated() + */ + public NameTypeDesignation addNameTypeDesignation(TaxonNameBase typeSpecies, Reference citation, + String citationMicroReference, String originalNameString, NameTypeDesignationStatus status, + boolean isRejectedType, boolean isConservedType, + /*boolean isLectoType, */ + boolean isNotDesignated, boolean addToAllHomotypicNames); + + /** + * Creates and adds a new {@link NameTypeDesignation name type designation} + * to this taxon name's set of type designations. + * + * @param typeSpecies the taxon name to be used as type of this taxon name + * @param citation the reference for this new designation + * @param citationMicroReference the string with the details (generally pages) within the reference + * @param originalNameString the taxon name string used in the reference to assert this designation + * @param status the name type designation status + * @param addToAllHomotypicNames the boolean indicating whether the name type designation should be + * added to all taxon names of the homotypical group this taxon name belongs to + * @return + * @see #getNameTypeDesignations() + * @see NameTypeDesignation + * @see TypeDesignationBase#isNotDesignated() + */ + public NameTypeDesignation addNameTypeDesignation(TaxonNameBase typeSpecies, Reference citation, + String citationMicroReference, String originalNameString, NameTypeDesignationStatus status, + boolean addToAllHomotypicNames); + + /** + * Returns the set of {@link SpecimenTypeDesignation specimen type designations} + * that typify this taxon name. + */ + public Set getSpecimenTypeDesignations(); + + /** + * Creates and adds a new {@link SpecimenTypeDesignation specimen type designation} + * to this taxon name's set of type designations. + * + * @param typeSpecimen the specimen to be used as a type for this taxon name + * @param status the specimen type designation status + * @param citation the reference for this new specimen type designation + * @param citationMicroReference the string with the details (generally pages) within the reference + * @param originalNameString the taxon name used in the reference to assert this designation + * @param isNotDesignated the boolean status for a specimen type designation without specimen type + * @param addToAllHomotypicNames the boolean indicating whether the specimen type designation should be + * added to all taxon names of the homotypical group the typified + * taxon name belongs to + * @return + * @see #getSpecimenTypeDesignations() + * @see SpecimenTypeDesignationStatus + * @see SpecimenTypeDesignation + * @see TypeDesignationBase#isNotDesignated() + */ + public SpecimenTypeDesignation addSpecimenTypeDesignation(DerivedUnit typeSpecimen, SpecimenTypeDesignationStatus status, + Reference citation, String citationMicroReference, String originalNameString, boolean isNotDesignated, + boolean addToAllHomotypicNames); + + /** + * Adds a {@link TypeDesignationBase type designation} to this taxon name's set of type designations + * + * @param typeDesignation the typeDesignation to be added to this taxon name + * @param addToAllNames the boolean indicating whether the type designation should be + * added to all taxon names of the homotypical group the typified + * taxon name belongs to + * @return true if the operation was succesful + * + * @throws IllegalArgumentException if the type designation already has typified names, an {@link IllegalArgumentException exception} + * is thrown. We do this to prevent a type designation to be used for multiple taxon names. + * + */ + public boolean addTypeDesignation(TypeDesignationBase typeDesignation, boolean addToAllNames); + + /** + * Returns the {@link HomotypicalGroup homotypical group} to which + * this taxon name belongs. A homotypical group represents all taxon names + * that share the same types. + * + * @see HomotypicalGroup + */ + + public HomotypicalGroup getHomotypicalGroup(); + + /** + * @see #getHomotypicalGroup() + */ + public void setHomotypicalGroup(HomotypicalGroup homotypicalGroup); + + /** + * Returns the complete string containing the + * {@link eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getNomenclaturalCitation() nomenclatural reference citation} + * and the {@link #getNomenclaturalMicroReference() details} assigned to this taxon name. + * + * @return the string containing the nomenclatural reference of this taxon name + * @see eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getNomenclaturalCitation() + * @see #getNomenclaturalReference() + * @see #getNomenclaturalMicroReference() + */ + public String getCitationString(); + + /** + * Returns the string containing the publication date (generally only year) + * of the {@link #getNomenclaturalReference() nomenclatural reference} for this taxon name, null if there is + * no nomenclatural reference. + * + * @return the string containing the publication date of this taxon name + * @see eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getYear() + */ + public String getReferenceYear(); + + /** + * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon bases} that refer to this taxon name. + * In this context a taxon base means the use of a taxon name by a reference + * either as a {@link eu.etaxonomy.cdm.model.taxon.Taxon taxon} ("accepted/correct" name) or + * as a (junior) {@link eu.etaxonomy.cdm.model.taxon.Synonym synonym}. + * A taxon name can be used by several distinct {@link eu.etaxonomy.cdm.model.reference.Reference references} but only once + * within a taxonomic treatment (identified by one reference). + * + * @see #getTaxa() + * @see #getSynonyms() + */ + public Set getTaxonBases(); + + /** + * Adds a new {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon base} + * to the set of taxon bases using this taxon name. + * + * @param taxonBase the taxon base to be added + * @see #getTaxonBases() + * @see #removeTaxonBase(TaxonBase) + */ + //TODO protected + public void addTaxonBase(TaxonBase taxonBase); + + /** + * Removes one element from the set of {@link eu.etaxonomy.cdm.model.taxon.TaxonBase taxon bases} that refer to this taxon name. + * + * @param taxonBase the taxon base which should be removed from the corresponding set + * @see #getTaxonBases() + * @see #addTaxonBase(TaxonBase) + */ + public void removeTaxonBase(TaxonBase taxonBase); + + /** + * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.Taxon taxa} ("accepted/correct" names according to any + * reference) that are based on this taxon name. This set is a subset of + * the set returned by getTaxonBases(). + * + * @see eu.etaxonomy.cdm.model.taxon.Taxon + * @see #getTaxonBases() + * @see #getSynonyms() + */ + public Set getTaxa(); + + /** + * Returns the set of {@link eu.etaxonomy.cdm.model.taxon.Synonym (junior) synonyms} (according to any + * reference) that are based on this taxon name. This set is a subset of + * the set returned by getTaxonBases(). + * + * @see eu.etaxonomy.cdm.model.taxon.Synonym + * @see #getTaxonBases() + * @see #getTaxa() + */ + public Set getSynonyms(); + + /** + * Returns the set of {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name descriptions} assigned + * to this taxon name. A taxon name description is a piece of information + * concerning the taxon name like for instance the content of its first + * publication (protolog) or a picture of this publication. + * + * @see #addDescription(TaxonNameDescription) + * @see #removeDescription(TaxonNameDescription) + * @see eu.etaxonomy.cdm.model.description.TaxonNameDescription + */ + public Set getDescriptions(); + + /** + * Adds a new {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name description} + * to the set of taxon name descriptions assigned to this taxon name. The + * content of the {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName() taxonName attribute} of the + * taxon name description itself will be replaced with this taxon name. + * + * @param description the taxon name description to be added + * @see #getDescriptions() + * @see #removeDescription(TaxonNameDescription) + */ + public void addDescription(TaxonNameDescription description); + + /** + * Removes one element from the set of {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription taxon name descriptions} assigned + * to this taxon name. The content of the {@link eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName() taxonName attribute} + * of the description itself will be set to "null". + * + * @param description the taxon name description which should be removed + * @see #getDescriptions() + * @see #addDescription(TaxonNameDescription) + * @see eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName() + */ + public void removeDescription(TaxonNameDescription description); + + public void mergeHomotypicGroups(TaxonNameBase name); + + /** + * Returns the boolean value indicating whether a given taxon name belongs + * to the same {@link HomotypicalGroup homotypical group} as this taxon name (true) + * or not (false). Returns "true" only if the homotypical groups of both + * taxon names exist and if they are identical. + * + * @param homoTypicName the taxon name the homotypical group of which is to be checked + * @return the boolean value of the check + * @see HomotypicalGroup + */ + public boolean isHomotypic(TaxonNameBase homoTypicName); + + /** + * Checks whether name is a basionym for ALL names + * in its homotypical group. + * Returns false if there are no other names in the group + * @param name + * @return + */ + public boolean isGroupsBasionym(); + + /** + * Checks whether a basionym relationship exists between fromName and toName. + * + * @param fromName + * @param toName + * @return + */ + public boolean isBasionymFor(TaxonNameBase newCombinationName); + + /** + * Creates a basionym relationship to all other names in this names homotypical + * group. + * + * @see HomotypicalGroup.setGroupBasionym(TaxonNameBase basionymName) + */ + public void makeGroupsBasionym(); + + //********* Rank comparison shortcuts ********************// + /** + * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this + * taxon name is higher than the genus rank (true) or not (false). + * Suprageneric non viral names are monomials. + * Returns false if rank is null. + * + * @see #isGenus() + * @see #isInfraGeneric() + * @see #isSpecies() + * @see #isInfraSpecific() + */ + public boolean isSupraGeneric(); + + /** + * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this + * taxon name is the genus rank (true) or not (false). Non viral names with + * genus rank are monomials. Returns false if rank is null. + * + * @see #isSupraGeneric() + * @see #isInfraGeneric() + * @see #isSpecies() + * @see #isInfraSpecific() + */ + public boolean isGenus(); + + /** + * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this + * taxon name is higher than the species rank and lower than the + * genus rank (true) or not (false). Infrageneric non viral names are + * binomials. Returns false if rank is null. + * + * @see #isSupraGeneric() + * @see #isGenus() + * @see #isSpecies() + * @see #isInfraSpecific() + */ + public boolean isInfraGeneric(); + + /** + * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this + * taxon name is higher than the species rank (true) or not (false). + * Returns false if rank is null. + * + * @see #isGenus() + * @see #isInfraGeneric() + * @see #isSpecies() + * @see #isInfraSpecific() + */ + public boolean isSupraSpecific(); + + /** + * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this + * taxon name is the species rank (true) or not (false). Non viral names + * with species rank are binomials. + * Returns false if rank is null. + * + * @see #isSupraGeneric() + * @see #isGenus() + * @see #isInfraGeneric() + * @see #isInfraSpecific() + */ + public boolean isSpecies(); + + /** + * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this + * taxon name is lower than the species rank (true) or not (false). + * Infraspecific non viral names are trinomials. + * Returns false if rank is null. + * + * @see #isSupraGeneric() + * @see #isGenus() + * @see #isInfraGeneric() + * @see #isSpecies() + */ + public boolean isInfraSpecific(); + + /** + * Returns true if this name's rank indicates a rank that aggregates species like species + * aggregates or species groups, false otherwise. This methods currently returns false + * for all user defined ranks. + * + *@see Rank#isSpeciesAggregate() + * + * @return + */ + public boolean isSpeciesAggregate(); + + /** + * Creates a basionym relationship between this name and + * each name in its homotypic group. + * + * @param basionymName + */ + public void setAsGroupsBasionym(); + + /** + * Removes basionym relationship between this name and + * each name in its homotypic group. + * + * @param basionymName + */ + public void removeAsGroupsBasionym(); + + +} diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NonViralName.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NonViralName.java index 1a84af309d..2253287faf 100644 --- a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NonViralName.java +++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NonViralName.java @@ -56,7 +56,10 @@ import eu.etaxonomy.cdm.validation.annotation.NoDuplicateNames; @CorrectEpithetsForRank(groups = Level2.class) @NameMustHaveAuthority(groups = Level2.class) @NoDuplicateNames(groups = Level3.class) -public class NonViralName extends TaxonNameBase implements Cloneable{ +public class NonViralName + extends TaxonNameBase + implements INonViralName{ + private static final long serialVersionUID = 4441110073881088033L; diff --git a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonNameBase.java b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonNameBase.java index 38a12a3ce2..c453783f84 100644 --- a/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonNameBase.java +++ b/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/TaxonNameBase.java @@ -150,7 +150,7 @@ import eu.etaxonomy.cdm.validation.annotation.ValidTaxonomicYear; @Table(appliesTo="TaxonNameBase", indexes = { @org.hibernate.annotations.Index(name = "taxonNameBaseTitleCacheIndex", columnNames = { "titleCache" }), @org.hibernate.annotations.Index(name = "taxonNameBaseNameCacheIndex", columnNames = { "nameCache" }) }) public abstract class TaxonNameBase, S extends INameCacheStrategy> extends IdentifiableEntity - implements IParsable, IRelated, IMatchable, Cloneable { + implements ITaxonNameBase, IParsable, IRelated, IMatchable, Cloneable { private static final long serialVersionUID = -4530368639601532116L; private static final Logger logger = Logger.getLogger(TaxonNameBase.class); @@ -956,10 +956,12 @@ public abstract class TaxonNameBase, S extends INam this.hybridChildRelations = hybridChildRelations; } + @Override public boolean isProtectedFullTitleCache() { return protectedFullTitleCache; } + @Override public void setProtectedFullTitleCache(boolean protectedFullTitleCache) { this.protectedFullTitleCache = protectedFullTitleCache; } @@ -1126,6 +1128,7 @@ public abstract class TaxonNameBase, S extends INam //********* METHODS **************************************/ + @Override public String generateFullTitle(){ if (cacheStrategy == null){ logger.warn("No CacheStrategy defined for nonViralName: " + this.getUuid()); @@ -1136,10 +1139,12 @@ public abstract class TaxonNameBase, S extends INam } + @Override public void setFullTitleCache(String fullTitleCache){ setFullTitleCache(fullTitleCache, PROTECTED); } + @Override public void setFullTitleCache(String fullTitleCache, boolean protectCache){ fullTitleCache = getTruncatedCache(fullTitleCache); this.fullTitleCache = fullTitleCache; @@ -1165,6 +1170,7 @@ public abstract class TaxonNameBase, S extends INam * * @return false */ + @Override @Transient public boolean isCodeCompliant() { //FIXME @@ -1172,11 +1178,13 @@ public abstract class TaxonNameBase, S extends INam return false; } + @Override @Transient public List getTaggedName(){ return getCacheStrategy().getTaggedTitle(this); } + @Override @Transient public String getFullTitleCache(){ if (protectedFullTitleCache){ @@ -1356,6 +1364,7 @@ public abstract class TaxonNameBase, S extends INam * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String) * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) */ + @Override @Transient public Set getNameRelations() { Set rels = new HashSet(); @@ -1377,6 +1386,7 @@ public abstract class TaxonNameBase, S extends INam * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) * @see #addNameRelationship(NameRelationship) */ + @Override public void addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, String ruleConsidered){ addRelationshipToName(toName, type, null, null, ruleConsidered); // NameRelationship rel = new NameRelationship(toName, this, type, ruleConsidered); @@ -1396,6 +1406,7 @@ public abstract class TaxonNameBase, S extends INam * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) * @see #addNameRelationship(NameRelationship) */ + @Override public NameRelationship addRelationshipToName(TaxonNameBase toName, NameRelationshipType type, Reference citation, String microCitation, String ruleConsidered){ if (toName == null){ throw new NullPointerException("Null is not allowed as name for a name relationship"); @@ -1419,6 +1430,7 @@ public abstract class TaxonNameBase, S extends INam * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String) * @see #addNameRelationship(NameRelationship) */ + @Override public NameRelationship addRelationshipFromName(TaxonNameBase fromName, NameRelationshipType type, String ruleConsidered){ //fromName.addRelationshipToName(this, type, null, null, ruleConsidered); return this.addRelationshipFromName(fromName, type, null, null, ruleConsidered); @@ -1438,6 +1450,7 @@ public abstract class TaxonNameBase, S extends INam * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String) * @see #addNameRelationship(NameRelationship) */ + @Override public NameRelationship addRelationshipFromName(TaxonNameBase fromName, NameRelationshipType type, Reference citation, String microCitation, String ruleConsidered){ return fromName.addRelationshipToName(this, type, citation, microCitation, ruleConsidered); } @@ -1479,6 +1492,7 @@ public abstract class TaxonNameBase, S extends INam * @param nameRelation the name relationship which should be deleted from one of both sets * @see #getNameRelations() */ + @Override public void removeNameRelationship(NameRelationship nameRelation) { TaxonNameBase fromName = nameRelation.getFromName(); @@ -1501,6 +1515,7 @@ public abstract class TaxonNameBase, S extends INam this.relationsFromThisName.remove(nameRelation); } + @Override public void removeRelationToTaxonName(TaxonNameBase toTaxonName) { Set nameRelationships = new HashSet(); // nameRelationships.addAll(this.getNameRelations()); @@ -1551,6 +1566,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getRelationsToThisName() * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String) */ + @Override public Set getRelationsFromThisName() { if(relationsFromThisName == null) { this.relationsFromThisName = new HashSet<>(); @@ -1566,6 +1582,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getRelationsFromThisName() * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String) */ + @Override public Set getRelationsToThisName() { if(relationsToThisName == null) { this.relationsToThisName = new HashSet<>(); @@ -1582,6 +1599,7 @@ public abstract class TaxonNameBase, S extends INam * @see NomenclaturalStatus * @see NomenclaturalStatusType */ + @Override public Set getStatus() { if(status == null) { this.status = new HashSet<>(); @@ -1596,9 +1614,11 @@ public abstract class TaxonNameBase, S extends INam * @param nomStatus the nomenclatural status to be added * @see #getStatus() */ + @Override public void addStatus(NomenclaturalStatus nomStatus) { this.status.add(nomStatus); } + @Override public NomenclaturalStatus addStatus(NomenclaturalStatusType statusType, Reference citation, String microCitation) { NomenclaturalStatus newStatus = NomenclaturalStatus.NewInstance(statusType, citation, microCitation); this.status.add(newStatus); @@ -1613,6 +1633,7 @@ public abstract class TaxonNameBase, S extends INam * @param nomStatus the nomenclatural status of this taxon name which should be deleted * @see #getStatus() */ + @Override public void removeStatus(NomenclaturalStatus nomStatus) { //TODO to be implemented? logger.warn("not yet fully implemented?"); @@ -1695,6 +1716,7 @@ public abstract class TaxonNameBase, S extends INam * false otherwise (also in case this taxon name is the only one in the * homotypical group). */ + @Override @Transient public boolean isOriginalCombination(){ Set relationsFromThisName = this.getRelationsFromThisName(); @@ -1714,6 +1736,7 @@ public abstract class TaxonNameBase, S extends INam * false otherwise (also in case this taxon name is the only one in the * homotypical group). */ + @Override @Transient public boolean isReplacedSynonym(){ Set relationsFromThisName = this.getRelationsFromThisName(); @@ -1736,6 +1759,7 @@ public abstract class TaxonNameBase, S extends INam * * If no basionym exists null is returned. */ + @Override @Transient public TaxonNameBase getBasionym(){ Set basionyms = getBasionyms(); @@ -1753,6 +1777,7 @@ public abstract class TaxonNameBase, S extends INam * Karsten transferred later this taxon to the genus Picea. Therefore, * Pinus abies L. is the basionym of the new combination Picea abies (L.) H. Karst. */ + @Override @Transient public Set getBasionyms(){ Set result = new HashSet(); @@ -1777,6 +1802,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getBasionym() * @see #addBasionym(TaxonNameBase, String) */ + @Override public void addBasionym(T basionym){ addBasionym(basionym, null, null, null); } @@ -1794,6 +1820,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getBasionym() * @see #addBasionym(TaxonNameBase) */ + @Override public NameRelationship addBasionym(T basionym, Reference citation, String microcitation, String ruleConsidered){ if (basionym != null){ return basionym.addRelationshipToName(this, NameRelationshipType.BASIONYM(), citation, microcitation, ruleConsidered); @@ -1806,6 +1833,7 @@ public abstract class TaxonNameBase, S extends INam * Returns the set of taxon names which are the {@link NameRelationshipType#REPLACED_SYNONYM() replaced synonyms} of this taxon name. * */ + @Override @Transient public Set getReplacedSynonyms(){ Set result = new HashSet(); @@ -1832,6 +1860,7 @@ public abstract class TaxonNameBase, S extends INam * @see #addBasionym(TaxonNameBase) */ //TODO: Check if true: The replaced synonym cannot have itself a replaced synonym (?). + @Override public void addReplacedSynonym(T replacedSynonym, Reference citation, String microcitation, String ruleConsidered){ if (replacedSynonym != null){ replacedSynonym.addRelationshipToName(this, NameRelationshipType.REPLACED_SYNONYM(), citation, microcitation, ruleConsidered); @@ -1847,6 +1876,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getBasionym() * @see #addBasionym(TaxonNameBase) */ + @Override public void removeBasionyms(){ Set removeRelations = new HashSet(); for (NameRelationship nameRelation : this.getRelationsToThisName()){ @@ -1867,6 +1897,7 @@ public abstract class TaxonNameBase, S extends INam * * @see Rank */ + @Override public Rank getRank(){ return this.rank; } @@ -1874,6 +1905,7 @@ public abstract class TaxonNameBase, S extends INam /** * @see #getRank() */ + @Override public void setRank(Rank rank){ this.rank = rank; } @@ -1887,6 +1919,7 @@ public abstract class TaxonNameBase, S extends INam * @see eu.etaxonomy.cdm.model.reference.INomenclaturalReference * @see eu.etaxonomy.cdm.model.reference.Reference */ + @Override public INomenclaturalReference getNomenclaturalReference(){ return this.nomenclaturalReference; } @@ -1898,6 +1931,7 @@ public abstract class TaxonNameBase, S extends INam * @throws IllegalArgumentException if parameter nomenclaturalReference is not assignable from {@link INomenclaturalReference} * @see #getNomenclaturalReference() */ + @Override public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference){ if(nomenclaturalReference != null){ if(!INomenclaturalReference.class.isAssignableFrom(nomenclaturalReference.getClass())){ @@ -1914,6 +1948,7 @@ public abstract class TaxonNameBase, S extends INam * The appended phrase is a non-atomised addition to a name. It is * not ruled by a nomenclatural code. */ + @Override public String getAppendedPhrase(){ return this.appendedPhrase; } @@ -1921,6 +1956,7 @@ public abstract class TaxonNameBase, S extends INam /** * @see #getAppendedPhrase() */ + @Override public void setAppendedPhrase(String appendedPhrase){ this.appendedPhrase = StringUtils.isBlank(appendedPhrase)? null : appendedPhrase; } @@ -1934,12 +1970,14 @@ public abstract class TaxonNameBase, S extends INam * requires the existence of a nomenclatural reference. */ //Details of the nomenclatural reference (protologue). + @Override public String getNomenclaturalMicroReference(){ return this.nomenclaturalMicroReference; } /** * @see #getNomenclaturalMicroReference() */ + @Override public void setNomenclaturalMicroReference(String nomenclaturalMicroReference){ this.nomenclaturalMicroReference = StringUtils.isBlank(nomenclaturalMicroReference)? null : nomenclaturalMicroReference; } @@ -1967,6 +2005,7 @@ public abstract class TaxonNameBase, S extends INam /** * @param warnings */ + @Override public void addParsingProblems(int problems){ parsingProblem = ParserProblem.addProblems(parsingProblem, problems); } @@ -2009,6 +2048,7 @@ public abstract class TaxonNameBase, S extends INam * @see NameTypeDesignation * @see SpecimenTypeDesignation */ + @Override public Set getTypeDesignations() { if(typeDesignations == null) { this.typeDesignations = new HashSet(); @@ -2022,6 +2062,7 @@ public abstract class TaxonNameBase, S extends INam * * @param typeDesignation the type designation which should be deleted */ + @Override @SuppressWarnings("deprecation") public void removeTypeDesignation(TypeDesignationBase typeDesignation) { this.typeDesignations.remove(typeDesignation); @@ -2041,6 +2082,7 @@ public abstract class TaxonNameBase, S extends INam * @see NameTypeDesignation * @see HomotypicalGroup */ + @Override @Transient public Set getSpecimenTypeDesignationsOfHomotypicalGroup() { return this.getHomotypicalGroup().getSpecimenTypeDesignations(); @@ -2058,6 +2100,7 @@ public abstract class TaxonNameBase, S extends INam * @see NameTypeDesignation * @see SpecimenTypeDesignation */ + @Override @Transient public Set getNameTypeDesignations() { Set result = new HashSet(); @@ -2088,6 +2131,7 @@ public abstract class TaxonNameBase, S extends INam * @see NameTypeDesignation * @see TypeDesignationBase#isNotDesignated() */ + @Override public NameTypeDesignation addNameTypeDesignation(TaxonNameBase typeSpecies, Reference citation, String citationMicroReference, @@ -2120,6 +2164,7 @@ public abstract class TaxonNameBase, S extends INam * @see NameTypeDesignation * @see TypeDesignationBase#isNotDesignated() */ + @Override public NameTypeDesignation addNameTypeDesignation(TaxonNameBase typeSpecies, Reference citation, String citationMicroReference, @@ -2137,6 +2182,7 @@ public abstract class TaxonNameBase, S extends INam * Returns the set of {@link SpecimenTypeDesignation specimen type designations} * that typify this taxon name. */ + @Override @Transient public Set getSpecimenTypeDesignations() { Set result = new HashSet(); @@ -2168,6 +2214,7 @@ public abstract class TaxonNameBase, S extends INam * @see SpecimenTypeDesignation * @see TypeDesignationBase#isNotDesignated() */ + @Override public SpecimenTypeDesignation addSpecimenTypeDesignation(DerivedUnit typeSpecimen, SpecimenTypeDesignationStatus status, Reference citation, @@ -2198,6 +2245,7 @@ public abstract class TaxonNameBase, S extends INam * is thrown. We do this to prevent a type designation to be used for multiple taxon names. * */ + @Override public boolean addTypeDesignation(TypeDesignationBase typeDesignation, boolean addToAllNames){ //currently typeDesignations are not persisted with the homotypical group //so explicit adding to the homotypical group is not necessary. @@ -2247,6 +2295,7 @@ public abstract class TaxonNameBase, S extends INam * @see HomotypicalGroup */ + @Override public HomotypicalGroup getHomotypicalGroup() { if (homotypicalGroup == null){ homotypicalGroup = new HomotypicalGroup(); @@ -2258,6 +2307,7 @@ public abstract class TaxonNameBase, S extends INam /** * @see #getHomotypicalGroup() */ + @Override public void setHomotypicalGroup(HomotypicalGroup homotypicalGroup) { if (homotypicalGroup == null){ throw new IllegalArgumentException("HomotypicalGroup of name should never be null but was set to 'null'"); @@ -2285,6 +2335,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getNomenclaturalReference() * @see #getNomenclaturalMicroReference() */ + @Override @Transient public String getCitationString(){ return getNomenclaturalReference().getNomenclaturalCitation(getNomenclaturalMicroReference()); @@ -2307,6 +2358,7 @@ public abstract class TaxonNameBase, S extends INam * @return the string containing the publication date of this taxon name * @see eu.etaxonomy.cdm.model.reference.INomenclaturalReference#getYear() */ + @Override @Transient @ValidTaxonomicYear(groups=Level3.class) public String getReferenceYear(){ @@ -2328,6 +2380,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getTaxa() * @see #getSynonyms() */ + @Override public Set getTaxonBases() { if(taxonBases == null) { this.taxonBases = new HashSet(); @@ -2344,6 +2397,7 @@ public abstract class TaxonNameBase, S extends INam * @see #removeTaxonBase(TaxonBase) */ //TODO protected + @Override public void addTaxonBase(TaxonBase taxonBase){ Method method = ReflectionUtils.findMethod(TaxonBase.class, "setName", new Class[] {TaxonNameBase.class}); ReflectionUtils.makeAccessible(method); @@ -2357,6 +2411,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getTaxonBases() * @see #addTaxonBase(TaxonBase) */ + @Override public void removeTaxonBase(TaxonBase taxonBase){ Method method = ReflectionUtils.findMethod(TaxonBase.class, "setName", new Class[] {TaxonNameBase.class}); ReflectionUtils.makeAccessible(method); @@ -2374,6 +2429,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getTaxonBases() * @see #getSynonyms() */ + @Override @Transient public Set getTaxa(){ Set result = new HashSet(); @@ -2394,6 +2450,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getTaxonBases() * @see #getTaxa() */ + @Override @Transient public Set getSynonyms() { Set result = new HashSet(); @@ -2504,6 +2561,7 @@ public abstract class TaxonNameBase, S extends INam * @see #removeDescription(TaxonNameDescription) * @see eu.etaxonomy.cdm.model.description.TaxonNameDescription */ + @Override public Set getDescriptions() { return descriptions; } @@ -2518,6 +2576,7 @@ public abstract class TaxonNameBase, S extends INam * @see #getDescriptions() * @see #removeDescription(TaxonNameDescription) */ + @Override public void addDescription(TaxonNameDescription description) { java.lang.reflect.Field field = ReflectionUtils.findField(TaxonNameDescription.class, "taxonName", TaxonNameBase.class); ReflectionUtils.makeAccessible(field); @@ -2534,6 +2593,7 @@ public abstract class TaxonNameBase, S extends INam * @see #addDescription(TaxonNameDescription) * @see eu.etaxonomy.cdm.model.description.TaxonNameDescription#getTaxonName() */ + @Override public void removeDescription(TaxonNameDescription description) { java.lang.reflect.Field field = ReflectionUtils.findField(TaxonNameDescription.class, "taxonName", TaxonNameBase.class); ReflectionUtils.makeAccessible(field); @@ -2543,6 +2603,7 @@ public abstract class TaxonNameBase, S extends INam // *********** HOMOTYPIC GROUP METHODS ************************************************** + @Override @Transient public void mergeHomotypicGroups(TaxonNameBase name){ this.getHomotypicalGroup().merge(name.getHomotypicalGroup()); @@ -2560,6 +2621,7 @@ public abstract class TaxonNameBase, S extends INam * @return the boolean value of the check * @see HomotypicalGroup */ + @Override @Transient public boolean isHomotypic(TaxonNameBase homoTypicName) { if (homoTypicName == null) { @@ -2583,6 +2645,7 @@ public abstract class TaxonNameBase, S extends INam * @param name * @return */ + @Override @Transient public boolean isGroupsBasionym() { if (homotypicalGroup == null){ @@ -2615,6 +2678,7 @@ public abstract class TaxonNameBase, S extends INam * @param toName * @return */ + @Override @Transient public boolean isBasionymFor(TaxonNameBase newCombinationName) { Set relations = newCombinationName.getRelationsToThisName(); @@ -2633,6 +2697,7 @@ public abstract class TaxonNameBase, S extends INam * * @see HomotypicalGroup.setGroupBasionym(TaxonNameBase basionymName) */ + @Override @Transient public void makeGroupsBasionym() { this.homotypicalGroup.setGroupBasionym(this); @@ -2651,6 +2716,7 @@ public abstract class TaxonNameBase, S extends INam * @see #isSpecies() * @see #isInfraSpecific() */ + @Override @Transient public boolean isSupraGeneric() { if (rank == null){ @@ -2668,6 +2734,7 @@ public abstract class TaxonNameBase, S extends INam * @see #isSpecies() * @see #isInfraSpecific() */ + @Override @Transient public boolean isGenus() { if (rank == null){ @@ -2686,6 +2753,7 @@ public abstract class TaxonNameBase, S extends INam * @see #isSpecies() * @see #isInfraSpecific() */ + @Override @Transient public boolean isInfraGeneric() { if (rank == null){ @@ -2704,6 +2772,7 @@ public abstract class TaxonNameBase, S extends INam * @see #isSpecies() * @see #isInfraSpecific() */ + @Override @Transient public boolean isSupraSpecific(){ if (rank == null) { @@ -2723,6 +2792,7 @@ public abstract class TaxonNameBase, S extends INam * @see #isInfraGeneric() * @see #isInfraSpecific() */ + @Override @Transient public boolean isSpecies() { if (rank == null){ @@ -2741,6 +2811,7 @@ public abstract class TaxonNameBase, S extends INam * @see #isInfraGeneric() * @see #isSpecies() */ + @Override @Transient public boolean isInfraSpecific() { if (rank == null){ @@ -2758,6 +2829,7 @@ public abstract class TaxonNameBase, S extends INam * * @return */ + @Override @Transient public boolean isSpeciesAggregate() { if (rank == null){ @@ -2780,6 +2852,7 @@ public abstract class TaxonNameBase, S extends INam * @see #isCodeCompliant() * @see #getHasProblem() */ + @Override public NomenclaturalCode getNomenclaturalCode() { logger.warn("TaxonNameBase has no specific Code defined. Use subclasses"); return null; @@ -2808,6 +2881,7 @@ public abstract class TaxonNameBase, S extends INam * * @param basionymName */ + @Override @Transient public void setAsGroupsBasionym() { @@ -2865,6 +2939,7 @@ public abstract class TaxonNameBase, S extends INam * * @param basionymName */ + @Override @Transient public void removeAsGroupsBasionym() { -- 2.34.1