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.name;
|
11
|
|
12
|
import java.util.Set;
|
13
|
import java.util.UUID;
|
14
|
|
15
|
import javax.persistence.Transient;
|
16
|
import javax.xml.bind.annotation.XmlEnum;
|
17
|
import javax.xml.bind.annotation.XmlEnumValue;
|
18
|
import javax.xml.bind.annotation.XmlType;
|
19
|
|
20
|
import org.apache.log4j.Logger;
|
21
|
|
22
|
import eu.etaxonomy.cdm.model.common.EnumeratedTermVoc;
|
23
|
import eu.etaxonomy.cdm.model.common.IEnumTerm;
|
24
|
import eu.etaxonomy.cdm.model.common.Language;
|
25
|
|
26
|
/**
|
27
|
* The class for the five nomenclature codes (ICNB, ICBN, ICNCP, ICZN and ICVCN)
|
28
|
* ruling {@link TaxonNameBase taxon names}.
|
29
|
* <P>
|
30
|
* The standard set of nomenclature code instances will be automatically created
|
31
|
* as the project starts. But this class allows to extend this standard set by
|
32
|
* creating new instances of additional nomenclature codes if unlikely needed.
|
33
|
* <P>
|
34
|
* This class corresponds to: <ul>
|
35
|
* <li> NomenclaturalCodeTerm according to the TDWG ontology
|
36
|
* <li> NomenclaturalCodesEnum according to the TCS
|
37
|
* <li> CodeOfNomenclatureEnum according to the ABCD schema
|
38
|
* </ul>
|
39
|
*
|
40
|
* @author a.mueller
|
41
|
* @created 19.05.2008
|
42
|
* @version 2.0
|
43
|
*/
|
44
|
|
45
|
@XmlType(name = "NomenclaturalCode")
|
46
|
@XmlEnum
|
47
|
public enum NomenclaturalCode implements IEnumTerm<NomenclaturalCode> {
|
48
|
//0
|
49
|
/**
|
50
|
* International Code of Nomenclature of Bacteria
|
51
|
*/
|
52
|
@XmlEnumValue("ICNB")
|
53
|
ICNB(UUID.fromString("ff4b0979-7abf-4b40-95c0-8b8b1e8a4d5e"), "ICNB"),
|
54
|
|
55
|
//1
|
56
|
/**
|
57
|
* International Code of Nomenclature for algae, fungi, and plants
|
58
|
* Former International Code of Botanical Nomenclature
|
59
|
*/
|
60
|
@XmlEnumValue("ICNAFP")
|
61
|
ICNAFP(UUID.fromString("540fc02a-8a8e-4813-89d2-581dad4dd482"), "ICNAFP"),
|
62
|
|
63
|
//2
|
64
|
/**
|
65
|
* International Code of Cultivated Plants
|
66
|
*/
|
67
|
@XmlEnumValue("ICNCP")
|
68
|
ICNCP(UUID.fromString("65a432b5-92b1-4c9a-8090-2a185e423d2e"),"ICNCP"),
|
69
|
|
70
|
//3
|
71
|
/**
|
72
|
* International Code of Zoological Nomenclature
|
73
|
*/
|
74
|
@XmlEnumValue("ICZN")
|
75
|
ICZN(UUID.fromString("b584c2f8-dbe5-4454-acad-2b45e63ec11b"), "ICZN"),
|
76
|
|
77
|
//4
|
78
|
/**
|
79
|
* International Code for Virus Classification and Nomenclature
|
80
|
*/
|
81
|
@XmlEnumValue("ICVCN") ICVCN(UUID.fromString("e9d6d6b4-ccb7-4f28-b828-0b1501f8c75a"), "ICVCN");
|
82
|
|
83
|
private static final Logger logger = Logger.getLogger(NomenclaturalCode.class);
|
84
|
|
85
|
public String getTitleCache() {
|
86
|
return getMessage();
|
87
|
}
|
88
|
|
89
|
private NomenclaturalCode(UUID uuid, String titleCache){
|
90
|
delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, titleCache, titleCache, null);
|
91
|
}
|
92
|
|
93
|
|
94
|
|
95
|
/* (non-Javadoc)
|
96
|
* @see java.lang.Enum#toString()
|
97
|
*/
|
98
|
@Override
|
99
|
public String toString() {
|
100
|
return "NomenclaturalCode" + " <" + getUuid() + "> " + this.name();
|
101
|
}
|
102
|
|
103
|
public static NomenclaturalCode fromString(String string){
|
104
|
for(NomenclaturalCode code : NomenclaturalCode.values()){
|
105
|
if(code.name().equals(string)) {
|
106
|
return code;
|
107
|
}
|
108
|
}
|
109
|
if ("ICBN".equals(string)){ //former name of the ICNAFP
|
110
|
return ICNAFP;
|
111
|
}
|
112
|
return null;
|
113
|
}
|
114
|
|
115
|
/**
|
116
|
* Creates a new particular {@link TaxonNameBase taxon name} (botanical, zoological,
|
117
|
* cultivar plant, bacterial or viral name) instance depending on <i>this</i>
|
118
|
* nomenclature code only containing the given {@link Rank rank}.
|
119
|
*
|
120
|
* @param rank the rank of the new taxon name instance
|
121
|
* @see BotanicalName#NewInstance(Rank)
|
122
|
* @see ZoologicalName#NewInstance(Rank)
|
123
|
* @see CultivarPlantName#NewInstance(Rank)
|
124
|
* @see BacterialName#NewInstance(Rank)
|
125
|
* @see ViralName#NewInstance(Rank)
|
126
|
*/
|
127
|
public TaxonNameBase<?,?> getNewTaxonNameInstance(Rank rank){
|
128
|
TaxonNameBase<?,?> result;
|
129
|
|
130
|
switch (this){
|
131
|
case ICNAFP:
|
132
|
result = BotanicalName.NewInstance(rank);
|
133
|
break;
|
134
|
case ICZN:
|
135
|
result = ZoologicalName.NewInstance(rank);
|
136
|
break;
|
137
|
case ICNCP:
|
138
|
result = CultivarPlantName.NewInstance(rank);
|
139
|
break;
|
140
|
case ICNB:
|
141
|
result = BacterialName.NewInstance(rank);
|
142
|
break;
|
143
|
case ICVCN:
|
144
|
result = ViralName.NewInstance(rank);
|
145
|
break;
|
146
|
default:
|
147
|
logger.warn("Unknown nomenclatural code: " + this.getUuid());
|
148
|
result = null;
|
149
|
}
|
150
|
return result;
|
151
|
}
|
152
|
|
153
|
/**
|
154
|
* Creates a new particular {@link TaxonNameBase taxon name} (botanical, zoological,
|
155
|
* cultivar plant, bacterial or viral name) instance depending on <i>this</i>
|
156
|
* nomenclature code only containing the given {@link Rank rank}.
|
157
|
*
|
158
|
* @param rank the rank of the new taxon name instance
|
159
|
* @see BotanicalName#NewInstance(Rank)
|
160
|
* @see ZoologicalName#NewInstance(Rank)
|
161
|
* @see CultivarPlantName#NewInstance(Rank)
|
162
|
* @see BacterialName#NewInstance(Rank)
|
163
|
* @see ViralName#NewInstance(Rank)
|
164
|
*/
|
165
|
@Transient
|
166
|
public <T extends TaxonNameBase> Class<? extends T> getCdmClass(){
|
167
|
Class<? extends T> result;
|
168
|
switch (this){
|
169
|
case ICNAFP:
|
170
|
result = (Class<T>)BotanicalName.class;
|
171
|
break;
|
172
|
case ICZN:
|
173
|
result = (Class<T>)ZoologicalName.class;
|
174
|
break;
|
175
|
case ICNCP:
|
176
|
result = (Class<T>)CultivarPlantName.class;
|
177
|
break;
|
178
|
case ICNB:
|
179
|
result = (Class<T>)BacterialName.class;
|
180
|
break;
|
181
|
case ICVCN:
|
182
|
result = (Class<T>)ViralName.class;
|
183
|
break;
|
184
|
default:
|
185
|
logger.warn("Unknown nomenclatural code: " + this.getUuid());
|
186
|
result = null;
|
187
|
}
|
188
|
return result;
|
189
|
}
|
190
|
|
191
|
/**
|
192
|
* Returns the recommended value for the accepted taxon status according to
|
193
|
* http://code.google.com/p/darwincore/wiki/Taxon#taxonomicStatus
|
194
|
*/
|
195
|
public String acceptedTaxonStatusLabel(){
|
196
|
switch(this){
|
197
|
case ICNAFP:
|
198
|
return "accepted";
|
199
|
case ICZN:
|
200
|
return "valid";
|
201
|
default:
|
202
|
logger.error("Not implemented yet");
|
203
|
return "accepted";
|
204
|
}
|
205
|
}
|
206
|
|
207
|
/**
|
208
|
* Returns the recommended value for the accepted taxon status according to
|
209
|
* http://code.google.com/p/darwincore/wiki/Taxon#taxonomicStatus
|
210
|
*/
|
211
|
public String synonymStatusLabel(){
|
212
|
switch(this){
|
213
|
case ICNAFP:
|
214
|
return "synonym";
|
215
|
case ICZN:
|
216
|
return "invalid";
|
217
|
default:
|
218
|
logger.error("Not implemented yet");
|
219
|
return "synonym";
|
220
|
}
|
221
|
}
|
222
|
|
223
|
// *************************** DELEGATE **************************************/
|
224
|
|
225
|
private static EnumeratedTermVoc<NomenclaturalCode> delegateVoc;
|
226
|
private IEnumTerm<NomenclaturalCode> delegateVocTerm;
|
227
|
|
228
|
static {
|
229
|
delegateVoc = EnumeratedTermVoc.getVoc(NomenclaturalCode.class);
|
230
|
}
|
231
|
|
232
|
@Override
|
233
|
public String getKey(){return delegateVocTerm.getKey();}
|
234
|
|
235
|
@Override
|
236
|
public String getMessage(){return delegateVocTerm.getMessage();}
|
237
|
|
238
|
@Override
|
239
|
public String getMessage(Language language){return delegateVocTerm.getMessage(language);}
|
240
|
|
241
|
|
242
|
@Override
|
243
|
public UUID getUuid() {return delegateVocTerm.getUuid();}
|
244
|
|
245
|
@Override
|
246
|
public NomenclaturalCode getKindOf() {return delegateVocTerm.getKindOf();}
|
247
|
|
248
|
@Override
|
249
|
public Set<NomenclaturalCode> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
|
250
|
|
251
|
@Override
|
252
|
public boolean isKindOf(NomenclaturalCode ancestor) {return delegateVocTerm.isKindOf(ancestor); }
|
253
|
|
254
|
@Override
|
255
|
public Set<NomenclaturalCode> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
|
256
|
|
257
|
|
258
|
public static NomenclaturalCode getByKey(String key){return delegateVoc.getByKey(key);}
|
259
|
public static NomenclaturalCode getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
|
260
|
|
261
|
|
262
|
}
|