Revision 892efc69
Added by Andreas Kohlbecker almost 14 years ago
cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/name/Rank.java | ||
---|---|---|
9 | 9 |
|
10 | 10 |
package eu.etaxonomy.cdm.model.name; |
11 | 11 |
|
12 |
import java.util.HashMap; |
|
13 |
import java.util.List; |
|
14 |
import java.util.Map; |
|
15 |
import java.util.UUID; |
|
16 |
|
|
17 |
import javax.persistence.Entity; |
|
18 |
import javax.persistence.Transient; |
|
12 | 19 |
import javax.xml.bind.annotation.XmlAccessType; |
13 | 20 |
import javax.xml.bind.annotation.XmlAccessorType; |
14 | 21 |
import javax.xml.bind.annotation.XmlType; |
15 | 22 |
|
16 |
import eu.etaxonomy.cdm.model.common.Language; |
|
17 |
import eu.etaxonomy.cdm.model.common.OrderedTermBase; |
|
18 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
19 |
import eu.etaxonomy.cdm.model.description.State; |
|
20 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
|
21 |
|
|
22 | 23 |
import org.apache.log4j.Logger; |
23 | 24 |
import org.hibernate.envers.Audited; |
24 | 25 |
import org.hibernate.search.annotations.Indexed; |
25 | 26 |
|
26 |
import java.util.*; |
|
27 |
|
|
28 |
import javax.persistence.*; |
|
27 |
import eu.etaxonomy.cdm.common.CdmUtils; |
|
28 |
import eu.etaxonomy.cdm.model.common.DefinedTermBase; |
|
29 |
import eu.etaxonomy.cdm.model.common.Language; |
|
30 |
import eu.etaxonomy.cdm.model.common.OrderedTermBase; |
|
31 |
import eu.etaxonomy.cdm.model.common.Representation; |
|
32 |
import eu.etaxonomy.cdm.model.common.TermVocabulary; |
|
33 |
import eu.etaxonomy.cdm.model.location.NamedAreaLevel; |
|
34 |
import eu.etaxonomy.cdm.model.location.NamedAreaType; |
|
35 |
import eu.etaxonomy.cdm.model.location.TdwgArea; |
|
36 |
import eu.etaxonomy.cdm.strategy.exceptions.UnknownCdmTypeException; |
|
29 | 37 |
|
30 | 38 |
/** |
31 | 39 |
* The class representing the taxonomical ranks (like "Family", "Genus" or |
... | ... | |
103 | 111 |
private static final UUID uuidSubspecificAggregate = UUID.fromString("72c248b9-027d-4402-b375-dd4f0850c9ad"); |
104 | 112 |
private static final UUID uuidSubspecies = UUID.fromString("462a7819-8b00-4190-8313-88b5be81fad5"); |
105 | 113 |
private static final UUID uuidInfraspecies = UUID.fromString("f28ebc9e-bd50-4194-9af1-42f5cb971a2c"); |
114 |
private static final UUID uuidNatio = UUID.fromString("965f2f38-7f97-4270-ab5a-1999bf050a22"); |
|
106 | 115 |
private static final UUID uuidVariety = UUID.fromString("d5feb6a5-af5c-45ef-9878-bb4f36aaf490"); |
107 | 116 |
private static final UUID uuidBioVariety = UUID.fromString("a3a364cb-1a92-43fc-a717-3c44980a0991"); |
108 | 117 |
private static final UUID uuidPathoVariety = UUID.fromString("2f4f4303-a099-47e3-9048-d749d735423b"); |
... | ... | |
122 | 131 |
private static final UUID uuidCultivar = UUID.fromString("5e98415b-dc6e-440b-95d6-ea33dbb39ad0"); |
123 | 132 |
private static final UUID uuidUnknownRank = UUID.fromString("5c4d6755-2cf6-44ca-9220-cccf8881700b"); |
124 | 133 |
|
125 |
private static Rank UNKNOWN_RANK; |
|
126 |
private static Rank CULTIVAR; |
|
127 |
private static Rank CULTIVARGROUP; |
|
128 |
private static Rank GRAFTCHIMAERA; |
|
129 |
private static Rank GREX; |
|
130 |
private static Rank DENOMINATIONCLASS; |
|
131 |
private static Rank CANDIDATE; |
|
132 |
private static Rank INFRASPECIFICTAXON; |
|
133 |
private static Rank SUBSUBFORM; |
|
134 |
private static Rank SUBFORM; |
|
135 |
private static Rank SPECIALFORM; |
|
136 |
private static Rank FORM; |
|
137 |
private static Rank CONVAR; |
|
138 |
private static Rank SUBSUBVARIETY; |
|
139 |
private static Rank SUBVARIETY; |
|
140 |
private static Rank PATHOVARIETY; |
|
141 |
private static Rank BIOVARIETY; |
|
142 |
private static Rank VARIETY; |
|
143 |
private static Rank INFRASPECIES; |
|
144 |
private static Rank SUBSPECIES; |
|
145 |
private static Rank SUBSPECIFICAGGREGATE; |
|
146 |
private static Rank SPECIES; |
|
147 |
private static Rank INFRAGENERICTAXON; |
|
148 |
private static Rank SPECIESAGGREGATE; |
|
149 |
private static Rank SPECIESGROUP; |
|
150 |
private static Rank SUBSERIES; |
|
151 |
private static Rank SERIES; |
|
152 |
private static Rank SUBSECTION_BOTANY; |
|
153 |
private static Rank SECTION_BOTANY; |
|
154 |
private static Rank INFRAGENUS; |
|
155 |
private static Rank SUBGENUS; |
|
156 |
private static Rank GENUS; |
|
157 |
private static Rank SUPRAGENERICTAXON; |
|
158 |
private static Rank INFRATRIBE; |
|
159 |
private static Rank SUBTRIBE; |
|
160 |
private static Rank TRIBE; |
|
161 |
private static Rank SUPERTRIBE; |
|
162 |
private static Rank INFRAFAMILY; |
|
163 |
private static Rank SUBFAMILY; |
|
164 |
private static Rank FAMILY; |
|
165 |
private static Rank SUPERFAMILY; |
|
166 |
private static Rank SUBSECTION_ZOOLOGY; |
|
167 |
private static Rank SECTION_ZOOLOGY; |
|
168 |
private static Rank INFRAORDER; |
|
169 |
private static Rank SUBORDER; |
|
170 |
private static Rank ORDER; |
|
171 |
private static Rank SUPERORDER; |
|
172 |
private static Rank INFRACLASS; |
|
173 |
private static Rank SUBCLASS; |
|
174 |
private static Rank CLASS; |
|
175 |
private static Rank SUPERCLASS; |
|
176 |
private static Rank INFRADIVISION; |
|
177 |
private static Rank SUBDIVISION; |
|
178 |
private static Rank DIVISION; |
|
179 |
private static Rank SUPERDIVISION; |
|
180 |
private static Rank INFRAPHYLUM; |
|
181 |
private static Rank SUBPHYLUM; |
|
182 |
private static Rank PHYLUM; |
|
183 |
private static Rank SUPERPHYLUM; |
|
184 |
private static Rank INFRAKINGDOM; |
|
185 |
private static Rank SUBKINGDOM; |
|
186 |
private static Rank KINGDOM; |
|
187 |
private static Rank SUPERKINGDOM; |
|
188 |
private static Rank DOMAIN; |
|
189 |
private static Rank EMPIRE; |
|
190 | 134 |
|
191 |
// ************* CONSTRUCTORS *************/ |
|
135 |
private static Map<String, UUID> abbrevMap = null; |
|
136 |
private static Map<String, UUID> labelMap = null; |
|
137 |
|
|
138 |
protected static Map<UUID, Rank> termMap = null; |
|
139 |
|
|
140 |
|
|
141 |
// ********************* CONSTRUCTORS ************************************+/ |
|
192 | 142 |
/** |
193 | 143 |
* Class constructor: creates a new empty rank instance. |
194 | 144 |
* |
... | ... | |
236 | 186 |
return new Rank(term, label, labelAbbrev); |
237 | 187 |
} |
238 | 188 |
|
239 |
//********* METHODS **************************************/ |
|
189 |
//********* METHODS **************************************/ |
|
190 |
|
|
191 |
protected static Rank getTermByUuid(UUID uuid){ |
|
192 |
if (termMap == null){ |
|
193 |
return null; //better return null then initialize the termMap in an unwanted way |
|
194 |
} |
|
195 |
return (Rank)termMap.get(uuid); |
|
196 |
} |
|
240 | 197 |
|
241 | 198 |
public static final Rank EMPIRE(){ |
242 |
return EMPIRE;
|
|
199 |
return getTermByUuid(uuidEmpire);
|
|
243 | 200 |
} |
244 | 201 |
public static final Rank DOMAIN(){ |
245 |
return DOMAIN;
|
|
202 |
return getTermByUuid(uuidDomain);
|
|
246 | 203 |
} |
247 | 204 |
public static final Rank SUPERKINGDOM(){ |
248 |
return SUPERKINGDOM;
|
|
205 |
return getTermByUuid(uuidSuperkingdom);
|
|
249 | 206 |
} |
250 | 207 |
public static final Rank KINGDOM(){ |
251 |
return KINGDOM;
|
|
208 |
return getTermByUuid(uuidKingdom);
|
|
252 | 209 |
} |
253 | 210 |
public static final Rank SUBKINGDOM(){ |
254 |
return SUBKINGDOM;
|
|
211 |
return getTermByUuid(uuidSubkingdom);
|
|
255 | 212 |
} |
256 | 213 |
public static final Rank INFRAKINGDOM(){ |
257 |
return INFRAKINGDOM;
|
|
214 |
return getTermByUuid(uuidInfrakingdom);
|
|
258 | 215 |
} |
259 | 216 |
public static final Rank SUPERPHYLUM(){ |
260 |
return SUPERPHYLUM;
|
|
217 |
return getTermByUuid(uuidSuperphylum);
|
|
261 | 218 |
} |
262 | 219 |
public static final Rank PHYLUM(){ |
263 |
return PHYLUM;
|
|
220 |
return getTermByUuid(uuidPhylum);
|
|
264 | 221 |
} |
265 | 222 |
public static final Rank SUBPHYLUM(){ |
266 |
return SUBPHYLUM;
|
|
223 |
return getTermByUuid(uuidSubphylum);
|
|
267 | 224 |
} |
268 | 225 |
public static final Rank INFRAPHYLUM(){ |
269 |
return INFRAPHYLUM;
|
|
226 |
return getTermByUuid(uuidInfraphylum);
|
|
270 | 227 |
} |
271 | 228 |
public static final Rank SUPERDIVISION(){ |
272 |
return SUPERDIVISION;
|
|
229 |
return getTermByUuid(uuidSuperdivision);
|
|
273 | 230 |
} |
274 | 231 |
public static final Rank DIVISION(){ |
275 |
return DIVISION;
|
|
232 |
return getTermByUuid(uuidDivision);
|
|
276 | 233 |
} |
277 | 234 |
public static final Rank SUBDIVISION(){ |
278 |
return SUBDIVISION;
|
|
235 |
return getTermByUuid(uuidSubdivision);
|
|
279 | 236 |
} |
280 | 237 |
public static final Rank INFRADIVISION(){ |
281 |
return INFRADIVISION;
|
|
238 |
return getTermByUuid(uuidInfradivision);
|
|
282 | 239 |
} |
283 | 240 |
public static final Rank SUPERCLASS(){ |
284 |
return SUPERCLASS;
|
|
241 |
return getTermByUuid(uuidSuperclass);
|
|
285 | 242 |
} |
286 | 243 |
public static final Rank CLASS(){ |
287 |
return CLASS;
|
|
244 |
return getTermByUuid(uuidClass);
|
|
288 | 245 |
} |
289 | 246 |
public static final Rank SUBCLASS(){ |
290 |
return SUBCLASS;
|
|
247 |
return getTermByUuid(uuidSubclass);
|
|
291 | 248 |
} |
292 | 249 |
public static final Rank INFRACLASS(){ |
293 |
return INFRACLASS;
|
|
250 |
return getTermByUuid(uuidInfraclass);
|
|
294 | 251 |
} |
295 | 252 |
public static final Rank SUPERORDER(){ |
296 |
return SUPERORDER;
|
|
253 |
return getTermByUuid(uuidSuperorder);
|
|
297 | 254 |
} |
298 | 255 |
public static final Rank ORDER(){ |
299 |
return ORDER;
|
|
256 |
return getTermByUuid(uuidOrder);
|
|
300 | 257 |
} |
301 | 258 |
public static final Rank SUBORDER(){ |
302 |
return SUBORDER;
|
|
259 |
return getTermByUuid(uuidSuborder);
|
|
303 | 260 |
} |
304 | 261 |
public static final Rank INFRAORDER(){ |
305 |
return INFRAORDER;
|
|
262 |
return getTermByUuid(uuidInfraorder);
|
|
306 | 263 |
} |
307 | 264 |
public static final Rank SUPERFAMILY(){ |
308 |
return SUPERFAMILY;
|
|
265 |
return getTermByUuid(uuidSuperfamily);
|
|
309 | 266 |
} |
310 | 267 |
public static final Rank FAMILY(){ |
311 |
return FAMILY;
|
|
268 |
return getTermByUuid(uuidFamily);
|
|
312 | 269 |
} |
313 | 270 |
public static final Rank SUBFAMILY(){ |
314 |
return SUBFAMILY;
|
|
271 |
return getTermByUuid(uuidSubfamily);
|
|
315 | 272 |
} |
316 | 273 |
public static final Rank INFRAFAMILY(){ |
317 |
return INFRAFAMILY;
|
|
274 |
return getTermByUuid(uuidInfrafamily);
|
|
318 | 275 |
} |
319 | 276 |
public static final Rank SUPERTRIBE(){ |
320 |
return SUPERTRIBE;
|
|
277 |
return getTermByUuid(uuidSupertribe);
|
|
321 | 278 |
} |
322 | 279 |
public static final Rank TRIBE(){ |
323 |
return TRIBE;
|
|
280 |
return getTermByUuid(uuidTribe);
|
|
324 | 281 |
} |
325 | 282 |
public static final Rank SUBTRIBE(){ |
326 |
return SUBTRIBE;
|
|
283 |
return getTermByUuid(uuidSubtribe);
|
|
327 | 284 |
} |
328 | 285 |
public static final Rank INFRATRIBE(){ |
329 |
return INFRATRIBE;
|
|
286 |
return getTermByUuid(uuidInfratribe);
|
|
330 | 287 |
} |
331 | 288 |
public static final Rank SUPRAGENERICTAXON(){ |
332 |
return SUPRAGENERICTAXON;
|
|
289 |
return getTermByUuid(uuidSupragenericTaxon);
|
|
333 | 290 |
} |
334 | 291 |
public static final Rank GENUS(){ |
335 |
return GENUS;
|
|
292 |
return getTermByUuid(uuidGenus);
|
|
336 | 293 |
} |
337 | 294 |
public static final Rank SUBGENUS(){ |
338 |
return SUBGENUS;
|
|
295 |
return getTermByUuid(uuidSubgenus);
|
|
339 | 296 |
} |
340 | 297 |
public static final Rank INFRAGENUS(){ |
341 |
return INFRAGENUS;
|
|
298 |
return getTermByUuid(uuidInfragenus);
|
|
342 | 299 |
} |
343 | 300 |
public static final Rank SECTION_BOTANY(){ |
344 |
return SECTION_BOTANY;
|
|
301 |
return getTermByUuid(uuidSectionBotany);
|
|
345 | 302 |
} |
346 | 303 |
public static final Rank SUBSECTION_BOTANY(){ |
347 |
return SUBSECTION_BOTANY;
|
|
304 |
return getTermByUuid(uuidSubsectionBotany);
|
|
348 | 305 |
} |
349 | 306 |
public static final Rank SECTION_ZOOLOGY(){ |
350 |
return SECTION_ZOOLOGY;
|
|
307 |
return getTermByUuid(uuidSectionZoology);
|
|
351 | 308 |
} |
352 | 309 |
public static final Rank SUBSECTION_ZOOLOGY(){ |
353 |
return SUBSECTION_ZOOLOGY;
|
|
310 |
return getTermByUuid(uuidSubsectionZoology);
|
|
354 | 311 |
} |
355 | 312 |
public static final Rank SERIES(){ |
356 |
return SERIES;
|
|
313 |
return getTermByUuid(uuidSeries);
|
|
357 | 314 |
} |
358 | 315 |
public static final Rank SUBSERIES(){ |
359 |
return SUBSERIES;
|
|
316 |
return getTermByUuid(uuidSubseries);
|
|
360 | 317 |
} |
361 | 318 |
public static final Rank SPECIESAGGREGATE(){ |
362 |
return SPECIESAGGREGATE;
|
|
319 |
return getTermByUuid(uuidSpeciesAggregate);
|
|
363 | 320 |
} |
364 | 321 |
public static final Rank SPECIESGROUP(){ |
365 |
return SPECIESGROUP;
|
|
322 |
return getTermByUuid(uuidSpeciesGroup);
|
|
366 | 323 |
} |
367 | 324 |
public static final Rank INFRAGENERICTAXON(){ |
368 |
return INFRAGENERICTAXON;
|
|
325 |
return getTermByUuid(uuidInfragenericTaxon);
|
|
369 | 326 |
} |
370 | 327 |
public static final Rank SPECIES(){ |
371 |
return SPECIES;
|
|
328 |
return getTermByUuid(uuidSpecies);
|
|
372 | 329 |
} |
373 | 330 |
public static final Rank SUBSPECIFICAGGREGATE(){ |
374 |
return SUBSPECIFICAGGREGATE;
|
|
331 |
return getTermByUuid(uuidSubspecificAggregate);
|
|
375 | 332 |
} |
376 | 333 |
public static final Rank SUBSPECIES(){ |
377 |
return SUBSPECIES;
|
|
334 |
return getTermByUuid(uuidSubspecies);
|
|
378 | 335 |
} |
379 | 336 |
public static final Rank INFRASPECIES(){ |
380 |
return INFRASPECIES;
|
|
337 |
return getTermByUuid(uuidInfraspecies);
|
|
381 | 338 |
} |
382 | 339 |
public static final Rank VARIETY(){ |
383 |
return VARIETY;
|
|
340 |
return getTermByUuid(uuidVariety);
|
|
384 | 341 |
} |
385 | 342 |
public static final Rank BIOVARIETY(){ |
386 |
return BIOVARIETY;
|
|
343 |
return getTermByUuid(uuidBioVariety);
|
|
387 | 344 |
} |
388 | 345 |
public static final Rank PATHOVARIETY(){ |
389 |
return PATHOVARIETY;
|
|
346 |
return getTermByUuid(uuidPathoVariety);
|
|
390 | 347 |
} |
391 | 348 |
public static final Rank SUBVARIETY(){ |
392 |
return SUBVARIETY;
|
|
349 |
return getTermByUuid(uuidSubvariety);
|
|
393 | 350 |
} |
394 | 351 |
public static final Rank SUBSUBVARIETY(){ |
395 |
return SUBSUBVARIETY;
|
|
352 |
return getTermByUuid(uuidSubsubvariety );
|
|
396 | 353 |
} |
397 | 354 |
public static final Rank CONVAR(){ |
398 |
return CONVAR;
|
|
355 |
return getTermByUuid(uuidConvar);
|
|
399 | 356 |
} |
400 | 357 |
public static final Rank FORM(){ |
401 |
return FORM;
|
|
358 |
return getTermByUuid(uuidForm);
|
|
402 | 359 |
} |
403 | 360 |
public static final Rank SPECIALFORM(){ |
404 |
return SPECIALFORM;
|
|
361 |
return getTermByUuid(uuidSpecialForm);
|
|
405 | 362 |
} |
406 | 363 |
public static final Rank SUBFORM(){ |
407 |
return SUBFORM;
|
|
364 |
return getTermByUuid(uuidSubform);
|
|
408 | 365 |
} |
409 | 366 |
public static final Rank SUBSUBFORM(){ |
410 |
return SUBSUBFORM;
|
|
367 |
return getTermByUuid(uuidSubsubform);
|
|
411 | 368 |
} |
412 | 369 |
public static final Rank INFRASPECIFICTAXON(){ |
413 |
return INFRASPECIFICTAXON;
|
|
370 |
return getTermByUuid(uuidInfraspecificTaxon);
|
|
414 | 371 |
} |
415 | 372 |
public static final Rank CANDIDATE(){ |
416 |
return CANDIDATE;
|
|
373 |
return getTermByUuid(uuidCandidate);
|
|
417 | 374 |
} |
418 | 375 |
public static final Rank DENOMINATIONCLASS(){ |
419 |
return DENOMINATIONCLASS;
|
|
376 |
return getTermByUuid(uuidDenominationClass);
|
|
420 | 377 |
} |
421 | 378 |
public static final Rank GREX(){ |
422 |
return GREX;
|
|
379 |
return getTermByUuid(uuidGrex);
|
|
423 | 380 |
} |
424 | 381 |
public static final Rank GRAFTCHIMAERA(){ |
425 |
return GRAFTCHIMAERA;
|
|
382 |
return getTermByUuid(uuidGraftChimaera);
|
|
426 | 383 |
} |
427 | 384 |
public static final Rank CULTIVARGROUP(){ |
428 |
return CULTIVARGROUP;
|
|
385 |
return getTermByUuid(uuidCultivarGroup);
|
|
429 | 386 |
} |
430 | 387 |
public static final Rank CULTIVAR(){ |
431 |
return CULTIVAR;
|
|
388 |
return getTermByUuid(uuidCultivar);
|
|
432 | 389 |
} |
433 | 390 |
public static final Rank UNKNOWN_RANK(){ |
434 |
return UNKNOWN_RANK; |
|
391 |
return getTermByUuid(uuidUnknownRank); |
|
392 |
} |
|
393 |
public static final Rank NATIO(){ |
|
394 |
return getTermByUuid(uuidNatio); |
|
435 | 395 |
} |
436 | 396 |
|
397 |
|
|
437 | 398 |
/** |
438 | 399 |
* Returns the boolean value indicating whether <i>this</i> rank is higher than |
439 | 400 |
* the genus rank (true) or not (false). Returns false if <i>this</i> rank is null. |
... | ... | |
485 | 446 |
*/ |
486 | 447 |
@Transient |
487 | 448 |
public boolean isSpeciesAggregate(){ |
488 |
return (this.equals(Rank.SPECIESAGGREGATE) || this.equals(Rank.SPECIESGROUP()));
|
|
449 |
return (this.equals(Rank.SPECIESAGGREGATE()) || (this.isLower(Rank.SPECIESAGGREGATE()) && this.isHigher(Rank.SPECIES())));
|
|
489 | 450 |
} |
490 | 451 |
|
491 | 452 |
/** |
... | ... | |
599 | 560 |
|
600 | 561 |
/** |
601 | 562 |
* Returns the rank identified through an abbreviated name for a given nomenclatural code. |
602 |
* Preliminary implementation.
|
|
563 |
* See also {@link #getRankByAbbreviation(String, boolean)}
|
|
603 | 564 |
* |
604 | 565 |
* @param abbrev the string for the name abbreviation |
605 | 566 |
* @param nc the nomenclatural code |
606 | 567 |
* @return the rank |
607 | 568 |
*/ |
608 |
public static Rank getRankByAbbreviation(String abbrev, NomenclaturalCode nc) |
|
609 |
throws UnknownCdmTypeException{ |
|
569 |
public static Rank getRankByAbbreviation(String abbrev, NomenclaturalCode nc) throws UnknownCdmTypeException{ |
|
610 | 570 |
return getRankByAbbreviation(abbrev, nc, false); |
611 | 571 |
} |
612 | 572 |
|
... | ... | |
614 | 574 |
// Preliminary implementation for BotanicalNameParser. |
615 | 575 |
// not yet complete |
616 | 576 |
/** |
617 |
* Returns the rank identified through an abbreviated name. |
|
618 |
* Preliminary implementation for BotanicalNameParser. |
|
577 |
* Returns the rank identified through an abbreviated representation. |
|
578 |
* At the moment it uses the English abbreviations (being Latin because |
|
579 |
* we do not have Latin representations yet. |
|
580 |
* TODO |
|
581 |
* If no according abbreviation is available it throws either an UnknownCdmTypeException |
|
582 |
* or an #Rank.UNKNOWN() object depending on the useUnknown flag. |
|
619 | 583 |
* |
620 | 584 |
* @param abbrev the string for the name abbreviation |
621 | 585 |
* @param useUnknown if true the rank UNKNOWN_RANK is returned if the abbrev is |
622 |
* unknown or not yet implemented
|
|
586 |
* unknown or not yet existent
|
|
623 | 587 |
* @return the rank |
624 | 588 |
*/ |
625 |
public static Rank getRankByAbbreviation(String abbrev, boolean useUnknown) |
|
626 |
throws UnknownCdmTypeException{ |
|
627 |
if (abbrev == null){ throw new NullPointerException("abbrev is 'null' in getRankByAbbreviation"); |
|
628 |
}else if (abbrev.equalsIgnoreCase("reg.")){ return Rank.KINGDOM(); |
|
629 |
}else if (abbrev.equalsIgnoreCase("subreg.")){ return Rank.SUBKINGDOM(); |
|
630 |
}else if (abbrev.equalsIgnoreCase("phyl.")){return Rank.PHYLUM(); |
|
631 |
}else if (abbrev.equalsIgnoreCase("subphyl.")) { return Rank.SUBPHYLUM(); |
|
632 |
}else if (abbrev.equalsIgnoreCase("div.")) { return Rank.DIVISION(); |
|
633 |
}else if (abbrev.equalsIgnoreCase("subdiv.")) { return Rank.SUBDIVISION(); |
|
634 |
}else if (abbrev.equalsIgnoreCase("cl.")) { return Rank.CLASS(); |
|
635 |
}else if (abbrev.equalsIgnoreCase("subcl.")) { return Rank.SUBCLASS(); |
|
636 |
}else if (abbrev.equalsIgnoreCase("superor.")) { return Rank.SUPERORDER(); |
|
637 |
}else if (abbrev.equalsIgnoreCase("ordo")) { return Rank.ORDER(); |
|
638 |
}else if (abbrev.equalsIgnoreCase("subor.")) { return Rank.SUBORDER(); |
|
639 |
}else if (abbrev.equalsIgnoreCase("fam.")) { return Rank.FAMILY(); |
|
640 |
}else if (abbrev.equalsIgnoreCase("subfam.")) { return Rank.SUBFAMILY(); |
|
641 |
}else if (abbrev.equalsIgnoreCase("trib.")) { return Rank.TRIBE(); |
|
642 |
}else if (abbrev.equalsIgnoreCase("subtrib.")) { return Rank.SUBTRIBE(); |
|
643 |
}else if (abbrev.equalsIgnoreCase("gen.")) { return Rank.GENUS(); |
|
644 |
}else if (abbrev.equalsIgnoreCase("subg.")) { return Rank.SUBGENUS(); |
|
645 |
}else if (abbrev.equalsIgnoreCase("sect.")) { return Rank.SECTION_BOTANY(); |
|
646 |
}else if (abbrev.equalsIgnoreCase("subsect.")) { return Rank.SUBSECTION_BOTANY(); |
|
647 |
}else if (abbrev.equalsIgnoreCase("ser.")) { return Rank.SERIES(); |
|
648 |
}else if (abbrev.equalsIgnoreCase("subser.")) { return Rank.SUBSERIES(); |
|
649 |
}else if (abbrev.equalsIgnoreCase("aggr.")) { return Rank.SPECIESAGGREGATE(); |
|
650 |
}else if (abbrev.equalsIgnoreCase("group")) { return Rank.SPECIESGROUP(); |
|
651 |
}else if (abbrev.equalsIgnoreCase("sp.")) { return Rank.SPECIES(); |
|
652 |
}else if (abbrev.equalsIgnoreCase("subsp.")) { return Rank.SUBSPECIES(); |
|
653 |
}else if (abbrev.equalsIgnoreCase("convar.")) { return Rank.CONVAR(); |
|
654 |
}else if (abbrev.equalsIgnoreCase("var.")) { return Rank.VARIETY(); |
|
655 |
}else if (abbrev.equalsIgnoreCase("subvar.")) { return Rank.SUBVARIETY(); |
|
656 |
}else if (abbrev.equalsIgnoreCase("f.")) { return Rank.FORM(); |
|
657 |
}else if (abbrev.equalsIgnoreCase("subf.")) { return Rank.SUBFORM(); |
|
658 |
//TODO |
|
659 |
//}else if (abbrev.equalsIgnoreCase("f.spec.")) { return Rank.FORMA_SPEC(); |
|
660 |
}else if (abbrev.equalsIgnoreCase("t.infgen.")) { return Rank.INFRAGENERICTAXON(); |
|
661 |
}else if (abbrev.equalsIgnoreCase("t.infr.")) { return Rank.INFRASPECIFICTAXON(); |
|
589 |
public static Rank getRankByAbbreviation(String abbrev, boolean useUnknown) throws UnknownCdmTypeException{ |
|
590 |
Rank result = null; |
|
591 |
if (abbrev == null){ |
|
592 |
throw new NullPointerException("Abbrev is NULL in getRankByAbbreviation"); |
|
593 |
} |
|
594 |
if (abbrevMap == null){ |
|
595 |
return null; |
|
596 |
} |
|
597 |
UUID uuid = abbrevMap.get(abbrev); |
|
598 |
if (uuid != null ){ |
|
599 |
result = getTermByUuid(uuid); |
|
600 |
} |
|
601 |
if (result != null){ |
|
602 |
return result; |
|
662 | 603 |
}else { |
663 | 604 |
if (abbrev == null){ |
664 | 605 |
abbrev = "(null)"; |
665 | 606 |
} |
666 | 607 |
if (useUnknown){ |
667 |
logger.info("Unknown rank name: " + abbrev+". Rank 'UNKNOWN_RANK' created instead");
|
|
608 |
logger.info("Unknown rank name: " + abbrev + ". Rank 'UNKNOWN_RANK' created instead");
|
|
668 | 609 |
return Rank.UNKNOWN_RANK(); |
669 | 610 |
}else{ |
670 |
if (abbrev == null){ |
|
671 |
abbrev = "(null)"; |
|
672 |
} |
|
673 | 611 |
throw new UnknownCdmTypeException("Unknown rank abbreviation: " + abbrev); |
674 | 612 |
} |
675 | 613 |
} |
... | ... | |
680 | 618 |
/** |
681 | 619 |
* Returns the rank identified through an abbreviated name for a given nomenclatural code. |
682 | 620 |
* Preliminary implementation for ICBN and ICZN. |
621 |
* See also {@link #getRankByAbbreviation(String, boolean)} |
|
622 |
|
|
683 | 623 |
* |
684 | 624 |
* @param abbrev the string for the name abbreviation |
685 | 625 |
* @param nc the nomenclatural code |
... | ... | |
731 | 671 |
/** |
732 | 672 |
* Returns the rank identified through a name. |
733 | 673 |
* Preliminary implementation for BotanicalNameParser. |
674 |
* TODO At the moment we do not have Latin representations yet. |
|
734 | 675 |
* |
735 | 676 |
* @param rankName the string for the name of the rank |
736 | 677 |
* @param useUnknown if true the rank UNKNOWN_RANK is returned if the rank name is |
... | ... | |
793 | 734 |
} |
794 | 735 |
} |
795 | 736 |
} |
796 |
|
|
797 |
public static Rank getRankByEnglishName(String rankName, NomenclaturalCode nc, boolean useUnknown) |
|
798 |
throws UnknownCdmTypeException{ |
|
799 |
if (rankName.equalsIgnoreCase("Kingdom")){ return Rank.KINGDOM(); |
|
800 |
}else if (rankName.equalsIgnoreCase("Subkingdom")){ return Rank.SUBKINGDOM(); |
|
801 |
}else if (rankName.equalsIgnoreCase("Infrakingdom")){ return Rank.INFRAKINGDOM(); |
|
802 |
}else if (rankName.equalsIgnoreCase("Division")){ return Rank.DIVISION(); |
|
803 |
}else if (rankName.equalsIgnoreCase("Phylum")){ return Rank.PHYLUM(); |
|
804 |
}else if (rankName.equalsIgnoreCase("Subdivision")){ return Rank.SUBDIVISION(); |
|
805 |
}else if (rankName.equalsIgnoreCase("Subphylum")){ return Rank.SUBPHYLUM(); |
|
806 |
}else if (rankName.equalsIgnoreCase("Superclass")){ return Rank.SUPERCLASS(); |
|
807 |
}else if (rankName.equalsIgnoreCase("Class")){ return Rank.CLASS(); |
|
808 |
}else if (rankName.equalsIgnoreCase("Subclass")){ return Rank.SUBCLASS(); |
|
809 |
}else if (rankName.equalsIgnoreCase("Infraclass")){ return Rank.INFRACLASS(); |
|
810 |
}else if (rankName.equalsIgnoreCase("Superorder")){ return Rank.SUPERORDER(); |
|
811 |
}else if (rankName.equalsIgnoreCase("Order")){ return Rank.ORDER(); |
|
812 |
}else if (rankName.equalsIgnoreCase("Suborder")){ return Rank.SUBORDER(); |
|
813 |
}else if (rankName.equalsIgnoreCase("Infraorder")){ return Rank.INFRAORDER(); |
|
814 |
}else if (rankName.equalsIgnoreCase("Section")){ return Rank.SECTION_ZOOLOGY(); |
|
815 |
//(Sub-)Sectio |
|
816 |
}else if (rankName.equalsIgnoreCase("Section")){ |
|
817 |
if (nc != null && nc.equals(NomenclaturalCode.ICZN)){ return Rank.SECTION_ZOOLOGY; |
|
818 |
}else if (nc != null && nc.equals(NomenclaturalCode.ICBN)){return Rank.SECTION_BOTANY; |
|
737 |
|
|
738 |
public static Rank getRankByEnglishName(String rankName, NomenclaturalCode nc, boolean useUnknown) throws UnknownCdmTypeException{ |
|
739 |
Rank result = null; |
|
740 |
if (rankName == null){ |
|
741 |
throw new NullPointerException("Abbrev is NULL in getRankByAbbreviation"); |
|
742 |
} |
|
743 |
if (labelMap == null){ |
|
744 |
return null; |
|
745 |
} |
|
746 |
//handle section and subsection (not unique representations) |
|
747 |
if (rankName.equalsIgnoreCase("Section")){ |
|
748 |
if (nc != null && nc.equals(NomenclaturalCode.ICZN)){ return Rank.SECTION_ZOOLOGY(); |
|
749 |
}else if (nc != null && nc.equals(NomenclaturalCode.ICBN)){return Rank.SECTION_BOTANY(); |
|
819 | 750 |
}else{ |
820 | 751 |
String errorWarning = "Section is only defined for ICZN and ICBN at the moment but here needed for " + ((nc == null)? "(null)": nc.toString()); |
821 | 752 |
logger.warn(errorWarning); |
822 | 753 |
throw new UnknownCdmTypeException (errorWarning); |
823 | 754 |
} |
824 | 755 |
}else if (rankName.equalsIgnoreCase("Subsection")){ |
825 |
if (nc != null && nc.equals(NomenclaturalCode.ICZN)){ return Rank.SECTION_ZOOLOGY; |
|
826 |
}else if (nc != null && nc.equals(NomenclaturalCode.ICBN)){ return Rank.SECTION_BOTANY; |
|
756 |
if (nc != null && nc.equals(NomenclaturalCode.ICZN)){ return Rank.SECTION_ZOOLOGY();
|
|
757 |
}else if (nc != null && nc.equals(NomenclaturalCode.ICBN)){ return Rank.SECTION_BOTANY();
|
|
827 | 758 |
}else{ |
828 | 759 |
String errorWarning = "Subsection is only defined for ICZN and ICBN at the moment but here needed for " + ((nc == null)? "(null)": nc.toString()); |
829 | 760 |
logger.warn(errorWarning); |
830 | 761 |
throw new UnknownCdmTypeException (errorWarning); |
831 | 762 |
} |
832 |
}else if (rankName.equalsIgnoreCase("Superfamily")){ return Rank.SUPERFAMILY(); |
|
833 |
}else if (rankName.equalsIgnoreCase("Family")){ return Rank.FAMILY(); |
|
834 |
}else if (rankName.equalsIgnoreCase("Subfamily")){ return Rank.SUBFAMILY(); |
|
835 |
}else if (rankName.equalsIgnoreCase("Tribe")){ return Rank.TRIBE(); |
|
836 |
}else if (rankName.equalsIgnoreCase("Subtribe")){ return Rank.SUBTRIBE(); |
|
837 |
}else if (rankName.equalsIgnoreCase("Genus")){ return Rank.GENUS(); |
|
838 |
}else if (rankName.equalsIgnoreCase("Subgenus")){ return Rank.SUBGENUS(); |
|
839 |
}else if (rankName.equalsIgnoreCase("Species")){ return Rank.SPECIES(); |
|
840 |
}else if (rankName.equalsIgnoreCase("Subspecies")){ return Rank.SUBSPECIES(); |
|
841 |
//Natio |
|
842 |
// }else if (rankName.equalsIgnoreCase("Natio")){ return Rank.NATIO(); |
|
843 |
|
|
844 |
}else if (rankName.equalsIgnoreCase("Variety")){ return Rank.VARIETY(); |
|
845 |
}else if (rankName.equalsIgnoreCase("Subvariety")){ return Rank.SUBVARIETY(); |
|
763 |
} |
|
846 | 764 |
|
847 |
}else if (rankName.equalsIgnoreCase("Forma")){ return Rank.FORM(); |
|
848 |
}else if (rankName.equalsIgnoreCase("Subforma")){ return Rank.SUBFORM(); |
|
765 |
rankName = rankName.toLowerCase(); |
|
849 | 766 |
|
850 |
}else{ |
|
767 |
UUID uuid = labelMap.get(rankName); |
|
768 |
if (uuid != null ){ |
|
769 |
result = getTermByUuid(uuid); |
|
770 |
} |
|
771 |
if (result != null){ |
|
772 |
return result; |
|
773 |
}else { |
|
851 | 774 |
if (rankName == null){ |
852 | 775 |
rankName = "(null)"; |
853 | 776 |
} |
854 | 777 |
if (useUnknown){ |
855 |
logger.info("Unknown rank name: " + rankName+". Rank 'UNKNOWN_RANK' created instead");
|
|
778 |
logger.info("Unknown rank name: " + rankName + ". Rank 'UNKNOWN_RANK' created instead");
|
|
856 | 779 |
return Rank.UNKNOWN_RANK(); |
857 | 780 |
}else{ |
858 |
if (rankName == null){ |
|
859 |
rankName = "(null)"; |
|
860 |
} |
|
861 |
throw new UnknownCdmTypeException("Unknown rank name: " + rankName); |
|
781 |
throw new UnknownCdmTypeException("Unknown rank: " + rankName); |
|
862 | 782 |
} |
863 | 783 |
} |
864 | 784 |
} |
785 |
|
|
865 | 786 |
|
866 | 787 |
public static Rank getRankByName(String rankName, NomenclaturalCode nc, boolean useUnknown) |
867 | 788 |
throws UnknownCdmTypeException { |
... | ... | |
874 | 795 |
return getRankByName(rankName, useUnknown); |
875 | 796 |
} |
876 | 797 |
|
877 |
//TODO |
|
878 |
//dummy implementation for BerlinModelImport |
|
879 |
// not yet complete |
|
880 | 798 |
/** |
881 |
* Returns the abbreviated rank name for <i>this</i> rank according to the |
|
882 |
* Berlin Model. Preliminary implementation for BerlinModelImport. |
|
799 |
* Returns the abbreviated rank name for <i>this</i> rank according to the English representation |
|
800 |
* abbreviated label. |
|
801 |
* TODO Needs to be changed to Latin as soon as Latin representations are available. |
|
883 | 802 |
* |
884 | 803 |
* @return the abbreviation string for <i>this</i> rank |
885 | 804 |
*/ |
886 | 805 |
public String getAbbreviation(){ |
887 |
if (this.equals(Rank.ORDER()) ){return "ordo";} |
|
888 |
if (this.equals(Rank.FAMILY()) ){return "fam.";} |
|
889 |
else if (this.equals(Rank.SUBFAMILY()) ){return "subfam.";} |
|
890 |
else if (this.equals(Rank.TRIBE()) ){return "trib.";} |
|
891 |
else if (this.equals(Rank.SUBTRIBE()) ){return "subtrib.";} |
|
892 |
else if (this.equals(Rank.GENUS()) ){return "gen.";} |
|
893 |
else if (this.equals(Rank.SUBGENUS()) ){return "subg.";} |
|
894 |
else if (this.equals(Rank.SECTION_BOTANY()) ){return "sect.";} |
|
895 |
else if (this.equals(Rank.SUBSECTION_BOTANY()) ){return "subsect.";} |
|
896 |
else if (this.equals(Rank.SERIES()) ){return "ser.";} |
|
897 |
//else if (this.equals(Rank.AGGREGATE()) ){return "aggr.";} |
|
898 |
else if (this.equals(Rank.SPECIES()) ){return "sp.";} |
|
899 |
else if (this.equals(Rank.SUBSPECIES()) ){return "subsp.";} |
|
900 |
else if (this.equals(Rank.VARIETY()) ){return "var.";} |
|
901 |
else if (this.equals(Rank.CONVAR()) ){return "convar.";} |
|
902 |
else if (this.equals(Rank.SUBVARIETY()) ){return "subvar.";} |
|
903 |
else if (this.equals(Rank.FORM()) ){return "f.";} |
|
904 |
else if (this.equals(Rank.SPECIALFORM()) ){return "f.spec.";} |
|
905 |
else if (this.equals(Rank.INFRAGENERICTAXON()) ){return "t.infgen.";} |
|
906 |
else if (this.equals(Rank.INFRASPECIFICTAXON()) ){return "t.infr.";} |
|
907 |
else { |
|
806 |
Language language = Language.ENGLISH(); |
|
807 |
String result = this.getRepresentation(language).getAbbreviatedLabel(); |
|
808 |
if (result== null) { |
|
908 | 809 |
logger.warn("Abbreviation for this Rank " + this.toString() + " not yet implemented"); |
909 |
return "xxx."; |
|
810 |
return "no abbreviation available."; |
|
811 |
}else{ |
|
812 |
return result; |
|
910 | 813 |
} |
911 | 814 |
} |
912 | 815 |
@Transient |
913 | 816 |
public String getInfraGenericMarker() throws UnknownCdmTypeException{ |
817 |
String result = null; |
|
914 | 818 |
if (! this.isInfraGeneric()){ |
915 | 819 |
throw new IllegalStateException("An infrageneric marker is only available for a infrageneric rank but was asked for rank: " + this.toString()); |
916 |
}else if (this.equals(Rank.SUBGENUS())){ |
|
917 |
return "subg."; |
|
918 |
}else if (this.equals(Rank.INFRAGENUS())){ |
|
919 |
return "infrag."; //?? |
|
920 |
}else if (this.equals(Rank.SECTION_BOTANY())){ |
|
921 |
return "sect."; |
|
922 |
}else if (this.equals(Rank.SUBSECTION_BOTANY())){ |
|
923 |
return "subsect."; |
|
924 |
}else if (this.equals(Rank.SERIES())){ |
|
925 |
return "ser."; |
|
926 |
}else if (this.equals(Rank.SUBSERIES())){ |
|
927 |
return "subser."; |
|
928 |
}else if (this.equals(Rank.SPECIESAGGREGATE())){ |
|
929 |
return "aggr."; |
|
930 |
}else if (this.equals(Rank.SPECIESGROUP())){ |
|
931 |
return "group"; |
|
932 |
}else { |
|
820 |
}else{ |
|
821 |
result = this.getAbbreviation(); |
|
822 |
} |
|
823 |
if (result == null){ |
|
933 | 824 |
throw new UnknownCdmTypeException("Abbreviation for rank unknown: " + this.toString()); |
934 | 825 |
} |
826 |
return result; |
|
827 |
} |
|
828 |
|
|
829 |
|
|
830 |
|
|
831 |
@Override |
|
832 |
public Rank readCsvLine(Class<Rank> termClass, List<String> csvLine, Map<UUID, DefinedTermBase> terms) { |
|
833 |
return super.readCsvLine(termClass, csvLine, terms); |
|
935 | 834 |
} |
936 | 835 |
|
937 | 836 |
@Override |
938 | 837 |
protected void setDefaultTerms(TermVocabulary<Rank> termVocabulary) { |
939 |
Rank.BIOVARIETY = termVocabulary.findTermByUuid(Rank.uuidBioVariety); |
|
940 |
Rank.CANDIDATE = termVocabulary.findTermByUuid(Rank.uuidCandidate); |
|
941 |
Rank.CLASS = termVocabulary.findTermByUuid(Rank.uuidClass); |
|
942 |
Rank.CONVAR = termVocabulary.findTermByUuid(Rank.uuidConvar); |
|
943 |
Rank.CULTIVAR = termVocabulary.findTermByUuid(Rank.uuidCultivar); |
|
944 |
Rank.CULTIVARGROUP = termVocabulary.findTermByUuid(Rank.uuidCultivarGroup); |
|
945 |
Rank.DENOMINATIONCLASS = termVocabulary.findTermByUuid(Rank.uuidDenominationClass); |
|
946 |
Rank.DIVISION = termVocabulary.findTermByUuid(Rank.uuidDivision); |
|
947 |
Rank.DOMAIN = termVocabulary.findTermByUuid(Rank.uuidDomain); |
|
948 |
Rank.EMPIRE = termVocabulary.findTermByUuid(Rank.uuidEmpire); |
|
949 |
Rank.FAMILY = termVocabulary.findTermByUuid(Rank.uuidFamily); |
|
950 |
Rank.FORM = termVocabulary.findTermByUuid(Rank.uuidForm); |
|
951 |
Rank.GENUS = termVocabulary.findTermByUuid(Rank.uuidGenus); |
|
952 |
Rank.GRAFTCHIMAERA = termVocabulary.findTermByUuid(Rank.uuidGraftChimaera); |
|
953 |
Rank.GREX = termVocabulary.findTermByUuid(Rank.uuidGrex); |
|
954 |
Rank.INFRACLASS = termVocabulary.findTermByUuid(Rank.uuidInfraclass); |
|
955 |
Rank.INFRADIVISION = termVocabulary.findTermByUuid(Rank.uuidInfradivision); |
|
956 |
Rank.INFRAFAMILY = termVocabulary.findTermByUuid(Rank.uuidInfrafamily); |
|
957 |
Rank.INFRAGENERICTAXON = termVocabulary.findTermByUuid(Rank.uuidInfragenericTaxon); |
|
958 |
Rank.INFRAGENUS = termVocabulary.findTermByUuid(Rank.uuidInfragenus); |
|
959 |
Rank.INFRAKINGDOM = termVocabulary.findTermByUuid(Rank.uuidInfrakingdom); |
|
960 |
Rank.INFRAORDER = termVocabulary.findTermByUuid(Rank.uuidInfraorder); |
|
961 |
Rank.INFRAPHYLUM = termVocabulary.findTermByUuid(Rank.uuidInfraphylum); |
|
962 |
Rank.INFRASPECIES = termVocabulary.findTermByUuid(Rank.uuidInfraspecies); |
|
963 |
Rank.INFRASPECIFICTAXON = termVocabulary.findTermByUuid(Rank.uuidInfraspecificTaxon); |
|
964 |
Rank.INFRATRIBE = termVocabulary.findTermByUuid(Rank.uuidInfratribe); |
|
965 |
Rank.KINGDOM = termVocabulary.findTermByUuid(Rank.uuidKingdom); |
|
966 |
Rank.ORDER = termVocabulary.findTermByUuid(Rank.uuidOrder); |
|
967 |
Rank.PATHOVARIETY = termVocabulary.findTermByUuid(Rank.uuidPathoVariety); |
|
968 |
Rank.PHYLUM = termVocabulary.findTermByUuid(Rank.uuidPhylum); |
|
969 |
Rank.SECTION_BOTANY = termVocabulary.findTermByUuid(Rank.uuidSectionBotany); |
|
970 |
Rank.SECTION_ZOOLOGY = termVocabulary.findTermByUuid(Rank.uuidSectionZoology); |
|
971 |
Rank.SERIES = termVocabulary.findTermByUuid(Rank.uuidSeries); |
|
972 |
Rank.SPECIALFORM = termVocabulary.findTermByUuid(Rank.uuidSpecialForm); |
|
973 |
Rank.SPECIES = termVocabulary.findTermByUuid(Rank.uuidSpecies); |
|
974 |
Rank.SPECIESAGGREGATE = termVocabulary.findTermByUuid(Rank.uuidSpeciesAggregate); |
|
975 |
Rank.SPECIESGROUP = termVocabulary.findTermByUuid(Rank.uuidSpeciesGroup); |
|
976 |
Rank.SUBCLASS = termVocabulary.findTermByUuid(Rank.uuidSubclass); |
|
977 |
Rank.SUBDIVISION = termVocabulary.findTermByUuid(Rank.uuidSubdivision); |
|
978 |
Rank.SUBFAMILY = termVocabulary.findTermByUuid(Rank.uuidSubfamily); |
|
979 |
Rank.SUBFORM = termVocabulary.findTermByUuid(Rank.uuidSubform); |
|
980 |
Rank.SUBGENUS = termVocabulary.findTermByUuid(Rank.uuidSubgenus); |
|
981 |
Rank.SUBKINGDOM = termVocabulary.findTermByUuid(Rank.uuidSubkingdom); |
|
982 |
Rank.SUBORDER = termVocabulary.findTermByUuid(Rank.uuidSuborder); |
|
983 |
Rank.SUBPHYLUM = termVocabulary.findTermByUuid(Rank.uuidSubphylum); |
|
984 |
Rank.SUBSECTION_BOTANY = termVocabulary.findTermByUuid(Rank.uuidSubsectionBotany); |
|
985 |
Rank.SUBSECTION_ZOOLOGY = termVocabulary.findTermByUuid(Rank.uuidSubsectionZoology); |
|
986 |
Rank.SUBSERIES = termVocabulary.findTermByUuid(Rank.uuidSubseries); |
|
987 |
Rank.SUBSPECIES = termVocabulary.findTermByUuid(Rank.uuidSubspecies); |
|
988 |
Rank.SUBSPECIFICAGGREGATE = termVocabulary.findTermByUuid(Rank.uuidSubspecificAggregate); |
|
989 |
Rank.SUBSUBFORM = termVocabulary.findTermByUuid(Rank.uuidSubsubform); |
|
990 |
Rank.SUBSUBVARIETY = termVocabulary.findTermByUuid(Rank.uuidSubsubvariety); |
|
991 |
Rank.SUBTRIBE = termVocabulary.findTermByUuid(Rank.uuidSubtribe); |
|
992 |
Rank.SUBVARIETY = termVocabulary.findTermByUuid(Rank.uuidSubvariety); |
|
993 |
Rank.SUPERCLASS = termVocabulary.findTermByUuid(Rank.uuidSuperclass); |
|
994 |
Rank.SUPERDIVISION = termVocabulary.findTermByUuid(Rank.uuidSuperdivision); |
|
995 |
Rank.SUPERFAMILY = termVocabulary.findTermByUuid(Rank.uuidSuperfamily); |
|
996 |
Rank.SUPERKINGDOM = termVocabulary.findTermByUuid(Rank.uuidSuperkingdom); |
|
997 |
Rank.SUPERORDER = termVocabulary.findTermByUuid(Rank.uuidSuperorder); |
|
998 |
Rank.SUPERPHYLUM = termVocabulary.findTermByUuid(Rank.uuidSuperphylum); |
|
999 |
Rank.SUPERTRIBE = termVocabulary.findTermByUuid(Rank.uuidSupertribe); |
|
1000 |
Rank.SUPRAGENERICTAXON = termVocabulary.findTermByUuid(Rank.uuidSupragenericTaxon); |
|
1001 |
Rank.TRIBE = termVocabulary.findTermByUuid(Rank.uuidTribe); |
|
1002 |
Rank.UNKNOWN_RANK = termVocabulary.findTermByUuid(Rank.uuidUnknownRank); |
|
1003 |
Rank.VARIETY = termVocabulary.findTermByUuid(Rank.uuidVariety); |
|
838 |
termMap = new HashMap<UUID, Rank>(); |
|
839 |
for (Rank term : termVocabulary.getTerms()){ |
|
840 |
termMap.put(term.getUuid(), (Rank)term); |
|
841 |
addRank(term); |
|
842 |
} |
|
1004 | 843 |
} |
844 |
|
|
845 |
/** |
|
846 |
* @param term |
|
847 |
*/ |
|
848 |
private void addRank(Rank rank) { |
|
849 |
if (rank == null){ |
|
850 |
logger.warn("rank is NULL"); |
|
851 |
return; |
|
852 |
} |
|
853 |
if (rank.getUuid().equals(uuidSectionZoology) || rank.getUuid().equals(uuidSubsectionZoology )){ |
|
854 |
//sect./subsect. is used for botanical sections, see also #getRankByAbbreviation(String, NomenclaturalCode, boolean) |
|
855 |
return; |
|
856 |
} |
|
857 |
Language lang = Language.DEFAULT(); //TODO should be Latin but at the moment we have only English representations |
|
858 |
Representation representation = rank.getRepresentation(lang); |
|
859 |
String abbrevLabel = representation.getAbbreviatedLabel(); |
|
860 |
String label = representation.getLabel(); |
|
861 |
if (abbrevLabel == null){ |
|
862 |
logger.warn("label is NULL"); |
|
863 |
return; |
|
864 |
} |
|
865 |
//initialize maps |
|
866 |
if (abbrevMap == null){ |
|
867 |
abbrevMap = new HashMap<String, UUID>(); |
|
868 |
} |
|
869 |
if (labelMap == null){ |
|
870 |
labelMap = new HashMap<String, UUID>(); |
|
871 |
} |
|
872 |
//add to map |
|
873 |
abbrevMap.put(abbrevLabel, rank.getUuid()); |
|
874 |
labelMap.put(label.toLowerCase(), rank.getUuid()); |
|
875 |
} |
|
876 |
|
|
1005 | 877 |
} |
Also available in: Unified diff
merging /branches/cdmlib/SPRINT-Chichorieae1/ to trunk