Project

General

Profile

Download (7.84 KB) Statistics
| Branch: | Tag: | Revision:
1 9479da48 Andreas Müller
/**
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 f6765014 ben.clark
import javax.persistence.Entity;
14
import javax.persistence.FetchType;
15 228c04ef Katja Luther
import javax.persistence.JoinColumn;
16 f6765014 ben.clark
import javax.persistence.ManyToOne;
17 b70a7f94 Andreas Kohlbecker
import javax.persistence.Transient;
18 dd2d8fac a.babadshanjan
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 a2312bea a.babadshanjan
import javax.xml.bind.annotation.XmlRootElement;
23 dd2d8fac a.babadshanjan
import javax.xml.bind.annotation.XmlSchemaType;
24
import javax.xml.bind.annotation.XmlType;
25 9479da48 Andreas Müller
26 f6765014 ben.clark
import org.apache.log4j.Logger;
27
import org.hibernate.annotations.Cascade;
28
import org.hibernate.annotations.CascadeType;
29 ee91bcd9 ben.clark
import org.hibernate.envers.Audited;
30 f6765014 ben.clark
31 483579cd Andreas Müller
import eu.etaxonomy.cdm.model.occurrence.DerivedUnit;
32 1d36aa54 Andreas Müller
import eu.etaxonomy.cdm.model.reference.Reference;
33 f6765014 ben.clark
34 9479da48 Andreas Müller
/**
35 09887ea6 m.geoffroy
 * The class representing a typification of one or several {@link TaxonNameBase taxon names} by a
36 483579cd Andreas Müller
 * {@link eu.etaxonomy.cdm.model.occurrence.DerivedUnit specimen or a figure}. All {@link TaxonNameBase taxon names}
37 d82717cb m.geoffroy
 * 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 2d4607f2 a.babadshanjan
 * {@link SpecimenTypeDesignationStatus status} like "holotype" or "isotype".
40 9e86cd74 m.geoffroy
 * <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 79263e24 m.geoffroy
 * 
47 d82717cb m.geoffroy
 * @see		TypeDesignationBase
48 7eba4302 m.geoffroy
 * @see		NameTypeDesignation
49
 * @author	m.doering
50 9479da48 Andreas Müller
 * @version 1.0
51 7eba4302 m.geoffroy
 * @created 08-Nov-2007 13:06:38
52 9479da48 Andreas Müller
 */
