- no change (just updated "last edited" for svn)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / common / MarkerType.java
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.common;
11
12
13 import java.util.HashMap;
14 import java.util.Map;
15 import java.util.UUID;
16
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;
22
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;
28
29 /**
30 * Marker types similar to dynamically defined attributes. These content types
31 * like "IS_DOUBTFUL", "COMPLETE" or specific local flags.
32 * @author m.doering
33 * @created 08-Nov-2007 13:06:33
34 */
35 @XmlAccessorType(XmlAccessType.FIELD)
36 @XmlType(name = "MarkerType")
37 @Entity
38 @Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
39 @Audited
40 public class MarkerType extends DefinedTermBase<MarkerType> {
41 private static final long serialVersionUID = -9117424749919907396L;
42 public static final Logger logger = Logger.getLogger(MarkerType.class);
43
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");
54
55 protected static Map<UUID, MarkerType> termMap = null;
56
57 @XmlAttribute(name = "isTechnical")
58 @Field(analyze = Analyze.NO)
59 private boolean isTechnical=false;
60
61 // ***************************** FACTORY METHODD ************************/
62
63 public static MarkerType NewInstance(String term, String label, String labelAbbrev){
64 return new MarkerType(term, label, labelAbbrev);
65 }
66
67
68 // ***************************** CONSTRUCTOR ******************************/
69
70 //for hibernate use only
71 @Deprecated
72 protected MarkerType() {
73 super(TermType.MarkerType);
74 }
75
76 //***************************** CONSTRUCTOR **************************************/
77
78 private MarkerType(String term, String label, String labelAbbrev) {
79 super(TermType.MarkerType, term, label, labelAbbrev);
80 }
81
82 // ******************** METHODS **************************************************/
83
84 /**
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
92 */
93 public boolean isTechnical() {
94 return isTechnical;
95 }
96
97 /**
98 * @param isTechnical the isTechnical to set
99 */
100 public void setTechnical(boolean isTechnical) {
101 this.isTechnical = isTechnical;
102 }
103
104 //***************************** TERMS **************************************/
105
106
107 /* (non-Javadoc)
108 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
109 */
110 @Override
111 public void resetTerms(){
112 termMap = null;
113 }
114
115
116 protected static MarkerType getTermByUuid(UUID uuid){
117 if (termMap == null){
118 DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
119 vocabularyStore.initialize();
120 }
121 return termMap.get(uuid);
122 }
123
124 public static final MarkerType IMPORTED(){
125 return getTermByUuid(uuidImported);
126 }
127
128 public static final MarkerType TO_BE_CHECKED(){
129 return getTermByUuid(uuidToBeChecked);
130 }
131
132 public static final MarkerType IS_DOUBTFUL(){
133 return getTermByUuid(uuidIsDoubtful);
134 }
135
136 public static final MarkerType COMPLETE(){
137 return getTermByUuid(uuidComplete);
138 }
139
140 public static final MarkerType PUBLISH(){
141 return getTermByUuid(uuidPublish);
142 }
143
144 public static final MarkerType IN_BIBLIOGRAPHY(){
145 return getTermByUuid(uuidInBibliography);
146 }
147
148 public static final MarkerType ENDEMIC(){
149 return getTermByUuid(uuidEndemic);
150 }
151
152 public static final MarkerType MODIFIABLE(){
153 return getTermByUuid(uuidModifiable);
154 }
155 public static final MarkerType USE(){
156 return getTermByUuid(uuidUse);
157 }
158 public static final MarkerType COMPUTED(){
159 return getTermByUuid(uuidComputed);
160 }
161
162 @Override
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);
167 }
168 }
169
170 }