Project

General

Profile

Download (7.47 KB) Statistics
| Branch: | Tag: | Revision:
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.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;
24

    
25
import org.apache.logging.log4j.LogManager;import org.apache.logging.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.DerivedUnit;
31
import eu.etaxonomy.cdm.model.reference.Reference;
32

    
33
/**
34
 * The class representing a typification of one or several {@link TaxonName taxon names} by a
35
 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnit specimen or a figure}. All {@link TaxonName taxon names}
36
 * which have a {@link Rank rank} "species aggregate" or lower can only be typified
37
 * by specimens. Moreover each typification by a specimen (or by a figure) has a
38
 * {@link SpecimenTypeDesignationStatus status} like "holotype" or "isotype".
39
 * <P>
40
 * This class corresponds to: <ul>
41
 * <li> NomenclaturalType according to the TDWG ontology
42
 * <li> Typification (partially) according to the TCS
43
 * <li> NomenclaturalTypeDesignation according to the ABCD schema
44
 * </ul>
45
 *
46
 * @see		TypeDesignationBase
47
 * @see		NameTypeDesignation
48
 * @author	m.doering
49
 * @since 08-Nov-2007 13:06:38
50
 */
51
@XmlRootElement(name = "SpecimenTypeDesignation")
52
@XmlAccessorType(XmlAccessType.FIELD)
53
@XmlType(name = "SpecimenTypeDesignation", propOrder = {
54
    "typeSpecimen"
55
})
56
@Entity
57
@Audited
58
public class SpecimenTypeDesignation
59
        extends TypeDesignationBase<SpecimenTypeDesignationStatus> {
60

    
61
	private static final long serialVersionUID = 6481627446997275007L;
62
	private static final Logger logger = LogManager.getLogger(SpecimenTypeDesignation.class);
63

    
64
	@XmlElement(name = "TypeSpecimen")
65
	@XmlIDREF
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;
71

    
72

    
73
    public static SpecimenTypeDesignation NewInstance() {
74
        return new SpecimenTypeDesignation();
75
    }
76

    
77
//	/**
78
//	 * Creates a new specimen type designation instance
79
//	 * (including its {@link reference.Reference reference source} and eventually
80
//	 * the taxon name string originally used by this reference when establishing
81
//	 * the former designation) and adds it to the corresponding
82
//	 * {@link HomotypicalGroup#getSpecimenTypeDesignations() specimen type designation set} of the
83
//	 * {@link HomotypicalGroup homotypical group}.
84
//	 *
85
//	 * @param specimen				the derived unit (specimen or figure) used as type
86
//	 * @param status				the type designation status
87
//	 * @param citation				the reference source for the new designation
88
//	 * @param citationMicroReference	the string with the details describing the exact localisation within the reference
89
//	 * @param originalNameString	the taxon name string used originally in the reference source for the new designation
90
//	 * @see							#SpecimenTypeDesignation(DerivedUnit, TypeDesignationStatus, Reference, String, String)
91
//	 * @see							HomotypicalGroup#addSpecimenTypeDesignation(SpecimenTypeDesignation, boolean)
92
//	 * @see							occurrence.DerivedUnit
93
//	 */
94
//	protected static SpecimenTypeDesignation NewInstance2(DerivedUnit specimen, TypeDesignationStatus status,
95
//			Reference citation, String citationMicroReference, String originalNameString){
96
//		SpecimenTypeDesignation specTypeDesig = new SpecimenTypeDesignation(specimen, status, citation, citationMicroReference, originalNameString);
97
//		return specTypeDesig;
98
//	}
99

    
100
// ************* CONSTRUCTORS *************/
101
	/**
102
	 * Class constructor: creates a new empty specimen type designation.
103
	 *
104
	 * @see	#SpecimenTypeDesignation(DerivedUnit, SpecimenTypeDesignationStatus,
105
	 * Reference, String, String, boolean)
106
	 */
107
	protected SpecimenTypeDesignation(){
108
	}
109

    
110

    
111
	/**
112
	 * Class constructor: creates a new specimen type designation instance
113
	 * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and
114
	 * eventually the taxon name string originally used by this reference when
115
	 * establishing the former designation).
116
	 *
117
	 * @param specimen				the derived unit (specimen or figure) used
118
	 * 								as type
119
	 * @param status				the type designation status
120
	 * @param citation				the reference source for the new designation
121
	 * @param citationMicroReference	the string with the details describing
122
	 * 								the exact localisation within the reference
123
	 * @param originalNameString	the taxon name string used originally in the
124
	 * 								reference source for the new designation
125
	 * @param isNotDesignated		the boolean flag indicating whether there is no specimen type at all for
126
	 * 								<i>this</i> specimen type designation
127
	 * @see							#SpecimenTypeDesignation()
128
	 * @see							TaxonName#addSpecimenTypeDesignation(Specimen, SpecimenTypeDesignationStatus, Reference, String, String, boolean, boolean)
129
	 * @see							TypeDesignationBase#isNotDesignated()
130
	 * @see							eu.etaxonomy.cdm.model.occurrence.DerivedUnit
131
	 */
132
	protected SpecimenTypeDesignation(DerivedUnit specimen, SpecimenTypeDesignationStatus status, Reference citation, String citationMicroReference,
133
			String originalNameString, boolean isNotDesignated) {
134
		super(citation, citationMicroReference, originalNameString, isNotDesignated);
135
		this.setTypeSpecimen(specimen);
136
		this.setTypeStatus(status);
137
	}
138

    
139
//********* METHODS **************************************/
140

    
141
	@Override
142
	public void removeType() {
143
		this.setTypeSpecimen(null);
144
	}
145

    
146
	/**
147
	 * Returns the {@link DerivedUnit.DerivedUnit derived unit} (specimen or figure) that is used
148
	 * in <i>this</i> specimen type designation to typify the {@link TaxonName taxon name}.
149
	 *
150
	 * @see   #getHomotypicalGroup()
151
	 */
152
	public DerivedUnit getTypeSpecimen(){
153
		return this.typeSpecimen;
154
	}
155

    
156
	/**
157
	 * @see  #getTypeSpecimen()
158
	 */
159
	public void setTypeSpecimen(DerivedUnit typeSpecimen){
160
		if (this.typeSpecimen == typeSpecimen){
161
			return;
162
		}
163
		if (this.typeSpecimen != null){
164
			this.typeSpecimen.removeSpecimenTypeDesignation(this);
165
		}
166
		if (typeSpecimen != null && ! typeSpecimen.getSpecimenTypeDesignations().contains(this)){
167
			typeSpecimen.addSpecimenTypeDesignation(this);
168
		}
169
		this.typeSpecimen = typeSpecimen;
170
	}
171

    
172
//*********************** CLONE ********************************************************/
173

    
174
	/**
175
	 * Clones <i>this</i> type specimen. This is a shortcut that enables to create
176
	 * a new instance that differs only slightly from <i>this</i> type specimen by
177
	 * modifying only some of the attributes.
178
	 *
179
	 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone()
180
	 * @see java.lang.Object#clone()
181
	 */
182
	@Override
183
	public SpecimenTypeDesignation clone() {
184

    
185
		SpecimenTypeDesignation result;
186
		try {
187
			result = (SpecimenTypeDesignation)super.clone();
188
			//no changes to: typeSpecimen
189
			return result;
190
		} catch (CloneNotSupportedException e) {
191
			logger.warn("Object does not implement cloneable");
192
			e.printStackTrace();
193
			return null;
194
		}
195
	}
196
}
(31-31/39)