root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/common/MarkerType.java

Revision 14887, 5.1 kB (checked in by a.kohlbecker, 10 days ago)

merging branches/cdmlib/Kew_Palm_Use_Data_Extension into trunk & cleaning up a bit

  • Property svn:keywords set to Id
Line 
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
10package eu.etaxonomy.cdm.model.common;
11
12
13import java.util.HashMap;
14import java.util.Map;
15import java.util.UUID;
16
17import javax.persistence.Entity;
18import javax.xml.bind.annotation.XmlAccessType;
19import javax.xml.bind.annotation.XmlAccessorType;
20import javax.xml.bind.annotation.XmlAttribute;
21import javax.xml.bind.annotation.XmlType;
22
23import org.apache.log4j.Logger;
24import org.hibernate.envers.Audited;
25import org.hibernate.search.annotations.Field;
26import org.hibernate.search.annotations.Index;
27import 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 * @version 1.0
34 * @created 08-Nov-2007 13:06:33
35 */
36@XmlAccessorType(XmlAccessType.FIELD)
37@XmlType(name = "MarkerType")
38@Entity
39@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
40@Audited
41public class MarkerType extends DefinedTermBase<MarkerType> {
42        private static final long serialVersionUID = -9117424749919907396L;
43        public static final Logger logger = Logger.getLogger(MarkerType.class);
44
45        private static final UUID uuidImported = UUID.fromString("96878790-4ceb-42a2-9738-a2242079b679");
46        private static final UUID uuidToBeChecked = UUID.fromString("34204192-b41d-4857-a1d4-28992bef2a2a");
47        private static final UUID uuidIsDoubtful = UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e");
48        private static final UUID uuidComplete = UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433");
49        private static final UUID uuidPublish = UUID.fromString("0522c2b3-b21c-400c-80fc-a251c3501dbc");
50        private static final UUID uuidInBibliography = UUID.fromString("2cdb492e-3b8b-4784-8c26-25159835231d");
51        private static final UUID uuidEndemic = UUID.fromString("efe95ade-8a6c-4a0e-800e-437c8b50c45e");
52        private static final UUID uuidModifiable = UUID.fromString("c21bc83f-c8ae-4126-adee-10dfe817e96a");
53        private static final UUID uuidUse = UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039");
54       
55        protected static Map<UUID, MarkerType> termMap = null;         
56
57        public static MarkerType NewInstance(String term, String label, String labelAbbrev){
58                return new MarkerType(term, label, labelAbbrev);
59        }
60       
61       
62       
63    @XmlAttribute(name = "isTechnical")
64    @Field(index=Index.UN_TOKENIZED)
65    private boolean isTechnical=false;
66   
67
68
69       
70        /**
71         * Constructor
72         * @param term
73         * @param label
74         */
75        public MarkerType() {
76        }
77
78        /**
79         * A flag indicating if markers of this type are user content or technical information
80         * to be used by applications only. E.g. a FeatureTree may have a marker that defines
81         * the role of this FeatureTree ("for ordering") whereas a {@link eu.etaxonomy.cdm.model.taxon.Taxon taxon}
82         * may have a user defined marker "completed" that indicates that this taxon does not
83         * need further investigation. The earlier will be flagged isTechnical=true whereas
84         * the later will be flagged as isTechnical=false
85         * @return the isTechnical
86         */
87        public boolean isTechnical() {
88                return isTechnical;
89        }
90
91        /**
92         * @param isTechnical the isTechnical to set
93         */
94        public void setTechnical(boolean isTechnical) {
95                this.isTechnical = isTechnical;
96        }
97       
98//***************************** CONSTRUCTOR **************************************/     
99
100        /**
101         * Constructor
102         * @param term
103         * @param label
104         */
105        protected MarkerType(String term, String label, String labelAbbrev) {
106                super(term, label, labelAbbrev);
107        }
108
109//***************************** TERMS **************************************/
110   
111       
112        /* (non-Javadoc)
113         * @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
114         */
115        @Override
116        public void resetTerms(){
117                termMap = null;
118        }
119
120       
121        protected static MarkerType getTermByUuid(UUID uuid){
122                if (termMap == null){
123                        DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
124                        vocabularyStore.initialize();
125                }
126                return (MarkerType)termMap.get(uuid);
127        }
128       
129        public static final MarkerType IMPORTED(){
130                return getTermByUuid(uuidImported);
131        }
132
133        public static final MarkerType TO_BE_CHECKED(){
134                return getTermByUuid(uuidToBeChecked);
135        }
136
137        public static final MarkerType IS_DOUBTFUL(){
138                return getTermByUuid(uuidIsDoubtful);
139        }
140
141        public static final MarkerType COMPLETE(){
142                return getTermByUuid(uuidComplete);
143        }
144
145        public static final MarkerType PUBLISH(){
146                return getTermByUuid(uuidPublish);
147        }
148       
149        public static final MarkerType IN_BIBLIOGRAPHY(){
150                return getTermByUuid(uuidInBibliography);
151        }
152
153        public static final MarkerType ENDEMIC(){
154                return getTermByUuid(uuidEndemic);
155        }
156       
157        public static final MarkerType MODIFIABLE(){
158                return getTermByUuid(uuidModifiable);
159        }
160        public static final MarkerType USE(){
161                return getTermByUuid(uuidUse);
162        }
163       
164        @Override
165        protected void setDefaultTerms(TermVocabulary<MarkerType> termVocabulary) {
166                termMap = new HashMap<UUID, MarkerType>();
167                for (MarkerType term : termVocabulary.getTerms()){
168                        termMap.put(term.getUuid(), (MarkerType)term);
169                }
170        }
171
172}
Note: See TracBrowser for help on using the browser.