refactored folder structure
[taxeditor.git] / taxeditor-store / src / main / java / eu / etaxonomy / taxeditor / model / NameRelationsUtil.java
1 // $Id$
2 /**
3 * Copyright (C) 2007 EDIT
4 * European Distributed Institute of Taxonomy
5 * http://www.e-taxonomy.eu
6 *
7 * The contents of this file are subject to the Mozilla Public License Version 1.1
8 * See LICENSE.TXT at the top of this package for the full license terms.
9 */
10
11 package eu.etaxonomy.taxeditor.model;
12
13 import java.util.SortedSet;
14
15 import eu.etaxonomy.cdm.model.name.NameRelationshipType;
16 import eu.etaxonomy.cdm.model.name.NomenclaturalCode;
17 import eu.etaxonomy.taxeditor.preference.PreferencesUtil;
18 import eu.etaxonomy.taxeditor.store.CdmStore;
19
20 /**
21 * @author p.ciardelli
22 * @created 30.04.2009
23 * @version 1.0
24 */
25 public class NameRelationsUtil {
26
27 /**
28 * Get the type's label out of the session's name relations vocabulary, not directly
29 * from the object.
30 *
31 * @param type
32 * @return
33 */
34 public static String getNameRelationTypeLabel(NameRelationshipType type) {
35 boolean isZoological =
36 PreferencesUtil.getPreferredNomenclaturalCode()
37 == NomenclaturalCode.ICZN ? true : false;
38 return getNameRelationTypeLabel(type, isZoological);
39 }
40
41 public static String getNameRelationTypeLabel(NameRelationshipType type, boolean isZoological) {
42
43 SortedSet<NameRelationshipType> vocab =
44 CdmStore.getDefault().getNameRelationshipTypes();
45
46 // SortedSet<NameRelationshipType> vocab =
47 // CdmSessionDataRepository.getDefault().getNameRelationshipTypes();
48 for (NameRelationshipType type1 : vocab) {
49 if (type1.equals(type)) {
50
51 if (isZoological &&
52 type1.equals(NameRelationshipType.BASIONYM())) {
53 return "original combination for";
54 } else {
55 return type1.getLabel();
56 }
57 }
58 }
59 return "";
60 }
61
62 /**
63 * Get the inverse representation of the type out of the session's
64 * name relations vocabulary, not directly from the object.
65 *
66 * @param type
67 * @return
68 */
69 public static String getNameRelationInverseTypeLabel(NameRelationshipType type) {
70 boolean isZoological =
71 PreferencesUtil.getPreferredNomenclaturalCode()
72 == NomenclaturalCode.ICZN ? true : false;
73 return getNameRelationInverseTypeLabel(type, isZoological);
74 }
75
76 public static String getNameRelationInverseTypeLabel(NameRelationshipType type, boolean isZoological) {
77
78 SortedSet<NameRelationshipType> vocab =
79 CdmStore.getDefault().getNameRelationshipTypes();
80
81 // SortedSet<NameRelationshipType> vocab =
82 // CdmSessionDataRepository.getDefault().getNameRelationshipTypes();
83 for (NameRelationshipType type1 : vocab) {
84 if (type1.equals(type)) {
85 return type1.getInverseLabel();
86 }
87 }
88 return "";
89 }
90 }