2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.model
.term
;
11 import java
.util
.HashMap
;
14 import java
.util
.UUID
;
16 import javax
.persistence
.Entity
;
17 import javax
.xml
.bind
.annotation
.XmlAccessType
;
18 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
19 import javax
.xml
.bind
.annotation
.XmlRootElement
;
20 import javax
.xml
.bind
.annotation
.XmlType
;
22 import org
.hibernate
.envers
.Audited
;
29 @XmlAccessorType(XmlAccessType
.FIELD
)
30 @XmlType(name
= "DefinedTerm")
31 @XmlRootElement(name
= "DefinedTerm")
33 //@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
34 //@Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
36 public class DefinedTerm
extends DefinedTermBase
<DefinedTerm
> implements Comparable
<DefinedTerm
> {
37 private static final long serialVersionUID
= -6965540410672076893L;
39 //Determination modifier
40 public static final UUID uuidConfer
= UUID
.fromString("20db670a-2db2-49cc-bbdd-eace33694b7f");
41 public static final UUID uuidAffinis
= UUID
.fromString("128f0b54-73e2-4efb-bfda-a6243185a562");
44 private static final UUID uuidMale
= UUID
.fromString("600a5212-cc02-431d-8a80-2bf595bd1eab");
45 private static final UUID uuidFemale
= UUID
.fromString("b4cfe0cb-b35c-4f97-9b6b-2b3c096ea2c0");
46 private static final UUID uuidHermaphrodite
= UUID
.fromString("0deddc65-2505-4c77-91a7-17d0de24afcc");
47 private static final UUID uuidUnknown
= UUID
.fromString("4f5e4c51-a664-48ad-8238-2e9f49eaf8dd");
50 private static final UUID uuidIts1
= UUID
.fromString("3f2de4f6-d1a2-4c3a-be70-3c997ef92543");
53 public static final UUID uuidSpecimenScan
= UUID
.fromString("acda15be-c0e2-4ea8-8783-b9b0c4ad7f03");
54 public static final UUID uuidDetailImage
= UUID
.fromString("31eb8d02-bf5d-437c-bcc6-87a626445f34");
58 public static final UUID uuidSampleDesignation
= UUID
.fromString("fadeba12-1be3-4bc7-9ff5-361b088d86fc");
59 public static final UUID uuidLsid
= UUID
.fromString("26729412-9df6-4cc3-9e5d-501531ca21f0");
60 public static final UUID uuidAlternativeFieldNumber
= UUID
.fromString("054fd3d1-1961-42f8-b024-b91184ac9e0c");
61 public static final UUID uuidTropicosNameIdentifier
= UUID
.fromString("6205e531-75b0-4f2a-9a9c-b1247fb080ab");
62 public static final UUID uuidIpniNameIdentifier
= UUID
.fromString("009a602f-0ff6-4231-93db-f458e8229aca");
63 public static final UUID uuidWfoNameIdentifier
= UUID
.fromString("048e0cf9-f59c-42dd-bfeb-3a5cba0191c7");
64 //currently only used in Caryophyllales_spp
65 public static final UUID uuidPlantListIdentifier
= UUID
.fromString("06e4c3bd-7bf6-447a-b96e-2844b279f276");
68 //TaxonNode Agent Relation Type
69 public static final UUID uuidLastScrutiny
= UUID
.fromString("b4495910-28e9-4a49-86cf-a0476c78f460");
70 public static final UUID uuidAuthorOfSubtree
= UUID
.fromString("c2c7e9b7-d6a7-48a0-b13f-a7a2e2a9b8c9");
72 protected static Map
<UUID
, DefinedTerm
> termMap
= null;
75 protected static DefinedTerm
getTermByUuid(UUID uuid
){
76 if (termMap
== null || termMap
.isEmpty()){
77 return getTermByClassAndUUID(DefinedTerm
.class, uuid
);
79 return termMap
.get(uuid
);
84 * Creates a new empty {@link DefinedTerm} instance.
86 * @see #NewInstance(String, String, String)
88 public static DefinedTerm
NewInstance(TermType termType
) {
89 return new DefinedTerm(termType
);
92 public static DefinedTerm
NewInstance(TermType termType
, Set
<Representation
> representations
){
93 DefinedTerm term
= null;
94 for (Representation representation
: representations
) {
96 term
= new DefinedTerm(termType
);
98 term
.addRepresentation(representation
);
103 public static DefinedTerm
NewInstance(TermType termType
, String description
, String label
, String labelAbbrev
){
104 return new DefinedTerm(termType
, description
, label
, labelAbbrev
);
108 public static DefinedTerm
NewModifierInstance(String description
, String label
, String labelAbbrev
){
109 return new DefinedTerm(TermType
.Modifier
, description
, label
, labelAbbrev
);
112 public static DefinedTerm
NewInstitutionTypeInstance(String description
, String label
, String labelAbbrev
){
113 return new DefinedTerm(TermType
.InstitutionType
, description
, label
, labelAbbrev
);
116 public static DefinedTerm
NewStageInstance(String description
, String label
, String labelAbbrev
){
117 return new DefinedTerm(TermType
.Stage
, description
, label
, labelAbbrev
);
120 public static DefinedTerm
NewSexInstance(String description
, String label
, String labelAbbrev
){
121 return new DefinedTerm(TermType
.Sex
, description
, label
, labelAbbrev
);
124 public static DefinedTerm
NewScopeInstance(String description
, String label
, String labelAbbrev
){
125 return new DefinedTerm(TermType
.Scope
, description
, label
, labelAbbrev
);
128 public static DefinedTerm
NewDnaMarkerInstance(String description
, String label
, String labelAbbrev
){
129 return new DefinedTerm(TermType
.DnaMarker
, description
, label
, labelAbbrev
);
132 public static DefinedTerm
NewKindOfUnitInstance(String description
, String label
, String labelAbbrev
){
133 return new DefinedTerm(TermType
.KindOfUnit
, description
, label
, labelAbbrev
);
136 public static DefinedTerm
NewIdentifierTypeInstance(String description
, String label
, String labelAbbrev
){
137 return new DefinedTerm(TermType
.IdentifierType
, description
, label
, labelAbbrev
);
140 public static DefinedTerm
NewTaxonNodeAgentRelationTypeInstance(String description
, String label
, String labelAbbrev
){
141 return new DefinedTerm(TermType
.TaxonNodeAgentRelationType
, description
, label
, labelAbbrev
);
144 //******************* CONSTRUCTOR ***********************************/
146 //for hibernate/javassist use only
148 protected DefinedTerm(){super(TermType
.Unknown
);}
150 protected DefinedTerm(TermType termType
){
154 public DefinedTerm(TermType type
, String description
, String label
, String labelAbbrev
) {
155 super(type
, description
, label
, labelAbbrev
);
158 //*************************** TERM MAP *********************/
161 public static final DefinedTerm
DETERMINATION_MODIFIER_AFFINIS(){
162 return getTermByUuid(uuidAffinis
);
165 public static final DefinedTerm
DETERMINATION_MODIFIER_CONFER(){
166 return getTermByUuid(uuidConfer
);
169 public static DefinedTerm
SEX_MALE(){
170 return getTermByUuid(uuidMale
);
173 public static DefinedTerm
SEX_FEMALE(){
174 return getTermByUuid(uuidFemale
);
177 public static DefinedTerm
SEX_HERMAPHRODITE(){
178 return getTermByUuid(uuidHermaphrodite
);
181 public static DefinedTerm
SEX_UNKNOWN(){
182 return getTermByUuid(uuidUnknown
);
185 public static DefinedTerm
ITS1_MARKER(){
186 return getTermByUuid(uuidIts1
);
189 public static DefinedTerm
IDENTIFIER_NAME_TROPICOS(){
190 return getTermByUuid(uuidTropicosNameIdentifier
);
192 public static DefinedTerm
IDENTIFIER_NAME_IPNI(){
193 return getTermByUuid(uuidIpniNameIdentifier
);
195 public static DefinedTerm
IDENTIFIER_NAME_WFO(){
196 return getTermByUuid(uuidWfoNameIdentifier
);
199 public static DefinedTerm
WFO_NAME_IDENTIFIER(){
200 return getTermByUuid(uuidWfoNameIdentifier
);
205 public void resetTerms() {
210 protected void setDefaultTerms(TermVocabulary
<DefinedTerm
> termVocabulary
) {
211 if (termMap
== null){
212 termMap
= new HashMap
<>();
214 for (DefinedTerm term
: termVocabulary
.getTerms()){
215 termMap
.put(term
.getUuid(), term
);
220 protected int partOfCsvLineIndex(){
225 // void readIsPartOf(DefinedTerm newInstance, List<String> csvLine, Map<UUID, DefinedTermBase> terms) {
227 // String partOfString = csvLine.get(index);
229 // if(StringUtils.isNotBlank(partOfString)) {
230 // UUID partOfUuid = UUID.fromString(partOfString);
231 // DefinedTerm partOf = (DefinedTerm)terms.get(partOfUuid);
232 // partOf.addIncludes(newInstance);