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.
10 package eu
.etaxonomy
.cdm
.model
.description
;
13 import java
.util
.HashMap
;
14 import java
.util
.HashSet
;
18 import javax
.persistence
.Entity
;
19 import javax
.persistence
.FetchType
;
20 import javax
.persistence
.ManyToOne
;
21 import javax
.persistence
.OneToMany
;
22 import javax
.xml
.bind
.annotation
.XmlAccessType
;
23 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
24 import javax
.xml
.bind
.annotation
.XmlElement
;
25 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
26 import javax
.xml
.bind
.annotation
.XmlIDREF
;
27 import javax
.xml
.bind
.annotation
.XmlRootElement
;
28 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
29 import javax
.xml
.bind
.annotation
.XmlType
;
30 import javax
.xml
.bind
.annotation
.adapters
.XmlJavaTypeAdapter
;
32 import org
.apache
.log4j
.Logger
;
33 import org
.hibernate
.envers
.Audited
;
35 import eu
.etaxonomy
.cdm
.jaxb
.MultilanguageTextAdapter
;
36 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
37 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
38 import eu
.etaxonomy
.cdm
.model
.common
.MultilanguageText
;
39 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
40 import eu
.etaxonomy
.cdm
.model
.common
.VersionableEntity
;
43 * This class represents the assignment of values ({@link State state terms}) to {@link Feature features}
44 * corresponding to {@link CategoricalData categorical data}. A state data instance
45 * constitutes an atomized part of an information piece (categorical data) so
46 * that several state data instances may belong to one categorical data
49 * This class corresponds to CharacterStateDataType according to the SDD schema.
53 * @created 08-Nov-2007 13:06:53
55 @XmlAccessorType(XmlAccessType
.FIELD
)
56 @XmlType(name
= "StateData", propOrder
= {
61 @XmlRootElement(name
= "StateData")
64 public class StateData
extends VersionableEntity
{
65 private static final long serialVersionUID
= -4380314126624505415L;
66 @SuppressWarnings("unused")
67 private static final Logger logger
= Logger
.getLogger(StateData
.class);
69 @XmlElement(name
= "State")
71 @XmlSchemaType(name
= "IDREF")
72 @ManyToOne(fetch
= FetchType
.LAZY
)
75 @XmlElementWrapper(name
= "Modifiers")
76 @XmlElement(name
= "Modifier")
77 @OneToMany(fetch
= FetchType
.LAZY
)
78 private Set
<Modifier
> modifiers
= new HashSet
<Modifier
>();
80 @XmlElement(name
= "ModifyingText")
81 @XmlJavaTypeAdapter(MultilanguageTextAdapter
.class)
82 @OneToMany(fetch
= FetchType
.LAZY
)
83 private Map
<Language
,LanguageString
> modifyingText
= new HashMap
<Language
,LanguageString
>();
86 * Class constructor: creates a new empty state data instance.
93 * Creates a new empty state data instance.
95 public static StateData
NewInstance(){
96 return new StateData();
100 * Returns the {@link State state term} used in <i>this</i> state data.
102 public State
getState(){
108 public void setState(State state
){
114 * Returns the set of {@link Modifier modifiers} used to qualify the validity
115 * of <i>this</i> state data. This is only metainformation.
117 public Set
<Modifier
> getModifiers(){
118 return this.modifiers
;
122 * Adds a {@link Modifier modifier} to the set of {@link #getModifiers() modifiers}
123 * used to qualify the validity of <i>this</i> state data.
125 * @param modifier the modifier to be added to <i>this</i> state data
126 * @see #getModifiers()
128 public void addModifier(Modifier modifier
){
129 this.modifiers
.add(modifier
);
132 * Removes one element from the set of {@link #getModifiers() modifiers}
133 * used to qualify the validity of <i>this</i> state data.
135 * @param modifier the modifier which should be removed
136 * @see #getModifiers()
137 * @see #addModifier(Modifier)
139 public void removeModifier(Modifier modifier
){
140 this.modifiers
.remove(modifier
);
145 * Returns the {@link MultilanguageText multilanguage text} used to qualify the validity
146 * of <i>this</i> state data. The different {@link LanguageString language strings}
147 * contained in the multilanguage text should all have the same meaning.<BR>
148 * A multilanguage text does not belong to a controlled {@link TermVocabulary term vocabulary}
149 * as a {@link Modifier modifier} does.
151 * NOTE: the actual content of <i>this</i> state data is NOT
152 * stored in the modifying text. This is only metainformation
153 * (like "Some experts express doubt about this assertion").
155 public Map
<Language
,LanguageString
> getModifyingText(){
156 return this.modifyingText
;
160 * Creates a {@link LanguageString language string} based on the given text string
161 * and the given {@link Language language} and adds it to the {@link MultilanguageText multilanguage text}
162 * used to qualify the validity of <i>this</i> state data.
164 * @param text the string describing the validity
165 * in a particular language
166 * @param language the language in which the text string is formulated
167 * @see #getModifyingText()
168 * @see #addModifyingText(LanguageString)
170 public void addModifyingText(String text
, Language language
){
171 this.modifyingText
.put(language
, LanguageString
.NewInstance(text
, language
));
174 * Adds a translated {@link LanguageString text in a particular language}
175 * to the {@link MultilanguageText multilanguage text} used to qualify the validity
176 * of <i>this</i> state data.
178 * @param text the language string describing the validity
179 * in a particular language
180 * @see #getModifyingText()
181 * @see #addModifyingText(String, Language)
183 public void addModifyingText(LanguageString text
){
184 this.modifyingText
.put(text
.getLanguage(),text
);
187 * Removes from the {@link MultilanguageText multilanguage text} used to qualify the validity
188 * of <i>this</i> state data the one {@link LanguageString language string}
189 * with the given {@link Language language}.
191 * @param lang the language in which the language string to be removed
192 * has been formulated
193 * @see #getModifyingText()
195 public void removeModifyingText(Language lang
){
196 this.modifyingText
.remove(lang
);