1
|
package eu.etaxonomy.cdm.model.description;
|
2
|
|
3
|
import java.util.Map;
|
4
|
import java.util.UUID;
|
5
|
|
6
|
import javax.persistence.Entity;
|
7
|
import javax.xml.bind.annotation.XmlAccessType;
|
8
|
import javax.xml.bind.annotation.XmlAccessorType;
|
9
|
import javax.xml.bind.annotation.XmlElement;
|
10
|
import javax.xml.bind.annotation.XmlIDREF;
|
11
|
import javax.xml.bind.annotation.XmlRootElement;
|
12
|
import javax.xml.bind.annotation.XmlSchemaType;
|
13
|
import javax.xml.bind.annotation.XmlType;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.hibernate.envers.Audited;
|
17
|
|
18
|
import eu.etaxonomy.cdm.model.common.DefinedTermBase;
|
19
|
import eu.etaxonomy.cdm.model.common.Language;
|
20
|
import eu.etaxonomy.cdm.model.common.Representation;
|
21
|
import eu.etaxonomy.cdm.model.common.TermType;
|
22
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
23
|
|
24
|
@XmlAccessorType(XmlAccessType.PROPERTY)
|
25
|
@XmlType(name="NaturalLanguageTerm")
|
26
|
@XmlRootElement(name = "NaturalLanguageTerm")
|
27
|
@Entity
|
28
|
//@Indexed disabled to reduce clutter in indexes, since this type is not used by any search
|
29
|
//@Indexed(index = "eu.etaxonomy.cdm.model.common.DefinedTermBase")
|
30
|
@Audited
|
31
|
public class NaturalLanguageTerm extends DefinedTermBase<NaturalLanguageTerm> {
|
32
|
private static final long serialVersionUID = 6754598791831848705L;
|
33
|
@SuppressWarnings("unused")
|
34
|
private static final Logger logger = Logger.getLogger(NaturalLanguageTerm.class);
|
35
|
|
36
|
protected static Map<UUID, NaturalLanguageTerm> termMap = null;
|
37
|
|
38
|
|
39
|
private static NaturalLanguageTerm FROM = new NaturalLanguageTerm();
|
40
|
private static NaturalLanguageTerm TO = new NaturalLanguageTerm();
|
41
|
private static NaturalLanguageTerm UP_TO = new NaturalLanguageTerm();
|
42
|
private static NaturalLanguageTerm MOST_FREQUENTLY = new NaturalLanguageTerm();
|
43
|
private static NaturalLanguageTerm ON_AVERAGE = new NaturalLanguageTerm();
|
44
|
private static NaturalLanguageTerm MORE_OR_LESS = new NaturalLanguageTerm();
|
45
|
|
46
|
private static final UUID uuidTo = UUID.fromString("9087cdcd-8b08-4082-a1de-34c9ba9fb494");
|
47
|
|
48
|
|
49
|
public static NaturalLanguageTerm NewInstance(String term, String label, String labelAbbrev) {
|
50
|
return new NaturalLanguageTerm(term, label, labelAbbrev);
|
51
|
}
|
52
|
|
53
|
|
54
|
//********************************** Constructor *******************************************************************/
|
55
|
|
56
|
//for hibernate use only
|
57
|
@Deprecated
|
58
|
protected NaturalLanguageTerm() {
|
59
|
super(TermType.NaturalLanguageTerm);
|
60
|
}
|
61
|
|
62
|
private NaturalLanguageTerm(String term, String label, String labelAbbrev) {
|
63
|
super(TermType.NaturalLanguageTerm, term, label, labelAbbrev);
|
64
|
}
|
65
|
|
66
|
//********************************** Methods *******************************************************************/
|
67
|
|
68
|
|
69
|
@Override
|
70
|
protected void setDefaultTerms(
|
71
|
TermVocabulary<NaturalLanguageTerm> termVocabulary) {
|
72
|
//NaturalLanguageTerm.TO = termVocabulary.findTermByUuid(NaturalLanguageTerm.uuidTo);
|
73
|
//NaturalLanguageTerm.TO.setLabel("eip");
|
74
|
|
75
|
}
|
76
|
|
77
|
/* (non-Javadoc)
|
78
|
* @see eu.etaxonomy.cdm.model.common.DefinedTermBase#resetTerms()
|
79
|
*/
|
80
|
@Override
|
81
|
public void resetTerms(){
|
82
|
termMap = null;
|
83
|
}
|
84
|
|
85
|
|
86
|
@XmlElement(name = "KindOf", namespace = "http://etaxonomy.eu/cdm/model/common/1.0")
|
87
|
@XmlIDREF
|
88
|
@XmlSchemaType(name = "IDREF")
|
89
|
@Override
|
90
|
public NaturalLanguageTerm getKindOf(){
|
91
|
return super.getKindOf();
|
92
|
}
|
93
|
|
94
|
@Override
|
95
|
public void setKindOf(NaturalLanguageTerm kindOf){
|
96
|
super.setKindOf(kindOf);
|
97
|
}
|
98
|
|
99
|
/**
|
100
|
* Returns the "from" term.
|
101
|
*/
|
102
|
public static final NaturalLanguageTerm FROM(){
|
103
|
NaturalLanguageTerm nlt = FROM;
|
104
|
Representation representation = Representation.NewInstance("", "from", "", Language.ENGLISH());
|
105
|
Representation representation2 = Representation.NewInstance("", "de", "", Language.FRENCH());
|
106
|
Representation representation3 = Representation.NewInstance("", "von", "", Language.GERMAN());
|
107
|
nlt.addRepresentation(representation);
|
108
|
nlt.addRepresentation(representation2);
|
109
|
nlt.addRepresentation(representation3);
|
110
|
return nlt;
|
111
|
}
|
112
|
|
113
|
/**
|
114
|
* Returns the "to" term.
|
115
|
*/
|
116
|
public static final NaturalLanguageTerm TO(){
|
117
|
NaturalLanguageTerm nlt = TO;
|
118
|
Representation representation = Representation.NewInstance("", "to", "", Language.ENGLISH());
|
119
|
Representation representation2 = Representation.NewInstance("", "à", "", Language.FRENCH());
|
120
|
nlt.addRepresentation(representation);
|
121
|
nlt.addRepresentation(representation2);
|
122
|
return nlt;
|
123
|
}
|
124
|
|
125
|
public static final NaturalLanguageTerm UP_TO(){
|
126
|
NaturalLanguageTerm nlt = UP_TO;
|
127
|
Representation representation = Representation.NewInstance("", "up to", "", Language.ENGLISH());
|
128
|
Representation representation2 = Representation.NewInstance("", "jusqu'à", "", Language.FRENCH());
|
129
|
nlt.addRepresentation(representation);
|
130
|
nlt.addRepresentation(representation2);
|
131
|
return nlt;
|
132
|
}
|
133
|
|
134
|
public static final NaturalLanguageTerm MOST_FREQUENTLY(){
|
135
|
NaturalLanguageTerm nlt = MOST_FREQUENTLY;
|
136
|
Representation representation = Representation.NewInstance("", "most frequently", "", Language.ENGLISH());
|
137
|
Representation representation2 = Representation.NewInstance("", "plus fréquemment", "", Language.FRENCH());
|
138
|
nlt.addRepresentation(representation);
|
139
|
nlt.addRepresentation(representation2);
|
140
|
return nlt;
|
141
|
}
|
142
|
|
143
|
public static final NaturalLanguageTerm ON_AVERAGE(){
|
144
|
NaturalLanguageTerm nlt = ON_AVERAGE;
|
145
|
Representation representation = Representation.NewInstance("", "on average", "", Language.ENGLISH());
|
146
|
Representation representation2 = Representation.NewInstance("", "en moyenne", "", Language.FRENCH());
|
147
|
nlt.addRepresentation(representation);
|
148
|
nlt.addRepresentation(representation2);
|
149
|
return nlt;
|
150
|
}
|
151
|
|
152
|
public static final NaturalLanguageTerm MORE_OR_LESS(){
|
153
|
NaturalLanguageTerm nlt = MORE_OR_LESS;
|
154
|
Representation representation = Representation.NewInstance("", "+/-", "", Language.ENGLISH());
|
155
|
nlt.addRepresentation(representation);
|
156
|
return nlt;
|
157
|
}
|
158
|
}
|