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
|
package eu.etaxonomy.cdm.model.common;
|
10
|
|
11
|
import java.util.HashMap;
|
12
|
import java.util.Map;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import javax.persistence.Entity;
|
16
|
import javax.xml.bind.annotation.XmlAccessType;
|
17
|
import javax.xml.bind.annotation.XmlAccessorType;
|
18
|
import javax.xml.bind.annotation.XmlRootElement;
|
19
|
import javax.xml.bind.annotation.XmlType;
|
20
|
|
21
|
import org.hibernate.envers.Audited;
|
22
|
import org.hibernate.search.annotations.Indexed;
|
23
|
|
24
|
|
25
|
/**
|
26
|
* @author a.mueller
|
27
|
* @created 2013-06-19
|
28
|
*
|
29
|
*/
|
30
|
@XmlAccessorType(XmlAccessType.FIELD)
|
31
|
@XmlType(name = "DefinedTerm")
|
32
|
@XmlRootElement(name = "DefinedTerm")
|
33
|
@Entity
|
34
|
@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
|
35
|
@Audited
|
36
|
public class DefinedTerm extends DefinedTermBase<DefinedTerm> implements Comparable<DefinedTerm> {
|
37
|
private static final long serialVersionUID = -6965540410672076893L;
|
38
|
|
39
|
//Determination modifier
|
40
|
public static final UUID uuidConfer = UUID.fromString("20db670a-2db2-49cc-bbdd-eace33694b7f");
|
41
|
public static final UUID uuidAffinis = UUID.fromString("128f0b54-73e2-4efb-bfda-a6243185a562");
|
42
|
|
43
|
//Sex
|
44
|
private static final UUID uuidMale = UUID.fromString("600a5212-cc02-431d-8a80-2bf595bd1eab");
|
45
|
private static final UUID uuidFemale = UUID.fromString("b4cfe0cb-b35c-4f97-9b6b-2b3c096ea2c0");
|
46
|
private static final UUID uuidHermaphrodite = UUID.fromString("0deddc65-2505-4c77-91a7-17d0de24afcc");
|
47
|
private static final UUID uuidUnknown = UUID.fromString("4f5e4c51-a664-48ad-8238-2e9f49eaf8dd");
|
48
|
|
49
|
//Marker
|
50
|
private static final UUID uuidIts1 = UUID.fromString("3f2de4f6-d1a2-4c3a-be70-3c997ef92543");
|
51
|
|
52
|
//kindOfUnit
|
53
|
public static final UUID uuidSpecimenScan = UUID.fromString("acda15be-c0e2-4ea8-8783-b9b0c4ad7f03");
|
54
|
public static final UUID uuidDetailImage = UUID.fromString("31eb8d02-bf5d-437c-bcc6-87a626445f34");
|
55
|
//...
|
56
|
|
57
|
|
58
|
protected static Map<UUID, DefinedTerm> termMap = null;
|
59
|
|
60
|
|
61
|
protected static DefinedTerm getTermByUuid(UUID uuid){
|
62
|
if (termMap == null){
|
63
|
return null;
|
64
|
}else{
|
65
|
return termMap.get(uuid);
|
66
|
}
|
67
|
}
|
68
|
|
69
|
|
70
|
public static DefinedTerm NewInstance(TermType termType, String description, String label, String labelAbbrev){
|
71
|
return new DefinedTerm(termType, description, label, labelAbbrev);
|
72
|
}
|
73
|
|
74
|
|
75
|
public static DefinedTerm NewModifierInstance(String description, String label, String labelAbbrev){
|
76
|
return new DefinedTerm(TermType.Modifier, description, label, labelAbbrev);
|
77
|
}
|
78
|
|
79
|
public static DefinedTerm NewInstitutionTypeInstance(String description, String label, String labelAbbrev){
|
80
|
return new DefinedTerm(TermType.InstitutionType, description, label, labelAbbrev);
|
81
|
}
|
82
|
|
83
|
public static DefinedTerm NewStageInstance(String description, String label, String labelAbbrev){
|
84
|
return new DefinedTerm(TermType.Stage, description, label, labelAbbrev);
|
85
|
}
|
86
|
|
87
|
public static DefinedTerm NewSexInstance(String description, String label, String labelAbbrev){
|
88
|
return new DefinedTerm(TermType.Sex, description, label, labelAbbrev);
|
89
|
}
|
90
|
|
91
|
public static DefinedTerm NewScopeInstance(String description, String label, String labelAbbrev){
|
92
|
return new DefinedTerm(TermType.Scope, description, label, labelAbbrev);
|
93
|
}
|
94
|
|
95
|
public static DefinedTerm NewDnaMarkerInstance(String description, String label, String labelAbbrev){
|
96
|
return new DefinedTerm(TermType.DnaMarker, description, label, labelAbbrev);
|
97
|
}
|
98
|
|
99
|
public static DefinedTerm NewKindOfUnitInstance(String description, String label, String labelAbbrev){
|
100
|
return new DefinedTerm(TermType.KindOfUnit, description, label, labelAbbrev);
|
101
|
}
|
102
|
|
103
|
public static DefinedTerm NewIdentifierTypeInstance(String description, String label, String labelAbbrev){
|
104
|
return new DefinedTerm(TermType.IdentifierType, description, label, labelAbbrev);
|
105
|
}
|
106
|
|
107
|
//******************* CONSTRUCTOR ***********************************/
|
108
|
|
109
|
//for hibernate/javassist use only
|
110
|
@Deprecated
|
111
|
protected DefinedTerm(){super(TermType.Unknown);}
|
112
|
|
113
|
public DefinedTerm(TermType type, String description, String label, String labelAbbrev) {
|
114
|
super(type, description, label, labelAbbrev);
|
115
|
}
|
116
|
|
117
|
//*************************** TERM MAP *********************/
|
118
|
|
119
|
|
120
|
public static final DefinedTerm DETERMINATION_MODIFIER_AFFINIS(){
|
121
|
return getTermByUuid(uuidAffinis);
|
122
|
}
|
123
|
|
124
|
public static final DefinedTerm DETERMINATION_MODIFIER_CONFER(){
|
125
|
return getTermByUuid(uuidConfer);
|
126
|
}
|
127
|
|
128
|
public static DefinedTerm SEX_MALE(){
|
129
|
return getTermByUuid(uuidMale);
|
130
|
}
|
131
|
|
132
|
public static DefinedTerm SEX_FEMALE(){
|
133
|
return getTermByUuid(uuidFemale);
|
134
|
}
|
135
|
|
136
|
public static DefinedTerm SEX_HERMAPHRODITE(){
|
137
|
return getTermByUuid(uuidHermaphrodite);
|
138
|
}
|
139
|
|
140
|
public static DefinedTerm SEX_UNKNOWN(){
|
141
|
return getTermByUuid(uuidUnknown);
|
142
|
}
|
143
|
|
144
|
public static DefinedTerm ITS1_MARKER(){
|
145
|
return getTermByUuid(uuidIts1);
|
146
|
}
|
147
|
|
148
|
|
149
|
@Override
|
150
|
public void resetTerms() {
|
151
|
termMap = null;
|
152
|
}
|
153
|
|
154
|
@Override
|
155
|
protected void setDefaultTerms(TermVocabulary<DefinedTerm> termVocabulary) {
|
156
|
if (termMap == null){
|
157
|
termMap = new HashMap<UUID, DefinedTerm>();
|
158
|
}
|
159
|
for (DefinedTerm term : termVocabulary.getTerms()){
|
160
|
termMap.put(term.getUuid(), term);
|
161
|
}
|
162
|
}
|
163
|
|
164
|
@Override
|
165
|
protected int partOfCsvLineIndex(){
|
166
|
return 5;
|
167
|
}
|
168
|
|
169
|
// @Override
|
170
|
// void readIsPartOf(DefinedTerm newInstance, List<String> csvLine, Map<UUID, DefinedTermBase> terms) {
|
171
|
// int index = 7;
|
172
|
// String partOfString = csvLine.get(index);
|
173
|
//
|
174
|
// if(StringUtils.isNotBlank(partOfString)) {
|
175
|
// UUID partOfUuid = UUID.fromString(partOfString);
|
176
|
// DefinedTerm partOf = (DefinedTerm)terms.get(partOfUuid);
|
177
|
// partOf.addIncludes(newInstance);
|
178
|
// }
|
179
|
//
|
180
|
// }
|
181
|
|
182
|
}
|