(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / name / NomenclaturalStatusType.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
13
14 import eu.etaxonomy.cdm.model.common.OrderedTermBase;
15 import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException;
16
17 import org.apache.log4j.Logger;
18
19 import java.util.*;
20 import javax.persistence.*;
21
22 /**
23 * http://rs.tdwg.org/ontology/voc/TaxonName.rdf#PublicationStatus
24 * @author m.doering
25 * @version 1.0
26 * @created 08-Nov-2007 13:06:39
27 */
28 @Entity
29 public class NomenclaturalStatusType extends OrderedTermBase<NomenclaturalStatusType> {
30 static Logger logger = Logger.getLogger(NomenclaturalStatusType.class);
31
32 private static final UUID uuidAmbiguous = UUID.fromString("90f5012b-705b-4488-b4c6-002d2bc5198e");
33 private static final UUID uuidDoubtful = UUID.fromString("0ffeb39e-872e-4c0f-85ba-a4150d9f9e7d");
34 private static final UUID uuidConfusum = UUID.fromString("24955174-aa5c-4e71-a2fd-3efc79e885db");
35 private static final UUID uuidIllegitimate = UUID.fromString("b7c544cf-a375-4145-9d3e-4b97f3f18108");
36 private static final UUID uuidSuperfluous = UUID.fromString("6890483a-c6ba-4ae1-9ab1-9fbaa5736ce9");
37 private static final UUID uuidRejected = UUID.fromString("48107cc8-7a5b-482e-b438-efbba050b851");
38 private static final UUID uuidUtiqueRejected = UUID.fromString("04338fdd-c12a-402f-a1ca-68b4bf0be042");
39 private static final UUID uuidConservedProp = UUID.fromString("82bab006-5aed-4301-93ec-980deb30cbb1");
40 private static final UUID uuidOrthographyConservedProp = UUID.fromString("02f82bc5-1066-454b-a023-11967cba9092");
41 private static final UUID uuidLegitimate = UUID.fromString("51a3613c-b53b-4561-b0cd-9163d91c15aa");
42 private static final UUID uuidAlternative = UUID.fromString("3b8a8519-420f-4dfa-b050-b410cc257961");
43 private static final UUID uuidNovum = UUID.fromString("05fcb68f-af60-4851-b912-892512058897");
44 private static final UUID uuidUtiqueRejectedProp = UUID.fromString("643ee07f-026c-426c-b838-c778c8613383");
45 private static final UUID uuidOrthographyConserved = UUID.fromString("34a7d383-988b-4117-b8c0-52b947f8c711");
46 private static final UUID uuidRejectedProp = UUID.fromString("248e44c2-5436-4526-a352-f7467ecebd56");
47 private static final UUID uuidConserved = UUID.fromString("6330f719-e2bc-485f-892b-9f882058a966");
48 private static final UUID uuidSanctioned = UUID.fromString("1afe55c4-76aa-46c0-afce-4dc07f512733");
49 private static final UUID uuidInvalid = UUID.fromString("b09d4f51-8a77-442a-bbce-e7832aaf46b7");
50 private static final UUID uuidNudum = UUID.fromString("e0d733a8-7777-4b27-99a3-05ab50e9f312");
51 private static final UUID uuidCombinationInvalid = UUID.fromString("f858e619-7b7f-4225-913b-880a2143ec83");
52 private static final UUID uuidProvisional = UUID.fromString("a277507e-ad93-4978-9419-077eb889c951");
53
54
55
56 public NomenclaturalStatusType() {
57 super();
58 // TODO Auto-generated constructor stub
59 }
60
61 public NomenclaturalStatusType(String term, String label) {
62 super(term, label);
63 // TODO Auto-generated constructor stub
64 }
65
66 public static final NomenclaturalStatusType getUUID(UUID uuid){
67 return (NomenclaturalStatusType) findByUuid(uuid);
68 }
69
70
71 @Transient
72 public boolean isInvalidType(){
73 if (this.equals(INVALID()) ||
74 this.equals(NUDUM()) ||
75 this.equals(PROVISIONAL()) ||
76 this.equals(COMBINATION_INVALID())
77 ){
78 return true;
79 }else{
80 return false;
81 }
82 }
83
84 @Transient
85 public boolean isLegitimateType(){
86 if (this.equals(LEGITIMATE()) ||
87 this.equals(NOVUM()) ||
88 this.equals(ALTERNATIVE()) ||
89 this.equals(CONSERVED()) ||
90 this.equals(ORTHOGRAPHY_CONSERVED()) ||
91 this.equals(REJECTED_PROP()) ||
92 this.equals(UTIQUE_REJECTED_PROP())
93 ){
94 return true;
95 }else{
96 return false;
97 }
98 }
99
100 @Transient
101 public boolean isIllegitimateType(){
102 if (this.equals(ILLEGITIMATE()) ||
103 this.equals(SUPERFLUOUS()) ||
104 this.equals(REJECTED()) ||
105 this.equals(UTIQUE_REJECTED()) ||
106 this.equals(CONSERVED_PROP()) ||
107 this.equals(ORTHOGRAPHY_CONSERVED_PROP())
108 ){
109 return true;
110 }else{
111 return false;
112 }
113 }
114
115 public static final NomenclaturalStatusType AMBIGUOUS(){
116 return getUUID(uuidAmbiguous);
117 }
118
119 public static final NomenclaturalStatusType DOUBTFUL(){
120 return getUUID(uuidDoubtful);
121 }
122
123 public static final NomenclaturalStatusType CONFUSUM(){
124 return getUUID(uuidConfusum);
125 }
126
127 public static final NomenclaturalStatusType ILLEGITIMATE(){
128 return getUUID(uuidIllegitimate);
129 }
130
131 public static final NomenclaturalStatusType SUPERFLUOUS(){
132 return getUUID(uuidSuperfluous);
133 }
134
135 public static final NomenclaturalStatusType REJECTED(){
136 return getUUID(uuidRejected);
137 }
138
139 public static final NomenclaturalStatusType UTIQUE_REJECTED(){
140 return getUUID(uuidUtiqueRejected);
141 }
142
143 public static final NomenclaturalStatusType CONSERVED_PROP(){
144 return getUUID(uuidConservedProp);
145 }
146
147 public static final NomenclaturalStatusType ORTHOGRAPHY_CONSERVED_PROP(){
148 return getUUID(uuidOrthographyConservedProp);
149 }
150
151 public static final NomenclaturalStatusType LEGITIMATE(){
152 return getUUID(uuidLegitimate);
153 }
154
155 public static final NomenclaturalStatusType ALTERNATIVE(){
156 return getUUID(uuidAlternative);
157 }
158
159 public static final NomenclaturalStatusType NOVUM(){
160 return getUUID(uuidNovum);
161 }
162
163 public static final NomenclaturalStatusType UTIQUE_REJECTED_PROP(){
164 return getUUID(uuidUtiqueRejectedProp);
165 }
166
167 public static final NomenclaturalStatusType ORTHOGRAPHY_CONSERVED(){
168 return getUUID(uuidOrthographyConserved);
169 }
170
171 public static final NomenclaturalStatusType REJECTED_PROP(){
172 return getUUID(uuidRejectedProp);
173 }
174
175 public static final NomenclaturalStatusType CONSERVED(){
176 return getUUID(uuidConserved);
177 }
178
179 public static final NomenclaturalStatusType SANCTIONED(){
180 return getUUID(uuidSanctioned);
181 }
182
183 public static final NomenclaturalStatusType INVALID(){
184 return getUUID(uuidInvalid);
185 }
186
187 public static final NomenclaturalStatusType NUDUM(){
188 return getUUID(uuidNudum);
189 }
190
191 public static final NomenclaturalStatusType COMBINATION_INVALID(){
192 return getUUID(uuidCombinationInvalid);
193 }
194
195 public static final NomenclaturalStatusType PROVISIONAL(){
196 return getUUID(uuidProvisional);
197 }
198
199
200 //TODO Soraya
201 // nom. subnud.: nomen subnudum
202 // orth. var.: orthographic variant
203 // opus utique oppr.: operautique oppressa
204 // pro syn.: pro synonymo
205
206 /** TODO
207 * preliminary implementation for BotanicalNameParser
208 * * not yet complete
209 */
210 @Transient
211 public static NomenclaturalStatusType getNomenclaturalStatusTypeByAbbreviation(String statusAbbreviation) throws UnknownCdmTypeException{
212 if (statusAbbreviation == null){ throw new NullPointerException("statusAbbreviation is 'null' in getNomenclaturalStatusTypeByAbbreviation");
213 }else if (statusAbbreviation.equalsIgnoreCase("nom. superfl.")){ return NomenclaturalStatusType.SUPERFLUOUS();
214 }else if (statusAbbreviation.equalsIgnoreCase("nom. nud.")){ return NomenclaturalStatusType.NUDUM();
215 }else if (statusAbbreviation.equalsIgnoreCase("nom. illeg.")){return NomenclaturalStatusType.ILLEGITIMATE();
216 }else if (statusAbbreviation.equalsIgnoreCase("nom. inval.")) { return NomenclaturalStatusType.INVALID();
217 }else if (statusAbbreviation.equalsIgnoreCase("nom. cons.")) { return NomenclaturalStatusType.CONSERVED();
218 }else if (statusAbbreviation.equalsIgnoreCase("nom. alternativ.")) { return NomenclaturalStatusType.ALTERNATIVE();
219 //TODO
220 //}else if (statusAbbreviation.equalsIgnoreCase("nom. subnud.")) { return NomenclaturalStatusType.su;
221 }else if (statusAbbreviation.equalsIgnoreCase("nom. rej.")) { return NomenclaturalStatusType.REJECTED();
222 }else if (statusAbbreviation.equalsIgnoreCase("nom. rej. prop.")) { return NomenclaturalStatusType.REJECTED_PROP();
223 }else if (statusAbbreviation.equalsIgnoreCase("nom. provis.")) { return NomenclaturalStatusType.PROVISIONAL();
224 //TODO
225 }else {
226 if (statusAbbreviation == null){
227 statusAbbreviation = "(null)";
228 }
229 throw new eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException("Unknown NomenclaturalStatusType abbreviation: " + statusAbbreviation);
230 }
231 }
232
233 }