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
.common
.Language
;
17 import eu
.etaxonomy
.cdm
.model
.common
.LanguageString
;
19 import eu
.etaxonomy
.cdm
.model
.common
.MultilanguageText
;
20 import eu
.etaxonomy
.cdm
.model
.common
.ReferencedEntityBase
;
22 import org
.apache
.log4j
.Logger
;
23 import org
.hibernate
.annotations
.Cascade
;
24 import org
.hibernate
.annotations
.CascadeType
;
28 import javax
.persistence
.*;
29 import javax
.xml
.bind
.annotation
.XmlAccessType
;
30 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
31 import javax
.xml
.bind
.annotation
.XmlElement
;
32 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
33 import javax
.xml
.bind
.annotation
.XmlIDREF
;
34 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
35 import javax
.xml
.bind
.annotation
.XmlType
;
36 import javax
.xml
.bind
.annotation
.adapters
.XmlJavaTypeAdapter
;
39 * The upmost (abstract) class for a description element of a specimen
40 * or of a taxon. A concrete description element assigns descriptive data to
41 * the feature. As experts use the word feature for the property itself but not
42 * for the actual description naming this class FeatureBase would make no sense.
47 * @created 08-Nov-2007 13:06:24
49 @XmlAccessorType(XmlAccessType
.FIELD
)
50 @XmlType(name
= "DescriptionElementBase", propOrder
= {
57 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
58 public abstract class DescriptionElementBase
extends ReferencedEntityBase
implements IMediaEntity
{
59 private static final Logger logger
= Logger
.getLogger(DescriptionElementBase
.class);
61 protected DescriptionElementBase(){
64 protected DescriptionElementBase(Feature feature
){
66 feature
= Feature
.UNKNOWN();
68 this.feature
= feature
;
71 //type, category of information. In structured descriptions characters
72 @XmlElement(name
= "Feature")
74 @XmlSchemaType(name
= "IDREF")
75 private Feature feature
;
77 @XmlElementWrapper(name
= "Modifiers")
78 @XmlElement(name
= "Modifier")
79 private Set
<Modifier
> modifiers
= new HashSet
<Modifier
>();
81 @XmlElement(name
= "ModifyingText")
82 @XmlJavaTypeAdapter(MultilanguageTextAdapter
.class)
83 private MultilanguageText modifyingText
;
85 @XmlElementWrapper(name
= "Media")
86 @XmlElement(name
= "Medium")
88 @XmlSchemaType(name
= "IDREF")
89 private Set
<Media
> media
= new HashSet
<Media
>();
93 @Cascade({CascadeType
.SAVE_UPDATE
})
94 public Set
<Media
> getMedia(){
97 protected void setMedia(Set
<Media
> media
) {
100 public void addMedia(Media media
){
101 this.media
.add(media
);
103 public void removeMedia(Media media
){
104 this.media
.remove(media
);
109 * Same as getFeature()
114 public Feature
getType(){
115 return this.getFeature();
118 * Same as setFeature(Feature feature)
119 * @see setFeature(Feature feature)
122 public void setType(Feature type
){
123 this.setFeature(type
);
127 @Cascade(CascadeType
.SAVE_UPDATE
)
128 public Feature
getFeature(){
131 public void setFeature(Feature feature
){
132 this.feature
= feature
;
137 public Set
<Modifier
> getModifiers(){
138 return this.modifiers
;
140 protected void setModifiers(Set
<Modifier
> modifiers
){
141 this.modifiers
= modifiers
;
143 public void addModifier(Modifier modifier
){
144 this.modifiers
.add(modifier
);
146 public void removeModifier(Modifier modifier
){
147 this.modifiers
.remove(modifier
);
151 public MultilanguageText
getModifyingText(){
152 return this.modifyingText
;
154 protected void setModifyingText(MultilanguageText modifyingText
){
155 this.modifyingText
= modifyingText
;
157 public LanguageString
addModifyingText(LanguageString description
){
158 return this.modifyingText
.add(description
);
160 public LanguageString
addModifyingText(String text
, Language language
){
161 return this.modifyingText
.put(language
, LanguageString
.NewInstance(text
, language
));
163 public LanguageString
removeModifyingText(Language language
){
164 return this.modifyingText
.remove(language
);