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 java.util.HashSet;
|
13
|
import java.util.Set;
|
14
|
|
15
|
import javax.persistence.Entity;
|
16
|
import javax.persistence.FetchType;
|
17
|
import javax.persistence.Inheritance;
|
18
|
import javax.persistence.InheritanceType;
|
19
|
import javax.persistence.ManyToMany;
|
20
|
import javax.persistence.ManyToOne;
|
21
|
import javax.xml.bind.annotation.XmlElement;
|
22
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
23
|
import javax.xml.bind.annotation.XmlIDREF;
|
24
|
import javax.xml.bind.annotation.XmlRootElement;
|
25
|
import javax.xml.bind.annotation.XmlSchemaType;
|
26
|
import javax.xml.bind.annotation.XmlSeeAlso;
|
27
|
import javax.xml.bind.annotation.XmlType;
|
28
|
|
29
|
import org.apache.log4j.Logger;
|
30
|
import org.hibernate.annotations.Cascade;
|
31
|
import org.hibernate.annotations.CascadeType;
|
32
|
import org.hibernate.envers.Audited;
|
33
|
|
34
|
import eu.etaxonomy.cdm.model.common.ReferencedEntityBase;
|
35
|
import eu.etaxonomy.cdm.model.reference.Reference;
|
36
|
import eu.etaxonomy.cdm.validation.Level2;
|
37
|
import eu.etaxonomy.cdm.validation.annotation.ValidTypeDesignation;
|
38
|
|
39
|
/**
|
40
|
* The (abstract) class representing a typification of one or several {@link TaxonNameBase taxon names}.<BR>
|
41
|
* All taxon names which have a {@link Rank rank} "species aggregate" or lower
|
42
|
* can only be typified by specimens (a {@link SpecimenTypeDesignation specimen type designation}), but taxon
|
43
|
* names with a higher rank might be typified by an other taxon name with
|
44
|
* rank "species" or "genus" (a {@link NameTypeDesignation name type designation}).
|
45
|
*
|
46
|
* @see TaxonNameBase
|
47
|
* @see NameTypeDesignation
|
48
|
* @see SpecimenTypeDesignation
|
49
|
* @author a.mueller
|
50
|
* @created 07.08.2008
|
51
|
* @version 1.0
|
52
|
*/
|
53
|
@XmlRootElement(name = "TypeDesignationBase")
|
54
|
@XmlType(name = "TypeDesignationBase", propOrder = {
|
55
|
"typifiedNames",
|
56
|
"notDesignated",
|
57
|
"typeStatus"
|
58
|
})
|
59
|
@XmlSeeAlso({
|
60
|
NameTypeDesignation.class,
|
61
|
SpecimenTypeDesignation.class
|
62
|
})
|
63
|
@Entity
|
64
|
@Audited
|
65
|
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
|
66
|
@ValidTypeDesignation(groups=Level2.class)
|
67
|
public abstract class TypeDesignationBase<T extends TypeDesignationStatusBase> extends ReferencedEntityBase implements ITypeDesignation {
|
68
|
private static final long serialVersionUID = 8622351017235131355L;
|
69
|
|
70
|
@SuppressWarnings("unused")
|
71
|
private static final Logger logger = Logger.getLogger(TypeDesignationBase.class);
|
72
|
|
73
|
@XmlElement(name = "IsNotDesignated")
|
74
|
private boolean notDesignated;
|
75
|
|
76
|
@XmlElementWrapper(name = "TypifiedNames")
|
77
|
@XmlElement(name = "TypifiedName")
|
78
|
@XmlIDREF
|
79
|
@XmlSchemaType(name = "IDREF")
|
80
|
@ManyToMany(fetch = FetchType.LAZY , mappedBy="typeDesignations")
|
81
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
82
|
private Set<TaxonNameBase> typifiedNames = new HashSet<TaxonNameBase>();
|
83
|
|
84
|
@XmlElement(name = "TypeStatus")
|
85
|
@XmlIDREF
|
86
|
@XmlSchemaType(name = "IDREF")
|
87
|
@ManyToOne(fetch = FetchType.LAZY, targetEntity = TypeDesignationStatusBase.class)
|
88
|
private T typeStatus;
|
89
|
|
90
|
// **************** CONSTRUCTOR *************************************/
|
91
|
|
92
|
/**
|
93
|
* Class constructor: creates a new empty type designation.
|
94
|
*
|
95
|
* @see #TypeDesignationBase(Reference, String, String, Boolean)
|
96
|
*/
|
97
|
protected TypeDesignationBase(){
|
98
|
super();
|
99
|
}
|
100
|
|
101
|
/**
|
102
|
* Class constructor: creates a new type designation
|
103
|
* (including its {@link Reference reference source} and eventually
|
104
|
* the taxon name string originally used by this reference when establishing
|
105
|
* the former designation).
|
106
|
*
|
107
|
* @param citation the reference source for the new designation
|
108
|
* @param citationMicroReference the string with the details describing the exact localisation within the reference
|
109
|
* @param originalNameString the taxon name string used originally in the reference source for the new designation
|
110
|
* @see #TypeDesignationBase()
|
111
|
* @see #isNotDesignated()
|
112
|
* @see TaxonNameBase#getTypeDesignations()
|
113
|
*/
|
114
|
protected TypeDesignationBase(Reference citation, String citationMicroReference, String originalNameString) {
|
115
|
this(citation, citationMicroReference, originalNameString, false);
|
116
|
}
|
117
|
|
118
|
/**
|
119
|
* Class constructor: creates a new type designation
|
120
|
* (including its {@link Reference reference source} and eventually
|
121
|
* the taxon name string originally used by this reference when establishing
|
122
|
* the former designation).
|
123
|
*
|
124
|
* @param citation the reference source for the new designation
|
125
|
* @param citationMicroReference the string with the details describing the exact localisation within the reference
|
126
|
* @param originalNameString the taxon name string used originally in the reference source for the new designation
|
127
|
* @param isNotDesignated the boolean flag indicating whether there is no type at all for
|
128
|
* <i>this</i> type designation
|
129
|
* @see #TypeDesignationBase()
|
130
|
* @see #isNotDesignated()
|
131
|
* @see TaxonNameBase#getTypeDesignations()
|
132
|
*/
|
133
|
protected TypeDesignationBase(Reference citation, String citationMicroReference, String originalNameString, boolean notDesignated){
|
134
|
super(citation, citationMicroReference, originalNameString);
|
135
|
this.notDesignated = notDesignated;
|
136
|
}
|
137
|
|
138
|
|
139
|
// **************** METHODS *************************************/
|
140
|
|
141
|
|
142
|
/**
|
143
|
* Returns the {@link TypeDesignationStatusBase type designation status} for <i>this</i> specimen type
|
144
|
* designation. This status describes which of the possible categories of
|
145
|
* types like "holotype", "neotype", "syntype" or "isotype" applies to <i>this</i>
|
146
|
* specimen type designation.
|
147
|
*/
|
148
|
public T getTypeStatus(){
|
149
|
return this.typeStatus;
|
150
|
}
|
151
|
/**
|
152
|
* @see #getTypeStatus()
|
153
|
*/
|
154
|
public void setTypeStatus(T typeStatus){
|
155
|
this.typeStatus = typeStatus;
|
156
|
}
|
157
|
|
158
|
/**
|
159
|
* Returns the set of {@link TaxonNameBase taxon names} typified in <i>this</i>
|
160
|
* type designation. This is a subset of the taxon names belonging to the
|
161
|
* corresponding {@link #getHomotypicalGroup() homotypical group}.
|
162
|
*/
|
163
|
@Override
|
164
|
public Set<TaxonNameBase> getTypifiedNames() {
|
165
|
return typifiedNames;
|
166
|
}
|
167
|
|
168
|
/**
|
169
|
* Returns the boolean value "true" if it is known that a type does not
|
170
|
* exist and therefore the {@link TaxonNameBase taxon name} to which <i>this</i>
|
171
|
* type designation is assigned must still be typified. Two
|
172
|
* cases must be differentiated: <BR><ul>
|
173
|
* <li> a) it is unknown whether a type exists and
|
174
|
* <li> b) it is known that no type exists
|
175
|
* </ul>
|
176
|
* If a) is true there should be no TypeDesignation instance at all
|
177
|
* assigned to the "typified" taxon name.<BR>
|
178
|
* If b) is true there should be a TypeDesignation instance with the
|
179
|
* flag isNotDesignated set. The typeName attribute, in case of a
|
180
|
* {@link NameTypeDesignation name type designation}, or the typeSpecimen attribute,
|
181
|
* in case of a {@link SpecimenTypeDesignation specimen type designation}, should then be "null".
|
182
|
*/
|
183
|
public boolean isNotDesignated() {
|
184
|
return notDesignated;
|
185
|
}
|
186
|
|
187
|
/**
|
188
|
* @see #isNotDesignated()
|
189
|
*/
|
190
|
public void setNotDesignated(boolean notDesignated) {
|
191
|
this.notDesignated = notDesignated;
|
192
|
}
|
193
|
|
194
|
/**
|
195
|
* @deprecated for bidirectional use only
|
196
|
*/
|
197
|
@Deprecated
|
198
|
protected void addTypifiedName(TaxonNameBase taxonName){
|
199
|
this.typifiedNames.add(taxonName);
|
200
|
}
|
201
|
|
202
|
/**
|
203
|
* @deprecated for bidirectional use only
|
204
|
*/
|
205
|
@Deprecated
|
206
|
protected void removeTypifiedName(TaxonNameBase taxonName){
|
207
|
this.typifiedNames.remove(taxonName);
|
208
|
if (taxonName.getTypeDesignations().contains(this)){
|
209
|
taxonName.removeTypeDesignation(this);
|
210
|
}
|
211
|
}
|
212
|
|
213
|
public abstract void removeType();
|
214
|
|
215
|
//*********************** CLONE ********************************************************/
|
216
|
|
217
|
/**
|
218
|
* Clones <i>this</i> type designation. This is a shortcut that enables to create
|
219
|
* a new instance that differs only slightly from <i>this</i> type designation by
|
220
|
* modifying only some of the attributes.<BR>
|
221
|
* CAUTION: the typifiedNames set is not cloned but empty after cloning as the typified
|
222
|
* names is considered to be the not owning part of a bidirectional relationship.
|
223
|
* This may be changed in future.
|
224
|
*
|
225
|
* @throws CloneNotSupportedException
|
226
|
*
|
227
|
* @see eu.etaxonomy.cdm.model.common.ReferencedEntityBase#clone()
|
228
|
* @see java.lang.Object#clone()
|
229
|
*/
|
230
|
@Override
|
231
|
public Object clone() throws CloneNotSupportedException {
|
232
|
TypeDesignationBase result = (TypeDesignationBase)super.clone();
|
233
|
|
234
|
result.typifiedNames = new HashSet<TaxonNameBase>();
|
235
|
// for (TaxonNameBase taxonNameBase : getTypifiedNames()){
|
236
|
// result.typifiedNames.add(taxonNameBase);
|
237
|
// }
|
238
|
|
239
|
|
240
|
//no changes to: notDesignated, typeStatus, homotypicalGroup
|
241
|
return result;
|
242
|
}
|
243
|
}
|