Merge branch 'hotfix/5.45.1'
[taxeditor.git] / eu.etaxonomy.taxeditor.store / src / main / java / eu / etaxonomy / taxeditor / model / NomenclaturalCodeHelper.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 package eu.etaxonomy.taxeditor.model;
10
11 import java.util.ArrayList;
12 import java.util.Arrays;
13 import java.util.List;
14
15 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
16 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
17
18 /**
19 * @author p.ciardelli
20 * @created 11.09.2009
21 */
22 public class NomenclaturalCodeHelper {
23
24 public static List<NomenclaturalCode> getAllCodes() {
25 return Arrays.asList(NomenclaturalCode.values());
26 }
27
28 public static List<NomenclaturalCode> getSupportedCodes() {
29 List<NomenclaturalCode> supportedCodes = new ArrayList<>();
30 NomenclaturalCode nomenclaturalCode =PreferencesUtil.getPreferredNomenclaturalCode();
31 for (NomenclaturalCode code : getAllCodes()) {
32 if (isSupported(code)) {
33 if (nomenclaturalCode != null && nomenclaturalCode.equals(code)){
34 supportedCodes.add(0, code);
35 }else{
36 supportedCodes.add(code);
37 }
38 }
39 }
40 return supportedCodes;
41 }
42
43 private static boolean isSupported(NomenclaturalCode code) {
44 if (code.equals(NomenclaturalCode.ICNAFP ) || code.equals(NomenclaturalCode.ICZN)) {
45 return true;
46 } else {
47 return false;
48 }
49 }
50
51 public static String getDescription(NomenclaturalCode code) {
52 if (code.equals(NomenclaturalCode.ICNP)) {
53 return "International Code of Nomenclature of Prokaryotes (ICNP)";
54 }
55 if (code.equals(NomenclaturalCode.ICNAFP )) {
56 return "International Code of Botanical Nomenclature (ICNAFP )";
57 }
58 if (code.equals(NomenclaturalCode.ICNCP)) {
59 return "International Code of Cultivated Plants (ICNCP)";
60 }
61 if (code.equals(NomenclaturalCode.ICZN)) {
62 return "International Code of Zoological Nomenclature (ICZN)";
63 }
64 if (code.equals(NomenclaturalCode.ICVCN)) {
65 return "International Code for Virus Classification and Nomenclature (ICVCN)";
66 }
67 return code.name();
68 }
69
70 public static NomenclaturalCode getDefaultCode() {
71 return NomenclaturalCode.ICNAFP ;
72 }
73 }