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
.xml
.bind
.annotation
.XmlAccessType
;
21 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
22 import javax
.xml
.bind
.annotation
.XmlElement
;
23 import javax
.xml
.bind
.annotation
.XmlElementWrapper
;
24 import javax
.xml
.bind
.annotation
.XmlIDREF
;
25 import javax
.xml
.bind
.annotation
.XmlRootElement
;
26 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
27 import javax
.xml
.bind
.annotation
.XmlType
;
29 import org
.apache
.log4j
.Logger
;
30 import org
.hibernate
.envers
.Audited
;
31 import org
.hibernate
.search
.annotations
.Indexed
;
33 import eu
.etaxonomy
.cdm
.model
.common
.Representation
;
34 import eu
.etaxonomy
.cdm
.model
.location
.NamedArea
;
35 import eu
.etaxonomy
.cdm
.model
.media
.Media
;
36 import eu
.etaxonomy
.cdm
.model
.occurrence
.SpecimenOrObservationBase
;
37 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
40 * The class representing single-access fixed dichotomous or polytomous authored
41 * decision keys (as opposed to {@link FeatureTree multiple-access keys}) used to identify
42 * {@link SpecimenOrObservationBase specimens or observations} (this means to assign {@link Taxon taxa} to).
43 * The determination process is based on the tree structure of the key and on
44 * the statements of its leads.
48 * @created 08-Nov-2007 13:06:28
51 @XmlAccessorType(XmlAccessType
.FIELD
)
52 @XmlType(name
= "MediaKey", propOrder
= {
59 @XmlRootElement(name
= "MediaKey")
61 @Indexed(index
= "eu.etaxonomy.cdm.model.media.Media")
63 public class MediaKey
extends Media
implements IIdentificationKey
{
65 private static final long serialVersionUID
= -29095811051894471L;
66 @SuppressWarnings("unused")
67 private static final Logger logger
= Logger
.getLogger(MediaKey
.class);
69 @XmlElementWrapper(name
= "CoveredTaxa")
70 @XmlElement(name
= "CoveredTaxon")
72 @XmlSchemaType(name
= "IDREF")
73 @ManyToMany(fetch
= FetchType
.LAZY
)
74 private Set
<Taxon
> coveredTaxa
= new HashSet
<Taxon
>();
76 @XmlElementWrapper( name
= "GeographicalScope")
77 @XmlElement( name
= "Area")
79 @XmlSchemaType(name
= "IDREF")
80 @ManyToMany(fetch
= FetchType
.LAZY
)
81 @JoinTable(name
="MediaKey_NamedArea")
82 private Set
<NamedArea
> geographicalScope
= new HashSet
<NamedArea
>();
84 @XmlElementWrapper(name
= "TaxonomicScope")
85 @XmlElement(name
= "Taxon")
87 @XmlSchemaType(name
= "IDREF")
88 @ManyToMany(fetch
= FetchType
.LAZY
)
90 name
="MediaKey_Taxon",
91 joinColumns
=@JoinColumn(name
="mediaKey_fk"),
92 inverseJoinColumns
=@JoinColumn(name
="taxon_fk")
94 private Set
<Taxon
> taxonomicScope
= new HashSet
<Taxon
>();
96 @XmlElementWrapper( name
= "ScopeRestrictions")
97 @XmlElement( name
= "Restriction")
99 @XmlSchemaType(name
= "IDREF")
100 @ManyToMany(fetch
= FetchType
.LAZY
)
101 @JoinTable(name
="MediaKey_Scope")
102 private Set
<Scope
> scopeRestrictions
= new HashSet
<Scope
>();
104 @XmlElementWrapper( name
= "KeyRepresentations")
105 @XmlElement( name
= "KeyRepresentation")
107 @XmlSchemaType(name
= "IDREF")
108 @ManyToMany(fetch
= FetchType
.LAZY
)
109 private Set
<Representation
> keyRepresentations
= new HashSet
<Representation
>();
112 * Class constructor: creates a new empty identification key instance.
114 protected MediaKey() {
119 * Creates a new empty identification key instance.
121 public static MediaKey
NewInstance(){
122 return new MediaKey();
127 * Returns the set of possible {@link Taxon taxa} corresponding to
128 * <i>this</i> identification key.
130 public Set
<Taxon
> getCoveredTaxa() {
134 * @see #getCoveredTaxa()
136 protected void setCoveredTaxa(Set
<Taxon
> coveredTaxa
) {
137 this.coveredTaxa
= coveredTaxa
;
141 * Adds a {@link Taxon taxa} to the set of {@link #getCoveredTaxa() covered taxa}
142 * corresponding to <i>this</i> identification key.
144 * @param taxon the taxon to be added to <i>this</i> identification key
145 * @see #getCoveredTaxa()
147 public void addCoveredTaxon(Taxon taxon
) {
148 this.coveredTaxa
.add(taxon
);
152 * Removes one element from the set of {@link #getCoveredTaxa() covered taxa}
153 * corresponding to <i>this</i> identification key.
155 * @param taxon the taxon which should be removed
156 * @see #getCoveredTaxa()
157 * @see #addCoveredTaxon(Taxon)
159 public void removeCoveredTaxon(Taxon taxon
) {
160 this.coveredTaxa
.remove(taxon
);
164 * Returns the set of {@link NamedArea named areas} indicating the geospatial
165 * data where <i>this</i> identification key is valid.
167 public Set
<NamedArea
> getGeographicalScope() {
168 return geographicalScope
;
172 * Adds a {@link NamedArea geoScope} to the set of {@link #getGeoScopes() geogspatial scopes}
173 * corresponding to <i>this</i> identification key.
175 * @param geoScope the named area to be added to <i>this</i> identification key
176 * @see #getGeoScopes()
178 public void addGeographicalScope(NamedArea geoScope
) {
179 this.geographicalScope
.add(geoScope
);
182 * Removes one element from the set of {@link #getGeoScopes() geogspatial scopes}
183 * corresponding to <i>this</i> identification key.
185 * @param geoScope the named area which should be removed
186 * @see #getGeoScopes()
187 * @see #addGeoScope(NamedArea)
189 public void removeGeographicalScope(NamedArea geoScope
) {
190 this.geographicalScope
.remove(geoScope
);
194 * Returns the set of {@link Taxon taxa} that define the taxonomic
195 * scope of <i>this</i> identification key
197 public Set
<Taxon
> getTaxonomicScope() {
198 return taxonomicScope
;
202 * Adds a {@link Taxon taxa} to the set of {@link #getTaxonomicScope() taxonomic scopes}
203 * corresponding to <i>this</i> identification key.
205 * @param taxon the taxon to be added to <i>this</i> identification key
206 * @see #getTaxonomicScope()
208 public void addTaxonomicScope(Taxon taxon
) {
209 this.taxonomicScope
.add(taxon
);
213 * Removes one element from the set of {@link #getTaxonomicScope() taxonomic scopes}
214 * corresponding to <i>this</i> identification key.
216 * @param taxon the taxon which should be removed
217 * @see #getTaxonomicScope()
218 * @see #addTaxonomicScope(Taxon)
220 public void removeTaxonomicScope(Taxon taxon
) {
221 this.taxonomicScope
.remove(taxon
);
225 * Returns the set of {@link Representation key representations} corresponding to
226 * <i>this</i> identification key
228 public Set
<Representation
> getKeyRepresentations() {
229 return keyRepresentations
;
233 * Adds a {@link Representation key representation} to the set of {@link #getKeyRepresentations() key representations}
234 * corresponding to <i>this</i> identification key.
236 * @param keyRepresentation the key representation to be added to <i>this</i> identification key
237 * @see #getKeyRepresentations()
239 public void addKeyRepresentation(Representation keyRepresentation
) {
240 this.keyRepresentations
.add(keyRepresentation
);
244 * Removes one element from the set of {@link #getKeyRepresentations() key representations}
245 * corresponding to <i>this</i> identification key.
247 * @param keyRepresentation the key representation which should be removed
248 * @see #getKeyRepresentations()
249 * @see #addKeyRepresentation(Representation)
251 public void removeKeyRepresentation(Representation keyRepresentation
) {
252 this.keyRepresentations
.remove(keyRepresentation
);
256 * Returns the set of {@link Scope scope restrictions} corresponding to
257 * <i>this</i> identification key
259 public Set
<Scope
> getScopeRestrictions() {
260 return scopeRestrictions
;
264 * Adds a {@link Scope scope restriction} to the set of {@link #getScopeRestrictions() scope restrictions}
265 * corresponding to <i>this</i> identification key.
267 * @param scopeRestriction the scope restriction to be added to <i>this</i> identification key
268 * @see #getScopeRestrictions()
270 public void addScopeRestriction(Scope scopeRestriction
) {
271 this.scopeRestrictions
.add(scopeRestriction
);
275 * Removes one element from the set of {@link #getScopeRestrictions() scope restrictions}
276 * corresponding to <i>this</i> identification key.
278 * @param scopeRestriction the scope restriction which should be removed
279 * @see #getScopeRestrictions()
280 * @see #addScopeRestriction(Scope)
282 public void removeScopeRestriction(Scope scopeRestriction
) {
283 this.scopeRestrictions
.remove(scopeRestriction
);