1
|
/**
|
2
|
* Copyright (C) 2007 EDIT
|
3
|
* European Distributed Institute of Taxonomy
|
4
|
* http://www.e-taxonomy.eu
|
5
|
*
|
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.
|
8
|
*/
|
9
|
|
10
|
package eu.etaxonomy.cdm.model.description;
|
11
|
|
12
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
13
|
import eu.etaxonomy.cdm.model.media.Media;
|
14
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
15
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
16
|
import org.apache.log4j.Logger;
|
17
|
import org.hibernate.envers.Audited;
|
18
|
|
19
|
import java.util.*;
|
20
|
|
21
|
import javax.persistence.*;
|
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.XmlTransient;
|
30
|
import javax.xml.bind.annotation.XmlType;
|
31
|
|
32
|
/**
|
33
|
* The class representing single-access fixed dichotomous or polytomous authored
|
34
|
* decision keys (as opposed to {@link FeatureTree multiple-access keys}) used to identify
|
35
|
* {@link SpecimenOrObservationBase specimens or observations} (this means to assign {@link Taxon taxa} to).
|
36
|
* The determination process is based on the tree structure of the key and on
|
37
|
* the statements of its leads.
|
38
|
*
|
39
|
* @author m.doering
|
40
|
* @version 1.0
|
41
|
* @created 08-Nov-2007 13:06:28
|
42
|
*/
|
43
|
|
44
|
@XmlAccessorType(XmlAccessType.FIELD)
|
45
|
@XmlType(name = "IdentificationKey", propOrder = {
|
46
|
"coveredTaxa",
|
47
|
"taxonomicScope",
|
48
|
"geoScopes"
|
49
|
})
|
50
|
@XmlRootElement(name = "IdentificationKey")
|
51
|
@Entity
|
52
|
@Audited
|
53
|
public class IdentificationKey extends Media {
|
54
|
private static final long serialVersionUID = -29095811051894471L;
|
55
|
@SuppressWarnings("unused")
|
56
|
private static final Logger logger = Logger.getLogger(IdentificationKey.class);
|
57
|
|
58
|
/*
|
59
|
* FIXME - shouldn't this be @ManyToMany - i.e. many keys can refer to the
|
60
|
* same taxon and some taxa will be covered by multiple keys?
|
61
|
*/
|
62
|
@XmlElementWrapper(name = "CoveredTaxa")
|
63
|
@XmlElement(name = "CoveredTaxon")
|
64
|
@XmlIDREF
|
65
|
@XmlSchemaType(name = "IDREF")
|
66
|
@OneToMany(fetch = FetchType.LAZY)
|
67
|
private Set<Taxon> coveredTaxa = new HashSet<Taxon>();
|
68
|
|
69
|
@XmlElementWrapper( name = "GeoScopes")
|
70
|
@XmlElement( name = "GeoScope")
|
71
|
@XmlIDREF
|
72
|
@XmlSchemaType(name = "IDREF")
|
73
|
@ManyToMany(fetch = FetchType.LAZY)
|
74
|
private Set<NamedArea> geoScopes = new HashSet<NamedArea>();
|
75
|
|
76
|
@XmlElementWrapper(name = "TaxonomicScope")
|
77
|
@XmlElement(name = "Taxon")
|
78
|
@XmlIDREF
|
79
|
@XmlSchemaType(name = "IDREF")
|
80
|
@ManyToMany(fetch = FetchType.LAZY)
|
81
|
@JoinTable(
|
82
|
name="IdentificationKey_Taxon",
|
83
|
joinColumns=@JoinColumn(name="identificationKey_fk"),
|
84
|
inverseJoinColumns=@JoinColumn(name="taxon_fk")
|
85
|
)
|
86
|
private Set<Taxon> taxonomicScope = new HashSet<Taxon>();
|
87
|
|
88
|
/**
|
89
|
* Class constructor: creates a new empty identification key instance.
|
90
|
*/
|
91
|
protected IdentificationKey() {
|
92
|
super();
|
93
|
}
|
94
|
|
95
|
/**
|
96
|
* Creates a new empty identification key instance.
|
97
|
*/
|
98
|
public static IdentificationKey NewInstance(){
|
99
|
return new IdentificationKey();
|
100
|
}
|
101
|
|
102
|
|
103
|
/**
|
104
|
* Returns the set of possible {@link Taxon taxa} corresponding to
|
105
|
* <i>this</i> identification key.
|
106
|
*/
|
107
|
public Set<Taxon> getCoveredTaxa() {
|
108
|
return coveredTaxa;
|
109
|
}
|
110
|
/**
|
111
|
* @see #getCoveredTaxa()
|
112
|
*/
|
113
|
protected void setCoveredTaxa(Set<Taxon> coveredTaxa) {
|
114
|
this.coveredTaxa = coveredTaxa;
|
115
|
}
|
116
|
|
117
|
/**
|
118
|
* Adds a {@link Taxon taxa} to the set of {@link #getCoveredTaxa() covered taxa}
|
119
|
* corresponding to <i>this</i> identification key.
|
120
|
*
|
121
|
* @param taxon the taxon to be added to <i>this</i> identification key
|
122
|
* @see #getCoveredTaxa()
|
123
|
*/
|
124
|
public void addCoveredTaxon(Taxon taxon) {
|
125
|
this.coveredTaxa.add(taxon);
|
126
|
}
|
127
|
|
128
|
/**
|
129
|
* Removes one element from the set of {@link #getCoveredTaxa() covered taxa}
|
130
|
* corresponding to <i>this</i> identification key.
|
131
|
*
|
132
|
* @param taxon the taxon which should be removed
|
133
|
* @see #getCoveredTaxa()
|
134
|
* @see #addCoveredTaxon(Taxon)
|
135
|
*/
|
136
|
public void removeCoveredTaxon(Taxon taxon) {
|
137
|
this.coveredTaxa.remove(taxon);
|
138
|
}
|
139
|
|
140
|
/**
|
141
|
* Returns the set of {@link NamedArea named areas} indicating the geospatial
|
142
|
* data where <i>this</i> identification key is valid.
|
143
|
*/
|
144
|
public Set<NamedArea> getGeoScopes() {
|
145
|
return geoScopes;
|
146
|
}
|
147
|
|
148
|
/**
|
149
|
* Adds a {@link NamedArea geoScope} to the set of {@link #getGeoScopes() geogspatial scopes}
|
150
|
* corresponding to <i>this</i> identification key.
|
151
|
*
|
152
|
* @param geoScope the named area to be added to <i>this</i> identification key
|
153
|
* @see #getGeoScopes()
|
154
|
*/
|
155
|
public void addGeoScope(NamedArea geoScope) {
|
156
|
this.geoScopes.add(geoScope);
|
157
|
}
|
158
|
/**
|
159
|
* Removes one element from the set of {@link #getGeoScopes() geogspatial scopes}
|
160
|
* corresponding to <i>this</i> identification key.
|
161
|
*
|
162
|
* @param geoScope the named area which should be removed
|
163
|
* @see #getGeoScopes()
|
164
|
* @see #addGeoScope(NamedArea)
|
165
|
*/
|
166
|
public void removeGeoScope(NamedArea geoScope) {
|
167
|
this.geoScopes.remove(geoScope);
|
168
|
}
|
169
|
|
170
|
/**
|
171
|
* Returns the set of {@link Taxon taxa} that define the taxonomic
|
172
|
* scope of <i>this</i> identification key
|
173
|
*/
|
174
|
public Set<Taxon> getTaxonomicScope() {
|
175
|
return taxonomicScope;
|
176
|
}
|
177
|
|
178
|
/**
|
179
|
* Adds a {@link Taxon taxa} to the set of {@link #getTaxonomicScope() taxonomic scopes}
|
180
|
* corresponding to <i>this</i> identification key.
|
181
|
*
|
182
|
* @param taxon the taxon to be added to <i>this</i> identification key
|
183
|
* @see #getTaxonomicScope()
|
184
|
*/
|
185
|
public void addTaxonomicScope(Taxon taxon) {
|
186
|
this.taxonomicScope.add(taxon);
|
187
|
}
|
188
|
|
189
|
/**
|
190
|
* Removes one element from the set of {@link #getTaxonomicScope() taxonomic scopes}
|
191
|
* corresponding to <i>this</i> identification key.
|
192
|
*
|
193
|
* @param taxon the taxon which should be removed
|
194
|
* @see #getTaxonomicScope()
|
195
|
* @see #addTaxonomicScope(Taxon)
|
196
|
*/
|
197
|
public void removeTaxonomicScope(Taxon taxon) {
|
198
|
this.taxonomicScope.remove(taxon);
|
199
|
}
|
200
|
}
|