bugfix for Coordinate Parser with whitespaces, Dateparsing, etc.
[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 org.apache.log4j.Logger;
14 import org.hibernate.envers.Audited;
15 import org.hibernate.search.annotations.Field;
16 import org.hibernate.search.annotations.Index;
17 import org.hibernate.search.annotations.Indexed;
18
19
20 import java.util.*;
21
22 import javax.persistence.*;
23 import javax.xml.bind.annotation.XmlAccessType;
24 import javax.xml.bind.annotation.XmlAccessorType;
25 import javax.xml.bind.annotation.XmlAttribute;
26 import javax.xml.bind.annotation.XmlType;
27
28 /**
29 * Marker types similar to dynamically defined attributes. These content types
30 * like "IS_DOUBTFUL", "COMPLETE" or specific local flags.
31 * @author m.doering
32 * @version 1.0
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
52 protected static Map<UUID, MarkerType> termMap = null;
53
54 public static MarkerType NewInstance(String term, String label, String labelAbbrev){
55 return new MarkerType(term, label, labelAbbrev);
56 }
57
58
59
60 @XmlAttribute(name = "isTechnical")
61 @Field(index=Index.UN_TOKENIZED)
62 private boolean isTechnical=false;
63
64
65
66
67 /**
68 * Constructor
69 * @param term
70 * @param label
71 */
72 public MarkerType() {
73 }
74
75 /**
76 * A flag indicating if markers of this type are user content or technical information
77 * to be used by applications only. E.g. a FeatureTree may have a marker that defines
78 * the role of this FeatureTree ("for ordering") whereas a {@link eu.etaxonomy.cdm.model.taxon.Taxon taxon}
79 * may have a user defined marker "completed" that indicates that this taxon does not
80 * need further investigation. The earlier will be flagged isTechnical=true whereas
81 * the later will be flagged as isTechnical=false
82 * @return the isTechnical
83 */
84 public boolean isTechnical() {
85 return isTechnical;
86 }
87
88 /**
89 * @param isTechnical the isTechnical to set
90 */
91 public void setTechnical(boolean isTechnical) {
92 this.isTechnical = isTechnical;
93 }
94
95 //***************************** CONSTRUCTOR **************************************/
96
97 /**
98 * Constructor
99 * @param term
100 * @param label
101 */
102 protected MarkerType(String term, String label, String labelAbbrev) {
103 super(term, label, labelAbbrev);
104 }
105
106 //***************************** TERMS **************************************/
107
108
109 /* (non-Javadoc)
110 * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
111 */
112 @Override
113 public void resetTerms(){
114 termMap = null;
115 }
116
117
118 protected static MarkerType getTermByUuid(UUID uuid){
119 if (termMap == null){
120 DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
121 vocabularyStore.initialize();
122 }
123 return (MarkerType)termMap.get(uuid);
124 }
125
126 public static final MarkerType IMPORTED(){
127 return getTermByUuid(uuidImported);
128 }
129
130 public static final MarkerType TO_BE_CHECKED(){
131 return getTermByUuid(uuidToBeChecked);
132 }
133
134 public static final MarkerType IS_DOUBTFUL(){
135 return getTermByUuid(uuidIsDoubtful);
136 }
137
138 public static final MarkerType COMPLETE(){
139 return getTermByUuid(uuidComplete);
140 }
141
142 public static final MarkerType PUBLISH(){
143 return getTermByUuid(uuidPublish);
144 }
145
146 public static final MarkerType IN_BIBLIOGRAPHY(){
147 return getTermByUuid(uuidInBibliography);
148 }
149
150 public static final MarkerType ENDEMIC(){
151 return getTermByUuid(uuidEndemic);
152 }
153
154 @Override
155 protected void setDefaultTerms(TermVocabulary<MarkerType> termVocabulary) {
156 termMap = new HashMap<UUID, MarkerType>();
157 for (MarkerType term : termVocabulary.getTerms()){
158 termMap.put(term.getUuid(), (MarkerType)term);
159 }
160 }
161
162 }