(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NameTypeDesignation.java
1 /**
2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
5 *
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.
8 */
9
10 package eu.etaxonomy.cdm.model.name;
11
12
13 import javax.persistence.Entity;
14 import javax.persistence.ManyToOne;
15 import javax.xml.bind.annotation.XmlType;
16
17 import org.apache.log4j.Logger;
18 import org.hibernate.annotations.Cascade;
19 import org.hibernate.annotations.CascadeType;
20
21 import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
22 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
23
24 /**
25 * The class representing a typification of a {@link TaxonNameBase taxon name} with
26 * a {@link Rank rank} above "species aggregate" by a species taxon name. A type of a
27 * genus name or of any subdivision of a genus can only be a species name.
28 * A type of a family name or of any subdivision of a family is a genus name
29 * (and resolving it: a species name typifying this genus).
30 * Moreover the designation of a particular species name as a type for a
31 * suprageneric taxon name might be nomenclaturally rejected or conserved.
32 * Depending on the date of publication, the same typification could be rejected
33 * according to one reference and later be conserved according to another
34 * reference, but a name type designation cannot be simultaneously rejected and
35 * conserved. Both names, the typified name and the species name used in
36 * the name type designation, must belong to the same {@link HomotypicalGroup homotypical group}.
37 *
38 * @see SpecimenTypeDesignation
39 * @author m.doering
40 * @version 1.0
41 * @created 08-Nov-2007 13:06:38
42 */
43 @XmlType(name="NameTypeDesignation")
44 @Entity
45 public class NameTypeDesignation extends ReferencedEntityBase {
46 static Logger logger = Logger.getLogger(NameTypeDesignation.class);
47 private boolean isRejectedType;
48 private boolean isConservedType;
49 private boolean isLectoType;
50 private ReferenceBase lectoTypeReference;
51 private String lectoTypeMicroReference;
52 private boolean isNotDesignated;
53 private TaxonNameBase typeSpecies;
54 private TaxonNameBase typifiedName;
55
56 // ************* CONSTRUCTORS *************/
57 /**
58 * Class constructor: creates a new empty name type designation.
59 *
60 * @see #NameTypeDesignation(TaxonNameBase, TaxonNameBase, ReferenceBase, String, String, boolean, boolean)
61 */
62 protected NameTypeDesignation() {
63 super();
64 }
65
66 /**
67 * Class constructor: creates a new name type designation instance
68 * (including its {@link reference.ReferenceBase reference source} and eventually
69 * the taxon name string originally used by this reference when establishing
70 * the former designation) and adds it to the corresponding
71 * {@link TaxonNameBase#getNameTypeDesignations() name type designation set} of the typified name.
72 * The typified name will be added to the {@link HomotypicalGroup homotypical group} to which
73 * the species taxon name used for the typification belongs.
74 *
75 * @param typifiedName the suprageneric taxon name to be typified
76 * @param typeSpecies the species taxon name typifying the suprageneric taxon name
77 * @param citation the reference source for the new designation
78 * @param citationMicroReference the string with the details describing the exact localisation within the reference
79 * @param originalNameString the taxon name string used originally in the reference source for the new designation
80 * @param isRejectedType the boolean flag indicating whether the competent authorities rejected
81 * this name type designation
82 * @param isConservedType the boolean flag indicating whether the competent authorities conserved
83 * this name type designation
84 * @param isNotDesignated see at {@link #isNotDesignated()}
85 * @see #NameTypeDesignation()
86 * @see TaxonNameBase#addNameTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean)
87 */
88 protected NameTypeDesignation(TaxonNameBase typifiedName, TaxonNameBase typeSpecies, ReferenceBase citation, String citationMicroReference,
89 String originalNameString, boolean isRejectedType, boolean isConservedType, boolean isNotDesignated) {
90 super(citation, citationMicroReference, originalNameString);
91 this.setTypeSpecies(typeSpecies);
92 this.setTypifiedName(typifiedName);
93 typifiedName.setHomotypicalGroup(typeSpecies.getHomotypicalGroup());
94 this.isRejectedType = isRejectedType;
95 this.isConservedType = isConservedType;
96 this.isNotDesignated = isNotDesignated;
97 }
98
99 //********* METHODS **************************************/
100
101 /**
102 * Returns the {@link TaxonNameBase taxon name} that plays the role of the
103 * typified taxon name in this taxon name type designation. The {@link Rank rank}
104 * of a taxon name typified by another taxon name must be higher than
105 * "species aggregate".
106 *
107 * @see #getTypeSpecies()
108 */
109 @ManyToOne
110 @Cascade({CascadeType.SAVE_UPDATE})
111 public TaxonNameBase getTypifiedName() {
112 return typifiedName;
113 }
114 /**
115 * @see #getTypifiedName()
116 */
117 private void setTypifiedName(TaxonNameBase typifiedName) {
118 this.typifiedName = typifiedName;
119 if (typifiedName != null){
120 typifiedName.getNameTypeDesignations().add(this);
121 }
122 }
123
124
125 /**
126 * Returns the {@link TaxonNameBase taxon name} that plays the role of the
127 * taxon name type in this taxon name type designation. The {@link Rank rank}
128 * of a taxon name type must be "species".
129 *
130 * @see #getTypifiedName()
131 */
132 @ManyToOne
133 @Cascade({CascadeType.SAVE_UPDATE})
134 public TaxonNameBase getTypeSpecies(){
135 return this.typeSpecies;
136 }
137 /**
138 * @see #getTypeSpecies()
139 */
140 private void setTypeSpecies(TaxonNameBase typeSpecies){
141 this.typeSpecies = typeSpecies;
142 }
143
144 /**
145 * Returns the boolean value "true" if the competent authorities decided to
146 * reject the use of the species taxon name for this taxon name type
147 * designation.
148 *
149 * @see #isConservedType()
150 */
151 public boolean isRejectedType(){
152 return this.isRejectedType;
153 }
154 /**
155 * @see #isRejectedType()
156 */
157 public void setRejectedType(boolean isRejectedType){
158 this.isRejectedType = isRejectedType;
159 }
160
161 /**
162 * Returns the boolean value "true" if the competent authorities decided to
163 * conserve the use of the species taxon name for this taxon name type
164 * designation.
165 *
166 * @see #isConservedType()
167 */
168 public boolean isConservedType(){
169 return this.isConservedType;
170 }
171 /**
172 * @see #isConservedType()
173 */
174 public void setConservedType(boolean isConservedType){
175 this.isConservedType = isConservedType;
176 }
177
178 /**
179 * Returns the boolean value "true" if the use of the species {@link TaxonNameBase taxon name} for
180 * this taxon name type designation was posterior to the publication of the
181 * typified taxon name. In this case the taxon name type designation should
182 * have a {@link reference.ReferenceBase reference} that is different to the
183 * nomenclatural reference of the typified taxon name.
184 *
185 * @see #getLectoTypeReference()
186 */
187 public boolean isLectoType() {
188 return isLectoType;
189 }
190
191 /**
192 * @see #isLectoType()
193 */
194 public void setLectoType(boolean isLectoType) {
195 this.isLectoType = isLectoType;
196 }
197
198 /**
199 * Returns the {@link reference.ReferenceBase reference} used in case this
200 * taxon name type designation is a lectotype. This reference is different
201 * to the nomenclatural reference of the typified taxon name.
202 *
203 * @see #isLectoType()
204 */
205 public ReferenceBase getLectoTypeReference() {
206 return lectoTypeReference;
207 }
208
209 /**
210 * @see #getLectoTypeReference()
211 */
212 public void setLectoTypeReference(ReferenceBase lectoTypeReference) {
213 this.lectoTypeReference = lectoTypeReference;
214 }
215
216 /**
217 * Returns the details string of the reference corresponding to this taxon
218 * type designation if it is a lectotype. The details describe the exact
219 * localisation within the publication used for the lectotype assignation.
220 * These are mostly (implicitly) pages but can also be figures or tables or
221 * any other element of a publication. A lectotype micro reference (details)
222 * requires the existence of a lectotype reference.
223 *
224 * @see #getLectoTypeReference()
225 */
226 public String getLectoTypeMicroReference() {
227 return lectoTypeMicroReference;
228 }
229
230 /**
231 * @see #getLectoTypeMicroReference()
232 */
233 public void setLectoTypeMicroReference(String lectoTypeMicroReference) {
234 this.lectoTypeMicroReference = lectoTypeMicroReference;
235 }
236
237 /**
238 * Returns the boolean value "true" if a name type does not exist.
239 * Two cases must be differentiated: <BR><ul>
240 * <li> a) it is unknown whether a name type exists and <BR>
241 * <li> b) it is known that no name type exists <BR>
242 * </ul>
243 * If b) is true there should be a NameTypeDesignation with the flag
244 * isNotDesignated set. The typeSpecies should then be "null".
245 */
246 public boolean isNotDesignated() {
247 return isNotDesignated;
248 }
249
250 /**
251 * @see #isNotDesignated()
252 */
253 public void setNotDesignated(boolean isNotDesignated) {
254 this.isNotDesignated = isNotDesignated;
255 }
256
257
258
259
260
261 }