53 a2312bea a.babadshanjan
@XmlRootElement(name = "SpecimenTypeDesignation")
54 dd2d8fac a.babadshanjan
@XmlAccessorType(XmlAccessType.FIELD)
55
@XmlType(name = "SpecimenTypeDesignation", propOrder = {
56 2d4607f2 a.babadshanjan
    "typeSpecimen"
57 dd2d8fac a.babadshanjan
})
58 9479da48 Andreas Müller
@Entity
59 ee91bcd9 ben.clark
@Audited
60 a42e27ce Andreas Müller
public class SpecimenTypeDesignation extends TypeDesignationBase<SpecimenTypeDesignationStatus> implements ITypeDesignation, Cloneable {
61 a3a73c60 Andreas Müller
	private static final long serialVersionUID = 6481627446997275007L;
62 bb6bc58f n.hoffmann
	private static final Logger logger = Logger.getLogger(SpecimenTypeDesignation.class);
63 dd2d8fac a.babadshanjan
	
64
	@XmlElement(name = "TypeSpecimen")
65 ddae61ce a.babadshanjan
	@XmlIDREF
66
	@XmlSchemaType(name = "IDREF")
67 ee91bcd9 ben.clark
	@ManyToOne(fetch = FetchType.LAZY)
68 ac7f8217 Katja Luther
	@JoinColumn(name="typeSpecimen_id")
69 903cecc9 Cherian Mathew
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
70 483579cd Andreas Müller
	private DerivedUnit typeSpecimen;
71 dd2d8fac a.babadshanjan
	
72 dce4c9cb Andreas Müller
//	/**
73
//	 * Creates a new specimen type designation instance
74 1d36aa54 Andreas Müller
//	 * (including its {@link reference.Reference reference source} and eventually
75 dce4c9cb Andreas Müller
//	 * 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}.
79
//	 * 
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 483579cd Andreas Müller
//	 * @see							#SpecimenTypeDesignation(DerivedUnit, TypeDesignationStatus, Reference, String, String)
86 dce4c9cb Andreas Müller
//	 * @see							HomotypicalGroup#addSpecimenTypeDesignation(SpecimenTypeDesignation, boolean)
87 483579cd Andreas Müller
//	 * @see							occurrence.DerivedUnit
88 dce4c9cb Andreas Müller
//	 */
89 483579cd Andreas Müller
//	protected static SpecimenTypeDesignation NewInstance2(DerivedUnit specimen, TypeDesignationStatus status,
90 1d36aa54 Andreas Müller
//			Reference citation, String citationMicroReference, String originalNameString){
91 dce4c9cb Andreas Müller
//		SpecimenTypeDesignation specTypeDesig = new SpecimenTypeDesignation(specimen, status, citation, citationMicroReference, originalNameString);
92
//		return specTypeDesig;
93
//	}
94
	
95 3c629d82 Andreas Müller
	
96 7eba4302 m.geoffroy
	// ************* CONSTRUCTORS *************/	
97
	/** 
98
	 * Class constructor: creates a new empty specimen type designation.
99
	 * 
100 483579cd Andreas Müller
	 * @see	#SpecimenTypeDesignation(DerivedUnit, SpecimenTypeDesignationStatus,
101 1d36aa54 Andreas Müller
	 * Reference, String, String, boolean)
102 7eba4302 m.geoffroy
	 */
103 3c629d82 Andreas Müller
	protected SpecimenTypeDesignation(){
104
	}
105
	
106 a641fad9 ben.clark
	public static SpecimenTypeDesignation NewInstance() {
107
		return new SpecimenTypeDesignation();
108
	}
109
	
110 7eba4302 m.geoffroy
	/**
111
	 * Class constructor: creates a new specimen type designation instance
112 1d36aa54 Andreas Müller
	 * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and 
113 c99ad027 n.hoffmann
	 * eventually the taxon name string originally used by this reference when 
114 d82717cb m.geoffroy
	 * establishing the former designation).
115 7eba4302 m.geoffroy
	 * 
116 c99ad027 n.hoffmann
	 * @param specimen				the derived unit (specimen or figure) used 
117
	 * 								as type
118 7eba4302 m.geoffroy
	 * @param status				the type designation status 
119
	 * @param citation				the reference source for the new designation
120 c99ad027 n.hoffmann
	 * @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 57883822 m.geoffroy
	 * @param isNotDesignated		the boolean flag indicating whether there is no specimen type at all for 
125
	 * 								<i>this</i> specimen type designation
126 7eba4302 m.geoffroy
	 * @see							#SpecimenTypeDesignation()
127 1d36aa54 Andreas Müller
	 * @see							TaxonNameBase#addSpecimenTypeDesignation(Specimen, SpecimenTypeDesignationStatus, Reference, String, String, boolean, boolean)
128 57883822 m.geoffroy
	 * @see							TypeDesignationBase#isNotDesignated()
129 483579cd Andreas Müller
	 * @see							eu.etaxonomy.cdm.model.occurrence.DerivedUnit
130 7eba4302 m.geoffroy
	 */
131 483579cd Andreas Müller
	protected SpecimenTypeDesignation(DerivedUnit specimen, SpecimenTypeDesignationStatus status, Reference citation, String citationMicroReference, 
132 57883822 m.geoffroy
			String originalNameString, boolean isNotDesignated) {
133
		super(citation, citationMicroReference, originalNameString, isNotDesignated);
134 9479da48 Andreas Müller
		this.setTypeSpecimen(specimen);
135 228c04ef Katja Luther
		
136 9479da48 Andreas Müller
		this.setTypeStatus(status);
137
	}
138
	
139 7eba4302 m.geoffroy
	//********* METHODS **************************************/
140 ad45fc6d Andreas Müller
	
141
	
142
	/* (non-Javadoc)
143
	 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#removeType()
144
	 */
145
	@Override
146
	public void removeType() {
147
		this.setTypeSpecimen(null);
148
	}
149
	
150 7eba4302 m.geoffroy
	/** 
151 483579cd Andreas Müller
	 * Returns the {@link DerivedUnit.DerivedUnit derived unit} (specimen or figure) that is used
152 d82717cb m.geoffroy
	 * in <i>this</i> specimen type designation to typify the {@link TaxonNameBase taxon name}.
153 7eba4302 m.geoffroy
	 *  
154
	 * @see   #getHomotypicalGroup()
155
	 */
156 483579cd Andreas Müller
	public DerivedUnit getTypeSpecimen(){
157 9479da48 Andreas Müller
		return this.typeSpecimen;
158
	}
159 bb2f0f32 Andreas Müller
	
160 7eba4302 m.geoffroy
	/**
161
	 * @see  #getTypeSpecimen()
162
	 */
163 483579cd Andreas Müller
	public void setTypeSpecimen(DerivedUnit typeSpecimen){
164 bb2f0f32 Andreas Müller
		if (this.typeSpecimen == typeSpecimen){
165
			return;
166
		}
167
		if (this.typeSpecimen != null){
168
			this.typeSpecimen.removeSpecimenTypeDesignation(this);
169
		}
170
		if (typeSpecimen != null && ! typeSpecimen.getSpecimenTypeDesignations().contains(this)){
171
			typeSpecimen.addSpecimenTypeDesignation(this);
172
		}
173 f1d41e41 Andreas Müller
		this.typeSpecimen = typeSpecimen;
174 9479da48 Andreas Müller
	}
175
176 dce4c9cb Andreas Müller
	/* (non-Javadoc)
177
	 * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
178 3c629d82 Andreas Müller
	 */
179 b70a7f94 Andreas Kohlbecker
	@Transient
180 dce4c9cb Andreas Müller
	public boolean isLectoType() {
181 ece46ca8 Andreas Kohlbecker
		if(getTypeStatus() == null){
182
			return false;
183
		}
184 2d4607f2 a.babadshanjan
		return getTypeStatus().isLectotype();
185 3c629d82 Andreas Müller
	}
186
	
187 a42e27ce Andreas Müller
//*********************** CLONE ********************************************************/
188
	
189
	/** 
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.
193
	 * 
194
	 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone()
195
	 * @see java.lang.Object#clone()
196
	 */
197
	@Override
198
	public Object clone() {
199
		SpecimenTypeDesignation result;
200
		try {
201
			result = (SpecimenTypeDesignation)super.clone();
202
			//no changes to: typeSpecimen
203
			return result;
204
		} catch (CloneNotSupportedException e) {
205
			logger.warn("Object does not implement cloneable");
206
			e.printStackTrace();
207
			return null;
208
		}
209
	}
210 ad45fc6d Andreas Müller
211 a42e27ce Andreas Müller
	
212 9479da48 Andreas Müller
}