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
.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
;
25 import org
.apache
.logging
.log4j
.LogManager
;
26 import org
.apache
.logging
.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 TaxonName taxon names} by a
36 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnit specimen or a figure}. All {@link TaxonName 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
50 * @since 08-Nov-2007 13:06:38
52 @XmlRootElement(name
= "SpecimenTypeDesignation")
53 @XmlAccessorType(XmlAccessType
.FIELD
)
54 @XmlType(name
= "SpecimenTypeDesignation", propOrder
= {
59 public class SpecimenTypeDesignation
60 extends TypeDesignationBase
<SpecimenTypeDesignationStatus
> {
62 private static final long serialVersionUID
= 6481627446997275007L;
63 private static final Logger logger
= LogManager
.getLogger();
65 @XmlElement(name
= "TypeSpecimen")
67 @XmlSchemaType(name
= "IDREF")
68 @ManyToOne(fetch
= FetchType
.LAZY
)
69 @JoinColumn(name
="typeSpecimen_id")
70 @Cascade({CascadeType
.SAVE_UPDATE
,CascadeType
.MERGE
})
71 private DerivedUnit typeSpecimen
;
74 public static SpecimenTypeDesignation
NewInstance() {
75 return new SpecimenTypeDesignation();
79 // * Creates a new specimen type designation instance
80 // * (including its {@link reference.Reference reference source} and eventually
81 // * the taxon name string originally used by this reference when establishing
82 // * the former designation) and adds it to the corresponding
83 // * {@link HomotypicalGroup#getSpecimenTypeDesignations() specimen type designation set} of the
84 // * {@link HomotypicalGroup homotypical group}.
86 // * @param specimen the derived unit (specimen or figure) used as type
87 // * @param status the type designation status
88 // * @param citation the reference source for the new designation
89 // * @param citationMicroReference the string with the details describing the exact localisation within the reference
90 // * @param originalInfo any information from the original source, might be the name as written in the source (#10097)
91 // * @see #SpecimenTypeDesignation(DerivedUnit, TypeDesignationStatus, Reference, String, String)
92 // * @see HomotypicalGroup#addSpecimenTypeDesignation(SpecimenTypeDesignation, boolean)
93 // * @see occurrence.DerivedUnit
95 // protected static SpecimenTypeDesignation NewInstance2(DerivedUnit specimen, TypeDesignationStatus status,
96 // Reference citation, String citationMicroReference, String originalInfo){
97 // SpecimenTypeDesignation specTypeDesig = new SpecimenTypeDesignation(specimen, status, citation, citationMicroReference, originalInfo);
98 // return specTypeDesig;
101 // ************* CONSTRUCTORS *************/
103 * Class constructor: creates a new empty specimen type designation.
105 * @see #SpecimenTypeDesignation(DerivedUnit, SpecimenTypeDesignationStatus,
106 * Reference, String, String, boolean)
108 protected SpecimenTypeDesignation(){
113 * Class constructor: creates a new specimen type designation instance
114 * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and
115 * eventually the taxon name string originally used by this reference when
116 * establishing the former designation).
118 * @param specimen the derived unit (specimen or figure) used
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 originalInfo any information from the original source, might be the name as written in the source (#10097)
125 * reference source for the new designation
126 * @param isNotDesignated the boolean flag indicating whether there is no specimen type at all for
127 * <i>this</i> specimen type designation
128 * @see #SpecimenTypeDesignation()
129 * @see TaxonName#addSpecimenTypeDesignation(Specimen, SpecimenTypeDesignationStatus, Reference, String, String, boolean, boolean)
130 * @see TypeDesignationBase#isNotDesignated()
131 * @see eu.etaxonomy.cdm.model.occurrence.DerivedUnit
133 protected SpecimenTypeDesignation(DerivedUnit specimen
, SpecimenTypeDesignationStatus status
, Reference citation
, String citationMicroReference
,
134 String originalInfo
, boolean isNotDesignated
) {
135 super(citation
, citationMicroReference
, originalInfo
, isNotDesignated
);
136 this.setTypeSpecimen(specimen
);
137 this.setTypeStatus(status
);
140 //********* METHODS **************************************/
143 public void removeType() {
144 this.setTypeSpecimen(null);
148 * Returns the {@link DerivedUnit.DerivedUnit derived unit} (specimen or figure) that is used
149 * in <i>this</i> specimen type designation to typify the {@link TaxonName taxon name}.
151 * @see #getHomotypicalGroup()
153 public DerivedUnit
getTypeSpecimen(){
154 return this.typeSpecimen
;
158 * @see #getTypeSpecimen()
160 public void setTypeSpecimen(DerivedUnit typeSpecimen
){
161 if (this.typeSpecimen
== typeSpecimen
){
164 if (this.typeSpecimen
!= null){
165 this.typeSpecimen
.removeSpecimenTypeDesignation(this);
167 if (typeSpecimen
!= null && ! typeSpecimen
.getSpecimenTypeDesignations().contains(this)){
168 typeSpecimen
.addSpecimenTypeDesignation(this);
170 this.typeSpecimen
= typeSpecimen
;
173 //*********************** CLONE ********************************************************/
176 * Clones <i>this</i> type specimen. This is a shortcut that enables to create
177 * a new instance that differs only slightly from <i>this</i> type specimen by
178 * modifying only some of the attributes.
180 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone()
181 * @see java.lang.Object#clone()
184 public SpecimenTypeDesignation
clone() {
186 SpecimenTypeDesignation result
;
188 result
= (SpecimenTypeDesignation
)super.clone();
189 //no changes to: typeSpecimen
191 } catch (CloneNotSupportedException e
) {
192 logger
.warn("Object does not implement cloneable");