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