2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.name
;
13 import javax
.persistence
.Entity
;
14 import javax
.persistence
.FetchType
;
15 import javax
.persistence
.JoinColumn
;
16 import javax
.persistence
.ManyToOne
;
17 import javax
.persistence
.Transient
;
18 import javax
.xml
.bind
.annotation
.XmlAccessType
;
19 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
20 import javax
.xml
.bind
.annotation
.XmlElement
;
21 import javax
.xml
.bind
.annotation
.XmlIDREF
;
22 import javax
.xml
.bind
.annotation
.XmlRootElement
;
23 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
24 import javax
.xml
.bind
.annotation
.XmlType
;
26 import org
.apache
.log4j
.Logger
;
27 import org
.hibernate
.annotations
.Cascade
;
28 import org
.hibernate
.annotations
.CascadeType
;
29 import org
.hibernate
.envers
.Audited
;
31 import eu
.etaxonomy
.cdm
.model
.occurrence
.DerivedUnit
;
32 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
35 * The class representing a typification of one or several {@link TaxonNameBase taxon names} by a
36 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnit 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".
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
47 * @see TypeDesignationBase
48 * @see NameTypeDesignation
51 * @created 08-Nov-2007 13:06:38
53 @XmlRootElement(name
= "SpecimenTypeDesignation")
54 @XmlAccessorType(XmlAccessType
.FIELD
)
55 @XmlType(name
= "SpecimenTypeDesignation", propOrder
= {
60 public class SpecimenTypeDesignation
extends TypeDesignationBase
<SpecimenTypeDesignationStatus
> implements ITypeDesignation
, Cloneable
{
61 private static final long serialVersionUID
= 6481627446997275007L;
62 private static final Logger logger
= Logger
.getLogger(SpecimenTypeDesignation
.class);
64 @XmlElement(name
= "TypeSpecimen")
66 @XmlSchemaType(name
= "IDREF")
67 @ManyToOne(fetch
= FetchType
.LAZY
)
68 @JoinColumn(name
="typeSpecimen_id")
69 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
70 private DerivedUnit typeSpecimen
;
73 // * Creates a new specimen type designation instance
74 // * (including its {@link reference.Reference reference source} and eventually
75 // * the taxon name string originally used by this reference when establishing
76 // * the former designation) and adds it to the corresponding
77 // * {@link HomotypicalGroup#getSpecimenTypeDesignations() specimen type designation set} of the
78 // * {@link HomotypicalGroup homotypical group}.
80 // * @param specimen the derived unit (specimen or figure) used as type
81 // * @param status the type designation status
82 // * @param citation the reference source for the new designation
83 // * @param citationMicroReference the string with the details describing the exact localisation within the reference
84 // * @param originalNameString the taxon name string used originally in the reference source for the new designation
85 // * @see #SpecimenTypeDesignation(DerivedUnit, TypeDesignationStatus, Reference, String, String)
86 // * @see HomotypicalGroup#addSpecimenTypeDesignation(SpecimenTypeDesignation, boolean)
87 // * @see occurrence.DerivedUnit
89 // protected static SpecimenTypeDesignation NewInstance2(DerivedUnit specimen, TypeDesignationStatus status,
90 // Reference citation, String citationMicroReference, String originalNameString){
91 // SpecimenTypeDesignation specTypeDesig = new SpecimenTypeDesignation(specimen, status, citation, citationMicroReference, originalNameString);
92 // return specTypeDesig;
96 // ************* CONSTRUCTORS *************/
98 * Class constructor: creates a new empty specimen type designation.
100 * @see #SpecimenTypeDesignation(DerivedUnit, SpecimenTypeDesignationStatus,
101 * Reference, String, String, boolean)
103 protected SpecimenTypeDesignation(){
106 public static SpecimenTypeDesignation
NewInstance() {
107 return new SpecimenTypeDesignation();
111 * Class constructor: creates a new specimen type designation instance
112 * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and
113 * eventually the taxon name string originally used by this reference when
114 * establishing the former designation).
116 * @param specimen the derived unit (specimen or figure) used
118 * @param status the type designation status
119 * @param citation the reference source for the new designation
120 * @param citationMicroReference the string with the details describing
121 * the exact localisation within the reference
122 * @param originalNameString the taxon name string used originally in the
123 * reference source for the new designation
124 * @param isNotDesignated the boolean flag indicating whether there is no specimen type at all for
125 * <i>this</i> specimen type designation
126 * @see #SpecimenTypeDesignation()
127 * @see TaxonNameBase#addSpecimenTypeDesignation(Specimen, SpecimenTypeDesignationStatus, Reference, String, String, boolean, boolean)
128 * @see TypeDesignationBase#isNotDesignated()
129 * @see eu.etaxonomy.cdm.model.occurrence.DerivedUnit
131 protected SpecimenTypeDesignation(DerivedUnit specimen
, SpecimenTypeDesignationStatus status
, Reference citation
, String citationMicroReference
,
132 String originalNameString
, boolean isNotDesignated
) {
133 super(citation
, citationMicroReference
, originalNameString
, isNotDesignated
);
134 this.setTypeSpecimen(specimen
);
136 this.setTypeStatus(status
);
139 //********* METHODS **************************************/
143 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#removeType()
146 public void removeType() {
147 this.setTypeSpecimen(null);
151 * Returns the {@link DerivedUnit.DerivedUnit derived unit} (specimen or figure) that is used
152 * in <i>this</i> specimen type designation to typify the {@link TaxonNameBase taxon name}.
154 * @see #getHomotypicalGroup()
156 public DerivedUnit
getTypeSpecimen(){
157 return this.typeSpecimen
;
161 * @see #getTypeSpecimen()
163 public void setTypeSpecimen(DerivedUnit typeSpecimen
){
164 if (this.typeSpecimen
== typeSpecimen
){
167 if (this.typeSpecimen
!= null){
168 this.typeSpecimen
.removeSpecimenTypeDesignation(this);
170 if (typeSpecimen
!= null && ! typeSpecimen
.getSpecimenTypeDesignations().contains(this)){
171 typeSpecimen
.addSpecimenTypeDesignation(this);
173 this.typeSpecimen
= typeSpecimen
;
177 * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
180 public boolean isLectoType() {
181 if(getTypeStatus() == null){
184 return getTypeStatus().isLectotype();
187 //*********************** CLONE ********************************************************/
190 * Clones <i>this</i> type specimen. This is a shortcut that enables to create
191 * a new instance that differs only slightly from <i>this</i> type specimen by
192 * modifying only some of the attributes.
194 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone()
195 * @see java.lang.Object#clone()
198 public Object
clone() {
199 SpecimenTypeDesignation result
;
201 result
= (SpecimenTypeDesignation
)super.clone();
202 //no changes to: typeSpecimen
204 } catch (CloneNotSupportedException e
) {
205 logger
.warn("Object does not implement cloneable");