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
;
13 import java
.util
.HashMap
;
15 import java
.util
.UUID
;
17 import javax
.persistence
.Entity
;
18 import javax
.xml
.bind
.annotation
.XmlAccessType
;
19 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
20 import javax
.xml
.bind
.annotation
.XmlRootElement
;
21 import javax
.xml
.bind
.annotation
.XmlType
;
23 import org
.apache
.log4j
.Logger
;
24 import org
.hibernate
.envers
.Audited
;
25 import org
.hibernate
.search
.annotations
.Indexed
;
27 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
28 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
29 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
32 * This class represents terms describing different types of absence
33 * (like "extinct" or just "absent") of a {@link Taxon taxon} in a {@link NamedArea particular area}.
37 * @created 08-Nov-2007 13:06:08
39 @XmlAccessorType(XmlAccessType
.FIELD
)
40 @XmlType(name
= "AbsenceTerm")
41 @XmlRootElement(name
= "AbsenceTerm")
43 @Indexed(index
= "eu.etaxonomy.cdm.model.common.DefinedTermBase")
45 public class AbsenceTerm
extends PresenceAbsenceTermBase
<AbsenceTerm
> {
46 private static final long serialVersionUID
= -7125360212309512860L;
47 private static final Logger logger
= Logger
.getLogger(AbsenceTerm
.class);
49 private static Map
<UUID
, AbsenceTerm
> termMap
= null;
51 private static final UUID uuidAbsence
=UUID
.fromString("59709861-f7d9-41f9-bb21-92559cedd598");
52 private static final UUID uuidNF
=UUID
.fromString("61cee840-801e-41d8-bead-015ad866c2f1");
53 private static final UUID uuidIF
=UUID
.fromString("aeec2947-2700-4623-8e32-9e3a430569d1");
54 private static final UUID uuidCF
=UUID
.fromString("9d4d3431-177a-4abe-8e4b-1558573169d6");
55 private static final UUID uuidNE
=UUID
.fromString("5c397f7b-59ef-4c11-a33c-45691ceda91b");
56 private static final UUID uuidIE
=UUID
.fromString("b74dc30b-ee93-496d-8c00-4d00abae1ec7");
60 * Creates a new empty absence term.
62 * @see #NewInstance(String, String, String)
64 public static AbsenceTerm
NewInstance(){
65 logger
.debug("NewInstance");
66 return new AbsenceTerm();
70 * Creates a new absence term with a description (in the {@link Language#DEFAULT() default language}),
71 * a label and a label abbreviation.
73 * @param term the string (in the default language) describing the
74 * new absence term to be created
75 * @param label the string identifying the new absence term to be created
76 * @param labelAbbrev the string identifying (in abbreviated form) the
77 * new absence term to be created
80 public static AbsenceTerm
NewInstance(String term
, String label
, String labelAbbrev
){
81 return new AbsenceTerm(term
, label
, labelAbbrev
);
84 // ************* CONSTRUCTORS *************/
86 * Class constructor: creates a new empty absence term.
88 * @see #AbsenceTerm(String, String, String)
90 public AbsenceTerm() {
94 * Class constructor: creates a new absence term with a description (in the {@link Language#DEFAULT() default language}),
95 * a label and a label abbreviation.
97 * @param term the string (in the default language) describing the
98 * new absence term to be created
99 * @param label the string identifying the new absence term to be created
100 * @param labelAbbrev the string identifying (in abbreviated form) the
101 * new absence term to be created
102 * @see #AbsenceTerm()
104 public AbsenceTerm(String term
, String label
, String labelAbbrev
) {
105 super(term
, label
, labelAbbrev
);
109 //************************** METHODS ********************************
112 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
115 public void resetTerms(){
119 protected static AbsenceTerm
getTermByUuid(UUID uuid
){
120 if (termMap
== null){
123 return (AbsenceTerm
)termMap
.get(uuid
);
128 public static final AbsenceTerm
ABSENT(){
129 return getTermByUuid(uuidAbsence
);
132 public static final AbsenceTerm
NATIVE_REPORTED_IN_ERROR(){
133 return getTermByUuid(uuidNF
);
136 public static final AbsenceTerm
CULTIVATED_REPORTED_IN_ERROR(){
137 return getTermByUuid(uuidCF
);
140 public static final AbsenceTerm
INTRODUCED_REPORTED_IN_ERROR(){
141 return getTermByUuid(uuidIF
);
144 public static final AbsenceTerm
NATIVE_FORMERLY_NATIVE(){
145 return getTermByUuid(uuidNE
);
148 public static final AbsenceTerm
INTRODUCED_FORMERLY_INTRODUCED(){
149 return getTermByUuid(uuidIE
);
152 //TODO make automatic like in TDWGArea
153 public static AbsenceTerm
getPresenceTermByAbbreviation(String abbrev
) {
154 if (abbrev
== null) { throw new NullPointerException("abbrev is 'null' in getPresenceTermByAbbreviation");
155 } else if (abbrev
.equalsIgnoreCase("cf")) { return AbsenceTerm
.CULTIVATED_REPORTED_IN_ERROR();
156 } else if (abbrev
.equalsIgnoreCase("if")) { return AbsenceTerm
.INTRODUCED_REPORTED_IN_ERROR();
157 } else if (abbrev
.equalsIgnoreCase("nf")) { return AbsenceTerm
.NATIVE_REPORTED_IN_ERROR();
158 } else if (abbrev
.equalsIgnoreCase("ne")) { return AbsenceTerm
.NATIVE_FORMERLY_NATIVE();
159 } else if (abbrev
.equalsIgnoreCase("ie")) { return AbsenceTerm
.INTRODUCED_FORMERLY_INTRODUCED();
161 logger
.warn("Unknown absence status term: " + abbrev
);
168 protected void setDefaultTerms(TermVocabulary
<AbsenceTerm
> termVocabulary
) {
169 termMap
= new HashMap
<UUID
, AbsenceTerm
>();
170 for (AbsenceTerm term
: termVocabulary
.getTerms()){
171 termMap
.put(term
.getUuid(), (AbsenceTerm
)term
); //TODO casting