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
;
30 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
33 * This class represents terms describing different types of absence
34 * (like "extinct" or just "absent") of a {@link Taxon taxon} in a {@link NamedArea particular area}.
38 * @created 08-Nov-2007 13:06:08
40 @XmlAccessorType(XmlAccessType
.FIELD
)
41 @XmlType(name
= "AbsenceTerm")
42 @XmlRootElement(name
= "AbsenceTerm")
44 @Indexed(index
= "eu.etaxonomy.cdm.model.common.DefinedTermBase")
46 public class AbsenceTerm
extends PresenceAbsenceTermBase
<AbsenceTerm
> {
47 private static final long serialVersionUID
= -7125360212309512860L;
48 private static final Logger logger
= Logger
.getLogger(AbsenceTerm
.class);
50 private static Map
<UUID
, AbsenceTerm
> termMap
= null;
52 private static final UUID uuidAbsence
=UUID
.fromString("59709861-f7d9-41f9-bb21-92559cedd598");
53 private static final UUID uuidNF
=UUID
.fromString("61cee840-801e-41d8-bead-015ad866c2f1");
54 private static final UUID uuidIF
=UUID
.fromString("aeec2947-2700-4623-8e32-9e3a430569d1");
55 private static final UUID uuidCF
=UUID
.fromString("9d4d3431-177a-4abe-8e4b-1558573169d6");
59 * Creates a new empty absence term.
61 * @see #NewInstance(String, String, String)
63 public static AbsenceTerm
NewInstance(){
64 logger
.debug("NewInstance");
65 return new AbsenceTerm();
69 * Creates a new absence term with a description (in the {@link Language#DEFAULT() default language}),
70 * a label and a label abbreviation.
72 * @param term the string (in the default language) describing the
73 * new absence term to be created
74 * @param label the string identifying the new absence term to be created
75 * @param labelAbbrev the string identifying (in abbreviated form) the
76 * new absence term to be created
79 public static AbsenceTerm
NewInstance(String term
, String label
, String labelAbbrev
){
80 return new AbsenceTerm(term
, label
, labelAbbrev
);
83 // ************* CONSTRUCTORS *************/
85 * Class constructor: creates a new empty absence term.
87 * @see #AbsenceTerm(String, String, String)
89 public AbsenceTerm() {
93 * Class constructor: creates a new absence term with a description (in the {@link Language#DEFAULT() default language}),
94 * a label and a label abbreviation.
96 * @param term the string (in the default language) describing the
97 * new absence term to be created
98 * @param label the string identifying the new absence term to be created
99 * @param labelAbbrev the string identifying (in abbreviated form) the
100 * new absence term to be created
101 * @see #AbsenceTerm()
103 public AbsenceTerm(String term
, String label
, String labelAbbrev
) {
104 super(term
, label
, labelAbbrev
);
108 //************************** METHODS ********************************
111 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
114 public void resetTerms(){
118 protected static AbsenceTerm
getTermByUuid(UUID uuid
){
119 if (termMap
== null){
122 return (AbsenceTerm
)termMap
.get(uuid
);
127 public static final AbsenceTerm
ABSENT(){
128 return getTermByUuid(uuidAbsence
);
131 public static final AbsenceTerm
NATIVE_REPORTED_IN_ERROR(){
132 return getTermByUuid(uuidNF
);
135 public static final AbsenceTerm
CULTIVATED_REPORTED_IN_ERROR(){
136 return getTermByUuid(uuidCF
);
139 public static final AbsenceTerm
INTRODUCED_REPORTED_IN_ERROR(){
140 return getTermByUuid(uuidIF
);
143 //TODO make automatic like in TDWGArea
144 public static AbsenceTerm
getPresenceTermByAbbreviation(String abbrev
) {
145 if (abbrev
== null) { throw new NullPointerException("abbrev is 'null' in getPresenceTermByAbbreviation");
146 } else if (abbrev
.equalsIgnoreCase("cf")) { return AbsenceTerm
.CULTIVATED_REPORTED_IN_ERROR();
147 } else if (abbrev
.equalsIgnoreCase("if")) { return AbsenceTerm
.INTRODUCED_REPORTED_IN_ERROR();
148 } else if (abbrev
.equalsIgnoreCase("nf")) { return AbsenceTerm
.NATIVE_REPORTED_IN_ERROR();
150 logger
.warn("Unknown absence status term: " + abbrev
);
157 protected void setDefaultTerms(TermVocabulary
<AbsenceTerm
> termVocabulary
) {
158 termMap
= new HashMap
<UUID
, AbsenceTerm
>();
159 for (AbsenceTerm term
: termVocabulary
.getTerms()){
160 termMap
.put(term
.getUuid(), (AbsenceTerm
)term
); //TODO casting