(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 * @return the isLectoType
180 */
181 public boolean isLectoType() {
182 return isLectoType;
183 }
184
185 /**
186 * @param isLectoType the isLectoType to set
187 */
188 public void setLectoType(boolean isLectoType) {
189 this.isLectoType = isLectoType;
190 }
191
192 /**
193 * @return the lectoTypeReference
194 */
195 public ReferenceBase getLectoTypeReference() {
196 return lectoTypeReference;
197 }
198
199 /**
200 * @param lectoTypeReference the lectoTypeReference to set
201 */
202 public void setLectoTypeReference(ReferenceBase lectoTypeReference) {
203 this.lectoTypeReference = lectoTypeReference;
204 }
205
206 /**
207 * @return the lectoTypeMicroReference
208 */
209 public String getLectoTypeMicroReference() {
210 return lectoTypeMicroReference;
211 }
212
213 /**
214 * @param lectoTypeMicroReference the lectoTypeMicroReference to set
215 */
216 public void setLectoTypeMicroReference(String lectoTypeMicroReference) {
217 this.lectoTypeMicroReference = lectoTypeMicroReference;
218 }
219
220 /**
221 * If true this indicates that a name type does not exist.
222 * This is differentiate that <BR>
223 * a) it is unknown if a name type exists and <BR>
224 * b) it is known that no name type exists <BR>
225 * If b is true there should be a NameTypeDesignation with <code>isNotDesignate == true</code>
226 * The typeSpecies should be <code>null</code> then.
227 * @return the notDesignated
228 */
229 public boolean isNotDesignated() {
230 return isNotDesignated;
231 }
232
233 /**
234 * @param notDesignated the notDesignated to set
235 */
236 public void setNotDesignated(boolean isNotDesignated) {
237 this.isNotDesignated = isNotDesignated;
238 }
239
240
241
242
243
244 }