Project

General

Profile

Download (9.6 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 a60f55d2 Andreas Müller
import javax.persistence.Entity;
13 f6765014 ben.clark
import javax.persistence.FetchType;
14 a60f55d2 Andreas Müller
import javax.persistence.ManyToOne;
15 999f1f6b Andreas Müller
import javax.persistence.Transient;
16 a2312bea a.babadshanjan
import javax.xml.bind.annotation.XmlAccessType;
17
import javax.xml.bind.annotation.XmlAccessorType;
18 bb6bc58f n.hoffmann
import javax.xml.bind.annotation.XmlElement;
19
import javax.xml.bind.annotation.XmlIDREF;
20 a2312bea a.babadshanjan
import javax.xml.bind.annotation.XmlRootElement;
21 bb6bc58f n.hoffmann
import javax.xml.bind.annotation.XmlSchemaType;
22 a60f55d2 Andreas Müller
import javax.xml.bind.annotation.XmlType;
23 9479da48 Andreas Müller
24
import org.apache.log4j.Logger;
25
import org.hibernate.annotations.Cascade;
26
import org.hibernate.annotations.CascadeType;
27 ee91bcd9 ben.clark
import org.hibernate.envers.Audited;
28 a60f55d2 Andreas Müller
29 1d36aa54 Andreas Müller
import eu.etaxonomy.cdm.model.reference.Reference;
30 9479da48 Andreas Müller
31
/**
32 d82717cb m.geoffroy
 * The class representing a typification of a {@link TaxonNameBase taxon name} with a {@link Rank rank}
33
 * above "species aggregate" by another taxon name.<BR>
34 95dc27ff m.geoffroy
 * According to nomenclature a type of a genus name or of any subdivision of a
35
 * genus can only be a species name. A type of a family name or of any
36 d82717cb m.geoffroy
 * subdivision of a family is a genus name.<BR>
37
 * Moreover the designation of a particular taxon name as a type might be
38
 * nomenclaturally rejected or conserved. Depending on the date of publication,
39
 * the same typification could be rejected according to one reference and later
40
 * be conserved according to another reference, but a name type designation
41 09887ea6 m.geoffroy
 * cannot be simultaneously rejected and conserved.<BR>
42
 * Name type designations are treated as {@link TypeDesignationBase type designations}
43
 * and not as {@link NameRelationship name relationships}.
44 9cafe0e8 m.geoffroy
 * 
45 d82717cb m.geoffroy
 * @see		TypeDesignationBase
46 7d954fd9 m.geoffroy
 * @see		SpecimenTypeDesignation
47
 * @author	m.doering
48 9479da48 Andreas Müller
 * @version 1.0
49
 * @created 08-Nov-2007 13:06:38
50
 */
51 a2312bea a.babadshanjan
@XmlRootElement(name = "NameTypeDesignation")
52
@XmlAccessorType(XmlAccessType.FIELD)
53
@XmlType(name = "NameTypeDesignation", propOrder = {
54 ee91bcd9 ben.clark
    "rejectedType",
55
    "conservedType",
56 a2312bea a.babadshanjan
    "typeName"
57
})
58 9479da48 Andreas Müller
@Entity
59 ee91bcd9 ben.clark
@Audited
60 a42e27ce Andreas Müller
public class NameTypeDesignation extends TypeDesignationBase<NameTypeDesignationStatus> implements ITypeDesignation, Cloneable {
61 ad45fc6d Andreas Müller
	private static final long serialVersionUID = 8478663508862210879L;
62 999f1f6b Andreas Müller
	final static Logger logger = Logger.getLogger(NameTypeDesignation.class);
63 a2312bea a.babadshanjan
	
64
	@XmlElement(name = "IsRejectedType")
65 ee91bcd9 ben.clark
	private boolean rejectedType;
66 a2312bea a.babadshanjan
	
67
	@XmlElement(name = "IsConservedType")
68 ee91bcd9 ben.clark
	private boolean conservedType;
69 a2312bea a.babadshanjan
	
70
	@XmlElement(name = "TypeName")
71
	@XmlIDREF
72
	@XmlSchemaType(name = "IDREF")
73 ee91bcd9 ben.clark
	@ManyToOne(fetch = FetchType.LAZY)
74 903cecc9 Cherian Mathew
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
75 78f6ad0d m.geoffroy
	private TaxonNameBase typeName;
76 0b0a1df7 Andreas Müller
77
	
78
	public static NameTypeDesignation NewInstance() {
79
		return new NameTypeDesignation();
80
	}
81 33269d91 a.babadshanjan
	
82 bb6bc58f n.hoffmann
	
83 7d954fd9 m.geoffroy
	// ************* CONSTRUCTORS *************/	
84
	/** 
85
	 * Class constructor: creates a new empty name type designation.
86
	 * 
87 1d36aa54 Andreas Müller
	 * @see	#NameTypeDesignation(TaxonNameBase, Reference, String, String, boolean, boolean, boolean)
88 33269d91 a.babadshanjan
	 */
89 7d954fd9 m.geoffroy
	protected NameTypeDesignation() {
90 33269d91 a.babadshanjan
	}
91 0b0a1df7 Andreas Müller
92 9479da48 Andreas Müller
93 7d954fd9 m.geoffroy
	/**
94
	 * Class constructor: creates a new name type designation instance
95 1d36aa54 Andreas Müller
	 * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and eventually
96 7d954fd9 m.geoffroy
	 * the taxon name string originally used by this reference when establishing
97 d82717cb m.geoffroy
	 * the former designation).
98 7d954fd9 m.geoffroy
	 * 
99 f2a881b3 m.geoffroy
	 * @param typeName				the taxon name used as a type 
100 7d954fd9 m.geoffroy
	 * @param citation				the reference source for the new designation
101
	 * @param citationMicroReference	the string with the details describing the exact localisation within the reference
102
	 * @param originalNameString	the taxon name string used originally in the reference source for the new designation
103
	 * @param isRejectedType		the boolean flag indicating whether the competent authorities rejected
104 b9d0e8d2 m.geoffroy
	 * 								<i>this</i> name type designation
105 7d954fd9 m.geoffroy
	 * @param isConservedType		the boolean flag indicating whether the competent authorities conserved
106 89fd9fcc a.babadshanjan
	 * 								<i>this</i> name type designation
107
	 * @param isNotDesignated		the boolean flag indicating whether there is no name type at all for 
108
	 * 								<i>this</i> name type designation
109
	 * @see							#NameTypeDesignation()
110
	 * @see							TypeDesignationBase#isNotDesignated()
111 1d36aa54 Andreas Müller
	 * @see							TaxonNameBase#addNameTypeDesignation(TaxonNameBase, Reference, String, String, boolean, boolean, boolean, boolean, boolean)
112 89fd9fcc a.babadshanjan
	 */
113
	protected NameTypeDesignation(TaxonNameBase typeName, NameTypeDesignationStatus status,
114 1d36aa54 Andreas Müller
			Reference citation, String citationMicroReference, String originalNameString) {
115 89fd9fcc a.babadshanjan
		super(citation, citationMicroReference, originalNameString);
116
		this.setTypeName(typeName);
117
		this.setTypeStatus(status);
118
	}
119
120
	/**
121
	 * Class constructor: creates a new name type designation instance
122 1d36aa54 Andreas Müller
	 * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and eventually
123 89fd9fcc a.babadshanjan
	 * the taxon name string originally used by this reference when establishing
124
	 * the former designation).
125
	 * 
126
	 * @param typeName				the taxon name used as a type 
127
	 * @param citation				the reference source for the new designation
128
	 * @param citationMicroReference	the string with the details describing the exact localisation within the reference
129
	 * @param originalNameString	the taxon name string used originally in the reference source for the new designation
130
	 * @param isRejectedType		the boolean flag indicating whether the competent authorities rejected
131
	 * 								<i>this</i> name type designation
132
	 * @param isConservedType		the boolean flag indicating whether the competent authorities conserved
133 b9d0e8d2 m.geoffroy
	 * 								<i>this</i> name type designation
134 57883822 m.geoffroy
	 * @param isNotDesignated		the boolean flag indicating whether there is no name type at all for 
135 d82717cb m.geoffroy
	 * 								<i>this</i> name type designation
136 7d954fd9 m.geoffroy
	 * @see							#NameTypeDesignation()
137 57883822 m.geoffroy
	 * @see							TypeDesignationBase#isNotDesignated()
138 1d36aa54 Andreas Müller
	 * @see							TaxonNameBase#addNameTypeDesignation(TaxonNameBase, Reference, String, String, boolean, boolean, boolean, boolean, boolean)
139 7d954fd9 m.geoffroy
	 */
140 ece46ca8 Andreas Kohlbecker
	protected NameTypeDesignation(	TaxonNameBase typeName, 
141 1d36aa54 Andreas Müller
									Reference citation, 
142 ece46ca8 Andreas Kohlbecker
									String citationMicroReference,
143
									String originalNameString, 
144
									NameTypeDesignationStatus status, 
145
									boolean rejectedType, 
146
									boolean conservedType, 
147
									boolean isNotDesignated
148
								) {
149
		this(typeName, status, citation, citationMicroReference, originalNameString);
150
		this.setNotDesignated(isNotDesignated);
151 ee91bcd9 ben.clark
		this.rejectedType = rejectedType;
152
		this.conservedType = conservedType;
153 9479da48 Andreas Müller
	}
154 33269d91 a.babadshanjan
		
155 7d954fd9 m.geoffroy
	//********* METHODS **************************************/
156
157 bb6bc58f n.hoffmann
158 ad45fc6d Andreas Müller
	/* (non-Javadoc)
159
	 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#removeType()
160
	 */
161
	@Override
162
	public void removeType() {
163
		this.typeName = null;	
164
	}
165
	
166 7d954fd9 m.geoffroy
	/** 
167
	 * Returns the {@link TaxonNameBase taxon name} that plays the role of the
168 b9d0e8d2 m.geoffroy
	 * taxon name type in <i>this</i> taxon name type designation. The {@link Rank rank}
169 d82717cb m.geoffroy
	 * of the taxon name type must be "species".
170 7d954fd9 m.geoffroy
	 */
171 78f6ad0d m.geoffroy
	public TaxonNameBase getTypeName(){
172
		return this.typeName;
173 9479da48 Andreas Müller
	}
174 7d954fd9 m.geoffroy
	/**
175 78f6ad0d m.geoffroy
	 * @see  #getTypeName()
176 7d954fd9 m.geoffroy
	 */
177 a641fad9 ben.clark
	public void setTypeName(TaxonNameBase typeName){
178 78f6ad0d m.geoffroy
		this.typeName = typeName;
179 9479da48 Andreas Müller
	}
180
181 7d954fd9 m.geoffroy
	/** 
182
	 * Returns the boolean value "true" if the competent authorities decided to
183 d82717cb m.geoffroy
	 * reject the use of the species taxon name as the type for <i>this</i> taxon
184
	 * name type designation.
185 7d954fd9 m.geoffroy
	 *  
186
	 * @see   #isConservedType()
187
	 */
188 9479da48 Andreas Müller
	public boolean isRejectedType(){
189 ee91bcd9 ben.clark
		return this.rejectedType;
190 9479da48 Andreas Müller
	}
191 7d954fd9 m.geoffroy
	/**
192
	 * @see  #isRejectedType()
193
	 */
194 ee91bcd9 ben.clark
	public void setRejectedType(boolean rejectedType){
195
		this.rejectedType = rejectedType;
196 9479da48 Andreas Müller
	}
197
198 7d954fd9 m.geoffroy
	/** 
199
	 * Returns the boolean value "true" if the competent authorities decided to
200 d82717cb m.geoffroy
	 * conserve the use of the species taxon name as the type for <i>this</i> taxon
201
	 * name type designation.
202 7d954fd9 m.geoffroy
	 *  
203 95dc27ff m.geoffroy
	 * @see   #isRejectedType()
204 7d954fd9 m.geoffroy
	 */
205 9479da48 Andreas Müller
	public boolean isConservedType(){
206 ee91bcd9 ben.clark
		return this.conservedType;
207 9479da48 Andreas Müller
	}
208 7d954fd9 m.geoffroy
	/**
209
	 * @see  #isConservedType()
210
	 */
211 ee91bcd9 ben.clark
	public void setConservedType(boolean conservedType){
212
		this.conservedType = conservedType;
213 9479da48 Andreas Müller
	}
214
215 999f1f6b Andreas Müller
	@Transient
216
	public boolean isLectoType() {
217 ece46ca8 Andreas Kohlbecker
		if (getTypeStatus() == null) {
218 07439f3b Andreas Müller
			return false;
219
		}
220 ece46ca8 Andreas Kohlbecker
		return getTypeStatus().isLectotype();
221 999f1f6b Andreas Müller
	}
222
	
223 e36e3262 m.geoffroy
	/** 
224 d82717cb m.geoffroy
	 * Returns the boolean value "true" if the use of the species {@link TaxonNameBase taxon name}
225
	 * as the type for <i>this</i> taxon name type designation was posterior to the
226
	 * publication of the typified taxon name. In this case the taxon name type
227 1d36aa54 Andreas Müller
	 * designation should have a {@link eu.etaxonomy.cdm.model.reference.Reference reference} that is different to the
228 d82717cb m.geoffroy
	 * {@link TaxonNameBase#getNomenclaturalReference() nomenclatural reference} of the typified taxon name.
229 e36e3262 m.geoffroy
	 *  
230 7b193710 m.geoffroy
	 * @see   ReferencedEntityBase#getCitation()
231 2b5d05a8 Andreas Müller
	 */
232 999f1f6b Andreas Müller
//	/* (non-Javadoc)
233
//	 * @see eu.etaxonomy.cdm.model.name.ITypeDesignation#isLectoType()
234
//	 */
235
//	public boolean isLectoType() {
236
//		return lectoType;
237
//	}
238
//
239
//	/**
240
//	 * @see   #isLectoType()
241
//	 */
242
//	public void setLectoType(boolean lectoType) {
243
//		this.lectoType = lectoType;
244
//	}
245 a42e27ce Andreas Müller
	
246
//*********************** CLONE ********************************************************/
247
	
248
	/** 
249
	 * Clones <i>this</i> name type. This is a shortcut that enables to create
250
	 * a new instance that differs only slightly from <i>this</i> name type by
251
	 * modifying only some of the attributes.
252
	 * 
253
	 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone()
254
	 * @see java.lang.Object#clone()
255
	 */
256
	@Override
257
	public Object clone() {
258
		NameTypeDesignation result;
259
		try {
260
			result = (NameTypeDesignation)super.clone();
261
			//no changes to: rejectedType, conservedType, typeName
262
			return result;
263
		} catch (CloneNotSupportedException e) {
264
			logger.warn("Object does not implement cloneable");
265
			e.printStackTrace();
266
			return null;
267
		}
268 ad45fc6d Andreas Müller
	}
269
270 9479da48 Andreas Müller
}