2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.description
;
12 import java
.util
.HashMap
;
14 import java
.util
.UUID
;
16 import javax
.persistence
.Entity
;
17 import javax
.xml
.bind
.annotation
.XmlAccessType
;
18 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
19 import javax
.xml
.bind
.annotation
.XmlRootElement
;
20 import javax
.xml
.bind
.annotation
.XmlType
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.hibernate
.envers
.Audited
;
24 import org
.hibernate
.search
.annotations
.Indexed
;
26 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
27 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
28 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
31 * This class represents terms describing different types of presence
32 * (like "native" or "introduced") of a {@link Taxon taxon} in a {@link NamedArea particular area}.
36 * @created 08-Nov-2007 13:06:44
38 @XmlAccessorType(XmlAccessType
.FIELD
)
39 @XmlType(name
= "PresenceTerm")
40 @XmlRootElement(name
= "PresenceTerm")
42 @Indexed(index
= "eu.etaxonomy.cdm.model.common.DefinedTermBase")
44 public class PresenceTerm
extends PresenceAbsenceTermBase
<PresenceTerm
> {
45 private static final long serialVersionUID
= -2876981902335193596L;
46 private static final Logger logger
= Logger
.getLogger(PresenceTerm
.class);
48 protected static Map
<UUID
, PresenceTerm
> termMap
= null;
50 private static final UUID uuidP
=UUID
.fromString("cef81d25-501c-48d8-bbea-542ec50de2c2");
51 private static final UUID uuidPD
=UUID
.fromString("75a60279-a4c2-4f53-bc57-466028a4b3db");
53 private static final UUID uuidN
=UUID
.fromString("ddeac4f2-d8fa-43b8-ad7e-ca13abdd32c7");
54 private static final UUID uuidNQ
=UUID
.fromString("925662c1-bb10-459a-8c53-da5a738ac770");
55 private static final UUID uuidND
=UUID
.fromString("310373bf-7df4-4d02-8cb3-bcc7448805fc");
56 private static final UUID uuidC
=UUID
.fromString("9eb99fe6-59e2-4445-8e6a-478365bd0fa9");
57 private static final UUID uuidI
=UUID
.fromString("643cf9d1-a5f1-4622-9837-82ef961e880b");
58 private static final UUID uuidIQ
=UUID
.fromString("83eb0aa0-1a45-495a-a3ca-bf6958b74366");
59 private static final UUID uuidID
=UUID
.fromString("0c54761e-4887-4788-9dfa-7190c88746e3");
60 private static final UUID uuidIP
=UUID
.fromString("da159544-b0dd-4599-a9c9-640826af8c17");
61 private static final UUID uuidIA
=UUID
.fromString("42946bd6-9c22-45ad-a910-7427e8f60bfd");
62 private static final UUID uuidIN
=UUID
.fromString("e191e89a-a751-4b0c-b883-7f1de70915c9");
63 private static final UUID uuidIC
=UUID
.fromString("fac8c347-8262-44a1-b0a4-db4de451c021");
64 private static final UUID uuidE
=UUID
.fromString("c3ee7048-15b7-4be1-b687-9ce9c1a669d6");
65 private static final UUID uuidNA
=UUID
.fromString("4e04990a-66fe-4fdf-856c-f40772fbcf0a");
66 private static final UUID uuidIV
=UUID
.fromString("dc536e3d-a753-4bbe-a386-dd8aff35c234");
69 //********* METHODS **************************************/
71 * Creates a new empty presence term.
73 * @see #NewInstance(String, String, String)
75 public static PresenceTerm
NewInstance(){
76 return new PresenceTerm();
80 * Creates a new presence term with a description (in the {@link Language#DEFAULT() default language}),
81 * a label and a label abbreviation.
83 * @param term the string (in the default language) describing the
84 * new presence term to be created
85 * @param label the string identifying the new presence term to be created
86 * @param labelAbbrev the string identifying (in abbreviated form) the
87 * new presence term to be created
90 public static PresenceTerm
NewInstance(String term
, String label
, String labelAbbrev
){
91 return new PresenceTerm(term
, label
, labelAbbrev
);
94 // ************* CONSTRUCTORS *************/
96 * Class constructor: creates a new empty presence term.
98 * @see #PresenceTerm(String, String, String)
100 public PresenceTerm() {
104 * Class constructor: creates a new presence term with a description (in the {@link Language#DEFAULT() default language}),
105 * a label and a label abbreviation.
107 * @param term the string (in the default language) describing the
108 * new presence term to be created
109 * @param label the string identifying the new presence term to be created
110 * @param labelAbbrev the string identifying (in abbreviated form) the
111 * new presence term to be created
112 * @see #PresenceTerm()
114 public PresenceTerm(String term
, String label
, String labelAbbrev
) {
115 super(term
, label
, labelAbbrev
);
120 //******************************* STATIC METHODS *****************************************
122 protected static PresenceTerm
getTermByUuid(UUID uuid
){
123 if (termMap
== null){
126 return (PresenceTerm
)termMap
.get(uuid
);
131 public static final PresenceTerm
PRESENT(){
132 return getTermByUuid(uuidP
);
134 public static final PresenceTerm
PRESENT_DOUBTFULLY(){
135 return getTermByUuid(uuidPD
);
137 public static final PresenceTerm
CULTIVATED(){
138 return getTermByUuid(uuidC
);
140 public static final PresenceTerm
ENDEMIC_FOR_THE_RELEVANT_AREA(){
141 return getTermByUuid(uuidE
);
143 public static final PresenceTerm
INTRODUCED(){
144 return getTermByUuid(uuidI
);
146 public static final PresenceTerm
INTRODUCED_ADVENTITIOUS(){
147 return getTermByUuid(uuidIA
);
150 public static final PresenceTerm
INTRODUCED_CULTIVATED(){
151 return getTermByUuid(uuidIC
);
154 public static final PresenceTerm
INTRODUCED_DOUBTFULLY_INTRODUCED(){
155 return getTermByUuid(uuidID
);
158 public static final PresenceTerm
INTRODUCED_NATURALIZED(){
159 return getTermByUuid(uuidIN
);
162 public static final PresenceTerm
INTRODUCED_PRESENCE_QUESTIONABLE(){
163 return getTermByUuid(uuidIQ
);
166 public static final PresenceTerm
INTRODUCED_UNCERTAIN_DEGREE_OF_NATURALISATION(){
167 return getTermByUuid(uuidIP
);
170 public static final PresenceTerm
NATIVE(){
171 return getTermByUuid(uuidN
);
174 public static final PresenceTerm
NATIVE_DOUBTFULLY_NATIVE(){
175 return getTermByUuid(uuidND
);
178 public static final PresenceTerm
NATIVE_PRESENCE_QUESTIONABLE(){
179 return getTermByUuid(uuidNQ
);
182 public static final PresenceTerm
INVASIVE(){
183 return getTermByUuid(uuidIV
);
186 public static final PresenceTerm
NATURALISED(){
187 return getTermByUuid(uuidNA
);
190 //TODO read from label(abbrevs) like in TDWGArea
191 public static PresenceTerm
getPresenceTermByAbbreviation(String abbrev
) {
192 if (abbrev
== null) { throw new NullPointerException("abbrev is 'null' in getPresenceTermByAbbreviation");
193 } else if (abbrev
.equalsIgnoreCase("c")) { return PresenceTerm
.CULTIVATED();
194 } else if (abbrev
.equalsIgnoreCase("e")) { return PresenceTerm
.ENDEMIC_FOR_THE_RELEVANT_AREA();
195 } else if (abbrev
.equalsIgnoreCase("i")) { return PresenceTerm
.INTRODUCED();
196 } else if (abbrev
.equalsIgnoreCase("ia")) { return PresenceTerm
.INTRODUCED_ADVENTITIOUS();
197 } else if (abbrev
.equalsIgnoreCase("ic")) { return PresenceTerm
.INTRODUCED_CULTIVATED();
198 } else if (abbrev
.equalsIgnoreCase("id")) { return PresenceTerm
.INTRODUCED_DOUBTFULLY_INTRODUCED();
199 } else if (abbrev
.equalsIgnoreCase("in")) { return PresenceTerm
.INTRODUCED_NATURALIZED();
200 } else if (abbrev
.equalsIgnoreCase("ip")) { return PresenceTerm
.INTRODUCED_UNCERTAIN_DEGREE_OF_NATURALISATION();
201 } else if (abbrev
.equalsIgnoreCase("iq")) { return PresenceTerm
.INTRODUCED_PRESENCE_QUESTIONABLE();
202 } else if (abbrev
.equalsIgnoreCase("n")) { return PresenceTerm
.NATIVE();
203 } else if (abbrev
.equalsIgnoreCase("nd")) { return PresenceTerm
.NATIVE_DOUBTFULLY_NATIVE();
204 } else if (abbrev
.equalsIgnoreCase("nq")) { return PresenceTerm
.NATIVE_PRESENCE_QUESTIONABLE();
205 } else if (abbrev
.equalsIgnoreCase("p")) { return PresenceTerm
.PRESENT();
206 } else if (abbrev
.equalsIgnoreCase("na")) { return PresenceTerm
.NATURALISED();
207 } else if (abbrev
.equalsIgnoreCase("iv")) { return PresenceTerm
.INVASIVE();
209 logger
.warn("Unknown presence status term: " + abbrev
);
214 //************************** METHODS ********************************
217 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
220 public void resetTerms(){
225 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#setDefaultTerms(eu.etaxonomy.cdm.model.common.TermVocabulary)
228 protected void setDefaultTerms(TermVocabulary
<PresenceTerm
> termVocabulary
) {
229 termMap
= new HashMap
<UUID
, PresenceTerm
>();
230 for (PresenceTerm term
: termVocabulary
.getTerms()){
231 termMap
.put(term
.getUuid(), (PresenceTerm
)term
); //TODO casting