Committing large number of changes relating to versioning implementation (#108)
[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.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlElement;
18 import javax.xml.bind.annotation.XmlIDREF;
19 import javax.xml.bind.annotation.XmlRootElement;
20 import javax.xml.bind.annotation.XmlSchemaType;
21 import javax.xml.bind.annotation.XmlType;
22
23 import org.apache.log4j.Logger;
24 import org.hibernate.annotations.Cascade;
25 import org.hibernate.annotations.CascadeType;
26 import org.hibernate.envers.Audited;
27
28 import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
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 implements ITypeDesignation {
62
63 static Logger logger = Logger.getLogger(NameTypeDesignation.class);
64
65 @XmlElement(name = "IsRejectedType")
66 private boolean rejectedType;
67
68 @XmlElement(name = "IsConservedType")
69 private boolean conservedType;
70
71 @XmlElement(name = "IsLectoType")
72 private boolean lectoType;
73
74 @XmlElement(name = "TypeName")
75 @XmlIDREF
76 @XmlSchemaType(name = "IDREF")
77 @ManyToOne(fetch = FetchType.LAZY)
78 @Cascade(CascadeType.SAVE_UPDATE)
79 private TaxonNameBase typeName;
80
81 // @XmlElement(name = "HomotypicalGroup")
82 // @XmlIDREF
83 // @XmlSchemaType(name = "IDREF")
84 // private HomotypicalGroup homotypicalGroup;
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 super();
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, ReferenceBase citation, String citationMicroReference,
119 String originalNameString, boolean rejectedType, boolean conservedType, boolean isNotDesignated) {
120 super(citation, citationMicroReference, originalNameString, isNotDesignated);
121 this.setTypeName(typeName);
122 this.rejectedType = rejectedType;
123 this.conservedType = conservedType;
124 }
125
126 //********* METHODS **************************************/
127
128
129 /**
130 * Returns the {@link TaxonNameBase taxon name} that plays the role of the
131 * taxon name type in <i>this</i> taxon name type designation. The {@link Rank rank}
132 * of the taxon name type must be "species".
133 */
134 public TaxonNameBase getTypeName(){
135 return this.typeName;
136 }
137 /**
138 * @see #getTypeName()
139 */
140 private void setTypeName(TaxonNameBase typeName){
141 this.typeName = typeName;
142 }
143
144 /**
145 * Returns the boolean value "true" if the competent authorities decided to
146 * reject the use of the species taxon name as the type for <i>this</i> taxon
147 * name type designation.
148 *
149 * @see #isConservedType()
150 */
151 public boolean isRejectedType(){
152 return this.rejectedType;
153 }
154 /**
155 * @see #isRejectedType()
156 */
157 public void setRejectedType(boolean rejectedType){
158 this.rejectedType = rejectedType;
159 }
160
161 /**
162 * Returns the boolean value "true" if the competent authorities decided to
163 * conserve the use of the species taxon name as the type for <i>this</i> taxon
164 * name type designation.
165 *
166 * @see #isRejectedType()
167 */
168 public boolean isConservedType(){
169 return this.conservedType;
170 }
171 /**
172 * @see #isConservedType()
173 */
174 public void setConservedType(boolean conservedType){
175 this.conservedType = conservedType;
176 }
177
178 /**
179 * Returns the boolean value "true" if the use of the species {@link TaxonNameBase taxon name}
180 * as the type for <i>this</i> taxon name type designation was posterior to the
181 * publication of the typified taxon name. In this case the taxon name type
182 * designation should have a {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference} that is different to the
183 * {@link TaxonNameBase#getNomenclaturalReference() nomenclatural reference} of the typified taxon name.
184 *
185 * @see ReferencedEntityBase#getCitation()
186 */
187 /* (non-Javadoc)
188 * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
189 */
190 public boolean isLectoType() {
191 return lectoType;
192 }
193
194 /**
195 * @see #isLectoType()
196 */
197 public void setLectoType(boolean lectoType) {
198 this.lectoType = lectoType;
199 }
200 }