Project

General

Profile

Download (8.98 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
import javax.persistence.Entity;
13
import javax.persistence.FetchType;
14
import javax.persistence.ManyToOne;
15
import javax.xml.bind.annotation.XmlAccessType;
16
import javax.xml.bind.annotation.XmlAccessorType;
17
import javax.xml.bind.annotation.XmlElement;
18
import javax.xml.bind.annotation.XmlIDREF;
19
import javax.xml.bind.annotation.XmlRootElement;
20
import javax.xml.bind.annotation.XmlSchemaType;
21
import javax.xml.bind.annotation.XmlType;
22

    
23
import org.apache.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
24
import org.hibernate.annotations.Cascade;
25
import org.hibernate.annotations.CascadeType;
26
import org.hibernate.envers.Audited;
27

    
28
import eu.etaxonomy.cdm.model.reference.Reference;
29

    
30
/**
31
 * The class representing a typification of a {@link TaxonName taxon name} with a {@link Rank rank}
32
 * above "species aggregate" by another taxon name.<BR>
33
 * According to nomenclature a type of a genus name or of any subdivision of a
34
 * genus can only be a species name. A type of a family name or of any
35
 * subdivision of a family is a genus name.<BR>
36
 * Moreover the designation of a particular taxon name as a type might be
37
 * nomenclaturally rejected or conserved. Depending on the date of publication,
38
 * the same typification could be rejected according to one reference and later
39
 * be conserved according to another reference, but a name type designation
40
 * cannot be simultaneously rejected and conserved.<BR>
41
 * Name type designations are treated as {@link TypeDesignationBase type designations}
42
 * and not as {@link NameRelationship name relationships}.
43
 *
44
 * @see		TypeDesignationBase
45
 * @see		SpecimenTypeDesignation
46
 * @author	m.doering
47
 * @since 08-Nov-2007 13:06:38
48
 */
49
@XmlRootElement(name = "NameTypeDesignation")
50
@XmlAccessorType(XmlAccessType.FIELD)
51
@XmlType(name = "NameTypeDesignation", propOrder = {
52
    "rejectedType",
53
    "conservedType",
54
    "typeName"
55
})
56
@Entity
57
@Audited
58
public class NameTypeDesignation
59
        extends TypeDesignationBase<NameTypeDesignationStatus>  {
60

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

    
64
	@XmlElement(name = "IsRejectedType")
65
	private boolean rejectedType;
66

    
67
	@XmlElement(name = "IsConservedType")
68
	private boolean conservedType;
69

    
70
	@XmlElement(name = "TypeName")
71
	@XmlIDREF
72
	@XmlSchemaType(name = "IDREF")
73
	@ManyToOne(fetch = FetchType.LAZY)
74
	@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
75
	private TaxonName typeName;
76

    
77

    
78
	public static NameTypeDesignation NewInstance() {
79
		return new NameTypeDesignation();
80
	}
81

    
82

    
83
	// ************* CONSTRUCTORS *************/
84
	/**
85
	 * Class constructor: creates a new empty name type designation.
86
	 *
87
	 * @see	#NameTypeDesignation(TaxonName, Reference, String, String, boolean, boolean, boolean)
88
	 */
89
	protected NameTypeDesignation() {
90
	}
91

    
92

    
93
	/**
94
	 * Class constructor: creates a new name type designation instance
95
	 * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and eventually
96
	 * the taxon name string originally used by this reference when establishing
97
	 * the former designation).
98
	 *
99
	 * @param typeName				the taxon name used as a type
100
	 * @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
	 * 								<i>this</i> name type designation
105
	 * @param isConservedType		the boolean flag indicating whether the competent authorities conserved
106
	 * 								<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
	 * @see							TaxonName#addNameTypeDesignation(TaxonName, Reference, String, String, boolean, boolean, boolean, boolean, boolean)
112
	 */
113
	protected NameTypeDesignation(TaxonName typeName, NameTypeDesignationStatus status,
114
			Reference citation, String citationMicroReference, String originalNameString) {
115
		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
	 * (including its {@link eu.etaxonomy.cdm.model.reference.Reference reference source} and eventually
123
	 * 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
	 * 								<i>this</i> name type designation
134
	 * @param isNotDesignated		the boolean flag indicating whether there is no name type at all for
135
	 * 								<i>this</i> name type designation
136
	 * @see							#NameTypeDesignation()
137
	 * @see							TypeDesignationBase#isNotDesignated()
138
	 * @see							TaxonName#addNameTypeDesignation(TaxonName, Reference, String, String, boolean, boolean, boolean, boolean, boolean)
139
	 */
140
	protected NameTypeDesignation(	TaxonName typeName,
141
									Reference citation,
142
									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
		this.rejectedType = rejectedType;
152
		this.conservedType = conservedType;
153
	}
154

    
155
	//********* METHODS **************************************/
156

    
157
	@Override
158
	public void removeType() {
159
		this.typeName = null;
160
	}
161

    
162
	/**
163
	 * Returns the {@link TaxonName taxon name} that plays the role of the
164
	 * taxon name type in <i>this</i> taxon name type designation. The {@link Rank rank}
165
	 * of the taxon name type must be "species".
166
	 */
167
	public TaxonName getTypeName(){
168
		return this.typeName;
169
	}
170
	/**
171
	 * @see  #getTypeName()
172
	 */
173
	public void setTypeName(TaxonName typeName){
174
		this.typeName = typeName;
175
	}
176

    
177
	/**
178
	 * Returns the boolean value "true" if the competent authorities decided to
179
	 * reject the use of the species taxon name as the type for <i>this</i> taxon
180
	 * name type designation.
181
	 *
182
	 * @see   #isConservedType()
183
	 */
184
	public boolean isRejectedType(){
185
		return this.rejectedType;
186
	}
187
	/**
188
	 * @see  #isRejectedType()
189
	 */
190
	public void setRejectedType(boolean rejectedType){
191
		this.rejectedType = rejectedType;
192
	}
193

    
194
	/**
195
	 * Returns the boolean value "true" if the competent authorities decided to
196
	 * conserve the use of the species taxon name as the type for <i>this</i> taxon
197
	 * name type designation.
198
	 *
199
	 * @see   #isRejectedType()
200
	 */
201
	public boolean isConservedType(){
202
		return this.conservedType;
203
	}
204
	/**
205
	 * @see  #isConservedType()
206
	 */
207
	public void setConservedType(boolean conservedType){
208
		this.conservedType = conservedType;
209
	}
210

    
211

    
212
	/**
213
	 * Returns the boolean value "true" if the use of the species {@link TaxonName taxon name}
214
	 * as the type for <i>this</i> taxon name type designation was posterior to the
215
	 * publication of the typified taxon name. In this case the taxon name type
216
	 * designation should have a {@link eu.etaxonomy.cdm.model.reference.Reference reference} that is different to the
217
	 * {@link TaxonName#getNomenclaturalReference() nomenclatural reference} of the typified taxon name.
218
	 *
219
	 * @see OriginalSourceBas#getCitation()
220
	 */
221

    
222
//*********************** CLONE ********************************************************/
223

    
224
	/**
225
	 * Clones <i>this</i> name type. This is a shortcut that enables to create
226
	 * a new instance that differs only slightly from <i>this</i> name type by
227
	 * modifying only some of the attributes.
228
	 *
229
	 * @see eu.etaxonomy.cdm.model.name.TypeDesignationBase#clone()
230
	 * @see java.lang.Object#clone()
231
	 */
232
	@Override
233
	public NameTypeDesignation clone() {
234

    
235
	    NameTypeDesignation result;
236
		try {
237
			result = (NameTypeDesignation)super.clone();
238
			//no changes to: rejectedType, conservedType, typeName
239
			return result;
240
		} catch (CloneNotSupportedException e) {
241
			logger.warn("Object does not implement cloneable");
242
			e.printStackTrace();
243
			return null;
244
		}
245
	}
246
}
(18-18/39)