merging branches/cdmlib/2.2 [7345:7377] to trunk
[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 import javax.persistence.Entity;
13 import javax.persistence.FetchType;
14 import javax.persistence.ManyToOne;
15 import javax.persistence.Transient;
16 import javax.xml.bind.annotation.XmlAccessType;
17 import javax.xml.bind.annotation.XmlAccessorType;
18 import javax.xml.bind.annotation.XmlElement;
19 import javax.xml.bind.annotation.XmlIDREF;
20 import javax.xml.bind.annotation.XmlRootElement;
21 import javax.xml.bind.annotation.XmlSchemaType;
22 import javax.xml.bind.annotation.XmlType;
23
24 import org.apache.log4j.Logger;
25 import org.hibernate.annotations.Cascade;
26 import org.hibernate.annotations.CascadeType;
27 import org.hibernate.envers.Audited;
28
29 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
30
31 /**
32 * The class representing a typification of a {@link TaxonNameBase taxon name} with a {@link Rank rank}
33 * above "species aggregate" by another taxon name.<BR>
34 * According to nomenclature a type of a genus name or of any subdivision of a
35 * genus can only be a species name. A type of a family name or of any
36 * subdivision of a family is a genus name.<BR>
37 * Moreover the designation of a particular taxon name as a type might be
38 * nomenclaturally rejected or conserved. Depending on the date of publication,
39 * the same typification could be rejected according to one reference and later
40 * be conserved according to another reference, but a name type designation
41 * cannot be simultaneously rejected and conserved.<BR>
42 * Name type designations are treated as {@link TypeDesignationBase type designations}
43 * and not as {@link NameRelationship name relationships}.
44 *
45 * @see TypeDesignationBase
46 * @see SpecimenTypeDesignation
47 * @author m.doering
48 * @version 1.0
49 * @created 08-Nov-2007 13:06:38
50 */
51 @XmlRootElement(name = "NameTypeDesignation")
52 @XmlAccessorType(XmlAccessType.FIELD)
53 @XmlType(name = "NameTypeDesignation", propOrder = {
54 "rejectedType",
55 "conservedType",
56 /*"lectoType",*/
57 "typeName"
58 })
59 @Entity
60 @Audited
61 public class NameTypeDesignation extends TypeDesignationBase<NameTypeDesignationStatus>
62 implements ITypeDesignation {
63
64 final static Logger logger = Logger.getLogger(NameTypeDesignation.class);
65
66 @XmlElement(name = "IsRejectedType")
67 private boolean rejectedType;
68
69 @XmlElement(name = "IsConservedType")
70 private boolean conservedType;
71
72 // @XmlElement(name = "IsLectoType")
73 // private boolean lectoType;
74
75 @XmlElement(name = "TypeName")
76 @XmlIDREF
77 @XmlSchemaType(name = "IDREF")
78 @ManyToOne(fetch = FetchType.LAZY)
79 @Cascade(CascadeType.SAVE_UPDATE)
80 private TaxonNameBase typeName;
81
82
83 public static NameTypeDesignation NewInstance() {
84 return new NameTypeDesignation();
85 }
86
87
88 // ************* CONSTRUCTORS *************/
89 /**
90 * Class constructor: creates a new empty name type designation.
91 *
92 * @see #NameTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean, boolean)
93 */
94 protected NameTypeDesignation() {
95 }
96
97
98 /**
99 * Class constructor: creates a new name type designation instance
100 * (including its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and eventually
101 * the taxon name string originally used by this reference when establishing
102 * the former designation).
103 *
104 * @param typeName the taxon name used as a type
105 * @param citation the reference source for the new designation
106 * @param citationMicroReference the string with the details describing the exact localisation within the reference
107 * @param originalNameString the taxon name string used originally in the reference source for the new designation
108 * @param isRejectedType the boolean flag indicating whether the competent authorities rejected
109 * <i>this</i> name type designation
110 * @param isConservedType the boolean flag indicating whether the competent authorities conserved
111 * <i>this</i> name type designation
112 * @param isNotDesignated the boolean flag indicating whether there is no name type at all for
113 * <i>this</i> name type designation
114 * @see #NameTypeDesignation()
115 * @see TypeDesignationBase#isNotDesignated()
116 * @see TaxonNameBase#addNameTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean, boolean, boolean, boolean)
117 */
118 protected NameTypeDesignation(TaxonNameBase typeName, NameTypeDesignationStatus status,
119 ReferenceBase citation, String citationMicroReference, String originalNameString) {
120 super(citation, citationMicroReference, originalNameString);
121 this.setTypeName(typeName);
122 this.setTypeStatus(status);
123 }
124
125 /**
126 * Class constructor: creates a new name type designation instance
127 * (including its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and eventually
128 * the taxon name string originally used by this reference when establishing
129 * the former designation).
130 *
131 * @param typeName the taxon name used as a type
132 * @param citation the reference source for the new designation
133 * @param citationMicroReference the string with the details describing the exact localisation within the reference
134 * @param originalNameString the taxon name string used originally in the reference source for the new designation
135 * @param isRejectedType the boolean flag indicating whether the competent authorities rejected
136 * <i>this</i> name type designation
137 * @param isConservedType the boolean flag indicating whether the competent authorities conserved
138 * <i>this</i> name type designation
139 * @param isNotDesignated the boolean flag indicating whether there is no name type at all for
140 * <i>this</i> name type designation
141 * @see #NameTypeDesignation()
142 * @see TypeDesignationBase#isNotDesignated()
143 * @see TaxonNameBase#addNameTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean, boolean, boolean, boolean)
144 */
145 protected NameTypeDesignation( TaxonNameBase typeName,
146 ReferenceBase citation,
147 String citationMicroReference,
148 String originalNameString,
149 NameTypeDesignationStatus status,
150 boolean rejectedType,
151 boolean conservedType,
152 boolean isNotDesignated
153 ) {
154 this(typeName, status, citation, citationMicroReference, originalNameString);
155 this.setNotDesignated(isNotDesignated);
156 this.rejectedType = rejectedType;
157 this.conservedType = conservedType;
158 }
159
160 //********* METHODS **************************************/
161
162
163 /**
164 * Returns the {@link TaxonNameBase taxon name} that plays the role of the
165 * taxon name type in <i>this</i> taxon name type designation. The {@link Rank rank}
166 * of the taxon name type must be "species".
167 */
168 public TaxonNameBase getTypeName(){
169 return this.typeName;
170 }
171 /**
172 * @see #getTypeName()
173 */
174 public void setTypeName(TaxonNameBase typeName){
175 this.typeName = typeName;
176 }
177
178 /**
179 * Returns the boolean value "true" if the competent authorities decided to
180 * reject the use of the species taxon name as the type for <i>this</i> taxon
181 * name type designation.
182 *
183 * @see #isConservedType()
184 */
185 public boolean isRejectedType(){
186 return this.rejectedType;
187 }
188 /**
189 * @see #isRejectedType()
190 */
191 public void setRejectedType(boolean rejectedType){
192 this.rejectedType = rejectedType;
193 }
194
195 /**
196 * Returns the boolean value "true" if the competent authorities decided to
197 * conserve the use of the species taxon name as the type for <i>this</i> taxon
198 * name type designation.
199 *
200 * @see #isRejectedType()
201 */
202 public boolean isConservedType(){
203 return this.conservedType;
204 }
205 /**
206 * @see #isConservedType()
207 */
208 public void setConservedType(boolean conservedType){
209 this.conservedType = conservedType;
210 }
211
212 @Transient
213 public boolean isLectoType() {
214 if (getTypeStatus() == null) {
215 return false;
216 }
217 return getTypeStatus().isLectotype();
218 }
219
220 /**
221 * Returns the boolean value "true" if the use of the species {@link TaxonNameBase taxon name}
222 * as the type for <i>this</i> taxon name type designation was posterior to the
223 * publication of the typified taxon name. In this case the taxon name type
224 * designation should have a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference} that is different to the
225 * {@link TaxonNameBase#getNomenclaturalReference() nomenclatural reference} of the typified taxon name.
226 *
227 * @see ReferencedEntityBase#getCitation()
228 */
229 // /* (non-Javadoc)
230 // * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
231 // */
232 // public boolean isLectoType() {
233 // return lectoType;
234 // }
235 //
236 // /**
237 // * @see #isLectoType()
238 // */
239 // public void setLectoType(boolean lectoType) {
240 // this.lectoType = lectoType;
241 // }
242 }