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.description;
|
11
|
|
12
|
|
13
|
import eu.etaxonomy.cdm.model.common.Language;
|
14
|
import eu.etaxonomy.cdm.model.common.LanguageString;
|
15
|
import eu.etaxonomy.cdm.model.common.MultilanguageText;
|
16
|
import eu.etaxonomy.cdm.model.common.TermVocabulary;
|
17
|
import eu.etaxonomy.cdm.model.common.VersionableEntity;
|
18
|
import org.apache.log4j.Logger;
|
19
|
|
20
|
import java.util.*;
|
21
|
|
22
|
import javax.persistence.*;
|
23
|
import javax.xml.bind.annotation.XmlAccessType;
|
24
|
import javax.xml.bind.annotation.XmlAccessorType;
|
25
|
import javax.xml.bind.annotation.XmlElement;
|
26
|
import javax.xml.bind.annotation.XmlElementWrapper;
|
27
|
import javax.xml.bind.annotation.XmlIDREF;
|
28
|
import javax.xml.bind.annotation.XmlRootElement;
|
29
|
import javax.xml.bind.annotation.XmlSchemaType;
|
30
|
import javax.xml.bind.annotation.XmlType;
|
31
|
|
32
|
/**
|
33
|
* This class represents the assignment of values ({@link State state terms}) to {@link Feature features}
|
34
|
* corresponding to {@link CategoricalData categorical data}. A state data instance
|
35
|
* constitutes an atomized part of an information piece (categorical data) so
|
36
|
* that several state data instances may belong to one categorical data
|
37
|
* instance.
|
38
|
* <P>
|
39
|
* This class corresponds to CharacterStateDataType according to the SDD schema.
|
40
|
*
|
41
|
* @author m.doering
|
42
|
* @version 1.0
|
43
|
* @created 08-Nov-2007 13:06:53
|
44
|
*/
|
45
|
@XmlAccessorType(XmlAccessType.FIELD)
|
46
|
@XmlType(name = "StateData", propOrder = {
|
47
|
"state",
|
48
|
"modifiers",
|
49
|
"modifyingText"
|
50
|
})
|
51
|
@XmlRootElement(name = "StateData")
|
52
|
@Entity
|
53
|
public class StateData extends VersionableEntity {
|
54
|
|
55
|
private static final Logger logger = Logger.getLogger(StateData.class);
|
56
|
|
57
|
@XmlElement(name = "State")
|
58
|
@XmlIDREF
|
59
|
@XmlSchemaType(name = "IDREF")
|
60
|
private State state;
|
61
|
|
62
|
@XmlElementWrapper(name = "Modifiers")
|
63
|
@XmlElement(name = "Modifier")
|
64
|
private Set<Modifier> modifiers = new HashSet<Modifier>();
|
65
|
|
66
|
@XmlElement(name = "ModifyingText")
|
67
|
private MultilanguageText modifyingText;
|
68
|
|
69
|
/**
|
70
|
* Class constructor: creates a new empty state data instance.
|
71
|
*/
|
72
|
public StateData() {
|
73
|
super();
|
74
|
}
|
75
|
|
76
|
/**
|
77
|
* Creates a new empty state data instance.
|
78
|
*/
|
79
|
public static StateData NewInstance(){
|
80
|
return new StateData();
|
81
|
}
|
82
|
|
83
|
/**
|
84
|
* Returns the {@link State state term} used in <i>this</i> state data.
|
85
|
*/
|
86
|
@ManyToOne
|
87
|
public State getState(){
|
88
|
return this.state;
|
89
|
}
|
90
|
/**
|
91
|
* @see #getState()
|
92
|
*/
|
93
|
public void setState(State state){
|
94
|
this.state = state;
|
95
|
}
|
96
|
|
97
|
|
98
|
/**
|
99
|
* Returns the set of {@link Modifier modifiers} used to qualify the validity
|
100
|
* of <i>this</i> state data. This is only metainformation.
|
101
|
*/
|
102
|
@OneToMany
|
103
|
public Set<Modifier> getModifiers(){
|
104
|
return this.modifiers;
|
105
|
}
|
106
|
/**
|
107
|
* @see #getModifiers()
|
108
|
*/
|
109
|
private void setModifiers(Set<Modifier> modifiers) {
|
110
|
this.modifiers = modifiers;
|
111
|
}
|
112
|
/**
|
113
|
* Adds a {@link Modifier modifier} to the set of {@link #getModifiers() modifiers}
|
114
|
* used to qualify the validity of <i>this</i> state data.
|
115
|
*
|
116
|
* @param modifier the modifier to be added to <i>this</i> state data
|
117
|
* @see #getModifiers()
|
118
|
*/
|
119
|
public void addModifier(Modifier modifier){
|
120
|
this.modifiers.add(modifier);
|
121
|
}
|
122
|
/**
|
123
|
* Removes one element from the set of {@link #getModifiers() modifiers}
|
124
|
* used to qualify the validity of <i>this</i> state data.
|
125
|
*
|
126
|
* @param modifier the modifier which should be removed
|
127
|
* @see #getModifiers()
|
128
|
* @see #addModifier(Modifier)
|
129
|
*/
|
130
|
public void removeModifier(Modifier modifier){
|
131
|
this.modifiers.remove(modifier);
|
132
|
}
|
133
|
|
134
|
|
135
|
/**
|
136
|
* Returns the {@link MultilanguageText multilanguage text} used to qualify the validity
|
137
|
* of <i>this</i> state data. The different {@link LanguageString language strings}
|
138
|
* contained in the multilanguage text should all have the same meaning.<BR>
|
139
|
* A multilanguage text does not belong to a controlled {@link TermVocabulary term vocabulary}
|
140
|
* as a {@link Modifier modifier} does.
|
141
|
* <P>
|
142
|
* NOTE: the actual content of <i>this</i> state data is NOT
|
143
|
* stored in the modifying text. This is only metainformation
|
144
|
* (like "Some experts express doubt about this assertion").
|
145
|
*/
|
146
|
public MultilanguageText getModifyingText(){
|
147
|
return this.modifyingText;
|
148
|
}
|
149
|
/**
|
150
|
* @see #getModifyingText()
|
151
|
*/
|
152
|
private void setModifyingText(MultilanguageText modifyingText) {
|
153
|
this.modifyingText = modifyingText;
|
154
|
}
|
155
|
/**
|
156
|
* Creates a {@link LanguageString language string} based on the given text string
|
157
|
* and the given {@link Language language} and adds it to the {@link MultilanguageText multilanguage text}
|
158
|
* used to qualify the validity of <i>this</i> state data.
|
159
|
*
|
160
|
* @param text the string describing the validity
|
161
|
* in a particular language
|
162
|
* @param language the language in which the text string is formulated
|
163
|
* @see #getModifyingText()
|
164
|
* @see #addModifyingText(LanguageString)
|
165
|
*/
|
166
|
public void addModifyingText(String text, Language language){
|
167
|
this.modifyingText.put(language, LanguageString.NewInstance(text, language));
|
168
|
}
|
169
|
/**
|
170
|
* Adds a translated {@link LanguageString text in a particular language}
|
171
|
* to the {@link MultilanguageText multilanguage text} used to qualify the validity
|
172
|
* of <i>this</i> state data.
|
173
|
*
|
174
|
* @param text the language string describing the validity
|
175
|
* in a particular language
|
176
|
* @see #getModifyingText()
|
177
|
* @see #addModifyingText(String, Language)
|
178
|
*/
|
179
|
public void addModifyingText(LanguageString text){
|
180
|
this.modifyingText.add(text);
|
181
|
}
|
182
|
/**
|
183
|
* Removes from the {@link MultilanguageText multilanguage text} used to qualify the validity
|
184
|
* of <i>this</i> state data the one {@link LanguageString language string}
|
185
|
* with the given {@link Language language}.
|
186
|
*
|
187
|
* @param lang the language in which the language string to be removed
|
188
|
* has been formulated
|
189
|
* @see #getModifyingText()
|
190
|
*/
|
191
|
public void removeModifyingText(Language lang){
|
192
|
this.modifyingText.remove(lang);
|
193
|
}
|
194
|
|
195
|
}
|