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.description;
|
11
|
|
12
|
import java.text.ParseException;
|
13
|
import java.util.HashMap;
|
14
|
import java.util.List;
|
15
|
import java.util.Map;
|
16
|
import java.util.UUID;
|
17
|
|
18
|
import javax.persistence.Entity;
|
19
|
import javax.xml.bind.annotation.XmlAccessType;
|
20
|
import javax.xml.bind.annotation.XmlAccessorType;
|
21
|
import javax.xml.bind.annotation.XmlAttribute;
|
22
|
import javax.xml.bind.annotation.XmlRootElement;
|
23
|
import javax.xml.bind.annotation.XmlType;
|
24
|
|
25
|
import org.apache.commons.lang.StringUtils;
|
26
|
import org.apache.log4j.Logger;
|
27
|
import org.hibernate.envers.Audited;
|
28
|
|
29
|
import eu.etaxonomy.cdm.model.common.CdmBase;
|
30
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
31
|
import eu.etaxonomy.cdm.model.common.Language;
|
32
|
import eu.etaxonomy.cdm.model.common.OrderedTermBase;
|
33
|
import eu.etaxonomy.cdm.model.common.TermType;
|
34
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
35
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
36
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
37
|
|
38
|
|
39
|
/**
|
40
|
* This class represents terms describing the {@link AbsenceTerm absence}
|
41
|
* (like "extinct") or the {@link PresenceTerm presence} (like "cultivated") of a
|
42
|
* {@link Taxon taxon} in an {@link NamedArea area}. These terms are only
|
43
|
* used for {@link Distribution distributions}.
|
44
|
*
|
45
|
* The current implementation includes multiple qualities of distribution status:<BR><BR>
|
46
|
*
|
47
|
* 1. Degree of "presence": present, presence questionable, reported in error, absent, ...<BR>
|
48
|
* 2. Nativeness/naturalization/...: native, alien (introduced), naturalized, cultivated, invasive, ... <BR>
|
49
|
* <BR>
|
50
|
* There might be further qualities like adventive(unwanted)<->introduced(wanted - for cultivation)
|
51
|
* <BR>
|
52
|
* For an interesting discussion of these status see Pyšek & al.: Alien plants in checklists and floras;
|
53
|
* Taxon 53(1), Feb. 2004: 131-143 <BR>
|
54
|
*
|
55
|
* Pyšek et al. distinguises<BR>
|
56
|
* native - alien<BR>
|
57
|
* alien => cultivated-outside cultivation<BR>
|
58
|
* outside cultivation=>casual - naturalized<BR>
|
59
|
* naturalized => non invasive - invasive<BR>
|
60
|
* invasive => not harmful - transformers - weeds
|
61
|
*
|
62
|
* @see http://dev.e-taxonomy.eu/redmine/issues/6000
|
63
|
*
|
64
|
* @author m.doering
|
65
|
* @created 08-Nov-2007 13:06:44
|
66
|
* @author a.mueller
|
67
|
*/
|
68
|
@XmlAccessorType(XmlAccessType.FIELD)
|
69
|
@XmlType(name = "PresenceAbsenceTerm")
|
70
|
@XmlRootElement(name = "PresenceAbsenceTerm")
|
71
|
@Entity
|
72
|
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
|
73
|
//@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
|
74
|
@Audited
|
75
|
public class PresenceAbsenceTerm extends OrderedTermBase<PresenceAbsenceTerm> {
|
76
|
private static final long serialVersionUID = 1036807546935584396L;
|
77
|
private static final Logger logger = Logger.getLogger(PresenceAbsenceTerm.class);
|
78
|
|
79
|
|
80
|
//presence base
|
81
|
public static final UUID uuidPresent=UUID.fromString("cef81d25-501c-48d8-bbea-542ec50de2c2");
|
82
|
private static final UUID uuidPD=UUID.fromString("75a60279-a4c2-4f53-bc57-466028a4b3db");
|
83
|
|
84
|
//presence
|
85
|
private static final UUID uuidN=UUID.fromString("ddeac4f2-d8fa-43b8-ad7e-ca13abdd32c7");
|
86
|
private static final UUID uuidND=UUID.fromString("310373bf-7df4-4d02-8cb3-bcc7448805fc");
|
87
|
private static final UUID uuidC=UUID.fromString("9eb99fe6-59e2-4445-8e6a-478365bd0fa9");
|
88
|
private static final UUID uuidI=UUID.fromString("643cf9d1-a5f1-4622-9837-82ef961e880b");
|
89
|
private static final UUID uuidID=UUID.fromString("0c54761e-4887-4788-9dfa-7190c88746e3");
|
90
|
private static final UUID uuidIP=UUID.fromString("da159544-b0dd-4599-a9c9-640826af8c17");
|
91
|
private static final UUID uuidIA=UUID.fromString("42946bd6-9c22-45ad-a910-7427e8f60bfd");
|
92
|
private static final UUID uuidIN=UUID.fromString("e191e89a-a751-4b0c-b883-7f1de70915c9");
|
93
|
private static final UUID uuidIC=UUID.fromString("fac8c347-8262-44a1-b0a4-db4de451c021");
|
94
|
private static final UUID uuidE=UUID.fromString("c3ee7048-15b7-4be1-b687-9ce9c1a669d6");
|
95
|
|
96
|
// private static final UUID uuidNa=UUID.fromString("4e04990a-66fe-4fdf-856c-f40772fbcf0a");
|
97
|
private static final UUID uuidNI=UUID.fromString("dc536e3d-a753-4bbe-a386-dd8aff35c234");
|
98
|
|
99
|
private static final UUID uuidNN=UUID.fromString("1b025e8b-901a-42e8-9739-119b410c6f03");
|
100
|
|
101
|
//doubtfully present
|
102
|
private static final UUID uuidNQ=UUID.fromString("925662c1-bb10-459a-8c53-da5a738ac770");
|
103
|
private static final UUID uuidCQ=UUID.fromString("4f31bfc8-3058-4d83-aea5-3a1fe9773f9f");
|
104
|
private static final UUID uuidIQ=UUID.fromString("83eb0aa0-1a45-495a-a3ca-bf6958b74366");
|
105
|
private static final UUID uuidEQ=UUID.fromString("5f954f08-267a-4928-b073-12328f74c187");
|
106
|
//intr. naturalized questionable
|
107
|
private static final UUID uuidINQ=UUID.fromString("9e0b413b-5a68-4e5b-91f2-227b4f832466");
|
108
|
//natur. invasive questionable
|
109
|
private static final UUID uuidNIQ=UUID.fromString("ac429d5f-e8ad-49ae-a41c-e4779b58b96a");
|
110
|
//natur. non-invasive questionable
|
111
|
private static final UUID uuidNNQ=UUID.fromString("11f56e2f-c16c-4b3d-a870-bb5d3b20e624");
|
112
|
|
113
|
|
114
|
//absence
|
115
|
private static final UUID uuidAbsence=UUID.fromString("59709861-f7d9-41f9-bb21-92559cedd598");
|
116
|
private static final UUID uuidReportedInError = UUID.fromString("38604788-cf05-4607-b155-86db456f7680");
|
117
|
|
118
|
private static final UUID uuidNF=UUID.fromString("61cee840-801e-41d8-bead-015ad866c2f1");
|
119
|
private static final UUID uuidIF=UUID.fromString("aeec2947-2700-4623-8e32-9e3a430569d1");
|
120
|
private static final UUID uuidCF=UUID.fromString("9d4d3431-177a-4abe-8e4b-1558573169d6");
|
121
|
private static final UUID uuidNE=UUID.fromString("5c397f7b-59ef-4c11-a33c-45691ceda91b");
|
122
|
private static final UUID uuidNDE=UUID.fromString("71b72e24-c2b6-44a5-bdab-39f083bf0f06");
|
123
|
private static final UUID uuidIE=UUID.fromString("b74dc30b-ee93-496d-8c00-4d00abae1ec7");
|
124
|
private static final UUID uuidEE=UUID.fromString("679b215d-c231-4ee2-ae12-3ffc3dd528ad");
|
125
|
private static final UUID uuidNaE=UUID.fromString("8d918a37-3add-4e1c-a233-c37dbee209aa");
|
126
|
private static final UUID uuidIAQ=UUID.fromString("73f75493-1185-4a3e-af1e-9a1f2e8dadb7");
|
127
|
private static final UUID uuidIAF=UUID.fromString("9b910b7b-43e3-4260-961c-6063b11cb7dc");
|
128
|
|
129
|
|
130
|
protected static Map<UUID, PresenceAbsenceTerm> termMap = null;
|
131
|
|
132
|
private String defaultColor = "000000";
|
133
|
|
134
|
@XmlAttribute(name = "absenceTerm")
|
135
|
private boolean absenceTerm = false;
|
136
|
|
137
|
//********* METHODS **************************************/
|
138
|
/**
|
139
|
* Creates a new empty presence term.
|
140
|
*
|
141
|
* @see #NewInstance(String, String, String)
|
142
|
*/
|
143
|
public static PresenceAbsenceTerm NewInstance(){
|
144
|
return new PresenceAbsenceTerm();
|
145
|
}
|
146
|
|
147
|
/**
|
148
|
* Creates a new presence term with a description (in the {@link Language#DEFAULT() default language}),
|
149
|
* a label and a label abbreviation.
|
150
|
*
|
151
|
* @param term the string (in the default language) describing the
|
152
|
* new presence term to be created
|
153
|
* @param label the string identifying the new presence term to be created
|
154
|
* @param labelAbbrev the string identifying (in abbreviated form) the
|
155
|
* new presence term to be created
|
156
|
* @see #NewInstance()
|
157
|
*/
|
158
|
public static PresenceAbsenceTerm NewPresenceInstance(String term, String label, String labelAbbrev){
|
159
|
return new PresenceAbsenceTerm(term, label, labelAbbrev, false);
|
160
|
}
|
161
|
|
162
|
/**
|
163
|
* Creates a new absence term with a description (in the {@link Language#DEFAULT() default language}),
|
164
|
* a label and a label abbreviation.
|
165
|
*
|
166
|
* @param term the string (in the default language) describing the
|
167
|
* new presence term to be created
|
168
|
* @param label the string identifying the new presence term to be created
|
169
|
* @param labelAbbrev the string identifying (in abbreviated form) the
|
170
|
* new presence term to be created
|
171
|
* @see #NewInstance()
|
172
|
*/
|
173
|
public static PresenceAbsenceTerm NewAbsenceInstance(String term, String label, String labelAbbrev){
|
174
|
return new PresenceAbsenceTerm(term, label, labelAbbrev, true);
|
175
|
}
|
176
|
|
177
|
|
178
|
//********************************** Constructor *******************************************************************/
|
179
|
|
180
|
//for hibernate use only
|
181
|
@Deprecated
|
182
|
protected PresenceAbsenceTerm() {
|
183
|
super(TermType.PresenceAbsenceTerm);
|
184
|
}
|
185
|
|
186
|
/**
|
187
|
* Class constructor: creates a new presence or absence term with a description
|
188
|
* (in the {@link Language#DEFAULT() default language}), a label and a label abbreviation.
|
189
|
*
|
190
|
* @param term the string (in the default language) describing the
|
191
|
* new presence or absence term to be created
|
192
|
* @param label the string identifying the new presence or absence term to be created
|
193
|
* @param labelAbbrev the string identifying (in abbreviated form) the
|
194
|
* new presence or absence term to be created
|
195
|
* @param isAbsenceTerm boolean value indicating if this term represents an absence or not
|
196
|
* @see #PresenceAbsenceTermBase()
|
197
|
*/
|
198
|
protected PresenceAbsenceTerm(String term, String label, String labelAbbrev, boolean isAbsenceTerm) {
|
199
|
super(TermType.PresenceAbsenceTerm, term, label, labelAbbrev);
|
200
|
this.setAbsenceTerm(isAbsenceTerm);
|
201
|
}
|
202
|
|
203
|
|
204
|
//******************************* STATIC METHODS *****************************************
|
205
|
|
206
|
protected static PresenceAbsenceTerm getTermByUuid(UUID uuid){
|
207
|
if (termMap == null || termMap.isEmpty()){
|
208
|
return getTermByClassAndUUID(PresenceAbsenceTerm.class, uuid);
|
209
|
} else {
|
210
|
return termMap.get(uuid);
|
211
|
}
|
212
|
}
|
213
|
|
214
|
//TODO read from label(abbrevs) like in TDWGArea
|
215
|
public static PresenceAbsenceTerm getPresenceAbsenceTermByAbbreviation(String abbrev) {
|
216
|
if (abbrev == null) { throw new NullPointerException("abbrev is 'null' in getPresenceTermByAbbreviation");
|
217
|
} else if (abbrev.equalsIgnoreCase("c")) { return PresenceAbsenceTerm.CULTIVATED();
|
218
|
} else if (abbrev.equalsIgnoreCase("e")) { return PresenceAbsenceTerm.ENDEMIC_FOR_THE_RELEVANT_AREA();
|
219
|
} else if (abbrev.equalsIgnoreCase("i")) { return PresenceAbsenceTerm.INTRODUCED();
|
220
|
} else if (abbrev.equalsIgnoreCase("ia")) { return PresenceAbsenceTerm.CASUAL();
|
221
|
} else if (abbrev.equalsIgnoreCase("ic")) { return PresenceAbsenceTerm.INTRODUCED_CULTIVATED();
|
222
|
} else if (abbrev.equalsIgnoreCase("id")) { return PresenceAbsenceTerm.INTRODUCED_DOUBTFULLY_INTRODUCED();
|
223
|
} else if (abbrev.equalsIgnoreCase("in")) { return PresenceAbsenceTerm.NATURALISED();
|
224
|
} else if (abbrev.equalsIgnoreCase("ip")) { return PresenceAbsenceTerm.INTRODUCED_UNCERTAIN_DEGREE_OF_NATURALISATION();
|
225
|
} else if (abbrev.equalsIgnoreCase("iq")) { return PresenceAbsenceTerm.INTRODUCED_PRESENCE_QUESTIONABLE();
|
226
|
} else if (abbrev.equalsIgnoreCase("n")) { return PresenceAbsenceTerm.NATIVE();
|
227
|
} else if (abbrev.equalsIgnoreCase("nd")) { return PresenceAbsenceTerm.NATIVE_DOUBTFULLY_NATIVE();
|
228
|
} else if (abbrev.equalsIgnoreCase("nq")) { return PresenceAbsenceTerm.NATIVE_PRESENCE_QUESTIONABLE();
|
229
|
} else if (abbrev.equalsIgnoreCase("p")) { return PresenceAbsenceTerm.PRESENT();
|
230
|
} else if (abbrev.equalsIgnoreCase("na")) { return PresenceAbsenceTerm.NATURALISED();
|
231
|
} else if (abbrev.equalsIgnoreCase("iv")) { return PresenceAbsenceTerm.INVASIVE();
|
232
|
//absence
|
233
|
} else if (abbrev.equalsIgnoreCase("cf")) { return PresenceAbsenceTerm.CULTIVATED_REPORTED_IN_ERROR();
|
234
|
} else if (abbrev.equalsIgnoreCase("if")) { return PresenceAbsenceTerm.INTRODUCED_REPORTED_IN_ERROR();
|
235
|
} else if (abbrev.equalsIgnoreCase("nf")) { return PresenceAbsenceTerm.NATIVE_REPORTED_IN_ERROR();
|
236
|
} else if (abbrev.equalsIgnoreCase("ne")) { return PresenceAbsenceTerm.NATIVE_FORMERLY_NATIVE();
|
237
|
} else if (abbrev.equalsIgnoreCase("ie")) { return PresenceAbsenceTerm.INTRODUCED_FORMERLY_INTRODUCED();
|
238
|
} else {
|
239
|
logger.warn("Unknown presence or absence status term abbreviation: " + abbrev);
|
240
|
return null;
|
241
|
}
|
242
|
}
|
243
|
|
244
|
/**
|
245
|
* The taxon is endemic for the given area.
|
246
|
* @see #PRESENT()
|
247
|
* @see #NATIVE()
|
248
|
* @see #ENDEMIC_DOUBTFULLY_PRESENT()
|
249
|
* @see #ENDEMIC_REPORTED_IN_ERROR()
|
250
|
*/
|
251
|
public static final PresenceAbsenceTerm ENDEMIC_FOR_THE_RELEVANT_AREA(){
|
252
|
return getTermByUuid(uuidE);
|
253
|
}
|
254
|
|
255
|
/**
|
256
|
* The taxon is endemic for the given area but doubtfully present.
|
257
|
* @see #ENDEMIC_FOR_THE_RELEVANT_AREA()
|
258
|
* @see #ENDEMIC_REPORTED_IN_ERROR()
|
259
|
* @see #PRESENT_DOUBTFULLY()
|
260
|
* @see #NATIVE_PRESENCE_QUESTIONABLE()
|
261
|
*/
|
262
|
public static final PresenceAbsenceTerm ENDEMIC_DOUBTFULLY_PRESENT(){
|
263
|
return getTermByUuid(uuidEQ);
|
264
|
}
|
265
|
|
266
|
/**
|
267
|
* The taxon if it exists is endemic for the given area but was only
|
268
|
* erroneously reported.
|
269
|
* So it either does not exist or it is unclear where it was originally found.
|
270
|
* @see #ENDEMIC_FOR_THE_RELEVANT_AREA()
|
271
|
* @see #ENDEMIC_DOUBTFULLY_PRESENT()
|
272
|
* @see #REPORTED_IN_ERROR()
|
273
|
* @see #NATIVE_REPORTED_IN_ERROR()
|
274
|
*/
|
275
|
public static final PresenceAbsenceTerm ENDEMIC_REPORTED_IN_ERROR(){
|
276
|
return getTermByUuid(uuidEE);
|
277
|
}
|
278
|
|
279
|
|
280
|
/**
|
281
|
* The taxon is present in the given area. No information given about
|
282
|
* nativeness/establishment means.
|
283
|
*
|
284
|
* @see #PRESENT_DOUBTFULLY()
|
285
|
* @see #ABSENT()
|
286
|
*/
|
287
|
public static final PresenceAbsenceTerm PRESENT(){
|
288
|
return getTermByUuid(uuidPresent);
|
289
|
}
|
290
|
|
291
|
/**
|
292
|
* Presence of the taxon in the given area is doubtful. No information given about
|
293
|
* nativeness/establishment means.
|
294
|
*
|
295
|
* @see #PRESENT()
|
296
|
* @see #ABSENT()
|
297
|
*/
|
298
|
public static final PresenceAbsenceTerm PRESENT_DOUBTFULLY(){
|
299
|
return getTermByUuid(uuidPD);
|
300
|
}
|
301
|
|
302
|
/**
|
303
|
* The taxon is not native but cultivated.
|
304
|
*
|
305
|
* @see #CULTIVATED_PRESENCE_QUESTIONABLE()
|
306
|
* @see #CULTIVATED_REPORTED_IN_ERROR()
|
307
|
*/
|
308
|
public static final PresenceAbsenceTerm CULTIVATED(){
|
309
|
return getTermByUuid(uuidC);
|
310
|
}
|
311
|
|
312
|
/**
|
313
|
* The taxon is cultivated but presence is questionable.
|
314
|
*
|
315
|
* @see #CULTIVATED()
|
316
|
* @see #CULTIVATED_REPORTED_IN_ERROR()
|
317
|
*/
|
318
|
public static final PresenceAbsenceTerm CULTIVATED_PRESENCE_QUESTIONABLE(){
|
319
|
return getTermByUuid(uuidCQ);
|
320
|
}
|
321
|
|
322
|
/**
|
323
|
* The taxon is erroneously reported as cultivated.
|
324
|
*
|
325
|
* @see #CULTIVATED()
|
326
|
* @see #CULTIVATED_REPORTED_IN_ERROR()
|
327
|
*/
|
328
|
public static final PresenceAbsenceTerm CULTIVATED_REPORTED_IN_ERROR(){
|
329
|
return getTermByUuid(uuidCF);
|
330
|
}
|
331
|
|
332
|
|
333
|
public static final PresenceAbsenceTerm INTRODUCED(){
|
334
|
return getTermByUuid(uuidI);
|
335
|
}
|
336
|
|
337
|
/**
|
338
|
* Casual alien or introduced: adventive (casual)
|
339
|
*
|
340
|
* @see #CASUAL_REPORTED_IN_ERROR()
|
341
|
* @see #CASUAL_PRESENCE_QUESTIONABLE()
|
342
|
* @see #INTRODUCED_ADVENTITIOUS()
|
343
|
*/
|
344
|
public static final PresenceAbsenceTerm CASUAL(){
|
345
|
return getTermByUuid(uuidIA);
|
346
|
}
|
347
|
/**
|
348
|
* Casual alien, presence questionable
|
349
|
*
|
350
|
* @see #CASUAL()
|
351
|
* @see #CASUAL_REPORTED_IN_ERROR()
|
352
|
* @see #PRESENT_DOUBTFULLY()
|
353
|
*/
|
354
|
public static final PresenceAbsenceTerm CASUAL_PRESENCE_QUESTIONABLE(){
|
355
|
return getTermByUuid(uuidIAQ);
|
356
|
}
|
357
|
/**
|
358
|
* Casual alien, reported in error
|
359
|
*
|
360
|
* @see #CASUAL()
|
361
|
* @see #CASUAL_PRESENCE_QUESTIONABLE()
|
362
|
* @see #REPORTED_IN_ERROR()
|
363
|
*/
|
364
|
public static final PresenceAbsenceTerm CASUAL_REPORTED_IN_ERROR(){
|
365
|
return getTermByUuid(uuidIAF);
|
366
|
}
|
367
|
|
368
|
|
369
|
/**
|
370
|
* This term is of questional value. Introduced often is handled as opposite
|
371
|
* of adventitious/adventive and describes how the alien species came
|
372
|
* - on purpose for cultivation (introduced) or not (adventive).
|
373
|
* Adventitious or better adventive is often a synonym for casual which might
|
374
|
* be the better term here.
|
375
|
*
|
376
|
* @deprecated better use {@link #CASUAL()}, which has the same result (same semantics, but more precise)
|
377
|
*/
|
378
|
@Deprecated
|
379
|
public static final PresenceAbsenceTerm INTRODUCED_ADVENTITIOUS(){
|
380
|
return getTermByUuid(uuidIA);
|
381
|
}
|
382
|
|
383
|
public static final PresenceAbsenceTerm INTRODUCED_CULTIVATED(){
|
384
|
return getTermByUuid(uuidIC);
|
385
|
}
|
386
|
|
387
|
public static final PresenceAbsenceTerm INTRODUCED_DOUBTFULLY_INTRODUCED(){
|
388
|
return getTermByUuid(uuidID);
|
389
|
}
|
390
|
|
391
|
|
392
|
public static final PresenceAbsenceTerm INTRODUCED_UNCERTAIN_DEGREE_OF_NATURALISATION(){
|
393
|
return getTermByUuid(uuidIP);
|
394
|
}
|
395
|
|
396
|
public static final PresenceAbsenceTerm INTRODUCED_PRESENCE_QUESTIONABLE(){
|
397
|
return getTermByUuid(uuidIQ);
|
398
|
}
|
399
|
|
400
|
public static final PresenceAbsenceTerm INTRODUCED_FORMERLY_INTRODUCED(){
|
401
|
return getTermByUuid(uuidIE);
|
402
|
}
|
403
|
|
404
|
public static final PresenceAbsenceTerm INTRODUCED_REPORTED_IN_ERROR(){
|
405
|
return getTermByUuid(uuidIF);
|
406
|
}
|
407
|
|
408
|
/**
|
409
|
* Use native if the taxon is native in the according area. Native and indigenous
|
410
|
* have the same meaning. Native might be problematic because the abbreviation
|
411
|
* N is already used for naturalised.
|
412
|
*
|
413
|
* @see #NATIVE_DOUBTFULLY_NATIVE()
|
414
|
* @see #NATIVE_PRESENCE_QUESTIONABLE()
|
415
|
* @see #NATIVE_REPORTED_IN_ERROR()
|
416
|
*/
|
417
|
public static final PresenceAbsenceTerm NATIVE(){
|
418
|
return getTermByUuid(uuidN);
|
419
|
}
|
420
|
|
421
|
/**
|
422
|
* Same as {@link #NATIVE()} but presence is questionable
|
423
|
* @see #NATIVE()
|
424
|
* @see #NATIVE_DOUBTFULLY_NATIVE()
|
425
|
* @see #NATIVE_REPORTED_IN_ERROR()
|
426
|
*/
|
427
|
public static final PresenceAbsenceTerm NATIVE_PRESENCE_QUESTIONABLE(){
|
428
|
return getTermByUuid(uuidNQ);
|
429
|
}
|
430
|
|
431
|
/**
|
432
|
* The taxon was formerly native, but is extinct now in the given area.
|
433
|
*
|
434
|
* @see #NATIVE()
|
435
|
* @see #ABSENT()
|
436
|
*/
|
437
|
public static final PresenceAbsenceTerm NATIVE_FORMERLY_NATIVE(){
|
438
|
return getTermByUuid(uuidNE);
|
439
|
}
|
440
|
|
441
|
/**
|
442
|
* Same as {@link #NATIVE()} but presence was reported in error, so
|
443
|
* finally it is not native.
|
444
|
* @see #NATIVE()
|
445
|
* @see #NATIVE_PRESENCE_QUESTIONABLE()
|
446
|
* @see #NATIVE_DOUBTFULLY_NATIVE()
|
447
|
*/
|
448
|
public static final PresenceAbsenceTerm NATIVE_REPORTED_IN_ERROR(){
|
449
|
return getTermByUuid(uuidNF);
|
450
|
}
|
451
|
|
452
|
/**
|
453
|
* Same as {@link #NATIVE()} but the nativeness is doubtful, while presence
|
454
|
* is NOT questionable
|
455
|
* @see #NATIVE()
|
456
|
* @see #NATIVE_PRESENCE_QUESTIONABLE()
|
457
|
* @see #NATIVE_REPORTED_IN_ERROR()
|
458
|
*/
|
459
|
public static final PresenceAbsenceTerm NATIVE_DOUBTFULLY_NATIVE(){
|
460
|
return getTermByUuid(uuidND);
|
461
|
}
|
462
|
|
463
|
/**
|
464
|
* Same as {@link #NATIVE()} but the nativeness is doubtful, while presence
|
465
|
* is NOT questionable
|
466
|
* @see #NATIVE_DOUBTFULLY_NATIVE()
|
467
|
* @see #NATIVE()
|
468
|
* @see #NATIVE_PRESENCE_QUESTIONABLE()
|
469
|
*/
|
470
|
public static final PresenceAbsenceTerm NATIVE_DOUBTFULLY_NATIVE_REPORTED_IN_ERROR(){
|
471
|
return getTermByUuid(uuidNDE);
|
472
|
}
|
473
|
|
474
|
|
475
|
/**
|
476
|
* Naturalized (or introduced: naturalized). Further distinction can be made by
|
477
|
* distinguishing invasive / non-invasive
|
478
|
* @see #NATURALISED_PRESENCE_QUESTIONABLE()
|
479
|
* @see #NATURALISED_REPORTED_IN_ERROR()
|
480
|
* @see #INVASIVE()
|
481
|
* @see #NON_INVASIVE
|
482
|
*/
|
483
|
public static final PresenceAbsenceTerm NATURALISED(){
|
484
|
return getTermByUuid(uuidIN);
|
485
|
}
|
486
|
|
487
|
/**
|
488
|
*
|
489
|
* @see #NATURALISED()
|
490
|
*/
|
491
|
public static final PresenceAbsenceTerm NATURALISED_PRESENCE_QUESTIONABLE(){
|
492
|
return getTermByUuid(uuidINQ);
|
493
|
}
|
494
|
|
495
|
public static final PresenceAbsenceTerm NATURALISED_REPORTED_IN_ERROR(){
|
496
|
return getTermByUuid(uuidNaE);
|
497
|
}
|
498
|
|
499
|
/**
|
500
|
* Naturalized invasive. <BR>
|
501
|
* The taxon is present but not native in the given area. Additionally
|
502
|
* it is spreading fast.
|
503
|
*
|
504
|
* @see #INVASIVE_PRESENCE_QUESTIONABLE()
|
505
|
* @see #NON_INVASIVE()
|
506
|
* @see #NON_INVASIVE_PRESENCE_QUESTIONABLE()
|
507
|
*/
|
508
|
public static final PresenceAbsenceTerm INVASIVE(){
|
509
|
return getTermByUuid(uuidNI);
|
510
|
}
|
511
|
/**
|
512
|
* Invasive, presence questionable.
|
513
|
*
|
514
|
* @see #INVASIVE()
|
515
|
* @see #NON_INVASIVE()
|
516
|
* @see #NON_INVASIVE_PRESENCE_QUESTIONABLE()
|
517
|
*/
|
518
|
public static final PresenceAbsenceTerm INVASIVE_PRESENCE_QUESTIONABLE(){
|
519
|
return getTermByUuid(uuidNIQ);
|
520
|
}
|
521
|
/**
|
522
|
* The taxon is present but not native in the given area (naturalized).
|
523
|
* Additionally it is spreading not so fast.
|
524
|
*
|
525
|
* @see #INVASIVE()
|
526
|
* @see #INVASIVE_PRESENCE_QUESTIONABLE()
|
527
|
* @see #NON_INVASIVE_PRESENCE_QUESTIONABLE()
|
528
|
*/
|
529
|
public static final PresenceAbsenceTerm NON_INVASIVE(){
|
530
|
return getTermByUuid(uuidNN);
|
531
|
}
|
532
|
/**
|
533
|
* The taxon is questionable present and not native in the given area (naturalized).
|
534
|
* Additionally it is spreading not so fast
|
535
|
*
|
536
|
* @see #NON_INVASIVE()
|
537
|
* @see #INVASIVE()
|
538
|
* @see #INVASIVE_PRESENCE_QUESTIONABLE()
|
539
|
*/
|
540
|
public static final PresenceAbsenceTerm NON_INVASIVE_PRESENCE_QUESTIONABLE(){
|
541
|
return getTermByUuid(uuidNNQ);
|
542
|
}
|
543
|
|
544
|
|
545
|
/**
|
546
|
* @see #PRESENT()
|
547
|
* @see #REPORTED_IN_ERROR()
|
548
|
*/
|
549
|
public static final PresenceAbsenceTerm ABSENT(){
|
550
|
return getTermByUuid(uuidAbsence);
|
551
|
}
|
552
|
|
553
|
/**
|
554
|
* The taxon is {@link #ABSENT() absent} in the given area
|
555
|
* but was erroneously reported as present.
|
556
|
*
|
557
|
* @see #ABSENT()
|
558
|
* @see #NATIVE_REPORTED_IN_ERROR()
|
559
|
* @see #INTRODUCED_REPORTED_IN_ERROR()
|
560
|
*/
|
561
|
public static final PresenceAbsenceTerm REPORTED_IN_ERROR(){
|
562
|
return getTermByUuid(uuidReportedInError);
|
563
|
}
|
564
|
|
565
|
|
566
|
//******************************** METHODS ****************************/
|
567
|
|
568
|
@Override
|
569
|
public void resetTerms(){
|
570
|
termMap = null;
|
571
|
}
|
572
|
|
573
|
@Override
|
574
|
protected void setDefaultTerms(TermVocabulary<PresenceAbsenceTerm> termVocabulary) {
|
575
|
termMap = new HashMap<UUID, PresenceAbsenceTerm>();
|
576
|
for (PresenceAbsenceTerm term : termVocabulary.getTerms()){
|
577
|
termMap.put(term.getUuid(), term);
|
578
|
}
|
579
|
}
|
580
|
|
581
|
@Override
|
582
|
public PresenceAbsenceTerm readCsvLine(Class<PresenceAbsenceTerm> termClass, List<String> csvLine, Map<UUID,DefinedTermBase> terms, boolean abbrevAsId){
|
583
|
PresenceAbsenceTerm newInstance = super.readCsvLine(termClass, csvLine, terms, abbrevAsId);
|
584
|
String abbreviatedLabel = csvLine.get(4);
|
585
|
// String uuid = (String)csvLine.get(0);
|
586
|
// map.put(abbreviatedLabel, UUID.fromString(uuid));
|
587
|
String symbol = csvLine.get(5);
|
588
|
newInstance.setSymbol(symbol);
|
589
|
String color = csvLine.get(6);
|
590
|
try {
|
591
|
newInstance.setDefaultColor(color);
|
592
|
} catch (ParseException e) {
|
593
|
throw new RuntimeException(e);
|
594
|
}
|
595
|
boolean isAbsence = csvLine.get(7).equals("1") ? true : false;
|
596
|
newInstance.setAbsenceTerm(isAbsence);
|
597
|
|
598
|
newInstance.getRepresentation(Language.DEFAULT()).setAbbreviatedLabel(abbreviatedLabel);
|
599
|
return newInstance;
|
600
|
}
|
601
|
|
602
|
/**
|
603
|
* @return the defaultColor
|
604
|
*/
|
605
|
public String getDefaultColor() {
|
606
|
return defaultColor;
|
607
|
}
|
608
|
|
609
|
/**
|
610
|
* @param defaultColor the defaultColor to set
|
611
|
* @throws ParseException
|
612
|
*/
|
613
|
//TODO make format checking a hibernate validation rule
|
614
|
public void setDefaultColor(String defaultColor) throws ParseException {
|
615
|
String regEx = "[0-9a-fA-F]{6}";
|
616
|
if (StringUtils.isEmpty(defaultColor)){
|
617
|
this.defaultColor = null;
|
618
|
}else if (StringUtils.isEmpty(defaultColor) || defaultColor.matches(regEx)){
|
619
|
this.defaultColor = defaultColor;
|
620
|
}else{
|
621
|
throw new java.text.ParseException("Default color is not of correct format. Required is 'FFFFFF'", -1);
|
622
|
}
|
623
|
}
|
624
|
|
625
|
/**
|
626
|
* Compares this OrderedTermBase with the specified OrderedTermBase for
|
627
|
* order. Returns a -1, 0, or +1 if the orderId of this object is greater
|
628
|
* than, equal to, or less than the specified object.
|
629
|
* <p>
|
630
|
* <b>Note:</b> The compare logic of this method is the <b>inverse logic</b>
|
631
|
* of the the one implemented in
|
632
|
* {@link java.lang.Comparable#compareTo(java.lang.Object)}
|
633
|
*
|
634
|
* @param orderedTerm
|
635
|
* the OrderedTermBase to be compared
|
636
|
* @param skipVocabularyCheck
|
637
|
* whether to skip checking if both terms to compare are in the
|
638
|
* same vocabulary
|
639
|
* @throws NullPointerException
|
640
|
* if the specified object is null
|
641
|
*/
|
642
|
@Override
|
643
|
protected int performCompareTo(PresenceAbsenceTerm presenceAbsenceTerm, boolean skipVocabularyCheck) {
|
644
|
|
645
|
PresenceAbsenceTerm presenceAbsenceTermLocal = CdmBase.deproxy(presenceAbsenceTerm, PresenceAbsenceTerm.class);
|
646
|
if(! skipVocabularyCheck){
|
647
|
if (this.vocabulary == null || presenceAbsenceTermLocal.vocabulary == null){
|
648
|
throw new IllegalStateException("An ordered term (" + this.toString() + " or " +
|
649
|
presenceAbsenceTermLocal.toString() + ") of class " + this.getClass() + " or " +
|
650
|
presenceAbsenceTermLocal.getClass() + " does not belong to a vocabulary and therefore "
|
651
|
+ "can not be compared");
|
652
|
}
|
653
|
if (presenceAbsenceTermLocal.isAbsenceTerm() != this.isAbsenceTerm() ){
|
654
|
if (presenceAbsenceTermLocal.isAbsenceTerm()){
|
655
|
return 1;
|
656
|
}else{
|
657
|
return -1;
|
658
|
}
|
659
|
|
660
|
}
|
661
|
}
|
662
|
|
663
|
int orderThat;
|
664
|
int orderThis;
|
665
|
try {
|
666
|
orderThat = presenceAbsenceTermLocal.orderIndex;//OLD: this.getVocabulary().getTerms().indexOf(orderedTerm);
|
667
|
orderThis = orderIndex; //OLD: this.getVocabulary().getTerms().indexOf(this);
|
668
|
} catch (RuntimeException e) {
|
669
|
throw e;
|
670
|
}
|
671
|
if (orderThis > orderThat){
|
672
|
return -1;
|
673
|
}else if (orderThis < orderThat){
|
674
|
return 1;
|
675
|
}else {
|
676
|
return 0;
|
677
|
}
|
678
|
}
|
679
|
|
680
|
|
681
|
public boolean isAbsenceTerm() {
|
682
|
return absenceTerm;
|
683
|
}
|
684
|
|
685
|
public void setAbsenceTerm(boolean isAbsenceTerm) {
|
686
|
this.absenceTerm = isAbsenceTerm;
|
687
|
}
|
688
|
|
689
|
|
690
|
}
|