Project

General

Profile

Download (7.7 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.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;
25

    
26
import org.apache.log4j.Logger;
27
import org.hibernate.annotations.Cascade;
28
import org.hibernate.annotations.CascadeType;
29
import org.hibernate.envers.Audited;
30

    
31
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
32
import eu.etaxonomy.cdm.model.reference.Reference;
33

    
34
/**
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".
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
 * @created 08-Nov-2007 13:06:38
51
 */
52
@XmlRootElement(name = "SpecimenTypeDesignation")
53
@XmlAccessorType(XmlAccessType.FIELD)
54
@XmlType(name = "SpecimenTypeDesignation", propOrder = {
55
    "typeSpecimen"
56
})
57
@Entity
58
@Audited
59
public class SpecimenTypeDesignation extends TypeDesignationBase<SpecimenTypeDesignationStatus> implements ITypeDesignation, Cloneable {
60
	private static final long serialVersionUID = 6481627446997275007L;
61
	private static final Logger logger = Logger.getLogger(SpecimenTypeDesignation.class);
62

    
63
	@XmlElement(name = "TypeSpecimen")
64
	@XmlIDREF
65
	@XmlSchemaType(name = "IDREF")
66
	@ManyToOne(fetch = FetchType.LAZY)
67
	@JoinColumn(name="typeSpecimen_id")
68
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
69
	private DerivedUnit typeSpecimen;
70

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

    
94

    
95
	// ************* CONSTRUCTORS *************/
96
	/**
97
	 * Class constructor: creates a new empty specimen type designation.
98
	 *
99
	 * @see	#SpecimenTypeDesignation(DerivedUnit, SpecimenTypeDesignationStatus,
100
	 * Reference, String, String, boolean)
101
	 */
102
	protected SpecimenTypeDesignation(){
103
	}
104

    
105
	public static SpecimenTypeDesignation NewInstance() {
106
		return new SpecimenTypeDesignation();
107
	}
108

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

    
135
		this.setTypeStatus(status);
136
	}
137

    
138
	//********* METHODS **************************************/
139

    
140

    
141
	/* (non-Javadoc)
142
	 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#removeType()
143
	 */
144
	@Override
145
	public void removeType() {
146
		this.setTypeSpecimen(null);
147
	}
148

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

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

    
175
	@Override
176
    @Transient
177
	public boolean isLectoType() {
178
		if(getTypeStatus() == null){
179
			return false;
180
		}
181
		return getTypeStatus().isLectotype();
182
	}
183

    
184
//*********************** CLONE ********************************************************/
185

    
186
	/**
187
	 * Clones <i>this</i> type specimen. This is a shortcut that enables to create
188
	 * a new instance that differs only slightly from <i>this</i> type specimen by
189
	 * modifying only some of the attributes.
190
	 *
191
	 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone()
192
	 * @see java.lang.Object#clone()
193
	 */
194
	@Override
195
	public Object clone() {
196
		SpecimenTypeDesignation result;
197
		try {
198
			result = (SpecimenTypeDesignation)super.clone();
199
			//no changes to: typeSpecimen
200
			return result;
201
		} catch (CloneNotSupportedException e) {
202
			logger.warn("Object does not implement cloneable");
203
			e.printStackTrace();
204
			return null;
205
		}
206
	}
207

    
208

    
209
}
(27-27/36)