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.occurrence;
|
11
|
|
12
|
import java.util.Set;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import javax.xml.bind.annotation.XmlEnum;
|
16
|
import javax.xml.bind.annotation.XmlEnumValue;
|
17
|
|
18
|
import org.apache.log4j.Logger;
|
19
|
|
20
|
import eu.etaxonomy.cdm.model.common.Language;
|
21
|
import eu.etaxonomy.cdm.model.description.Feature;
|
22
|
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
|
23
|
import eu.etaxonomy.cdm.model.term.EnumeratedTermVoc;
|
24
|
import eu.etaxonomy.cdm.model.term.IEnumTerm;
|
25
|
|
26
|
|
27
|
/**
|
28
|
* The specimen or observation type is used to define what a {@link SpecimenOrObservationBase specimen or observation}
|
29
|
* instance describes, may it be a {@link FieldUnit field unit} or a
|
30
|
* {@link DerivedUnit derived unit}.<BR>
|
31
|
* The vocabulary used derives mainly from the according vocabularies in ABCD, Darwin Core as well
|
32
|
* as from the former (before v3.3) CDM subclasses of {@link SpecimenOrObservationBase}.
|
33
|
* <BR><BR>
|
34
|
* In future versions this enum may also be expressed as a term, not an enum. For now the general policy is to
|
35
|
* transform former classes to general classes with enums as their types.
|
36
|
*
|
37
|
* @author a.mueller
|
38
|
* @since 27.06.2013
|
39
|
*/
|
40
|
@XmlEnum
|
41
|
public enum SpecimenOrObservationType implements IEnumTerm<SpecimenOrObservationType>{
|
42
|
|
43
|
//0
|
44
|
/**
|
45
|
* Unknown specimen or observation the type to be used if no information is available about the type.
|
46
|
* This type should be avoided if possible. In terms of doubtful occurrences one may consider to
|
47
|
* use "DerivedUnit", "Observation" or "OtherSpecimen" instead.
|
48
|
*/
|
49
|
@XmlEnumValue("Unknown")
|
50
|
Unknown(UUID.fromString("971a0c72-d4d2-4e41-8520-c9a87df34f48"), "Unknown unit type","UN", null),
|
51
|
|
52
|
//5
|
53
|
/**
|
54
|
* Generalization for all specimen or observation except for FieldUnits. One should use DerivedUnit
|
55
|
* only if no further specialization is available.
|
56
|
* Derived from the former (before v3.3.) CDM class "DerivedUnit".
|
57
|
*/
|
58
|
@XmlEnumValue("DerivedUnit")
|
59
|
DerivedUnit(UUID.fromString("da80443a-360b-4861-abeb-21e13beb5186"), "Derived Unit", "DU", null),
|
60
|
|
61
|
//1
|
62
|
/**
|
63
|
* A physical object representing one or more organisms, part of organism, or artifact(s) of an organism.
|
64
|
* Specialization of {@link SpecimenOrObservationType#DerivedUnit}.
|
65
|
*/
|
66
|
@XmlEnumValue("PreservedSpecimen")
|
67
|
PreservedSpecimen(UUID.fromString("95cd9246-4131-444f-ad2f-3b24ca294a1f"), "Preserved Specimen", "PS", DerivedUnit),
|
68
|
|
69
|
//2
|
70
|
/**
|
71
|
* Specialization of PreservedSpecimen, indicating that a specimen is a fossil or is derived
|
72
|
* from a fossil.
|
73
|
* Specialization of {@link SpecimenOrObservationType#PreservedSpecimen}.
|
74
|
*/
|
75
|
@XmlEnumValue("FossilSpecimen")
|
76
|
Fossil(UUID.fromString("1b0f8534-35eb-4c64-8e53-69e734043bd6"), "Fossil Specimen", "FS", PreservedSpecimen),
|
77
|
|
78
|
//3
|
79
|
/**
|
80
|
* An organism removed from its natural occurrence and now living in captivity or cultivation
|
81
|
* Specialization of {@link SpecimenOrObservationType#DerivedUnit}.
|
82
|
*/
|
83
|
@XmlEnumValue("LivingSpecimen")
|
84
|
LivingSpecimen(UUID.fromString("bc46169e-4d31-4eae-b5aa-1ddf0520c9a9"), "Living Specimen (ex situ)", "LS", DerivedUnit),
|
85
|
|
86
|
//4
|
87
|
/**
|
88
|
* All specimen types not covered by existing types.
|
89
|
* Specialization of {@link SpecimenOrObservationType#DerivedUnit}.
|
90
|
*/
|
91
|
//TODO does ABCD allow to use this also for Observations?
|
92
|
@XmlEnumValue("OtherSpecimen")
|
93
|
OtherSpecimen(UUID.fromString("b636da6a-b48f-4084-9594-25ea82429b70"), "Other Specimen", "OS", DerivedUnit),
|
94
|
|
95
|
//6
|
96
|
/**
|
97
|
* Generalization for all observations, may they be human observations or machine observations.
|
98
|
* Derived from the former (before v3.3) CDM class "Observation".
|
99
|
* Specialization of {@link SpecimenOrObservationType#DerivedUnit}. //TODO verify #3619
|
100
|
*/
|
101
|
@XmlEnumValue("Observation")
|
102
|
Observation(UUID.fromString("a8a254f1-7bed-47ec-bbee-86a794819c3b"), "Observation", "OB", DerivedUnit),
|
103
|
|
104
|
//7
|
105
|
/**
|
106
|
* Type for all observations made by a human.
|
107
|
* Specialization of {@link SpecimenOrObservationType#Observation}.
|
108
|
*/
|
109
|
@XmlEnumValue("HumanObservation")
|
110
|
HumanObservation(UUID.fromString("b960c06d-4bfc-4bea-bc53-aec0600409b1"), "Human Observation", "HO", Observation),
|
111
|
|
112
|
//8
|
113
|
/**
|
114
|
* Type for all observations made by a machine.
|
115
|
* Specialization of {@link SpecimenOrObservationType#Observation}.
|
116
|
*/
|
117
|
@XmlEnumValue("MachineObservation")
|
118
|
MachineObservation(UUID.fromString("b12a13fc-0f61-4055-b9b7-4eabd417c54c"), "Machine Observation", "MO", Observation),
|
119
|
|
120
|
//8a
|
121
|
/**
|
122
|
* Type for all tissue samples.
|
123
|
* Specialization of {@link SpecimenOrObservationType#PreservedSpecimen}.
|
124
|
*/
|
125
|
@XmlEnumValue("TissueSample")
|
126
|
TissueSample(UUID.fromString("3ad39d74-9bb3-4f9c-b261-8f5637bef582"), "Tissue Sample", "TS", PreservedSpecimen),
|
127
|
|
128
|
//8b
|
129
|
/**
|
130
|
* Type for all DNA Samples.
|
131
|
* Specialization of {@link SpecimenOrObservationType#TissueSample}.
|
132
|
*/
|
133
|
@XmlEnumValue("DnaSample")
|
134
|
DnaSample(UUID.fromString("6a724560-bdfa-41c9-b459-ab0f1fc74902"), "Dna Sample", "DS", TissueSample),
|
135
|
|
136
|
//9
|
137
|
/**
|
138
|
* Generalization for all types of media (StillImage, MovingImage, SoundRecording, MultiMedia).
|
139
|
* One should try to use a specialization instead of using the general type Media.
|
140
|
*/
|
141
|
@XmlEnumValue("Media")
|
142
|
Media(UUID.fromString("0efa6b3e-e67a-49d4-a758-f3fc688901a7"), "Media", "ME", null),
|
143
|
|
144
|
|
145
|
//10
|
146
|
/**
|
147
|
* A photograph, drawing, painting or similar.
|
148
|
* Specialization of {@link SpecimenOrObservationType#Media}.
|
149
|
*/
|
150
|
@XmlEnumValue("StillImage")
|
151
|
StillImage(UUID.fromString("a8d9ada5-7f22-4fcf-8693-ae68d527289b"), "Still Image", "SI", Media),
|
152
|
|
153
|
//11
|
154
|
/**
|
155
|
* A sequence of still images taken at regular intervals and intended to be played back as a moving image;
|
156
|
* may include sound.
|
157
|
* Specialization of {@link SpecimenOrObservationType#Media}.
|
158
|
*/
|
159
|
@XmlEnumValue("MovingImage")
|
160
|
MovingImage(UUID.fromString("56722418-9398-4367-afa1-46982fb93959"), "Moving Image", "MI", Media),
|
161
|
|
162
|
//12
|
163
|
/**
|
164
|
* An audio recording.
|
165
|
* Specialization of {@link SpecimenOrObservationType#Media}.
|
166
|
*/
|
167
|
@XmlEnumValue("SoundRecording")
|
168
|
SoundRecording(UUID.fromString("2a39ec19-4aae-4b74-bc5c-578c5dc94e7d"), "Sound Recording", "SR", Media),
|
169
|
|
170
|
//13
|
171
|
/**
|
172
|
* Any multi-media object which is not covered by DrawingOrPhoto, MovingImage or SoundRecording.
|
173
|
* Specialization of {@link SpecimenOrObservationType#Media}.
|
174
|
*/
|
175
|
@XmlEnumValue("Multimedia")
|
176
|
Multimedia(UUID.fromString("bfe3fef8-d294-4554-847a-c9d8a6b74313"), "Multimedia Object", "MM", Media),
|
177
|
|
178
|
//14
|
179
|
/**
|
180
|
* Type for all material samples belonging to a particular object or observation or a set of these.
|
181
|
* Specialization of {@link SpecimenOrObservationType#DerivedUnit}.
|
182
|
*/
|
183
|
@XmlEnumValue("MaterialSample")
|
184
|
MaterialSample(UUID.fromString("d6395063-63b3-485f-87d1-8b2eaf224a33"), "Material Sample", "MS", DerivedUnit),
|
185
|
|
186
|
|
187
|
//15
|
188
|
/**
|
189
|
* Type for all field data belonging to a particular object or observation or a set of these.
|
190
|
* Derived from the former (before v3.3 CDM class "FieldUnit".
|
191
|
*/
|
192
|
//TODO do we really need an own type for FieldUnit or is this covered by any of the other
|
193
|
//types (e.g. Observation)
|
194
|
@XmlEnumValue("FieldUnit")
|
195
|
FieldUnit(UUID.fromString("d38d22db-17f9-45ba-a32f-32393788726f"), "Field Unit", "FU", null),
|
196
|
;
|
197
|
|
198
|
@SuppressWarnings("unused")
|
199
|
private final Logger logger = Logger.getLogger(SpecimenOrObservationType.class);
|
200
|
|
201
|
|
202
|
private SpecimenOrObservationType(UUID uuid, String defaultString, String key){
|
203
|
this(uuid, defaultString, key, null);
|
204
|
logger.info("SpecimenOrObservationType hierarchie not yet fully implemented");
|
205
|
}
|
206
|
|
207
|
@SuppressWarnings("unchecked")
|
208
|
private SpecimenOrObservationType(UUID uuid, String defaultString, String key, SpecimenOrObservationType parent){
|
209
|
delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
|
210
|
}
|
211
|
|
212
|
|
213
|
/**
|
214
|
* Returns <code>true</code>, if it seems to make sense to use the {@link Feature feature}
|
215
|
* {@link Feature#OBSERVATION() observation} for creating an {@link IndividualsAssociation individuals association}.
|
216
|
*/
|
217
|
public boolean isFeatureObservation() {
|
218
|
if (this == Observation || this == HumanObservation || this == MachineObservation
|
219
|
){
|
220
|
return true;
|
221
|
}else{
|
222
|
return false;
|
223
|
}
|
224
|
}
|
225
|
|
226
|
/**
|
227
|
* Returns <code>true</code>, if it seems to make sense to use the {@link Feature feature}
|
228
|
* {@link Feature#SPECIMEN() specimen} for creating an {@link IndividualsAssociation individuals association}.
|
229
|
*/
|
230
|
public boolean isFeatureSpecimen() {
|
231
|
if (isPreservedSpecimen() || this == LivingSpecimen || this == SpecimenOrObservationType.OtherSpecimen
|
232
|
){
|
233
|
return true;
|
234
|
}else{
|
235
|
return false;
|
236
|
}
|
237
|
}
|
238
|
|
239
|
/**
|
240
|
* @return true if this type represents a preserved specimen or one of its specializations.
|
241
|
*/
|
242
|
public boolean isPreservedSpecimen() {
|
243
|
// if (this == PreservedSpecimen || this == Fossil
|
244
|
if (isKindOf(PreservedSpecimen) || this == PreservedSpecimen
|
245
|
){
|
246
|
return true;
|
247
|
}else{
|
248
|
return false;
|
249
|
}
|
250
|
}
|
251
|
|
252
|
/**
|
253
|
* Any field unit.
|
254
|
* @return
|
255
|
*/
|
256
|
public boolean isFieldUnit() {
|
257
|
if (this == FieldUnit){
|
258
|
return true;
|
259
|
}else{
|
260
|
return false;
|
261
|
}
|
262
|
}
|
263
|
|
264
|
/**
|
265
|
* All types except for field units.
|
266
|
* @return
|
267
|
*/
|
268
|
public boolean isAnyDerivedUnit() {
|
269
|
return ! isFieldUnit();
|
270
|
}
|
271
|
|
272
|
/**
|
273
|
* Any Media, may it be images, movies, sound recordings or multi media objects
|
274
|
* @return
|
275
|
*/
|
276
|
public boolean isMedia() {
|
277
|
if (this == Media || this == StillImage || this == MovingImage || this == Multimedia || this == SoundRecording ){
|
278
|
return true;
|
279
|
}else{
|
280
|
return false;
|
281
|
}
|
282
|
}
|
283
|
|
284
|
/**
|
285
|
* This method was initially created in the former class
|
286
|
* "DerivedUnitFacade.DerivedUnitType" for some specimen imports .
|
287
|
* It may be extended in future. However, it may also be decoupled from
|
288
|
* SpecimenOrObservationType to serve different use-cases.
|
289
|
* @param type
|
290
|
* @return
|
291
|
*/
|
292
|
public static SpecimenOrObservationType valueOf2(String type) {
|
293
|
if (type == null) {
|
294
|
return null;
|
295
|
}
|
296
|
type = type.replace(" ", "").toLowerCase();
|
297
|
if (type.matches("(preserved)?specimen")) {
|
298
|
return PreservedSpecimen;
|
299
|
} else if (type.equals("living(being|specimen)")) {
|
300
|
return LivingSpecimen;
|
301
|
} else if (type.equals("observation")) {
|
302
|
return Observation;
|
303
|
} else if (type.equals("fossil")) {
|
304
|
return Fossil;
|
305
|
} else if (type.equals("tissuesample")) {
|
306
|
return TissueSample;
|
307
|
} else if (type.equals("dnasample")) {
|
308
|
return DnaSample;
|
309
|
} else if (type.equals("field(observation|unit)")) {
|
310
|
return FieldUnit;
|
311
|
} else if (type.equals("derivedunit")) {
|
312
|
return DerivedUnit;
|
313
|
} else if (type.equals("unknown")) {
|
314
|
return Unknown;
|
315
|
}
|
316
|
return null;
|
317
|
}
|
318
|
|
319
|
// *************************** DELEGATE **************************************/
|
320
|
|
321
|
private static EnumeratedTermVoc<SpecimenOrObservationType> delegateVoc;
|
322
|
private IEnumTerm<SpecimenOrObservationType> delegateVocTerm;
|
323
|
|
324
|
static {
|
325
|
delegateVoc = EnumeratedTermVoc.getVoc(SpecimenOrObservationType.class);
|
326
|
}
|
327
|
|
328
|
@Override
|
329
|
public String getKey(){return delegateVocTerm.getKey();}
|
330
|
|
331
|
@Override
|
332
|
public String getLabel(){return delegateVocTerm.getLabel();}
|
333
|
|
334
|
@Override
|
335
|
public String getLabel(Language language){return delegateVocTerm.getLabel(language);}
|
336
|
|
337
|
|
338
|
@Override
|
339
|
public UUID getUuid() {return delegateVocTerm.getUuid();}
|
340
|
|
341
|
@Override
|
342
|
public SpecimenOrObservationType getKindOf() {return delegateVocTerm.getKindOf();}
|
343
|
|
344
|
@Override
|
345
|
public Set<SpecimenOrObservationType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
|
346
|
|
347
|
@Override
|
348
|
public boolean isKindOf(SpecimenOrObservationType ancestor) {return delegateVocTerm.isKindOf(ancestor); }
|
349
|
|
350
|
@Override
|
351
|
public Set<SpecimenOrObservationType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
|
352
|
|
353
|
public static SpecimenOrObservationType getByKey(String key){return delegateVoc.getByKey(key);}
|
354
|
public static SpecimenOrObservationType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
|
355
|
|
356
|
}
|