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
.common
;
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
.XmlAttribute
;
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
.Analyze
;
26 import org
.hibernate
.search
.annotations
.Field
;
27 import org
.hibernate
.search
.annotations
.Indexed
;
30 * Marker types similar to dynamically defined attributes. These content types
31 * like "IS_DOUBTFUL", "COMPLETE" or specific local flags.
33 * @created 08-Nov-2007 13:06:33
35 @XmlAccessorType(XmlAccessType
.FIELD
)
36 @XmlType(name
= "MarkerType")
38 @Indexed(index
= "eu.etaxonomy.cdm.model.common.DefinedTermBase")
40 public class MarkerType
extends DefinedTermBase
<MarkerType
> {
41 private static final long serialVersionUID
= -9117424749919907396L;
42 public static final Logger logger
= Logger
.getLogger(MarkerType
.class);
44 private static final UUID uuidImported
= UUID
.fromString("96878790-4ceb-42a2-9738-a2242079b679");
45 private static final UUID uuidToBeChecked
= UUID
.fromString("34204192-b41d-4857-a1d4-28992bef2a2a");
46 private static final UUID uuidIsDoubtful
= UUID
.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e");
47 private static final UUID uuidComplete
= UUID
.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433");
48 private static final UUID uuidPublish
= UUID
.fromString("0522c2b3-b21c-400c-80fc-a251c3501dbc");
49 private static final UUID uuidInBibliography
= UUID
.fromString("2cdb492e-3b8b-4784-8c26-25159835231d");
50 private static final UUID uuidEndemic
= UUID
.fromString("efe95ade-8a6c-4a0e-800e-437c8b50c45e");
51 private static final UUID uuidModifiable
= UUID
.fromString("c21bc83f-c8ae-4126-adee-10dfe817e96a");
52 private static final UUID uuidUse
= UUID
.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039");
53 private static final UUID uuidComputed
= UUID
.fromString("5cc15a73-2947-44e3-9319-85dd20736e55");
55 protected static Map
<UUID
, MarkerType
> termMap
= null;
57 @XmlAttribute(name
= "isTechnical")
58 @Field(analyze
= Analyze
.NO
)
59 private boolean isTechnical
=false;
61 // ***************************** FACTORY METHODD ************************/
63 public static MarkerType
NewInstance(String term
, String label
, String labelAbbrev
){
64 return new MarkerType(term
, label
, labelAbbrev
);
68 // ***************************** CONSTRUCTOR ******************************/
70 //for hibernate use only
72 protected MarkerType() {
73 super(TermType
.MarkerType
);
76 //***************************** CONSTRUCTOR **************************************/
78 private MarkerType(String term
, String label
, String labelAbbrev
) {
79 super(TermType
.MarkerType
, term
, label
, labelAbbrev
);
82 // ******************** METHODS **************************************************/
85 * A flag indicating if markers of this type are user content or technical information
86 * to be used by applications only. E.g. a FeatureTree may have a marker that defines
87 * the role of this FeatureTree ("for ordering") whereas a {@link eu.etaxonomy.cdm.model.taxon.Taxon taxon}
88 * may have a user defined marker "completed" that indicates that this taxon does not
89 * need further investigation. The earlier will be flagged isTechnical=true whereas
90 * the later will be flagged as isTechnical=false
91 * @return the isTechnical
93 public boolean isTechnical() {
98 * @param isTechnical the isTechnical to set
100 public void setTechnical(boolean isTechnical
) {
101 this.isTechnical
= isTechnical
;
104 //***************************** TERMS **************************************/
108 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
111 public void resetTerms(){
116 protected static MarkerType
getTermByUuid(UUID uuid
){
117 if (termMap
== null){
118 DefaultTermInitializer vocabularyStore
= new DefaultTermInitializer();
119 vocabularyStore
.initialize();
121 return termMap
.get(uuid
);
124 public static final MarkerType
IMPORTED(){
125 return getTermByUuid(uuidImported
);
128 public static final MarkerType
TO_BE_CHECKED(){
129 return getTermByUuid(uuidToBeChecked
);
132 public static final MarkerType
IS_DOUBTFUL(){
133 return getTermByUuid(uuidIsDoubtful
);
136 public static final MarkerType
COMPLETE(){
137 return getTermByUuid(uuidComplete
);
140 public static final MarkerType
PUBLISH(){
141 return getTermByUuid(uuidPublish
);
144 public static final MarkerType
IN_BIBLIOGRAPHY(){
145 return getTermByUuid(uuidInBibliography
);
148 public static final MarkerType
ENDEMIC(){
149 return getTermByUuid(uuidEndemic
);
152 public static final MarkerType
MODIFIABLE(){
153 return getTermByUuid(uuidModifiable
);
155 public static final MarkerType
USE(){
156 return getTermByUuid(uuidUse
);
158 public static final MarkerType
COMPUTED(){
159 return getTermByUuid(uuidComputed
);
163 protected void setDefaultTerms(TermVocabulary
<MarkerType
> termVocabulary
) {
164 termMap
= new HashMap
<UUID
, MarkerType
>();
165 for (MarkerType term
: termVocabulary
.getTerms()){
166 termMap
.put(term
.getUuid(), term
);