e8bfe3701b3412c0c0d5363f3899b56d640fc277
[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
16 import java.util.*;
17
18 import javax.persistence.*;
19 import javax.xml.bind.annotation.XmlAccessType;
20 import javax.xml.bind.annotation.XmlAccessorType;
21 import javax.xml.bind.annotation.XmlType;
22
23 /**
24 * Marker types similar to dynamically defined attributes. These content types
25 * like "IS_DOUBTFUL", "COMPLETE" or specific local flags.
26 * @author m.doering
27 * @version 1.0
28 * @created 08-Nov-2007 13:06:33
29 */
30 @XmlAccessorType(XmlAccessType.FIELD)
31 @XmlType(name = "MarkerType")
32 @Entity
33 @Audited
34 public class MarkerType extends DefinedTermBase<MarkerType> {
35 private static final long serialVersionUID = -9117424749919907396L;
36 public static final Logger logger = Logger.getLogger(MarkerType.class);
37
38 private static final UUID uuidImported = UUID.fromString("96878790-4ceb-42a2-9738-a2242079b679");
39 private static final UUID uuidToBeChecked = UUID.fromString("34204192-b41d-4857-a1d4-28992bef2a2a");
40 private static final UUID uuidIsDoubtful = UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e");
41 private static final UUID uuidComplete = UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433");
42 private static final UUID uuidPublish = UUID.fromString("0522c2b3-b21c-400c-80fc-a251c3501dbc");
43 private static final UUID uuidInBibliography = UUID.fromString("2cdb492e-3b8b-4784-8c26-25159835231d");
44
45 protected static Map<UUID, MarkerType> termMap = null;
46
47 public static MarkerType NewInstance(String term, String label, String labelAbbrev){
48 return new MarkerType(term, label, labelAbbrev);
49 }
50
51 protected static MarkerType getTermByUuid(UUID uuid){
52 if (termMap == null){
53 DefaultTermInitializer vocabularyStore = new DefaultTermInitializer();
54 vocabularyStore.initialize();
55 }
56 return (MarkerType)termMap.get(uuid);
57 }
58
59
60 /**
61 * Constructor
62 * @param term
63 * @param label
64 */
65 public MarkerType() {
66 }
67
68 /**
69 * Constructor
70 * @param term
71 * @param label
72 */
73 protected MarkerType(String term, String label, String labelAbbrev) {
74 super(term, label, labelAbbrev);
75 }
76
77
78 public static final MarkerType IMPORTED(){
79 return getTermByUuid(uuidImported);
80 }
81
82 public static final MarkerType TO_BE_CHECKED(){
83 return getTermByUuid(uuidToBeChecked);
84 }
85
86 public static final MarkerType IS_DOUBTFUL(){
87 return getTermByUuid(uuidIsDoubtful);
88 }
89
90 public static final MarkerType COMPLETE(){
91 return getTermByUuid(uuidComplete);
92 }
93
94 public static final MarkerType PUBLISH(){
95 return getTermByUuid(uuidPublish);
96 }
97
98 public static final MarkerType IN_BIBLIOGRAPHY(){
99 return getTermByUuid(uuidInBibliography);
100 }
101
102 @Override
103 protected void setDefaultTerms(TermVocabulary<MarkerType> termVocabulary) {
104 termMap = new HashMap<UUID, MarkerType>();
105 for (MarkerType term : termVocabulary.getTerms()){
106 termMap.put(term.getUuid(), (MarkerType)term);
107 }
108 }
109
110 }