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
|
|
28
|
import eu.etaxonomy.cdm.model.term.TermType;
|
29
|
import eu.etaxonomy.cdm.model.term.TermVocabulary;
|
30
|
|
31
|
/**
|
32
|
* Marker types similar to dynamically defined attributes. These content types
|
33
|
* like "IS_DOUBTFUL", "COMPLETE" or specific local flags.
|
34
|
* @author m.doering
|
35
|
* @since 08-Nov-2007 13:06:33
|
36
|
*/
|
37
|
@XmlAccessorType(XmlAccessType.FIELD)
|
38
|
@XmlType(name = "MarkerType")
|
39
|
@Entity
|
40
|
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
|
41
|
//@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
|
42
|
@Audited
|
43
|
public class MarkerType extends AvailableForIdentifiableBase<MarkerType> {
|
44
|
|
45
|
private static final long serialVersionUID = -9117424749919907396L;
|
46
|
public static final Logger logger = Logger.getLogger(MarkerType.class);
|
47
|
|
48
|
private static final UUID uuidImported = UUID.fromString("96878790-4ceb-42a2-9738-a2242079b679");
|
49
|
private static final UUID uuidToBeChecked = UUID.fromString("34204192-b41d-4857-a1d4-28992bef2a2a");
|
50
|
private static final UUID uuidIsDoubtful = UUID.fromString("b51325c8-05fe-421a-832b-d86fc249ef6e");
|
51
|
public static final UUID uuidComplete = UUID.fromString("b4b1b2ab-89a8-4ce6-8110-d60b8b1bc433");
|
52
|
private static final UUID uuidPublish = UUID.fromString("0522c2b3-b21c-400c-80fc-a251c3501dbc");
|
53
|
private static final UUID uuidInBibliography = UUID.fromString("2cdb492e-3b8b-4784-8c26-25159835231d");
|
54
|
private static final UUID uuidEndemic = UUID.fromString("efe95ade-8a6c-4a0e-800e-437c8b50c45e");
|
55
|
private static final UUID uuidModifiable = UUID.fromString("c21bc83f-c8ae-4126-adee-10dfe817e96a");
|
56
|
private static final UUID uuidUse = UUID.fromString("2e6e42d9-e92a-41f4-899b-03c0ac64f039");
|
57
|
private static final UUID uuidComputed = UUID.fromString("5cc15a73-2947-44e3-9319-85dd20736e55");
|
58
|
private static final UUID uuidNomenclaturalRelevant = UUID.fromString("d520ffd4-4a59-453d-b2a1-cbaa50136439");
|
59
|
private static final UUID uuidCommonNameReference = UUID.fromString("ad315454-5fdc-492d-8c8c-5d98a5ec4b7f");
|
60
|
private static final UUID uuidDistributionEditorFact = UUID.fromString("bc55aea8-5a99-49b6-8ad2-fa6eecf27736");
|
61
|
|
62
|
//E+M, maybe general in future
|
63
|
public static final UUID uuidEpublished = UUID.fromString("212158af-c8cf-4b15-ab22-8d06667ea7e1");
|
64
|
|
65
|
public static final UUID uuidFallbackArea = UUID.fromString("e2b42891-aa85-4a09-981b-b7d8f5749c54");
|
66
|
|
67
|
|
68
|
protected static Map<UUID, MarkerType> termMap = null;
|
69
|
|
70
|
@XmlAttribute(name = "isTechnical")
|
71
|
@Field(analyze = Analyze.NO)
|
72
|
private boolean isTechnical=false;
|
73
|
|
74
|
// ***************************** FACTORY METHODD ************************/
|
75
|
|
76
|
public static MarkerType NewInstance(String term, String label, String labelAbbrev){
|
77
|
return new MarkerType(term, label, labelAbbrev);
|
78
|
}
|
79
|
|
80
|
|
81
|
// ***************************** CONSTRUCTOR ******************************/
|
82
|
|
83
|
//for hibernate use only
|
84
|
@Deprecated
|
85
|
protected MarkerType() {
|
86
|
super(TermType.MarkerType);
|
87
|
}
|
88
|
|
89
|
//***************************** CONSTRUCTOR **************************************/
|
90
|
|
91
|
private MarkerType(String term, String label, String labelAbbrev) {
|
92
|
super(TermType.MarkerType, term, label, labelAbbrev);
|
93
|
}
|
94
|
|
95
|
// ******************** METHODS **************************************************/
|
96
|
|
97
|
/**
|
98
|
* A flag indicating if markers of this type are user content or technical information
|
99
|
* to be used by applications only. E.g. a TermTree may have a marker that defines
|
100
|
* the role of this TermTree ("for ordering") whereas a {@link eu.etaxonomy.cdm.model.taxon.Taxon taxon}
|
101
|
* may have a user defined marker "completed" that indicates that this taxon does not
|
102
|
* need further investigation. The earlier will be flagged isTechnical=true whereas
|
103
|
* the later will be flagged as isTechnical=false
|
104
|
* @return the isTechnical
|
105
|
*/
|
106
|
public boolean isTechnical() {
|
107
|
return isTechnical;
|
108
|
}
|
109
|
|
110
|
/**
|
111
|
* @param isTechnical the isTechnical to set
|
112
|
*/
|
113
|
public void setTechnical(boolean isTechnical) {
|
114
|
this.isTechnical = isTechnical;
|
115
|
}
|
116
|
|
117
|
//***************************** TERMS **************************************/
|
118
|
|
119
|
@Override
|
120
|
public void resetTerms(){
|
121
|
termMap = null;
|
122
|
}
|
123
|
|
124
|
|
125
|
protected static MarkerType getTermByUuid(UUID uuid){
|
126
|
if (termMap == null || termMap.isEmpty()){
|
127
|
return getTermByClassAndUUID(MarkerType.class, uuid);
|
128
|
} else {
|
129
|
return termMap.get(uuid);
|
130
|
}
|
131
|
}
|
132
|
|
133
|
public static final MarkerType IMPORTED(){
|
134
|
return getTermByUuid(uuidImported);
|
135
|
}
|
136
|
|
137
|
public static final MarkerType TO_BE_CHECKED(){
|
138
|
return getTermByUuid(uuidToBeChecked);
|
139
|
}
|
140
|
|
141
|
public static final MarkerType IS_DOUBTFUL(){
|
142
|
return getTermByUuid(uuidIsDoubtful);
|
143
|
}
|
144
|
|
145
|
public static final MarkerType COMPLETE(){
|
146
|
return getTermByUuid(uuidComplete);
|
147
|
}
|
148
|
|
149
|
public static final MarkerType PUBLISH(){
|
150
|
return getTermByUuid(uuidPublish);
|
151
|
}
|
152
|
|
153
|
public static final MarkerType IN_BIBLIOGRAPHY(){
|
154
|
return getTermByUuid(uuidInBibliography);
|
155
|
}
|
156
|
|
157
|
public static final MarkerType ENDEMIC(){
|
158
|
return getTermByUuid(uuidEndemic);
|
159
|
}
|
160
|
|
161
|
public static final MarkerType MODIFIABLE(){
|
162
|
return getTermByUuid(uuidModifiable);
|
163
|
}
|
164
|
|
165
|
public static final MarkerType USE(){
|
166
|
return getTermByUuid(uuidUse);
|
167
|
}
|
168
|
|
169
|
public static final MarkerType COMPUTED(){
|
170
|
return getTermByUuid(uuidComputed);
|
171
|
}
|
172
|
|
173
|
// added in preparation for #7466
|
174
|
public static final MarkerType NOMENCLATURAL_RELEVANT(){
|
175
|
return getTermByUuid(uuidNomenclaturalRelevant);
|
176
|
}
|
177
|
|
178
|
|
179
|
public static final MarkerType COMMON_NAME_REFERENCE(){
|
180
|
return getTermByUuid(uuidCommonNameReference);
|
181
|
}
|
182
|
|
183
|
public static final MarkerType DISTRIBUTION_EDITOR_FACT(){
|
184
|
return getTermByUuid(uuidDistributionEditorFact);
|
185
|
}
|
186
|
|
187
|
@Override
|
188
|
protected void setDefaultTerms(TermVocabulary<MarkerType> termVocabulary) {
|
189
|
termMap = new HashMap<UUID, MarkerType>();
|
190
|
for (MarkerType term : termVocabulary.getTerms()){
|
191
|
termMap.put(term.getUuid(), term);
|
192
|
}
|
193
|
}
|
194
|
|
195
|
}
|