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
;
12 import java
.util
.HashSet
;
15 import javax
.persistence
.Entity
;
16 import javax
.persistence
.FetchType
;
17 import javax
.persistence
.JoinColumn
;
18 import javax
.persistence
.JoinTable
;
19 import javax
.persistence
.ManyToMany
;
20 import javax
.validation
.constraints
.NotNull
;
21 import javax
.xml
.bind
.annotation
.XmlAccessType
;
22 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
23 import javax
.xml
.bind
.annotation
.XmlElement
;
24 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
25 import javax
.xml
.bind
.annotation
.XmlIDREF
;
26 import javax
.xml
.bind
.annotation
.XmlRootElement
;
27 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
28 import javax
.xml
.bind
.annotation
.XmlType
;
30 import org
.apache
.log4j
.Logger
;
31 import org
.hibernate
.annotations
.Cascade
;
32 import org
.hibernate
.annotations
.CascadeType
;
33 import org
.hibernate
.envers
.Audited
;
34 import org
.hibernate
.search
.annotations
.Indexed
;
36 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
37 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
38 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
39 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
42 * The class representing single-access fixed dichotomous or polytomous authored
43 * decision keys (as opposed to {@link FeatureTree multiple-access keys}) used to identify
44 * {@link SpecimenOrObservationBase specimens or observations} (this means to assign {@link Taxon taxa} to).
45 * The determination process is based on the tree structure of the key and on
46 * the statements of its leads.
50 * @created 08-Nov-2007 13:06:28
53 @XmlAccessorType(XmlAccessType
.FIELD
)
54 @XmlType(name
= "MediaKey", propOrder
= {
61 @XmlRootElement(name
= "MediaKey")
63 @Indexed(index
= "eu.etaxonomy.cdm.model.media.Media")
65 public class MediaKey
extends Media
implements IIdentificationKey
{
66 private static final long serialVersionUID
= -29095811051894471L;
67 @SuppressWarnings("unused")
68 private static final Logger logger
= Logger
.getLogger(MediaKey
.class);
70 @XmlElementWrapper(name
= "CoveredTaxa")
71 @XmlElement(name
= "CoveredTaxon")
73 @XmlSchemaType(name
= "IDREF")
74 @ManyToMany(fetch
= FetchType
.LAZY
)
76 private Set
<Taxon
> coveredTaxa
= new HashSet
<Taxon
>();
78 @XmlElementWrapper( name
= "GeographicalScope")
79 @XmlElement( name
= "Area")
81 @XmlSchemaType(name
= "IDREF")
82 @ManyToMany(fetch
= FetchType
.LAZY
)
83 @JoinTable(name
="MediaKey_NamedArea")
85 private Set
<NamedArea
> geographicalScope
= new HashSet
<NamedArea
>();
87 @XmlElementWrapper(name
= "TaxonomicScope")
88 @XmlElement(name
= "Taxon")
90 @XmlSchemaType(name
= "IDREF")
91 @ManyToMany(fetch
= FetchType
.LAZY
)
93 name
="MediaKey_Taxon",
94 joinColumns
=@JoinColumn(name
="mediaKey_id"),
95 inverseJoinColumns
=@JoinColumn(name
="taxon_id")
98 private Set
<Taxon
> taxonomicScope
= new HashSet
<Taxon
>();
100 @XmlElementWrapper( name
= "ScopeRestrictions")
101 @XmlElement( name
= "Restriction")
103 @XmlSchemaType(name
= "IDREF")
104 @ManyToMany(fetch
= FetchType
.LAZY
)
105 @JoinTable(name
="MediaKey_Scope")
107 private Set
<Scope
> scopeRestrictions
= new HashSet
<Scope
>();
109 @XmlElementWrapper( name
= "KeyRepresentations")
110 @XmlElement( name
= "KeyRepresentation")
112 @XmlSchemaType(name
= "IDREF")
113 @ManyToMany(fetch
= FetchType
.LAZY
)
114 @Cascade({CascadeType
.SAVE_UPDATE
, CascadeType
.MERGE
,CascadeType
.DELETE
, CascadeType
.DELETE_ORPHAN
})
116 private Set
<Representation
> keyRepresentations
= new HashSet
<Representation
>();
119 * Class constructor: creates a new empty identification key instance.
121 protected MediaKey() {
126 * Creates a new empty identification key instance.
128 public static MediaKey
NewInstance(){
129 return new MediaKey();
134 * Returns the set of possible {@link Taxon taxa} corresponding to
135 * <i>this</i> identification key.
137 public Set
<Taxon
> getCoveredTaxa() {
138 if(coveredTaxa
== null) {
139 this.coveredTaxa
= new HashSet
<Taxon
>();
144 * @see #getCoveredTaxa()
146 protected void setCoveredTaxa(Set
<Taxon
> coveredTaxa
) {
147 this.coveredTaxa
= coveredTaxa
;
151 * Adds a {@link Taxon taxa} to the set of {@link #getCoveredTaxa() covered taxa}
152 * corresponding to <i>this</i> identification key.
154 * @param taxon the taxon to be added to <i>this</i> identification key
155 * @see #getCoveredTaxa()
157 public void addCoveredTaxon(Taxon taxon
) {
158 this.coveredTaxa
.add(taxon
);
162 * Removes one element from the set of {@link #getCoveredTaxa() covered taxa}
163 * corresponding to <i>this</i> identification key.
165 * @param taxon the taxon which should be removed
166 * @see #getCoveredTaxa()
167 * @see #addCoveredTaxon(Taxon)
169 public void removeCoveredTaxon(Taxon taxon
) {
170 this.coveredTaxa
.remove(taxon
);
174 * Returns the set of {@link NamedArea named areas} indicating the geospatial
175 * data where <i>this</i> identification key is valid.
177 public Set
<NamedArea
> getGeographicalScope() {
178 if(geographicalScope
== null) {
179 this.geographicalScope
= new HashSet
<NamedArea
>();
181 return geographicalScope
;
185 * Adds a {@link NamedArea geoScope} to the set of {@link #getGeoScopes() geogspatial scopes}
186 * corresponding to <i>this</i> identification key.
188 * @param geoScope the named area to be added to <i>this</i> identification key
189 * @see #getGeoScopes()
191 public void addGeographicalScope(NamedArea geoScope
) {
192 this.geographicalScope
.add(geoScope
);
195 * Removes one element from the set of {@link #getGeoScopes() geogspatial scopes}
196 * corresponding to <i>this</i> identification key.
198 * @param geoScope the named area which should be removed
199 * @see #getGeoScopes()
200 * @see #addGeoScope(NamedArea)
202 public void removeGeographicalScope(NamedArea geoScope
) {
203 this.geographicalScope
.remove(geoScope
);
207 * Returns the set of {@link Taxon taxa} that define the taxonomic
208 * scope of <i>this</i> identification key
210 public Set
<Taxon
> getTaxonomicScope() {
211 if(taxonomicScope
== null) {
212 this.taxonomicScope
= new HashSet
<Taxon
>();
214 return taxonomicScope
;
218 * Adds a {@link Taxon taxa} to the set of {@link #getTaxonomicScope() taxonomic scopes}
219 * corresponding to <i>this</i> identification key.
221 * @param taxon the taxon to be added to <i>this</i> identification key
222 * @see #getTaxonomicScope()
224 public void addTaxonomicScope(Taxon taxon
) {
225 this.taxonomicScope
.add(taxon
);
229 * Removes one element from the set of {@link #getTaxonomicScope() taxonomic scopes}
230 * corresponding to <i>this</i> identification key.
232 * @param taxon the taxon which should be removed
233 * @see #getTaxonomicScope()
234 * @see #addTaxonomicScope(Taxon)
236 public void removeTaxonomicScope(Taxon taxon
) {
237 this.taxonomicScope
.remove(taxon
);
241 * Returns the set of {@link Representation key representations} corresponding to
242 * <i>this</i> identification key
244 public Set
<Representation
> getKeyRepresentations() {
245 if(keyRepresentations
== null) {
246 this.keyRepresentations
= new HashSet
<Representation
>();
248 return keyRepresentations
;
252 * Adds a {@link Representation key representation} to the set of {@link #getKeyRepresentations() key representations}
253 * corresponding to <i>this</i> identification key.
255 * @param keyRepresentation the key representation to be added to <i>this</i> identification key
256 * @see #getKeyRepresentations()
258 public void addKeyRepresentation(Representation keyRepresentation
) {
259 this.keyRepresentations
.add(keyRepresentation
);
263 * Removes one element from the set of {@link #getKeyRepresentations() key representations}
264 * corresponding to <i>this</i> identification key.
266 * @param keyRepresentation the key representation which should be removed
267 * @see #getKeyRepresentations()
268 * @see #addKeyRepresentation(Representation)
270 public void removeKeyRepresentation(Representation keyRepresentation
) {
271 this.keyRepresentations
.remove(keyRepresentation
);
275 * Returns the set of {@link Scope scope restrictions} corresponding to
276 * <i>this</i> identification key
278 public Set
<Scope
> getScopeRestrictions() {
279 if(scopeRestrictions
== null) {
280 this.scopeRestrictions
= new HashSet
<Scope
>();
282 return scopeRestrictions
;
286 * Adds a {@link Scope scope restriction} to the set of {@link #getScopeRestrictions() scope restrictions}
287 * corresponding to <i>this</i> identification key.
289 * @param scopeRestriction the scope restriction to be added to <i>this</i> identification key
290 * @see #getScopeRestrictions()
292 public void addScopeRestriction(Scope scopeRestriction
) {
293 this.scopeRestrictions
.add(scopeRestriction
);
297 * Removes one element from the set of {@link #getScopeRestrictions() scope restrictions}
298 * corresponding to <i>this</i> identification key.
300 * @param scopeRestriction the scope restriction which should be removed
301 * @see #getScopeRestrictions()
302 * @see #addScopeRestriction(Scope)
304 public void removeScopeRestriction(Scope scopeRestriction
) {
305 this.scopeRestrictions
.remove(scopeRestriction
);