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