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 eu
.etaxonomy
.cdm
.jaxb
.MultilanguageTextAdapter
;
14 import eu
.etaxonomy
.cdm
.model
.media
.IMediaEntity
;
15 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
16 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
17 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
18 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
19 import eu
.etaxonomy
.cdm
.model
.common
.Language
;
20 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
21 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
23 import eu
.etaxonomy
.cdm
.model
.common
.MultilanguageText
;
24 import eu
.etaxonomy
.cdm
.model
.common
.ReferencedEntityBase
;
26 import org
.apache
.log4j
.Logger
;
27 import org
.hibernate
.annotations
.Cascade
;
28 import org
.hibernate
.annotations
.CascadeType
;
32 import javax
.persistence
.*;
33 import javax
.xml
.bind
.annotation
.XmlAccessType
;
34 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
35 import javax
.xml
.bind
.annotation
.XmlElement
;
36 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
37 import javax
.xml
.bind
.annotation
.XmlIDREF
;
38 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
39 import javax
.xml
.bind
.annotation
.XmlType
;
40 import javax
.xml
.bind
.annotation
.adapters
.XmlJavaTypeAdapter
;
43 * The upmost (abstract) class for a piece of information) about
44 * a {@link SpecimenOrObservationBase specimen}, a {@link Taxon taxon} or even a {@link TaxonNameBase taxon name}.
45 * A concrete description element assigns descriptive data to one {@link Feature feature}.<BR>
46 * Experts use the word feature for the property itself but not for the actual
47 * description element. Therefore naming this class FeatureBase would have
48 * leaded to confusion.
50 * This class corresponds to: <ul>
51 * <li> DescriptionsBaseType according to the the SDD schema
52 * <li> InfoItem according to the TDWG ontology
53 * <li> MeasurementOrFact according to the ABCD schema
58 * @created 08-Nov-2007 13:06:24
60 @XmlAccessorType(XmlAccessType
.FIELD
)
61 @XmlType(name
= "DescriptionElementBase", propOrder
= {
68 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
69 public abstract class DescriptionElementBase
extends ReferencedEntityBase
implements IMediaEntity
{
70 private static final Logger logger
= Logger
.getLogger(DescriptionElementBase
.class);
73 // ************* CONSTRUCTORS *************/
75 * Class constructor: creates a new empty description element instance.
77 * @see #DescriptionElementBase(Feature)
79 protected DescriptionElementBase(){
83 * Class constructor: creates a new description element instance with the
84 * given {@link Feature feature} that is described or measured.
86 * @param feature the feature described or measured
87 * @see #DescriptionElementBase()
89 protected DescriptionElementBase(Feature feature
){
91 feature
= Feature
.UNKNOWN();
93 this.feature
= feature
;
96 //type, category of information. In structured descriptions characters
97 @XmlElement(name
= "Feature")
99 @XmlSchemaType(name
= "IDREF")
100 private Feature feature
;
102 @XmlElementWrapper(name
= "Modifiers")
103 @XmlElement(name
= "Modifier")
104 private Set
<Modifier
> modifiers
= new HashSet
<Modifier
>();
106 @XmlElement(name
= "ModifyingText")
107 @XmlJavaTypeAdapter(MultilanguageTextAdapter
.class)
108 private MultilanguageText modifyingText
;
110 @XmlElementWrapper(name
= "Media")
111 @XmlElement(name
= "Medium")
113 @XmlSchemaType(name
= "IDREF")
114 private Set
<Media
> media
= new HashSet
<Media
>();
118 * Returns the set of {@link Media media} (that is pictures, movies,
119 * recorded sounds ...) <i>this</i> description element is based on.
122 @Cascade({CascadeType
.SAVE_UPDATE
})
123 public Set
<Media
> getMedia(){
129 protected void setMedia(Set
<Media
> media
) {
133 * Adds a {@link Media media} to the set of {@link #getMedia() media}
134 * <i>this</i> description element is based on.
136 * @param media the media to be added to <i>this</i> description element
139 public void addMedia(Media media
){
140 this.media
.add(media
);
143 * Removes one element from the set of {@link #getMedia() media}
144 * <i>this</i> description element is based on.
146 * @param media the media which should be removed
148 * @see #addMedia(Media)
150 public void removeMedia(Media media
){
151 this.media
.remove(media
);
156 * Does exactly the same as getFeature().
161 public Feature
getType(){
162 return this.getFeature();
165 * Does exactly the same as setFeature(Feature).
167 * @param type the feature to be described or measured
168 * @see #setFeature(Feature)
171 public void setType(Feature type
){
172 this.setFeature(type
);
176 * Returns the {@link Feature feature} <i>this</i> description element is for.
177 * A feature is a property that can be described or measured but not the
178 * description or the measurement itself.
181 @Cascade(CascadeType
.SAVE_UPDATE
)
182 public Feature
getFeature(){
188 public void setFeature(Feature feature
){
189 this.feature
= feature
;
194 * Returns the set of {@link Modifier modifiers} which modulate
195 * <i>this</i> description element.
198 public Set
<Modifier
> getModifiers(){
199 return this.modifiers
;
202 * @see #getModifiers()
204 protected void setModifiers(Set
<Modifier
> modifiers
){
205 this.modifiers
= modifiers
;
208 * Adds a {@link Modifier modifier} to the set of {@link #getModifiers() modifiers}
209 * which modulate <i>this</i> description element.
211 * @param modifier the modifier to be added to <i>this</i> description element
212 * @see #getModifiers()
214 public void addModifier(Modifier modifier
){
215 this.modifiers
.add(modifier
);
218 * Removes one element from the set of {@link #getModifiers() modifiers}
219 * which modulate <i>this</i> description element.
221 * @param modifier the modifier which should be removed
222 * @see #getModifiers()
223 * @see #addModifier(Modifier)
225 public void removeModifier(Modifier modifier
){
226 this.modifiers
.remove(modifier
);
231 * Returns the {@link MultilanguageText multilanguage text} used to modulate
232 * <i>this</i> description element. A multilanguage text does not belong to
233 * a controlled {@link TermVocabulary term vocabulary} as a {@link Modifier modifier} does.
235 public MultilanguageText
getModifyingText(){
236 return this.modifyingText
;
239 * @see #getModifyingText()
241 protected void setModifyingText(MultilanguageText modifyingText
){
242 this.modifyingText
= modifyingText
;
245 * Adds a translated {@link LanguageString text in a particular language}
246 * to the {@link MultilanguageText multilanguage text} used to modulate
247 * <i>this</i> description element.
249 * @param description the language string describing the modulation
250 * in a particular language
251 * @see #getModifyingText()
252 * @see #addModifyingText(String, Language)
254 public LanguageString
addModifyingText(LanguageString description
){
255 return this.modifyingText
.add(description
);
258 * Creates a {@link LanguageString language string} based on the given text string
259 * and the given {@link Language language} and adds it to the {@link MultilanguageText multilanguage text}
260 * used to modulate <i>this</i> description element. The different language
261 * strings contained in the multilanguage text should all have
264 * @param text the string describing the modulation
265 * in a particular language
266 * @param language the language in which the text string is formulated
267 * @see #getModifyingText()
268 * @see #addModifyingText(LanguageString)
270 public LanguageString
addModifyingText(String text
, Language language
){
271 return this.modifyingText
.put(language
, LanguageString
.NewInstance(text
, language
));
274 * Removes from the {@link MultilanguageText multilanguage text} used to modulate
275 * <i>this</i> description element the one {@link LanguageString language string}
276 * with the given {@link Language language}.
278 * @param language the language in which the language string to be removed
279 * has been formulated
280 * @see #getModifyingText()
282 public LanguageString
removeModifyingText(Language language
){
283 return this.modifyingText
.remove(language
);