(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / SpecimenTypeDesignation.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.occurrence.DerivedUnitBase;
14 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
15 import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
16 import org.apache.log4j.Logger;
17 import org.hibernate.annotations.Cascade;
18 import org.hibernate.annotations.CascadeType;
19
20 import java.util.*;
21
22 import javax.persistence.*;
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlElement;
26 import javax.xml.bind.annotation.XmlElementWrapper;
27 import javax.xml.bind.annotation.XmlIDREF;
28 import javax.xml.bind.annotation.XmlSchemaType;
29 import javax.xml.bind.annotation.XmlType;
30
31 /**
32 * The class representing a typification of an {@link HomotypicalGroup homotypical group} by a
33 * {@link occurrence.DerivedUnitBase specimen or a figure}. This allows to define a specimen type designation
34 * only once for the homotypical group instead of defining a type designation
35 * for each one of the taxon names subsumed under one homotypical group.
36 * All {@link TaxonNameBase taxon names} which have a {@link Rank rank}
37 * "species aggregate" or lower can only be typified by specimens.
38 * Moreover each typification by a specimen (or by a figure) has a {@link TypeDesignationStatus status}
39 * like "holotype" or "isotype".
40 * <P>
41 * This class corresponds to: <ul>
42 * <li> NomenclaturalType according to the TDWG ontology
43 * <li> Typification (partially) according to the TCS
44 * <li> NomenclaturalTypeDesignation according to the ABCD schema
45 * </ul>
46 *
47 * @see NameTypeDesignation
48 * @author m.doering
49 * @version 1.0
50 * @created 08-Nov-2007 13:06:38
51 */
52 @XmlAccessorType(XmlAccessType.FIELD)
53 @XmlType(name = "SpecimenTypeDesignation", propOrder = {
54 "homotypicalGroup",
55 "typeSpecimen",
56 "typeStatus",
57 "typifiedNames"
58 })
59 @Entity
60 public class SpecimenTypeDesignation extends TypeDesignationBase implements ITypeDesignation {
61
62 private static final Logger logger = Logger.getLogger(SpecimenTypeDesignation.class);
63
64 @XmlElement(name = "TypeSpecimen")
65 // @XmlIDREF
66 // @XmlSchemaType(name = "IDREF")
67 private DerivedUnitBase typeSpecimen;
68
69 @XmlElement(name = "TypeStatus")
70 private TypeDesignationStatus typeStatus;
71
72
73
74
75 // /**
76 // * Creates a new specimen type designation instance
77 // * (including its {@link reference.ReferenceBase reference source} and eventually
78 // * the taxon name string originally used by this reference when establishing
79 // * the former designation) and adds it to the corresponding
80 // * {@link HomotypicalGroup#getSpecimenTypeDesignations() specimen type designation set} of the
81 // * {@link HomotypicalGroup homotypical group}.
82 // *
83 // * @param specimen the derived unit (specimen or figure) used as type
84 // * @param status the type designation status
85 // * @param citation the reference source for the new designation
86 // * @param citationMicroReference the string with the details describing the exact localisation within the reference
87 // * @param originalNameString the taxon name string used originally in the reference source for the new designation
88 // * @see #SpecimenTypeDesignation(DerivedUnitBase, TypeDesignationStatus, ReferenceBase, String, String)
89 // * @see HomotypicalGroup#addSpecimenTypeDesignation(SpecimenTypeDesignation, boolean)
90 // * @see occurrence.DerivedUnitBase
91 // */
92 // protected static SpecimenTypeDesignation NewInstance2(DerivedUnitBase specimen, TypeDesignationStatus status,
93 // ReferenceBase citation, String citationMicroReference, String originalNameString){
94 // SpecimenTypeDesignation specTypeDesig = new SpecimenTypeDesignation(specimen, status, citation, citationMicroReference, originalNameString);
95 // return specTypeDesig;
96 // }
97
98
99 // ************* CONSTRUCTORS *************/
100 /**
101 * Class constructor: creates a new empty specimen type designation.
102 *
103 * @see #SpecimenTypeDesignation(DerivedUnitBase, TypeDesignationStatus,
104 * ReferenceBase, String, String)
105 */
106 protected SpecimenTypeDesignation(){
107
108 }
109
110 /**
111 * Class constructor: creates a new specimen type designation instance
112 * (including its {@link reference.ReferenceBase reference source} and
113 * eventually the taxon name string originally used by this reference when
114 * establishing the former designation) and adds it to the corresponding
115 * {@link HomotypicalGroup#getSpecimenTypeDesignations() specimen type
116 * designation set} of the {@link HomotypicalGroup homotypical group}.
117 *
118 * @param specimen the derived unit (specimen or figure) used
119 * as type
120 * @param status the type designation status
121 * @param citation the reference source for the new designation
122 * @param citationMicroReference the string with the details describing
123 * the exact localisation within the reference
124 * @param originalNameString the taxon name string used originally in the
125 * reference source for the new designation
126 * @see #SpecimenTypeDesignation()
127 * @see HomotypicalGroup#addSpecimenTypeDesignation(SpecimenTypeDesignation, boolean)
128 * @see occurrence.DerivedUnitBase
129 */
130 protected SpecimenTypeDesignation(DerivedUnitBase specimen, TypeDesignationStatus status, ReferenceBase citation, String citationMicroReference,
131 String originalNameString) {
132 super(citation, citationMicroReference, originalNameString);
133 this.setTypeSpecimen(specimen);
134 this.setTypeStatus(status);
135 }
136
137
138
139
140 //********* METHODS **************************************/
141
142
143
144 /**
145 * Returns the {@link occurrence.DerivedUnitBase derived unit} (specimen or figure) that is used
146 * in <i>this</i> specimen type designation to typify the {@link HomotypicalGroup homotypical group}.
147 *
148 * @see #getHomotypicalGroup()
149 */
150 @ManyToOne
151 @Cascade({CascadeType.SAVE_UPDATE})
152 public DerivedUnitBase getTypeSpecimen(){
153 return this.typeSpecimen;
154 }
155 /**
156 * @see #getTypeSpecimen()
157 */
158 public void setTypeSpecimen(DerivedUnitBase typeSpecimen){
159 this.typeSpecimen = typeSpecimen;
160 }
161
162 /**
163 * Returns the {@link TypeDesignationStatus type designation status} for <i>this</i> specimen type
164 * designation. This status describes which of the possible categories of
165 * types like "holotype", "neotype", "syntype" or "isotype" applies to <i>this</i>
166 * specimen type designation.
167 */
168 @ManyToOne
169 public TypeDesignationStatus getTypeStatus(){
170 return this.typeStatus;
171 }
172 /**
173 * @see #getTypeStatus()
174 */
175 public void setTypeStatus(TypeDesignationStatus typeStatus){
176 this.typeStatus = typeStatus;
177 }
178
179 /* (non-Javadoc)
180 * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
181 */
182 /**
183 * Returns the boolean value indicating whether <i>this</i> specimen type
184 * designation has a "lectotype" status (true) or not (false).<BR>
185 * A lectotype is a {@link occurrence.DerivedUnitBase specimen or illustration} designated as the
186 * nomenclatural type, when no holotype was indicated at the time of
187 * publication of the "type-bringing" {@link TaxonNameBase taxon name}, when the
188 * holotype is found to belong to more than one {@link HomotypicalGroup homotypical group},
189 * or as long as it is missing.
190 *
191 * @see TypeDesignationStatus#isLectotype()
192 * @see TypeDesignationStatus#HOLOTYPE()
193 */
194 @Transient
195 public boolean isLectoType() {
196 return typeStatus.isLectotype();
197 }
198
199 }