2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
6 * The contents of this file are subject to the Mozilla Public License Version 1.1
7 * See LICENSE.TXT at the top of this package for the full license terms.
10 package eu
.etaxonomy
.cdm
.model
.name
;
12 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
13 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
14 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.StrictReferenceBase
;
16 import eu
.etaxonomy
.cdm
.model
.taxon
.Synonym
;
17 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
19 import eu
.etaxonomy
.cdm
.model
.common
.IParsable
;
20 import eu
.etaxonomy
.cdm
.model
.common
.IRelated
;
21 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
22 import eu
.etaxonomy
.cdm
.model
.common
.IReferencedEntity
;
23 import eu
.etaxonomy
.cdm
.model
.common
.RelationshipBase
;
26 import org
.apache
.log4j
.Logger
;
27 import org
.hibernate
.annotations
.Cascade
;
28 import org
.hibernate
.annotations
.CascadeType
;
29 import org
.hibernate
.annotations
.Index
;
30 import org
.hibernate
.annotations
.Table
;
31 import org
.hibernate
.annotations
.Target
;
33 import eu
.etaxonomy
.cdm
.strategy
.cache
.INameCacheStrategy
;
37 import java
.lang
.reflect
.Method
;
40 import javax
.persistence
.*;
43 * The upmost (abstract) class for scientific taxon names regardless of any
44 * particular nomenclature code. The scientific taxon name does not depend
45 * on the use made of it in a publication or a treatment
46 * ({@link taxon.TaxonBase taxon concept respectively potential taxon})
47 * as an {@link taxon.Taxon "accepted" respectively "correct" (taxon) name}
48 * or as a {@link taxon.Synonym synonym}.
52 * @created 08-Nov-2007 13:06:57
55 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
56 @Table(appliesTo
="TaxonNameBase", indexes
= { @Index(name
= "taxonNameBaseTitleCacheIndex", columnNames
= { "titleCache" }) })
57 public abstract class TaxonNameBase
<T
extends TaxonNameBase
, S
extends INameCacheStrategy
> extends IdentifiableEntity
<TaxonNameBase
> implements IReferencedEntity
, IParsable
, IRelated
{
58 static Logger logger
= Logger
.getLogger(TaxonNameBase
.class);
59 private String appendedPhrase
;
60 private String nomenclaturalMicroReference
;
61 private boolean hasProblem
= false;
62 protected Set
<NameTypeDesignation
> nameTypeDesignations
= new HashSet
<NameTypeDesignation
>();
63 private Set
<SpecimenTypeDesignation
> specimenTypeDesignations
= new HashSet
<SpecimenTypeDesignation
>();
64 private HomotypicalGroup homotypicalGroup
= new HomotypicalGroup();
65 private Set
<NameRelationship
> relationsFromThisName
= new HashSet
<NameRelationship
>();
66 private Set
<NameRelationship
> relationsToThisName
= new HashSet
<NameRelationship
>();
67 private Set
<NomenclaturalStatus
> status
= new HashSet
<NomenclaturalStatus
>();
68 private Set
<TaxonBase
> taxonBases
= new HashSet
<TaxonBase
>();
70 private INomenclaturalReference nomenclaturalReference
;
72 static Method methodTaxonBaseSetName
;
74 // ************* CONSTRUCTORS *************/
76 * Class constructor: creates a new empty taxon name.
78 * @see #TaxonNameBase(Rank)
79 * @see #TaxonNameBase(HomotypicalGroup)
80 * @see #TaxonNameBase(Rank, HomotypicalGroup)
82 public TaxonNameBase() {
86 * Class constructor: creates a new taxon name
87 * only containing its {@link common.Rank rank}.
89 * @param rank the rank to be assigned to this taxon name
90 * @see #TaxonNameBase()
91 * @see #TaxonNameBase(HomotypicalGroup)
92 * @see #TaxonNameBase(Rank, HomotypicalGroup)
94 public TaxonNameBase(Rank rank
) {
98 * Class constructor: creates a new taxon name
99 * only containing its {@link common.HomotypicalGroup homotypical group}.
100 * The new taxon name will be also added to the set of taxon names
101 * belonging to this homotypical group. If the homotypical group
102 * does not exist a new instance will be created for it.
104 * @param homotypicalGroup the homotypical group to which this taxon name belongs
105 * @see #TaxonNameBase()
106 * @see #TaxonNameBase(Rank)
107 * @see #TaxonNameBase(Rank, HomotypicalGroup)
109 public TaxonNameBase(HomotypicalGroup homotypicalGroup
) {
110 this(null, homotypicalGroup
);
113 * Class constructor: creates a new taxon name
114 * only containing its {@link common.Rank rank} and
115 * its {@link common.HomotypicalGroup homotypical group}.
117 * @param rank the rank to be assigned to this taxon name
118 * @param homotypicalGroup the homotypical group to which this taxon name belongs
119 * @see #TaxonNameBase()
120 * @see #TaxonNameBase(Rank)
121 * @see #TaxonNameBase(HomotypicalGroup)
123 public TaxonNameBase(Rank rank
, HomotypicalGroup homotypicalGroup
) {
126 if (homotypicalGroup
== null){
127 homotypicalGroup
= new HomotypicalGroup();
129 homotypicalGroup
.addTypifiedName(this);
132 //********* METHODS **************************************/
134 //@Index(name="TaxonNameBaseTitleCacheIndex")
135 // public String getTitleCache(){
136 // return super.getTitleCache();
140 * Returns the boolean value "false" since the components of this taxon name
141 * cannot follow the rules of a corresponding {@link NomenclaturalCode nomenclatural code}
142 * which is not defined for this class. The nomenclature code depends on
143 * the concrete name subclass ({@link BacterialName BacterialName},
144 * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName},
145 * {@link ZoologicalName ZoologicalName} or {@link ViralName ViralName})
146 * to which a taxon name belongs.
151 public abstract boolean isCodeCompliant();
155 * Returns the set of all {@link NameRelationship name relationships}
156 * in which this taxon name is involved. A taxon name can be both source
157 * in some name relationships or target in some others.
159 * @see #getRelationsToThisName()
160 * @see #getRelationsFromThisName()
161 * @see #addNameRelationship(NameRelationship)
162 * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
163 * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
166 public Set
<NameRelationship
> getNameRelations() {
167 Set
<NameRelationship
> rels
= new HashSet
<NameRelationship
>();
168 rels
.addAll(getRelationsFromThisName());
169 rels
.addAll(getRelationsToThisName());
173 * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from this taxon name to another taxon name
174 * and adds it both to the set of {@link #getRelationsFromThisName() relations from this taxon name} and
175 * to the set of {@link #getRelationsToThisName() relations to the other taxon name}.
177 * @param toName the taxon name of the target for this new name relationship
178 * @param type the type of this new name relationship
179 * @param ruleConsidered the string which specifies the rule on which this name relationship is based
180 * @see #getRelationsToThisName()
181 * @see #getNameRelations()
182 * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
183 * @see #addNameRelationship(NameRelationship)
185 public void addRelationshipToName(TaxonNameBase toName
, NameRelationshipType type
, String ruleConsidered
){
186 NameRelationship rel
= new NameRelationship(toName
, this, type
, ruleConsidered
);
189 * Creates a new {@link NameRelationship#NameRelationship(TaxonNameBase, TaxonNameBase, NameRelationshipType, String) name relationship} from another taxon name to this taxon name
190 * and adds it both to the set of {@link #getRelationsToThisName() relations to this taxon name} and
191 * to the set of {@link #getRelationsFromThisName() relations from the other taxon name}.
193 * @param fromName the taxon name of the source for this new name relationship
194 * @param type the type of this new name relationship
195 * @param ruleConsidered the string which specifies the rule on which this name relationship is based
196 * @see #getRelationsFromThisName()
197 * @see #getNameRelations()
198 * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
199 * @see #addNameRelationship(NameRelationship)
201 public void addRelationshipFromName(TaxonNameBase fromName
, NameRelationshipType type
, String ruleConsidered
){
202 NameRelationship rel
= new NameRelationship(this, fromName
, type
, ruleConsidered
);
205 * Adds an existing {@link NameRelationship name relationship} either to the set of
206 * {@link #getRelationsToThisName() relations to this taxon name} or to the set of
207 * {@link #getRelationsFromThisName() relations from this taxon name}. If neither the
208 * source nor the target of the name relationship match with this taxon
209 * no addition will be carried out.
211 * @param rel the name relationship to be added to one of this taxon name's name relationships sets
212 * @see #getNameRelations()
213 * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
214 * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
216 protected void addNameRelationship(NameRelationship rel
) {
217 if (rel
!=null && rel
.getToName().equals(this)){
218 this.relationsToThisName
.add(rel
);
219 }else if(rel
!=null && rel
.getFromName().equals(this)){
220 this.relationsFromThisName
.add(rel
);
222 //TODO: raise error???
226 * Removes one {@link NameRelationship name relationship} from one of both sets of
227 * {@link #getNameRelations() name relationships} in which this taxon name is involved.
228 * The name relationship will also be removed from one of both sets belonging
229 * to the second taxon name involved. Furthermore the fromName and toName
230 * attributes of the name relationship object will be nullified.
232 * @param nameRelation the name relationship which should be deleted from one of both sets
233 * @see #getNameRelations()
235 public void removeNameRelationship(NameRelationship nameRelation
) {
236 //TODO to be implemented?
237 logger
.warn("not yet fully implemented?");
238 this.relationsToThisName
.remove(nameRelation
);
239 this.relationsFromThisName
.remove(nameRelation
);
244 * Does exactly the same as the addNameRelationship method provided that
245 * the given relationship is a name relationship.
247 * @param relation the relationship to be added to one of this taxon name's name relationships sets
248 * @see #addNameRelationship(NameRelationship)
249 * @see #getNameRelations()
250 * @see NameRelationship
251 * @see common.RelationshipBase
253 public void addRelationship(RelationshipBase relation
) {
254 if (relation
instanceof NameRelationship
){
255 addNameRelationship((NameRelationship
)relation
);
257 //TODO exception handling
263 * Returns the set of all {@link NameRelationship name relationships}
264 * in which this taxon name is involved as a source.
266 * @see #getNameRelations()
267 * @see #getRelationsToThisName()
268 * @see #addRelationshipFromName(TaxonNameBase, NameRelationshipType, String)
270 @OneToMany(mappedBy
="relatedFrom", fetch
= FetchType
.LAZY
)
271 @Cascade({CascadeType
.SAVE_UPDATE
})
272 public Set
<NameRelationship
> getRelationsFromThisName() {
273 return relationsFromThisName
;
275 private void setRelationsFromThisName(Set
<NameRelationship
> relationsFromThisName
) {
276 this.relationsFromThisName
= relationsFromThisName
;
280 * Returns the set of all {@link NameRelationship name relationships}
281 * in which this taxon name is involved as a target.
283 * @see #getNameRelations()
284 * @see #getRelationsFromThisName()
285 * @see #addRelationshipToName(TaxonNameBase, NameRelationshipType, String)
287 @OneToMany(mappedBy
="relatedTo", fetch
= FetchType
.LAZY
)
288 @Cascade({CascadeType
.SAVE_UPDATE
})
289 public Set
<NameRelationship
> getRelationsToThisName() {
290 return relationsToThisName
;
292 private void setRelationsToThisName(Set
<NameRelationship
> relationsToThisName
) {
293 this.relationsToThisName
= relationsToThisName
;
298 * Returns the set of {@link NomenclaturalStatus nomenclatural status} assigned
299 * to this taxon name according to its corresponding nomenclature code.
300 * This includes the {@link NomenclaturalStatusType type} of the nomenclatural status
301 * and the nomenclatural code rule considered.
303 * @see NomenclaturalStatus
304 * @see NomenclaturalStatusType
306 @OneToMany(fetch
= FetchType
.LAZY
)
307 @Cascade({CascadeType
.SAVE_UPDATE
})
308 public Set
<NomenclaturalStatus
> getStatus() {
314 protected void setStatus(Set
<NomenclaturalStatus
> nomStatus
) {
315 this.status
= nomStatus
;
318 * Adds a new {@link NomenclaturalStatus nomenclatural status}
319 * to this taxon name's set of nomenclatural status.
321 * @param nomStatus the nomenclatural status to be added
324 public void addStatus(NomenclaturalStatus nomStatus
) {
325 this.status
.add(nomStatus
);
328 * Removes one element from the set of nomenclatural status of this taxon name.
329 * Type and ruleConsidered attributes of the nomenclatural status object
332 * @param nomStatus the nomenclatural status of this taxon name which should be deleted
335 public void removeStatus(NomenclaturalStatus nomStatus
) {
336 //TODO to be implemented?
337 logger
.warn("not yet fully implemented?");
338 this.status
.remove(nomStatus
);
343 * Indicates whether this taxon name is a {@link NameRelationshipType.BASIONYM() basionym}
344 * or a {@link NameRelationshipType.REPLACED_SYNONYM() replaced synonym}
345 * of any other taxon name. Returns true, if a basionym or a replaced synonym
346 * relationship from this taxon name to another taxon name exists,
347 * false otherwise (also in case this taxon name is the only one in the
348 * homotypical group).
351 public boolean isOriginalCombination(){
352 Set
<NameRelationship
> relationsFromThisName
= this.getRelationsFromThisName();
353 for (NameRelationship relation
: relationsFromThisName
) {
354 if (relation
.getType().equals(NameRelationshipType
.BASIONYM()) ||
355 relation
.getType().equals(NameRelationshipType
.REPLACED_SYNONYM())) {
363 * Returns the taxon name which is the {@link NameRelationshipType.BASIONYM() basionym} of this taxon name.
364 * The basionym of a taxon name is its epithet-bringing synonym.
365 * For instance Pinus abies L. was published by Linnaeus and the botanist
366 * Karsten transferred later this taxon to the genus Picea. Therefore,
367 * Pinus abies L. is the basionym of the new combination Picea abies (L.) H. Karst.
370 public T
getBasionym(){
371 //TODO: pick the right name relationships...
375 * Assigns another taxon name as {@link NameRelationshipType.BASIONYM() basionym} of this taxon name.
376 * The basionym relationship will be added to this taxon name
377 * and to the basionym. The basionym cannot have itself a basionym.
379 * @see #getBasionym()
380 * @see #setBasionym(TaxonNameBase, String)
382 public void setBasionym(T basionym
){
383 setBasionym(basionym
, null);
386 * Assigns another taxon name as {@link NameRelationshipType.BASIONYM() basionym} of this taxon name
387 * and keeps the nomenclatural rule considered for it. The basionym
388 * relationship will be added to this taxon name and to the basionym.
389 * The basionym cannot have itself a basionym.
391 * @see #getBasionym()
392 * @see #setBasionym(TaxonNameBase)
394 public void setBasionym(T basionym
, String ruleConsidered
){
395 basionym
.addRelationshipToName(this, NameRelationshipType
.BASIONYM(), ruleConsidered
);
401 public abstract S
getCacheStrategy();
402 public abstract void setCacheStrategy(S cacheStrategy
);
405 * Returns the taxonomic {@link Rank rank} of this taxon name.
410 //@Cascade({CascadeType.SAVE_UPDATE})
411 public Rank
getRank(){
417 public void setRank(Rank rank
){
422 * Returns the {@link reference.INomenclaturalReference nomenclatural reference} of this taxon name.
423 * The nomenclatural reference is here meant to be the one publication
424 * this taxon name was originally published in while fulfilling the formal
425 * requirements as specified by the corresponding nomenclatural code.
427 * @see reference.INomenclaturalReference
428 * @see reference.ReferenceBase
431 @Cascade({CascadeType
.SAVE_UPDATE
})
432 @Target(ReferenceBase
.class)
433 public INomenclaturalReference
getNomenclaturalReference(){
434 return (INomenclaturalReference
) this.nomenclaturalReference
;
437 * Assigns a nomenclatural {@link reference.INomenclaturalReference nomenclatural reference} to this taxon name.
438 * The corresponding {@link reference.ReferenceBase.isNomenclaturallyRelevant nomenclaturally relevant flag} will be set to true
439 * as it is obviously used for nomenclatural purposes.
441 * @see #getNomenclaturalReference()
443 public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference
){
444 this.nomenclaturalReference
= nomenclaturalReference
;
448 * Returns the appended phrase string assigned to this taxon name.
449 * The appended phrase is a non-atomised addition to a name. It is
450 * not ruled by a nomenclatural code.
452 public String
getAppendedPhrase(){
453 return this.appendedPhrase
;
456 * @see #getAppendedPhrase()
458 public void setAppendedPhrase(String appendedPhrase
){
459 this.appendedPhrase
= appendedPhrase
;
463 * Returns the details string of the nomenclatural reference assigned
464 * to this taxon name. The details describe the exact localisation within
465 * the publication used as nomenclature reference. These are mostly
466 * (implicitly) pages but can also be figures or tables or any other
467 * element of a publication. A nomenclatural micro reference (details)
468 * requires the existence of a nomenclatural reference.
470 //Details of the nomenclatural reference (protologue).
471 public String
getNomenclaturalMicroReference(){
472 return this.nomenclaturalMicroReference
;
475 * @see #getNomenclaturalMicroReference()
477 public void setNomenclaturalMicroReference(String nomenclaturalMicroReference
){
478 this.nomenclaturalMicroReference
= nomenclaturalMicroReference
;
482 * Returns the boolean value of the flag indicating whether the used {@link eu.etaxonomy.cdm.strategy.parser.INonViralNameParser parser}
483 * method was able to parse the taxon name string successfully (false)
484 * or not (true). The parser itself may also depend on the {@link NomenclaturalCode nomenclatural code}
485 * governing the construction of this taxon name.
487 * @return the boolean value of the hasProblem flag
488 * @see #getNameCache()
490 public boolean getHasProblem(){
491 return this.hasProblem
;
494 * @see #getHasProblem()
496 public void setHasProblem(boolean hasProblem
){
497 this.hasProblem
= hasProblem
;
500 * Returns exactly the same boolean value as the {@link #getHasProblem() getHasProblem} method.
502 * @see #getHasProblem()
504 public boolean hasProblem(){
505 return getHasProblem();
510 * Returns the set of {@link NameTypeDesignation name type designations} assigned
511 * to this taxon name the rank of which must be above "species".
512 * The name type designations include all the taxon names used to typify
513 * this name and eventually the rejected or conserved status
514 * of these designations.
516 * @see NameTypeDesignation
517 * @see SpecimenTypeDesignation
520 //TODO @Cascade({CascadeType.SAVE_UPDATE, CascadeType.DELETE_ORPHAN})
521 @Cascade(CascadeType
.SAVE_UPDATE
)
522 public Set
<NameTypeDesignation
> getNameTypeDesignations() {
523 return nameTypeDesignations
;
526 * @see #getNameTypeDesignations()
528 protected void setNameTypeDesignations(Set
<NameTypeDesignation
> nameTypeDesignations
) {
529 this.nameTypeDesignations
= nameTypeDesignations
;
534 * Creates and adds a new {@link NameTypeDesignation name type designation}
535 * to this taxon name's set of name type designations.
537 * @param typeSpecies the taxon name to be used as type of this taxon name
538 * @param citation the reference for this new designation
539 * @param citationMicroReference the string with the details (generally pages) within the reference
540 * @param originalNameString the taxon name used in the reference to assert this designation
541 * @param isRejectedType the boolean status for rejected
542 * @param isConservedType the boolean status for conserved
543 * @see #getNameTypeDesignations()
544 * @see #addTypeDesignation(Specimen, TypeDesignationStatus, ReferenceBase, String, String)
546 public void addNameTypeDesignation(TaxonNameBase typeSpecies
, ReferenceBase citation
, String citationMicroReference
, String originalNameString
, boolean isRejectedType
, boolean isConservedType
) {
547 NameTypeDesignation td
= new NameTypeDesignation(this, typeSpecies
, citation
, citationMicroReference
, originalNameString
, isRejectedType
, isConservedType
);
551 * Removes one element from the set of {@link NameTypeDesignation name type designations} of this taxon name.
552 * The name type designation itself will be nullified.
554 * @param typeDesignation the name type designation of this taxon name which should be deleted
555 * @see #getNameTypeDesignations()
556 * @see #removeTypeDesignation(SpecimenTypeDesignation)
558 public void removeNameTypeDesignation(NameTypeDesignation typeDesignation
) {
560 logger
.warn("not yet fully implemented: nullify the name type designation itself?");
561 this.nameTypeDesignations
.remove(typeDesignation
);
565 * @return the specimenTypeDesignations
568 @Cascade(CascadeType
.SAVE_UPDATE
)
569 public Set
<SpecimenTypeDesignation
> getSpecimenTypeDesignations() {
570 return specimenTypeDesignations
;
573 * @param specimenTypeDesignations the specimenTypeDesignations to set
575 protected void setSpecimenTypeDesignations(Set
<SpecimenTypeDesignation
> specimenTypeDesignations
) {
576 this.specimenTypeDesignations
= specimenTypeDesignations
;
580 * Returns the set of {@link SpecimenTypeDesignation specimen type designations} assigned
581 * indirectly to this taxon name through its {@link HomotypicalGroup homotypical group}.
582 * The rank of this taxon name is generally "species" or below.
583 * The specimen type designations include all the specimens on which
584 * the typification of this name is based (and which are common to all
585 * taxon names belonging to the homotypical group) and eventually
586 * the status of these designations.
588 * @see SpecimenTypeDesignation
589 * @see NameTypeDesignation
592 public Set
<SpecimenTypeDesignation
> getSpecimenTypeDesignationsOfHomotypicalGroup() {
593 return this.getHomotypicalGroup().getTypeDesignations();
597 * Adds a new {@link SpecimenTypeDesignation specimen type designation}
598 * (using its attributes as parameters) to the set of specimen type designations assigned to the
599 * {@link HomotypicalGroup homotypical group} to which this taxon name belongs.
601 * @param typeSpecimen the specimen to be used as a type for this taxon name's homotypical group
602 * @param status the specimen type designation status
603 * @param citation the reference for this new specimen type designation
604 * @param citationMicroReference the string with the details (generally pages) within the reference
605 * @param originalNameString the taxon name used in the reference to assert this designation
606 * @see HomotypicalGroup#getTypeDesignations()
607 * @see #addTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean)
608 * @see TypeDesignationStatus
610 public void addSpecimenTypeDesignation(Specimen typeSpecimen
, TypeDesignationStatus status
, ReferenceBase citation
, String citationMicroReference
, String originalNameString
, boolean addToAllNames
) {
611 SpecimenTypeDesignation specimenTypeDesignation
=
612 SpecimenTypeDesignation
.NewInstance(typeSpecimen
, status
, citation
, citationMicroReference
, originalNameString
);
613 this.getHomotypicalGroup().addTypeDesignation(specimenTypeDesignation
, addToAllNames
);
616 //only to be used for xxx
618 * Adds a new {@link SpecimenTypeDesignation specimen type designation}
619 * to the set of specimen type designations assigned to the
620 * {@link HomotypicalGroup homotypical group} to which this taxon name belongs.
622 * @param specimenTypeDesignation the specimen type designation to be added for this taxon name's homotypical group
623 * @see #addSpecimenTypeDesignation(Specimen, TypeDesignationStatus, ReferenceBase, String, String, boolean)
624 * @see HomotypicalGroup#getTypeDesignations()
625 * @see #addTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean)
627 protected void addSpecimenTypeDesignation(SpecimenTypeDesignation specimenTypeDesignation
) {
628 this.specimenTypeDesignations
.add(specimenTypeDesignation
);
631 //only to be used for xxx
633 * Removes one element from the set of {@link SpecimenTypeDesignation specimen type designations} assigned to the
634 * {@link HomotypicalGroup homotypical group} to which this taxon name belongs.
636 * @param SpecimenTypeDesignation the specimen type designation which should be deleted
637 * @see HomotypicalGroup#getTypeDesignations()
638 * @see #removeTypeDesignation(SpecimenTypeDesignation)
639 * @see #removeNameTypeDesignation(NameTypeDesignation)
641 protected void removeSpecimenTypeDesignation(SpecimenTypeDesignation specimenTypeDesignation
) {
642 this.specimenTypeDesignations
.remove(specimenTypeDesignation
);
646 * Removes one element from the set of {@link SpecimenTypeDesignation specimen type designations} assigned to the
647 * {@link HomotypicalGroup homotypical group} to which this taxon name belongs.
648 * The specimen type designation itself will be nullified.
650 * @param typeDesignation the specimen type designation which should be deleted
651 * @see HomotypicalGroup#getTypeDesignations()
652 * @see #removeSpecimenTypeDesignation(SpecimenTypeDesignation)
653 * @see #removeNameTypeDesignation(NameTypeDesignation)
655 public void removeTypeDesignation(SpecimenTypeDesignation typeDesignation
) {
656 logger
.warn("not yet fully implemented: nullify the specimen type designation itself?");
657 this.homotypicalGroup
.removeTypeDesignation(typeDesignation
);
661 * Returns the {@link HomotypicalGroup homotypical group} to which
662 * this taxon name belongs. A homotypical group represents all taxon names
663 * that share the same type specimens.
665 * @see HomotypicalGroup
668 @Cascade({CascadeType
.SAVE_UPDATE
})
669 public HomotypicalGroup
getHomotypicalGroup() {
670 return homotypicalGroup
;
672 @Deprecated //only for bidirectional and persistence use
673 protected void setHomotypicalGroup(HomotypicalGroup newHomotypicalGroup
) {
674 this.homotypicalGroup
= newHomotypicalGroup
;
678 * @see #getNomenclaturalReference()
681 public StrictReferenceBase
getCitation(){
682 //TODO What is the purpose of this method differing from the getNomenclaturalReference method?
683 logger
.warn("getCitation not yet implemented");
688 * Returns the complete string containing the
689 * {@link reference.INomenclaturalReference#getNomenclaturalCitation() nomenclatural reference citation}
690 * (including {@link #getNomenclaturalMicroReference() details}) assigned to this taxon name.
692 * @return the string containing the nomenclatural reference of this taxon name
693 * @see reference.INomenclaturalReference#getNomenclaturalCitation()
694 * @see #getNomenclaturalReference()
695 * @see #getNomenclaturalMicroReference()
698 public String
getCitationString(){
699 logger
.warn("getCitationString not yet implemented");
704 public String
[] getProblems(){
705 logger
.warn("getProblems not yet implemented");
710 * Returns the string containing the publication date (generally only year)
711 * of the nomenclatural reference for this taxon name, null if there is
712 * no nomenclatural reference.
714 * @return the string containing the publication date of this taxon name
715 * @see reference.INomenclaturalReference#getYear()
718 public String
getReferenceYear(){
719 if (this.getNomenclaturalReference() != null ){
720 return this.getNomenclaturalReference().getYear();
727 * Returns the set of {@link taxon.TaxonBase taxon bases} that refer to this taxon name.
728 * In this context a taxon base means the use of a taxon name by a reference
729 * either as a taxon ("accepted/correct" name) or as a (junior) synonym.
730 * A taxon name can be used by several distinct references but only once
731 * within a taxonomic treatment (identified by one reference).
733 * @see taxon.TaxonBase
735 * @see #getSynonyms()
737 @OneToMany(mappedBy
="name", fetch
= FetchType
.LAZY
)
738 public Set
<TaxonBase
> getTaxonBases() {
739 return this.taxonBases
;
742 * @see #getTaxonBases()
744 protected void setTaxonBases(Set
<TaxonBase
> taxonBases
) {
745 if (taxonBases
== null){
746 taxonBases
= new HashSet
<TaxonBase
>();
748 this.taxonBases
= taxonBases
;
752 * Adds a new {@link taxon.TaxonBase taxon base}
753 * to the set of taxon bases using this taxon name.
755 * @param taxonBase the taxon base to be added
756 * @see #getTaxonBases()
759 public void addTaxonBase(TaxonBase taxonBase
){
760 taxonBases
.add(taxonBase
);
762 invokeSetMethod(methodTaxonBaseSetName
, taxonBase
);
765 * Removes one element from the set of {@link taxon.TaxonBase taxon bases} that refer to this taxon name.
767 * @param taxonBase the taxon base which should be removed from the corresponding set
768 * @see #addTaxonBase(TaxonBase)
770 public void removeTaxonBase(TaxonBase taxonBase
){
771 taxonBases
.remove(taxonBase
);
773 invokeSetMethodWithNull(methodTaxonBaseSetName
, taxonBase
);
776 private void initMethods(){
777 if (methodTaxonBaseSetName
== null){
779 methodTaxonBaseSetName
= TaxonBase
.class.getDeclaredMethod("setName", TaxonNameBase
.class);
780 methodTaxonBaseSetName
.setAccessible(true);
781 } catch (Exception e
) {
783 //TODO handle exception
790 * Returns the set of {@link taxon.Taxon taxa} ("accepted/correct" names according to any
791 * reference) that are based on this taxon name. This set is a subset of
792 * the set returned by getTaxonBases().
795 * @see #getTaxonBases()
796 * @see #getSynonyms()
799 public Set
<Taxon
> getTaxa(){
800 Set
<Taxon
> result
= new HashSet
<Taxon
>();
801 for (TaxonBase taxonBase
: this.taxonBases
){
802 if (taxonBase
instanceof Taxon
){
803 result
.add((Taxon
)taxonBase
);
810 * Returns the set of {@link taxon.Synonym (junior) synonyms} (according to any
811 * reference) that are based on this taxon name. This set is a subset of
812 * the set returned by getTaxonBases().
815 * @see #getTaxonBases()
819 public Set
<Synonym
> getSynonyms() {
820 Set
<Synonym
> result
= new HashSet
<Synonym
>();
821 for (TaxonBase taxonBase
: this.taxonBases
){
822 if (taxonBase
instanceof Synonym
){
823 result
.add((Synonym
)taxonBase
);
831 * Returns the boolean value indicating whether a given taxon name belongs
832 * to the same {@link HomotypicalGroup homotypical group} as this taxon name (true)
833 * or not (false). Returns "true" only if the homotypical groups of both
834 * taxon names exist and if they are identical.
836 * @param homoTypicName the taxon name the homotypical group of which is to be checked
837 * @return the boolean value of the check
838 * @see HomotypicalGroup
840 public boolean isHomotypic(TaxonNameBase homoTypicName
) {
841 if (homoTypicName
== null) {
844 HomotypicalGroup homotypicGroup
= homoTypicName
.getHomotypicalGroup();
845 if (homotypicGroup
== null || this.getHomotypicalGroup() == null) {
848 if (homotypicGroup
.equals(this.getHomotypicalGroup())) {
856 //********* Rank comparison shortcuts ********************//
858 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this
859 * taxon name is higher than the genus rank (true) or not (false).
860 * Suprageneric non viral names are monomials.
863 * @see #isInfraGeneric()
865 * @see #isInfraSpecific()
868 public boolean isSupraGeneric() {
869 return getRank().isSupraGeneric();
872 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this
873 * taxon name is the genus rank (true) or not (false). Non viral names with
874 * genus rank are monomials.
876 * @see #isSupraGeneric()
877 * @see #isInfraGeneric()
879 * @see #isInfraSpecific()
882 public boolean isGenus() {
883 return getRank().isGenus();
886 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this
887 * taxon name is higher than the species aggregate rank and lower than
888 * the genus rank (true) or not (false). Infrageneric non viral names
891 * @see #isSupraGeneric()
894 * @see #isInfraSpecific()
897 public boolean isInfraGeneric() {
898 return getRank().isInfraGeneric();
901 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this
902 * taxon name is the species or species aggregate rank (true) or not (false). Non viral names
903 * with species rank are binomials.
906 * @see #isSupraGeneric()
908 * @see #isInfraGeneric()
909 * @see #isInfraSpecific()
912 public boolean isSpecies() {
913 return getRank().isSpecies();
916 * Returns the boolean value indicating whether the taxonomic {@link Rank rank} of this
917 * taxon name is lower than the species rank (true) or not (false).
918 * Infraspecific non viral names are trinomials.
920 * @see #isSupraGeneric()
922 * @see #isInfraGeneric()
926 public boolean isInfraSpecific() {
927 return getRank().isInfraSpecific();
932 * Returns null as the {@link NomenclaturalCode nomenclatural code} that governs
933 * the construction of this taxon name since there is no specific
934 * nomenclatural code defined. The real implementention takes place in the
935 * subclasses {@link ViralName ViralName}, {@link BacterialName BacterialName},
936 * {@link BotanicalName BotanicalName}, {@link CultivarPlantName CultivarPlantName} and
937 * {@link ZoologicalName ZoologicalName}. Each taxon name is governed by one
938 * and only one nomenclatural code.
941 * @see #isCodeCompliant()
942 * @see #getHasProblem()
945 abstract public NomenclaturalCode
getNomeclaturalCode();
947 * @see eu.etaxonomy.cdm.model.common.IdentifiableEntity#generateTitle()
950 * Generates and returns the string with the scientific name of this
952 * This string may be stored in the inherited
953 * {@link common.IdentifiableEntity#getTitleCache() titleCache} attribute.
954 * This method overrides the generic and inherited
955 * IdentifiableEntity#generateTitle() method.
957 * @return the string with the composed name of this non viral taxon name with authorship (and maybe year)
958 * @see common.IdentifiableEntity#generateTitle()
959 * @see common.IdentifiableEntity#getTitleCache()
962 public String
generateTitle() {
963 // TODO Auto-generated method stub