Project

General

Profile

Download (11.5 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.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.EnumeratedTermVoc;
21
import eu.etaxonomy.cdm.model.common.IEnumTerm;
22
import eu.etaxonomy.cdm.model.common.Language;
23
import eu.etaxonomy.cdm.model.description.Feature;
24
import eu.etaxonomy.cdm.model.description.IndividualsAssociation;
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 field data belonging to a particular object or observation or a set of these.
181
	 * Derived from the former (before v3.3 CDM class "FieldUnit".
182
	 */
183
	//TODO do we really need an own type for FieldUnit or is this covered by any of the other
184
	//types (e.g. Observation)
185
	@XmlEnumValue("FieldUnit")
186
	FieldUnit(UUID.fromString("d38d22db-17f9-45ba-a32f-32393788726f"), "Field Unit", "FU", null),
187
	;
188

    
189
	@SuppressWarnings("unused")
190
	private static final Logger logger = Logger.getLogger(SpecimenOrObservationType.class);
191

    
192

    
193
	private SpecimenOrObservationType(UUID uuid, String defaultString, String key){
194
		this(uuid, defaultString, key, null);
195
		System.out.println("SpecimenOrObservationType hierarchie not yet fully implemented");
196
	}
197

    
198
	@SuppressWarnings("unchecked")
199
    private SpecimenOrObservationType(UUID uuid, String defaultString, String key, SpecimenOrObservationType parent){
200
		delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, defaultString, key, parent);
201
	}
202

    
203

    
204
	/**
205
	 * Returns <code>true</code>, if it seems to make sense to use the {@link Feature feature}
206
	 * {@link Feature#OBSERVATION() observation} for creating an {@link IndividualsAssociation individuals association}.
207
	 */
208
	public boolean isFeatureObservation() {
209
		if (this == Observation || this == HumanObservation || this == MachineObservation
210
			){
211
			return true;
212
		}else{
213
			return false;
214
		}
215
	}
216

    
217
	/**
218
	 * Returns <code>true</code>, if it seems to make sense to use the {@link Feature feature}
219
	 * {@link Feature#SPECIMEN() specimen} for creating an {@link IndividualsAssociation individuals association}.
220
	 */
221
	public boolean isFeatureSpecimen() {
222
		if (isPreservedSpecimen() || this == LivingSpecimen || this == SpecimenOrObservationType.OtherSpecimen
223
			){
224
			return true;
225
		}else{
226
			return false;
227
		}
228
	}
229

    
230
	/**
231
	 * @return true if this type represents a preserved specimen or one of its specializations.
232
	 */
233
	public boolean isPreservedSpecimen() {
234
//		if (this == PreservedSpecimen || this == Fossil
235
		if (isKindOf(PreservedSpecimen) || this == PreservedSpecimen
236
			){
237
			return true;
238
		}else{
239
			return false;
240
		}
241
	}
242

    
243
	/**
244
	 * Any field unit.
245
	 * @return
246
	 */
247
	public boolean isFieldUnit() {
248
		if (this == FieldUnit){
249
			return true;
250
		}else{
251
			return false;
252
		}
253
	}
254

    
255
	/**
256
	 * All types except for field units.
257
	 * @return
258
	 */
259
	public boolean isAnyDerivedUnit() {
260
		return ! isFieldUnit();
261
	}
262

    
263
	/**
264
	 * Any Media, may it be images, movies, sound recordings or multi media objects
265
	 * @return
266
	 */
267
	public boolean isMedia() {
268
		if (this == Media || this == StillImage || this == MovingImage || this == Multimedia	|| this == SoundRecording		){
269
			return true;
270
		}else{
271
			return false;
272
		}
273
	}
274

    
275
	/**
276
	 * This method was initially created in the former class
277
	 * "DerivedUnitFacade.DerivedUnitType" for some specimen imports .
278
	 * It may be extended in future. However, it may also be decoupled from
279
	 * SpecimenOrObservationType to serve different use-cases.
280
	 * @param type
281
	 * @return
282
	 */
283
	public static SpecimenOrObservationType valueOf2(String type) {
284
		if (type == null) {
285
			return null;
286
		}
287
		type = type.replace(" ", "").toLowerCase();
288
		if (type.matches("(preserved)?specimen")) {
289
			return PreservedSpecimen;
290
		} else if (type.equals("living(being|specimen)")) {
291
			return LivingSpecimen;
292
		} else if (type.equals("observation")) {
293
			return Observation;
294
		} else if (type.equals("fossil")) {
295
			return Fossil;
296
		} else if (type.equals("tissuesample")) {
297
			return TissueSample;
298
		} else if (type.equals("dnasample")) {
299
			return DnaSample;
300
		} else if (type.equals("field(observation|unit)")) {
301
			return FieldUnit;
302
		} else if (type.equals("derivedunit")) {
303
			return DerivedUnit;
304
		} else if (type.equals("unknown")) {
305
			return Unknown;
306
		}
307
		return null;
308
	}
309

    
310
	// *************************** DELEGATE **************************************/
311

    
312
	private static EnumeratedTermVoc<SpecimenOrObservationType> delegateVoc;
313
	private IEnumTerm<SpecimenOrObservationType> delegateVocTerm;
314

    
315
	static {
316
		delegateVoc = EnumeratedTermVoc.getVoc(SpecimenOrObservationType.class);
317
	}
318

    
319
	@Override
320
	public String getKey(){return delegateVocTerm.getKey();}
321

    
322
	@Override
323
    public String getMessage(){return delegateVocTerm.getMessage();}
324

    
325
	@Override
326
    public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
327

    
328

    
329
	@Override
330
    public UUID getUuid() {return delegateVocTerm.getUuid();}
331

    
332
	@Override
333
    public SpecimenOrObservationType getKindOf() {return delegateVocTerm.getKindOf();}
334

    
335
	@Override
336
    public Set<SpecimenOrObservationType> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
337

    
338
	@Override
339
	public boolean isKindOf(SpecimenOrObservationType ancestor) {return delegateVocTerm.isKindOf(ancestor);	}
340

    
341
	@Override
342
    public Set<SpecimenOrObservationType> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
343

    
344
	public static SpecimenOrObservationType getByKey(String key){return delegateVoc.getByKey(key);}
345
    public static SpecimenOrObservationType getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
346

    
347
}
(12-12/14)