X-Git-Url: https://dev.e-taxonomy.eu/gitweb/cdmlib.git/blobdiff_plain/c19dfdc5b08f4556fa2482c429402323e6b5a920..750d1487b1aa955808e96acc8d9e438cd565d15b:/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/NonViralName.java 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 f010c1580f..4570af8776 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 @@ -13,6 +13,8 @@ package eu.etaxonomy.cdm.model.name; import eu.etaxonomy.cdm.model.agent.INomenclaturalAuthor; import eu.etaxonomy.cdm.model.agent.TeamOrPersonBase; import eu.etaxonomy.cdm.model.reference.INomenclaturalReference; +import eu.etaxonomy.cdm.strategy.cache.INameCacheStrategy; +import eu.etaxonomy.cdm.strategy.cache.INonViralNameCacheStrategy; import eu.etaxonomy.cdm.strategy.cache.NonViralNameDefaultCacheStrategy; import org.apache.log4j.Logger; @@ -23,53 +25,100 @@ import org.hibernate.annotations.Target; import javax.persistence.*; /** - * Taxon name class for all non viral taxa. Parentetical authorship is derived - * from basionym relationship. + * The taxon name class for all non viral taxa. Parentetical authorship is derived + * from basionym relationship. The scientific name including author strings and + * maybe year can be stored as a string in the inherited {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute. + * The scientific name string without author strings and year can be stored in the {@link #getNameCache() nameCache} attribute. + * * @author m.doering * @version 1.0 * @created 08-Nov-2007 13:06:39 */ @Entity -public class NonViralName extends TaxonNameBase { - static Logger logger = Logger.getLogger(NonViralName.class); - //The suprageneric or the genus name +public class NonViralName extends TaxonNameBase { + private static final Logger logger = Logger.getLogger(NonViralName.class); + + private String nameCache; private String genusOrUninomial; - //Genus subdivision epithet private String infraGenericEpithet; - //species epithet private String specificEpithet; - //Species subdivision epithet private String infraSpecificEpithet; - //Author team that published the present combination private INomenclaturalAuthor combinationAuthorTeam; - //Author team that contributed to the publication of the present combination private INomenclaturalAuthor exCombinationAuthorTeam; - //Author team that published the original publication private INomenclaturalAuthor basionymAuthorTeam; - //Author team that contributed to the original publication of the name private INomenclaturalAuthor exBasionymAuthorTeam; - //concatenated und formated authorteams including basionym and combination authors private String authorshipCache; + protected boolean protectedAuthorshipCache; + protected boolean protectedNameCache; + + protected INonViralNameCacheStrategy cacheStrategy; + + // ************* CONSTRUCTORS *************/ //needed by hibernate + /** + * Class constructor: creates a new non viral taxon name instance + * only containing the {@link eu.etaxonomy.cdm.strategy.cache.NonViralNameDefaultCacheStrategy default cache strategy}. + * + * @see #NonViralName(Rank, HomotypicalGroup) + * @see #NonViralName(Rank, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup) + * @see eu.etaxonomy.cdm.strategy.cache.INonViralNameCacheStrategy + * @see eu.etaxonomy.cdm.strategy.cache.INameCacheStrategy + * @see eu.etaxonomy.cdm.strategy.cache.IIdentifiableEntityCacheStrategy + */ protected NonViralName(){ super(); setNameCacheStrategy(); } - private void setNameCacheStrategy(){ - if (getClass() == NonViralName.class){ - this.cacheStrategy = NonViralNameDefaultCacheStrategy.NewInstance(); - } - - } - - public NonViralName(Rank rank) { - super(rank); + /** + * Class constructor: creates a new non viral taxon name instance + * only containing its {@link common.Rank rank}, + * its {@link common.HomotypicalGroup homotypical group} and + * only containing the {@link eu.etaxonomy.cdm.strategy.cache.NonViralNameDefaultCacheStrategy default cache strategy}. + * + * @param rank the rank to be assigned to this non viral taxon name + * @param homotypicalGroup the homotypical group to which this non viral taxon name belongs + * @see #NonViralName() + * @see #NonViralName(Rank, String, String, String, TeamOrPersonBase, INomenclaturalReference, String, HomotypicalGroup) + * @see #NewInstance(Rank, HomotypicalGroup) + * @see eu.etaxonomy.cdm.strategy.cache.INonViralNameCacheStrategy + * @see eu.etaxonomy.cdm.strategy.cache.INameCacheStrategy + * @see eu.etaxonomy.cdm.strategy.cache.IIdentifiableEntityCacheStrategy + */ + protected NonViralName(Rank rank, HomotypicalGroup homotypicalGroup) { + super(rank, homotypicalGroup); setNameCacheStrategy(); } - public NonViralName(Rank rank, String genusOrUninomial, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef) { - super(rank); + /** + * Class constructor: creates a new non viral taxon name instance + * containing its {@link common.Rank rank}, + * its {@link common.HomotypicalGroup homotypical group}, + * its scientific name components, its {@link agent.TeamOrPersonBase author(team)}, + * its {@link reference.INomenclaturalReference nomenclatural reference} and + * the {@link eu.etaxonomy.cdm.strategy.cache.NonViralNameDefaultCacheStrategy default cache strategy}. + * + * @param rank the rank to be assigned to this non viral taxon name + * @param genusOrUninomial the string for this taxon name + * if its rank is genus or higher or for the genus part + * if its rank is lower than genus + * @param specificEpithet the string for the first epithet of + * this non viral taxon name if its rank is lower than genus + * @param infraSpecificEpithet the string for the second epithet of + * this non viral taxon name if its rank is lower than species + * @param combinationAuthorTeam the author or the team who published this non viral taxon name + * @param nomenclaturalReference the nomenclatural reference where this non viral taxon name was published + * @param nomenclMicroRef the string with the details for precise location within the nomenclatural reference + * @param homotypicalGroup the homotypical group to which this non viral taxon name belongs + * @see #NonViralName() + * @see #NonViralName(Rank, HomotypicalGroup) + * @see #NewInstance(Rank, HomotypicalGroup) + * @see eu.etaxonomy.cdm.strategy.cache.INonViralNameCacheStrategy + * @see eu.etaxonomy.cdm.strategy.cache.INameCacheStrategy + * @see eu.etaxonomy.cdm.strategy.cache.IIdentifiableEntityCacheStrategy + */ + protected NonViralName(Rank rank, String genusOrUninomial, String specificEpithet, String infraSpecificEpithet, TeamOrPersonBase combinationAuthorTeam, INomenclaturalReference nomenclaturalReference, String nomenclMicroRef, HomotypicalGroup homotypicalGroup) { + super(rank, homotypicalGroup); setNameCacheStrategy(); setGenusOrUninomial(genusOrUninomial); setSpecificEpithet(specificEpithet); @@ -78,91 +127,272 @@ public class NonViralName extends TaxonNameBase extends TaxonNameBase)cacheStrategy).getAuthorshipCache((T)this); + } + } /** - * returns concatenated und formated authorteams including basionym and - * combination authors + * Returns the concatenated and formated authorteams 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 authorteams for this non viral taxon name + * @see #generateAuthorship() */ public String getAuthorshipCache() { + if (protectedAuthorshipCache){ + return this.authorshipCache; + } + // is title dirty, i.e. equal NULL? + if (authorshipCache == null){ + this.authorshipCache = generateAuthorship(); + }else{ + //TODO get is Dirty of authors + this.authorshipCache = generateAuthorship(); + } return 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 + * @see #getAuthorshipCache() + */ public void setAuthorshipCache(String authorshipCache) { this.authorshipCache = authorshipCache; } + + + /** + * Returns the boolean value "true" if the components of this non viral taxon name + * follow the rules of the corresponding {@link NomenclaturalCode nomenclatural code}, + * "false" otherwise. The nomenclatural code depends on + * the concrete name subclass ({@link BacterialName BacterialName}, + * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName} or + * {@link ZoologicalName ZoologicalName} to which this non viral taxon name belongs. + * This method overrides the isCodeCompliant method from {@link TaxonNameBase#isCodeCompliant() TaxonNameBase}. + * + * @return the boolean value expressing the compliance of this non viral taxon name to its nomenclatural code + * @see TaxonNameBase#isCodeCompliant() + */ @Override @Transient public boolean isCodeCompliant() { - // TODO Auto-generated method stub + //FIXME + logger.warn("is CodeCompliant not yet implemented"); return false; } + /* (non-Javadoc) + * @see eu.etaxonomy.cdm.model.name.TaxonNameBase#getNomeclaturalCode() + */ + /** + * Returns null as {@link NomenclaturalCode nomenclatural code} that governs + * the construction of this non viral taxon name since there is no specific + * nomenclatural code defined. The real implementention takes place in the + * subclasses {@link BacterialName BacterialName}, + * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName} and + * {@link ZoologicalName ZoologicalName}. + * This method overrides the getNomeclaturalCode method from {@link TaxonNameBase#getNomeclaturalCode() TaxonNameBase}. + * + * @return null + * @see #isCodeCompliant() + * @see TaxonNameBase#getHasProblem() + */ + @Transient + @Override + public NomenclaturalCode getNomeclaturalCode() { + //TODO What is the purpose of overriding the inherited method? + logger.warn("Non Viral Name has no specific Code defined. Use subclasses"); + return null; + } + + /** + * 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() { + return protectedAuthorshipCache; + } + + /** + * @see #isProtectedAuthorshipCache() + * @see #getAuthorshipCache() + */ + public void setProtectedAuthorshipCache(boolean protectedAuthorshipCache) { + this.protectedAuthorshipCache = protectedAuthorshipCache; + } + + + + } \ No newline at end of file