a6c580667edf308257f37824c0f9bd9315fe32b4
[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 javax.persistence.Entity;
14 import javax.persistence.FetchType;
15 import javax.persistence.ManyToOne;
16 import javax.persistence.Transient;
17 import javax.xml.bind.annotation.XmlAccessType;
18 import javax.xml.bind.annotation.XmlAccessorType;
19 import javax.xml.bind.annotation.XmlElement;
20 import javax.xml.bind.annotation.XmlIDREF;
21 import javax.xml.bind.annotation.XmlRootElement;
22 import javax.xml.bind.annotation.XmlSchemaType;
23 import javax.xml.bind.annotation.XmlType;
24
25 import org.apache.log4j.Logger;
26 import org.hibernate.annotations.Cascade;
27 import org.hibernate.annotations.CascadeType;
28 import org.hibernate.envers.Audited;
29
30 import eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase;
31 import eu.etaxonomy.cdm.model.occurrence.Specimen;
32 import eu.etaxonomy.cdm.model.reference.ReferenceBase;
33
34 /**
35 * The class representing a typification of one or several {@link TaxonNameBase taxon names} by a
36 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase specimen or a figure}. All {@link TaxonNameBase taxon names}
37 * which have a {@link Rank rank} "species aggregate" or lower can only be typified
38 * by specimens. Moreover each typification by a specimen (or by a figure) has a
39 * {@link SpecimenTypeDesignationStatus status} 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 TypeDesignationBase
48 * @see NameTypeDesignation
49 * @author m.doering
50 * @version 1.0
51 * @created 08-Nov-2007 13:06:38
52 */
53 @XmlRootElement(name = "SpecimenTypeDesignation")
54 @XmlAccessorType(XmlAccessType.FIELD)
55 @XmlType(name = "SpecimenTypeDesignation", propOrder = {
56 "typeSpecimen"
57 })
58 @Entity
59 @Audited
60 public class SpecimenTypeDesignation extends TypeDesignationBase<SpecimenTypeDesignationStatus>
61 implements ITypeDesignation {
62 private static final long serialVersionUID = 6481627446997275007L;
63 @SuppressWarnings("unused")
64 private static final Logger logger = Logger.getLogger(SpecimenTypeDesignation.class);
65
66 @XmlElement(name = "TypeSpecimen")
67 @XmlIDREF
68 @XmlSchemaType(name = "IDREF")
69 @ManyToOne(fetch = FetchType.LAZY)
70 @Cascade(CascadeType.SAVE_UPDATE)
71 private DerivedUnitBase typeSpecimen;
72
73 // /**
74 // * Creates a new specimen type designation instance
75 // * (including its {@link reference.ReferenceBase reference source} and eventually
76 // * the taxon name string originally used by this reference when establishing
77 // * the former designation) and adds it to the corresponding
78 // * {@link HomotypicalGroup#getSpecimenTypeDesignations() specimen type designation set} of the
79 // * {@link HomotypicalGroup homotypical group}.
80 // *
81 // * @param specimen the derived unit (specimen or figure) used as type
82 // * @param status the type designation status
83 // * @param citation the reference source for the new designation
84 // * @param citationMicroReference the string with the details describing the exact localisation within the reference
85 // * @param originalNameString the taxon name string used originally in the reference source for the new designation
86 // * @see #SpecimenTypeDesignation(DerivedUnitBase, TypeDesignationStatus, ReferenceBase, String, String)
87 // * @see HomotypicalGroup#addSpecimenTypeDesignation(SpecimenTypeDesignation, boolean)
88 // * @see occurrence.DerivedUnitBase
89 // */
90 // protected static SpecimenTypeDesignation NewInstance2(DerivedUnitBase specimen, TypeDesignationStatus status,
91 // ReferenceBase citation, String citationMicroReference, String originalNameString){
92 // SpecimenTypeDesignation specTypeDesig = new SpecimenTypeDesignation(specimen, status, citation, citationMicroReference, originalNameString);
93 // return specTypeDesig;
94 // }
95
96
97 // ************* CONSTRUCTORS *************/
98 /**
99 * Class constructor: creates a new empty specimen type designation.
100 *
101 * @see #SpecimenTypeDesignation(DerivedUnitBase, SpecimenTypeDesignationStatus,
102 * ReferenceBase, String, String, boolean)
103 */
104 protected SpecimenTypeDesignation(){
105 }
106
107 /**
108 * Class constructor: creates a new specimen type designation instance
109 * (including its {@link eu.etaxonomy.cdm.model.reference.ReferenceBase reference source} and
110 * eventually the taxon name string originally used by this reference when
111 * establishing the former designation).
112 *
113 * @param specimen the derived unit (specimen or figure) used
114 * as type
115 * @param status the type designation status
116 * @param citation the reference source for the new designation
117 * @param citationMicroReference the string with the details describing
118 * the exact localisation within the reference
119 * @param originalNameString the taxon name string used originally in the
120 * reference source for the new designation
121 * @param isNotDesignated the boolean flag indicating whether there is no specimen type at all for
122 * <i>this</i> specimen type designation
123 * @see #SpecimenTypeDesignation()
124 * @see TaxonNameBase#addSpecimenTypeDesignation(Specimen, SpecimenTypeDesignationStatus, ReferenceBase, String, String, boolean, boolean)
125 * @see TypeDesignationBase#isNotDesignated()
126 * @see eu.etaxonomy.cdm.model.occurrence.DerivedUnitBase
127 */
128 protected SpecimenTypeDesignation(DerivedUnitBase specimen, SpecimenTypeDesignationStatus status, ReferenceBase citation, String citationMicroReference,
129 String originalNameString, boolean isNotDesignated) {
130 super(citation, citationMicroReference, originalNameString, isNotDesignated);
131 this.setTypeSpecimen(specimen);
132 this.setTypeStatus(status);
133 }
134
135 //********* METHODS **************************************/
136
137 /**
138 * Returns the {@link occurrence.DerivedUnitBase derived unit} (specimen or figure) that is used
139 * in <i>this</i> specimen type designation to typify the {@link TaxonNameBase taxon name}.
140 *
141 * @see #getHomotypicalGroup()
142 */
143 public DerivedUnitBase getTypeSpecimen(){
144 return this.typeSpecimen;
145 }
146 /**
147 * @see #getTypeSpecimen()
148 */
149 public void setTypeSpecimen(DerivedUnitBase typeSpecimen){
150 this.typeSpecimen = typeSpecimen;
151 }
152
153 /* (non-Javadoc)
154 * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
155 */
156 @Transient
157 public boolean isLectoType() {
158 return getTypeStatus().isLectotype();
159 }
160
161 }