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
;
13 import eu
.etaxonomy
.cdm
.model
.occurrence
.Specimen
;
14 import eu
.etaxonomy
.cdm
.model
.reference
.INomenclaturalReference
;
15 import eu
.etaxonomy
.cdm
.model
.reference
.ReferenceBase
;
16 import eu
.etaxonomy
.cdm
.model
.reference
.StrictReferenceBase
;
17 import eu
.etaxonomy
.cdm
.model
.common
.IdentifiableEntity
;
18 import eu
.etaxonomy
.cdm
.model
.common
.IReferencedEntity
;
19 import org
.apache
.log4j
.Logger
;
20 import org
.hibernate
.annotations
.Cascade
;
21 import org
.hibernate
.annotations
.CascadeType
;
23 import eu
.etaxonomy
.cdm
.strategy
.INameCacheStrategy
;
27 import javax
.persistence
.*;
30 * The upmost (abstract) class for scientific taxon names regardless of the any
31 * particular nomenclatural code. The scientific name including author strings and
32 * maybe year is stored in IdentifiableEntity.titleCache
35 * @created 08-Nov-2007 13:06:57
38 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
39 public abstract class TaxonNameBase
extends IdentifiableEntity
<TaxonNameBase
> implements IReferencedEntity
{
40 static Logger logger
= Logger
.getLogger(TaxonNameBase
.class);
41 //The scientific name without author strings and year
42 private String nameCache
;
43 //Non-atomised addition to a name not ruled by a nomenclatural code
44 private String appendedPhrase
;
45 //Details of the nomenclatural reference (protologue). These are mostly (implicitly) pages but can also be figures or
46 //tables or any other element of a publication. {only if a nomenclatural reference exists}
47 private String nomenclaturalMicroReference
;
48 //this flag will be set to true if the parseName method was unable to successfully parse the name
49 private boolean hasProblem
= false;
50 protected Set
<NameTypeDesignation
> nameTypeDesignations
= new HashSet();
51 private HomotypicalGroup homotypicalGroup
= new HomotypicalGroup();
52 private Set
<NameRelationship
> nameRelations
= new HashSet();
53 private Set
<NomenclaturalStatus
> status
= new HashSet();
55 //if set, the Reference.isNomenclaturallyRelevant flag should be set to true!
56 private INomenclaturalReference nomenclaturalReference
;
57 private Set
<TaxonNameBase
> newCombinations
= new HashSet();
58 // bidrectional with newCombinations. Keep congruent
59 private TaxonNameBase basionym
;
61 protected INameCacheStrategy cacheStrategy
;
65 public TaxonNameBase() {
68 public TaxonNameBase(Rank rank
) {
74 public String
getNameCache() {
77 public void setNameCache(String nameCache
) {
78 this.nameCache
= nameCache
;
83 public abstract boolean isCodeCompliant();
87 @Cascade({CascadeType
.SAVE_UPDATE
})
88 public Set
<NameRelationship
> getNameRelations() {
91 protected void setNameRelations(Set
<NameRelationship
> nameRelations
) {
92 this.nameRelations
= nameRelations
;
94 public void addNameRelation(NameRelationship nameRelation
) {
95 // checks whether this is a normal relation or an inverse one
96 // and adds it to the appropiate set
97 //this.inverseNameRelations
98 this.nameRelations
.add(nameRelation
);
100 public void removeNameRelation(NameRelationship nameRelation
) {
101 // this.inverseNameRelations
102 this.nameRelations
.remove(nameRelation
);
107 public Set
<NameRelationship
> getIncomingNameRelations() {
108 // FIXME: filter relations
109 return nameRelations
;
112 public Set
<NameRelationship
> getOutgoingNameRelations() {
113 // FIXME: filter relations
114 return nameRelations
;
120 @Cascade({CascadeType
.SAVE_UPDATE
})
121 public Set
<NomenclaturalStatus
> getStatus() {
124 protected void setStatus(Set
<NomenclaturalStatus
> status
) {
125 this.status
= status
;
127 public void addStatus(NomenclaturalStatus status
) {
128 this.status
.add(status
);
130 public void removeStatus(NomenclaturalStatus status
) {
131 this.status
.remove(status
);
137 @Cascade({CascadeType
.SAVE_UPDATE
})
138 public Set
<TaxonNameBase
> getNewCombinations() {
139 return newCombinations
;
141 protected void setNewCombinations(Set
<TaxonNameBase
> newCombinations
) {
142 this.newCombinations
= newCombinations
;
144 public void addNewCombination(TaxonNameBase newCombination
) {
145 // TODO: add basionym relation too!
146 this.newCombinations
.add(newCombination
);
148 public void removeNewCombination(TaxonNameBase newCombination
) {
149 this.newCombinations
.remove(newCombination
);
154 @Cascade({CascadeType
.SAVE_UPDATE
})
155 public TaxonNameBase
getBasionym(){
156 return this.basionym
;
158 public void setBasionym(TaxonNameBase basionym
){
159 // TODO: add newCombination relation too!
160 this.basionym
= basionym
;
167 public INameCacheStrategy
getCacheStrategy() {
168 return cacheStrategy
;
170 public void setCacheStrategy(INameCacheStrategy cacheStrategy
) {
171 this.cacheStrategy
= cacheStrategy
;
175 @Cascade({CascadeType
.SAVE_UPDATE
})
176 public Rank
getRank(){
179 public void setRank(Rank rank
){
184 @Cascade({CascadeType
.SAVE_UPDATE
})
185 public ReferenceBase
getNomenclaturalReference(){
186 return (ReferenceBase
) this.nomenclaturalReference
;
188 public void setNomenclaturalReference(INomenclaturalReference nomenclaturalReference
){
189 this.nomenclaturalReference
= nomenclaturalReference
;
193 public String
getAppendedPhrase(){
194 return this.appendedPhrase
;
196 public void setAppendedPhrase(String appendedPhrase
){
197 this.appendedPhrase
= appendedPhrase
;
200 public String
getNomenclaturalMicroReference(){
201 return this.nomenclaturalMicroReference
;
203 public void setNomenclaturalMicroReference(String nomenclaturalMicroReference
){
204 this.nomenclaturalMicroReference
= nomenclaturalMicroReference
;
207 public boolean getHasProblem(){
208 return this.hasProblem
;
210 public void setHasProblem(boolean hasProblem
){
211 this.hasProblem
= hasProblem
;
216 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.DELETE_ORPHAN
})
217 public Set
<NameTypeDesignation
> getNameTypeDesignations() {
218 return nameTypeDesignations
;
220 protected void setNameTypeDesignations(Set
<NameTypeDesignation
> nameTypeDesignations
) {
221 this.nameTypeDesignations
= nameTypeDesignations
;
224 public void addTypeDesignation(TaxonNameBase typeSpecies
, ReferenceBase citation
, String citationMicroReference
, String originalNameString
, boolean isRejectedType
, boolean isConservedType
) {
225 NameTypeDesignation td
= new NameTypeDesignation(this, typeSpecies
, citation
, citationMicroReference
, originalNameString
, isRejectedType
, isConservedType
);
227 public void addTypeDesignation(Specimen typeSpecimen
, TypeDesignationStatus status
, ReferenceBase citation
, String citationMicroReference
, String originalNameString
) {
228 this.homotypicalGroup
.addTypeDesignation(typeSpecimen
, status
, citation
, citationMicroReference
, originalNameString
);
230 public void removeTypeDesignation(NameTypeDesignation typeDesignation
) {
231 this.nameTypeDesignations
.remove(typeDesignation
);
233 public void removeTypeDesignation(SpecimenTypeDesignation typeDesignation
) {
234 this.homotypicalGroup
.removeTypeDesignation(typeDesignation
);
239 @Cascade({CascadeType
.SAVE_UPDATE
})
240 public HomotypicalGroup
getHomotypicalGroup() {
241 return homotypicalGroup
;
243 public void setHomotypicalGroup(HomotypicalGroup newHomotypicalGroup
) {
244 if(this.homotypicalGroup
== newHomotypicalGroup
) return;
245 if (homotypicalGroup
!= null) {
246 homotypicalGroup
.typifiedNames
.remove(this);
248 if (newHomotypicalGroup
!= null) {
249 newHomotypicalGroup
.typifiedNames
.add(this);
251 this.homotypicalGroup
= newHomotypicalGroup
;
255 public StrictReferenceBase
getCitation(){
260 public String
getCitationString(){
265 public String
[] getProblems(){
270 * returns year of according nomenclatural reference, null if nomenclatural
271 * reference does not exist
274 public String
getYear(){
280 * @param fullname fullname
282 public boolean parseName(String fullname
){