ref #9640, ref #10302 add codeEditon source to webservice
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NomenclaturalCodeEdition.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.name;
11
12 import java.util.ArrayList;
13 import java.util.List;
14 import java.util.Set;
15 import java.util.UUID;
16
17 import javax.xml.bind.annotation.XmlEnum;
18 import javax.xml.bind.annotation.XmlEnumValue;
19 import javax.xml.bind.annotation.XmlType;
20
21 import org.apache.commons.lang3.StringUtils;
22 import org.apache.logging.log4j.LogManager;
23 import org.apache.logging.log4j.Logger;
24
25 import eu.etaxonomy.cdm.common.DOI;
26 import eu.etaxonomy.cdm.common.URI;
27 import eu.etaxonomy.cdm.model.agent.Person;
28 import eu.etaxonomy.cdm.model.agent.Team;
29 import eu.etaxonomy.cdm.model.common.IdentifiableSource;
30 import eu.etaxonomy.cdm.model.common.Language;
31 import eu.etaxonomy.cdm.model.reference.Reference;
32 import eu.etaxonomy.cdm.model.reference.ReferenceFactory;
33 import eu.etaxonomy.cdm.model.term.EnumeratedTermVoc;
34 import eu.etaxonomy.cdm.model.term.IEnumTerm;
35 import eu.etaxonomy.cdm.strategy.parser.TimePeriodParser;
36
37 /**
38 * The class for the nomenclature code edition of the 5 nomenclatural codes (ICNP, ICBN, ICNCP, ICZN and ICVCN)
39 * ruling {@link TaxonName taxon names}.
40 * <P>
41 * See also https://www.wikidata.org/wiki/Q693148
42 * <P>
43 * @see NomenclaturalCode
44 *
45 * @author a.mueller
46 * @since 23.07.2019
47 */
48
49 @XmlType(name = "NomenclaturalCodeEdition")
50 @XmlEnum
51 public enum NomenclaturalCodeEdition implements IEnumTerm<NomenclaturalCodeEdition> {
52
53 //0
54 /**
55 * International Code of Nomenclature for algae, fungi, and plants.
56 * Shenzhen 2017
57 * Turland, N. J., Wiersema, J. H., Barrie, F. R., Greuter, W., Hawksworth, D. L., Herendeen, P. S., Knapp, S., Kusber, W.-H., Li, D.-Z., Marhold, K., May, T. W., McNeill, J., Monro, A. M., Prado, J., Price, M. J. & Smith, G. F. (eds.) 2018: International Code of Nomenclature for algae, fungi, and plants (Shenzhen Code) adopted by the Nineteenth International Botanical Congress Shenzhen, China, July 2017. Regnum Vegetabile 159. Glashütten: Koeltz Botanical Books. DOI https://doi.org/10.12705/Code.2018
58 */
59 @XmlEnumValue("Shenzhen")
60 ICN_2017_SHENZHEN(UUID.fromString("87e8ac37-97c4-43c7-a016-43f1a5c3503f"), "ICN", "Shenzhen", 2017, NomenclaturalCode.ICNAFP, "Q56701992","10.12705/Code.2018" ),
61
62 //1
63 /**
64 * International Code of Nomenclature for algae, fungi, and plants.
65 * Melbourne 2011
66 */
67 @XmlEnumValue("Melbourne")
68 ICN_2011_MELBOURNE(UUID.fromString("ea2ebf9e-e3eb-4aaf-8007-c6f9f8877451"), "ICN", "Melbourne", 2011, NomenclaturalCode.ICNAFP, "Q15895076", null),
69
70 //2
71 /**
72 * International Code of Botanical Nomenclature.
73 * Vienna 2005
74 */
75 @XmlEnumValue("Vienna")
76 ICN_2005_VIENNA(UUID.fromString("d8f9f3d6-96af-4d83-a8d5-04ff62ba4d9c"), "ICBN", "Vienna", 2005, NomenclaturalCode.ICNAFP, "Q15895126", null),
77
78 //3
79 /**
80 * International Code of Botanical Nomenclature.
81 * Saint Louis 1999
82 */
83 @XmlEnumValue("Saint Louis")
84 ICN_1999_ST_LOUIS(UUID.fromString("2746b72e-43be-4073-90d0-494a7afac271"), "ICBN", "Saint Louis", 1999, NomenclaturalCode.ICNAFP, "Q15895151", null),
85
86 //4
87 /**
88 * International Code of Botanical Nomenclature.
89 * Tokyo 1993
90 */
91 @XmlEnumValue("Tokyo")
92 ICN_1993_TOKYO(UUID.fromString("5a846761-839f-4f77-b614-7181b9b29355"), "ICBN", "Tokyo", 1993, NomenclaturalCode.ICNAFP, "Q15895201", null),
93
94 //5
95 /**
96 * International Code of Botanical Nomenclature.
97 * Berlin 1987
98 */
99 @XmlEnumValue("Berlin")
100 ICN_1987_BERLIN(UUID.fromString("5702fc16-e194-4ad2-bdaf-4451af523db2"), "ICBN", "Berlin", 1987, NomenclaturalCode.ICNAFP, null, null),
101
102 //6
103 /**
104 * International Code of Botanical Nomenclature.
105 * Sydney 1981
106 */
107 @XmlEnumValue("Sydney")
108 ICN_1981_Sydney(UUID.fromString("f956c556-6d79-4e0f-adeb-ed9d81f2fa24"), "ICBN", "Sydney", 1981, NomenclaturalCode.ICNAFP, null, null),
109
110 //7
111 /**
112 * International Code of Botanical Nomenclature.
113 * Leningrad 1975
114 */
115 @XmlEnumValue("Leningrad")
116 ICN_1975_TOKYO(UUID.fromString("f52e50b4-4c75-42dd-8efe-39cd966da712"), "ICBN", "Leningrad", 1975, NomenclaturalCode.ICNAFP, null, null),
117
118 //8
119 /**
120 * International Code of Botanical Nomenclature.
121 * Seattle 1969
122 */
123 @XmlEnumValue("Seattle")
124 ICN_1969_Seattle(UUID.fromString("2d19b5af-27cc-428e-affb-8a06563ff9cd"), "ICBN", "Seattle", 1969, NomenclaturalCode.ICNAFP, null, null),
125
126 //9
127 /**
128 * International Code of Botanical Nomenclature.
129 * Stockholm 1952
130 */
131 @XmlEnumValue("Stockholm")
132 ICN_1952_Stockholm(UUID.fromString("a0c07e5f-9b2b-4cd7-9f14-acd4729f175a"), "ICBN", "Stockholm", 1952, NomenclaturalCode.ICNAFP, null, null),
133
134 //10
135 /**
136 * International Code of Botanical Nomenclature.
137 * Cambridge Rules 1935
138 */
139 @XmlEnumValue("Cambridge")
140 //TODO abbrev correct?
141 ICN_1935_CAMBRIDGE(UUID.fromString("e6f7e578-2ce5-434d-9904-aaf2a6e06c43"), "ICBN", "Cambrdige", 1935, NomenclaturalCode.ICNAFP, null, null),
142
143 //11
144 /**
145 * International Code of Botanical Nomenclature.
146 * Vienna Rules 1905
147 */
148 @XmlEnumValue("Vienna 1905")
149 //TODO abbrev correct?
150 ICN_1905_VIENNA(UUID.fromString("23781153-540f-4c54-a5ae-5d6b6f490332"), "ICBN", "Vienna", 1905, NomenclaturalCode.ICNAFP, null, null),
151
152 //12
153 /**
154 * International Code of Botanical Nomenclature.
155 * Laws of botanical nomenclature 1867
156 */
157 @XmlEnumValue("Laws")
158 //TODO abbrev correct?
159 ICN_1867_LAWS(UUID.fromString("230314c3-0bb0-4488-8597-f4ef63d27781"), "ICBN", "Laws of botanical nomenclature", 1867, NomenclaturalCode.ICNAFP, null, null),
160
161
162 //*** ICZN **/
163 //z1
164 /**
165 * International Code of Zoological Nomenclature. Fourth edition. The International Trust for Zoological Nomenclature, London, UK.
166 * https://en.wikipedia.org/wiki/International_Code_of_Zoological_Nomenclature#Versions
167 */
168 @XmlEnumValue("ICZN_1999")
169 ICZN_1999(UUID.fromString("98f61693-67c5-40e1-a802-4989cb5ac4eb"), "ICZN", null, 1999, NomenclaturalCode.ICZN, null, "10.5962/bhl.title.50608"),
170
171 //z2
172 /**
173 * International Code of Zoological Nomenclature. Third edition. The International Trust for Zoological Nomenclature, London, UK.
174 * https://en.wikipedia.org/wiki/International_Code_of_Zoological_Nomenclature#Versions
175 */
176 @XmlEnumValue("ICZN_1985")
177 ICZN_1985(UUID.fromString("093110c8-f7e8-4f86-a794-e8e7b17c99d6"), "ICZN", null, 1985, NomenclaturalCode.ICZN, null, "10.5962/bhl.title.50611"),
178
179 //z3
180 /**
181 * International Code of Zoological Nomenclature. Second edition. The International Trust for Zoological Nomenclature, London, UK.
182 * https://en.wikipedia.org/wiki/International_Code_of_Zoological_Nomenclature#Versions
183 */
184 @XmlEnumValue("ICZN_1964")
185 ICZN_1964(UUID.fromString("2b4a9e59-45dd-444b-bf93-741bc727c38c"), "ICZN", null, 1964, NomenclaturalCode.ICZN, null, "10.5962/bhl.title.50606"),
186
187 //z4
188 /**
189 * International Code of Zoological Nomenclature: adopted by the XV International Congress of Zoology. The International Trust for Zoological Nomenclature, London, UK.
190 * https://en.wikipedia.org/wiki/International_Code_of_Zoological_Nomenclature#Versions
191 */
192 @XmlEnumValue("ICZN_1961")
193 ICZN_1961(UUID.fromString("b9de5507-1171-496c-8a8d-8af47e42724e"), "ICZN", null, 1961, NomenclaturalCode.ICZN, null, "10.5962/bhl.title.50303"),
194
195 //TODO older versions, see wikipedia
196
197 //bact1
198 /**
199 * Parker, C.T., Tindall, B.J. & Garrity, G.M. (2019) International Code of Nomenclature of Prokaryotes. 2008 Revision. Microbiology Society
200 * https://en.wikipedia.org/wiki/International_Code_of_Nomenclature_of_Prokaryotes#Versions
201 */
202 @XmlEnumValue("ICNP_2008")
203 ICNP_2008(UUID.fromString("1297a8e9-dfde-4db7-9f93-672453e8b3e6"), "ICNP", null, 2008, NomenclaturalCode.ICNP, null, "10.1099/ijsem.0.000778"),
204
205 //bact2
206 /**
207 * Lapage, S.P., Sneath, P.H.A., Lessel, E.F., Skerman, V.B.D., Seeliger, H.P.R. & Clark, W.A. (1992). International Code of Nomenclature of Bacteria. Bacteriological Code. 1990 Revision. American Society for Microbiology, Washington, D.C., ISBN 1-55581-039-X
208 * https://en.wikipedia.org/wiki/International_Code_of_Nomenclature_of_Prokaryotes#Versions
209 */
210 @XmlEnumValue("ICNP_1990")
211 ICNP_1990(UUID.fromString("fd5d6dd3-de58-4244-8290-c8d89323f163"), "ICNB", null, 1990, NomenclaturalCode.ICNP, null, "10.5962/bhl.title.50303"),
212
213 //bact3
214 /**
215 * Lapage, S.P., Sneath, P.H.A., Lessel, E.F., Skerman, V.B.D., Seeliger, H.P.R. & Clark, W.A. (1975). International Code of Nomenclature of Bacteria. 1975 Revision. American Society of Microbiology, Washington, D.C
216 * https://en.wikipedia.org/wiki/International_Code_of_Nomenclature_of_Prokaryotes#Versions
217 */
218 @XmlEnumValue("ICNP_1975")
219 ICNP_1975(UUID.fromString("2dafaf3c-abf6-4baf-82db-3332db25d654"), "ICNB", null, 1975, NomenclaturalCode.ICNP, null, null),
220
221 //cult plants 1
222 /**
223 * ISHS Secretariat: ICNCP - International Code for the Nomenclature for Cultivated Plants (9th edition). International Society for Horticultural Science, 15. Juni 2016
224 * https://www.ishs.org/news/icncp-international-code-nomenclature-cultivated-plants-9th-edition
225 */
226 @XmlEnumValue("ICNCP_2016")
227 ICNCP_2016(UUID.fromString("e395e7be-405f-4214-a3a2-2b19eef6a055"), "ICNCP", null, 2016, NomenclaturalCode.ICNCP, null, null),
228
229 //cult plants 2
230 /**
231 * International Code of Nomenclature for Cultivated Plants. 8th edition. [Scripta Horticulturae 10]
232 * https://www.ishs.org/news/icncp-international-code-nomenclature-cultivated-plants-9th-edition
233 */
234 @XmlEnumValue("ICNCP_2009")
235 ICNCP_2009(UUID.fromString("bc66202a-0ffb-4cf3-a1c9-520efd5e76e9"), "ICNCP", null, 2009, NomenclaturalCode.ICNCP, null, null),
236
237 //cult plants 3
238 /**
239 * SHS (International Society for Horticultural Science; Hrsg.): International Code of Nomenclature for Cultivated Plants, 7th edition. In: Acta Horticulturae Band 647, 2004. ISBN 90-6605-527-8.
240 * https://de.wikipedia.org/wiki/Internationaler_Code_der_Nomenklatur_der_Kulturpflanzen
241 */
242 @XmlEnumValue("ICNCP_2004")
243 ICNCP_2004(UUID.fromString("a29abcee-1f34-4320-afad-eb7ee23cc473"), "ICNCP", null, 2004, NomenclaturalCode.ICNCP, null, null),
244
245 //virus1
246 /**
247 * https://talk.ictvonline.org/ictv-reports/ictv_online_report/
248 * 10th report
249 */
250 @XmlEnumValue("ICVCN_2018")
251 //TODO abbrev correct?
252 ICVCN_2018(UUID.fromString("6a0debf3-7932-4b0c-b1b1-46641c273f36"), "ICVCN", null, 2019, NomenclaturalCode.ICVCN, null, null),
253
254 //virus2
255 /**
256 * https://talk.ictvonline.org/ictv-reports/ictv_9th_report/
257 * 9th report
258 */
259 @XmlEnumValue("ICVCN_2011")
260 //TODO abbrev correct?
261 ICVCN_2011(UUID.fromString("b55c0209-59e2-4fa2-9d64-63addfb15d6b"), "ICVCN", null, 2011, NomenclaturalCode.ICVCN, null, null),
262
263 ;
264
265 @SuppressWarnings("unused")
266 private static final Logger logger = LogManager.getLogger();
267
268 private static final String WIKIDATA_BASE_URL = "https://www.wikidata.org/wiki/";
269
270 private String location;
271
272 private Integer year;
273
274 private NomenclaturalCode code;
275
276 private String wikiDataId;
277
278 private DOI doi;
279
280 private String abbrev;
281
282 private Reference citation;
283
284 private NomenclaturalCodeEdition(UUID uuid, String abbrev, String location, Integer year, NomenclaturalCode code, String wikiDataId, String strDoi ){
285 delegateVocTerm = EnumeratedTermVoc.addTerm(getClass(), this, uuid, makeTitleCache(location, code, year), code.getKey() + year, null);
286 this.location = location;
287 this.year=year;
288 this.code=code;
289 this.wikiDataId = wikiDataId;
290 this.doi = (strDoi==null) ? null:DOI.fromString(strDoi);
291 }
292
293 /**
294 * @param location
295 * @param code
296 * @param year
297 * @return
298 */
299 private String makeTitleCache(String location, NomenclaturalCode code, Integer year) {
300 return (StringUtils.isNotBlank(location)? location: code.getTitleCache()) + " " + year;
301 }
302
303 public String getTitleCache() {
304 return getLabel();
305 }
306
307 @Override
308 public String toString() {
309 return this.name();
310 }
311
312 public boolean isNonViral() {
313 return this.code.isNonViral();
314 }
315 public boolean isZoological() {
316 return this.code.isZoological();
317 }
318 public boolean isBotanical() {
319 return this.code.isBotanical();
320 }
321 public boolean isCultivar() {
322 return this.code.isCultivar();
323 }
324 public boolean isBacterial() {
325 return this.code.isBacterial();
326 }
327 public boolean isViral() {
328 return this.code.isViral();
329 }
330 public boolean isFungus() {
331 return this.code.isFungus();
332 }
333
334
335 // public static NomenclaturalCodeEdition fromString(String string){
336 // xx;
337 // for(NomenclaturalCodeEdition code : NomenclaturalCodeEdition.values()){
338 // if(code.name().equalsIgnoreCase(string)) {
339 // return code;
340 // }
341 // }
342 // return null;
343 // }
344
345 public static List<NomenclaturalCodeEdition> forCode(NomenclaturalCode code){
346 List<NomenclaturalCodeEdition> result = new ArrayList<>();
347
348 Set<NomenclaturalCode> allCodes = code.getGeneralizationOf(true);
349 allCodes.add(code);
350
351 for(NomenclaturalCodeEdition edition : NomenclaturalCodeEdition.values()){
352 for (NomenclaturalCode nomCode: allCodes){
353 if(edition.getCode().equals(nomCode) && !result.contains(nomCode)) {
354 result.add(edition);
355 }
356 }
357 }
358 return result;
359 }
360
361 public String getAbbrev() {
362 return abbrev;
363 }
364
365 public String getLocation() {
366 return location;
367 }
368 public Integer getYear() {
369 return year;
370 }
371 public NomenclaturalCode getCode() {
372 return code;
373 }
374 public String getWikiDataId() {
375 return wikiDataId;
376 }
377 public URI getWikiDataUri() {
378 return StringUtils.isEmpty(wikiDataId)? null: URI.create(WIKIDATA_BASE_URL + wikiDataId);
379 }
380 public DOI getDoi() {
381 return this.doi;
382 }
383
384 private Reference getCitation() {
385 if (this.citation == null) {
386 if (this == NomenclaturalCodeEdition.ICN_2017_SHENZHEN) {
387 citation = ReferenceFactory.newBook();
388 citation.setTitle("International Code of Nomenclature for algae, fungi, and plants (Shenzhen Code), adopted by the Nineteenth International Botanical Congress, Shenzhen, China, July 2017.");
389 Team team = Team.NewInstance();
390 citation.setAuthorship(team);
391 team.addTeamMember(Person.NewInstance(null, "Turland", "N.J.", null));
392 team.addTeamMember(Person.NewInstance(null, "Wiersema", "J.H.", null));
393 team.addTeamMember(Person.NewInstance(null, "Barrie", "F.R.", null));
394 team.addTeamMember(Person.NewInstance(null, "Greuter", "W.", null));
395 team.addTeamMember(Person.NewInstance(null, "Hawksworth", "D.L.", null));
396 team.addTeamMember(Person.NewInstance(null, "Herendeen", "P.S.", null));
397 team.addTeamMember(Person.NewInstance(null, "Knapp", "S.", null));
398 team.addTeamMember(Person.NewInstance(null, "Kusber", "W.-H.", null));
399 team.addTeamMember(Person.NewInstance(null, "Li", "D.-Z.", null));
400 team.addTeamMember(Person.NewInstance(null, "Marhold", "K.", null));
401 team.addTeamMember(Person.NewInstance(null, "May", "T.W.", null));
402 team.addTeamMember(Person.NewInstance(null, "McNeill", "J.", null));
403 team.addTeamMember(Person.NewInstance(null, "Monro", "A.M.", null));
404 team.addTeamMember(Person.NewInstance(null, "Prado", "J.", null));
405 team.addTeamMember(Person.NewInstance(null, "Price", "M.J.", null));
406 //TODO eds.
407 team.addTeamMember(Person.NewInstance(null, "Smith", "G.F. (eds.)", null));
408 citation.setDatePublished(TimePeriodParser.parseStringVerbatim("2018"));
409 citation.setPlacePublished("Glashütten");
410 citation.setPublisher("Koeltz Botanical Books", "Glashütten");
411 citation.setDoi(ICN_2017_SHENZHEN.getDoi());
412 citation.setSeriesPart("Regnum Vegetabile 159");
413 }else {
414 //TODO other nom codes not yet implemented
415 }
416 }
417 return citation;
418 }
419
420 public IdentifiableSource getSource() {
421 if (getCitation() != null) {
422 return IdentifiableSource.NewPrimaryMediaSourceInstance(getCitation(), null);
423 } else {
424 return null;
425 }
426 }
427
428 // *************************** DELEGATE **************************************/
429
430 private static EnumeratedTermVoc<NomenclaturalCodeEdition> delegateVoc;
431 private IEnumTerm<NomenclaturalCodeEdition> delegateVocTerm;
432
433 static {
434 delegateVoc = EnumeratedTermVoc.getVoc(NomenclaturalCodeEdition.class);
435 }
436
437 @Override
438 public String getKey(){return delegateVocTerm.getKey();}
439
440 @Override
441 public String getLabel(){return delegateVocTerm.getLabel();}
442
443 @Override
444 public String getLabel(Language language){return delegateVocTerm.getLabel(language);}
445
446
447 @Override
448 public UUID getUuid() {return delegateVocTerm.getUuid();}
449
450 @Override
451 public NomenclaturalCodeEdition getKindOf() {return delegateVocTerm.getKindOf();}
452
453 @Override
454 public Set<NomenclaturalCodeEdition> getGeneralizationOf() {return delegateVocTerm.getGeneralizationOf();}
455
456 @Override
457 public boolean isKindOf(NomenclaturalCodeEdition ancestor) {return delegateVocTerm.isKindOf(ancestor); }
458
459 @Override
460 public Set<NomenclaturalCodeEdition> getGeneralizationOf(boolean recursive) {return delegateVocTerm.getGeneralizationOf(recursive);}
461
462
463 public static NomenclaturalCodeEdition getByKey(String key){return delegateVoc.getByKey(key);}
464 public static NomenclaturalCodeEdition getByUuid(UUID uuid) {return delegateVoc.getByUuid(uuid);}
465 }