(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 eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
14 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
15
16 import org.apache.log4j.Logger;
17 import org.hibernate.annotations.Cascade;
18 import org.hibernate.annotations.CascadeType;
19 import javax.persistence.*;
20 import javax.xml.bind.annotation.XmlAccessType;
21 import javax.xml.bind.annotation.XmlAccessorType;
22 import javax.xml.bind.annotation.XmlType;
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 * (or 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 TaxonNameBase typeSpecies;
50 private TaxonNameBase typifiedName;
51
52 // ************* CONSTRUCTORS *************/
53 /**
54 * Class constructor: creates a new empty name type designation.
55 *
56 * @see #NameTypeDesignation(TaxonNameBase, TaxonNameBase, ReferenceBase, String, String, boolean, boolean)
57 */
58 protected NameTypeDesignation() {
59 super();
60 }
61
62 /**
63 * Class constructor: creates a new name type designation instance
64 * (including its {@link reference.ReferenceBase reference source} and eventually
65 * the taxon name string originally used by this reference when establishing
66 * the former designation) and adds it to the corresponding
67 * {@link TaxonNameBase#getNameTypeDesignations() name type designation set} of the typified name.
68 * The typified name will be added to the {@link HomotypicalGroup homotypical group} to which
69 * the species taxon name used for the typification belongs.
70 *
71 * @param typifiedName the suprageneric taxon name to be typified
72 * @param typeSpecies the species taxon name typifying the suprageneric taxon name
73 * @param citation the reference source for the new designation
74 * @param citationMicroReference the string with the details describing the exact localisation within the reference
75 * @param originalNameString the taxon name string used originally in the reference source for the new designation
76 * @param isRejectedType the boolean flag indicating whether the competent authorities rejected
77 * this name type designation
78 * @param isConservedType the boolean flag indicating whether the competent authorities conserved
79 * this name type designation
80 * @see #NameTypeDesignation()
81 * @see TaxonNameBase#addNameTypeDesignation(TaxonNameBase, ReferenceBase, String, String, boolean, boolean)
82 */
83 protected NameTypeDesignation(TaxonNameBase typifiedName, TaxonNameBase typeSpecies, ReferenceBase citation, String citationMicroReference,
84 String originalNameString, boolean isRejectedType, boolean isConservedType) {
85 super(citation, citationMicroReference, originalNameString);
86 this.setTypeSpecies(typeSpecies);
87 this.setTypifiedName(typifiedName);
88 typifiedName.setHomotypicalGroup(typeSpecies.getHomotypicalGroup());
89 this.isRejectedType = isRejectedType;
90 this.isConservedType = isConservedType;
91 }
92
93 //********* METHODS **************************************/
94
95 /**
96 * Returns the {@link TaxonNameBase taxon name} that plays the role of the
97 * typified taxon name in this taxon name type designation. The {@link Rank rank}
98 * of a taxon name typified by another taxon name must be higher than
99 * "species aggregate".
100 *
101 * @see #getTypeSpecies()
102 */
103 @Cascade({CascadeType.SAVE_UPDATE})
104 public TaxonNameBase getTypifiedName() {
105 return typifiedName;
106 }
107 /**
108 * @see #getTypifiedName()
109 */
110 private void setTypifiedName(TaxonNameBase typifiedName) {
111 this.typifiedName = typifiedName;
112 if (typifiedName != null){
113 typifiedName.getNameTypeDesignations().add(this);
114 }
115 }
116
117
118 /**
119 * Returns the {@link TaxonNameBase taxon name} that plays the role of the
120 * taxon name type in this taxon name type designation. The {@link Rank rank}
121 * of a taxon name type must be "species".
122 *
123 * @see #getTypifiedName()
124 */
125 @ManyToOne
126 @Cascade({CascadeType.SAVE_UPDATE})
127 public TaxonNameBase getTypeSpecies(){
128 return this.typeSpecies;
129 }
130 /**
131 * @see #getTypeSpecies()
132 */
133 private void setTypeSpecies(TaxonNameBase typeSpecies){
134 this.typeSpecies = typeSpecies;
135 }
136
137 /**
138 * Returns the boolean value "true" if the competent authorities decided to
139 * reject the use of the species taxon name for this taxon name type
140 * designation.
141 *
142 * @see #isConservedType()
143 */
144 public boolean isRejectedType(){
145 return this.isRejectedType;
146 }
147 /**
148 * @see #isRejectedType()
149 */
150 public void setRejectedType(boolean isRejectedType){
151 this.isRejectedType = isRejectedType;
152 }
153
154 /**
155 * Returns the boolean value "true" if the competent authorities decided to
156 * conserve the use of the species taxon name for this taxon name type
157 * designation.
158 *
159 * @see #isConservedType()
160 */
161 public boolean isConservedType(){
162 return this.isConservedType;
163 }
164 /**
165 * @see #isConservedType()
166 */
167 public void setConservedType(boolean isConservedType){
168 this.isConservedType = isConservedType;
169 }
170
171 }