1 |
9479da48
|
Andreas Müller
|
/**
|
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 |
a2a36ad5
|
ben.clark
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
13 |
ca21f846
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.media.Media;
|
14 |
509b132a
|
m.geoffroy
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
15 |
9479da48
|
Andreas Müller
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
16 |
|
|
import org.apache.log4j.Logger;
|
17 |
ee91bcd9
|
ben.clark
|
import org.hibernate.envers.Audited;
|
18 |
f6765014
|
ben.clark
|
|
19 |
9479da48
|
Andreas Müller
|
import java.util.*;
|
20 |
a2a36ad5
|
ben.clark
|
|
21 |
9479da48
|
Andreas Müller
|
import javax.persistence.*;
|
22 |
01b7ddbf
|
a.babadshanjan
|
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 |
a2a36ad5
|
ben.clark
|
import javax.xml.bind.annotation.XmlTransient;
|
30 |
01b7ddbf
|
a.babadshanjan
|
import javax.xml.bind.annotation.XmlType;
|
31 |
9479da48
|
Andreas Müller
|
|
32 |
|
|
/**
|
33 |
3a9870fa
|
m.geoffroy
|
* 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 |
509b132a
|
m.geoffroy
|
*
|
39 |
|
|
* @author m.doering
|
40 |
9479da48
|
Andreas Müller
|
* @version 1.0
|
41 |
|
|
* @created 08-Nov-2007 13:06:28
|
42 |
|
|
*/
|
43 |
b484eedb
|
Andreas Müller
|
|
44 |
01b7ddbf
|
a.babadshanjan
|
@XmlAccessorType(XmlAccessType.FIELD)
|
45 |
|
|
@XmlType(name = "IdentificationKey", propOrder = {
|
46 |
a2a36ad5
|
ben.clark
|
"coveredTaxa",
|
47 |
|
|
"taxonomicScope",
|
48 |
|
|
"geoScopes"
|
49 |
01b7ddbf
|
a.babadshanjan
|
})
|
50 |
|
|
@XmlRootElement(name = "IdentificationKey")
|
51 |
9479da48
|
Andreas Müller
|
@Entity
|
52 |
ee91bcd9
|
ben.clark
|
@Audited
|
53 |
9479da48
|
Andreas Müller
|
public class IdentificationKey extends Media {
|
54 |
03abbcde
|
Andreas Müller
|
private static final long serialVersionUID = -29095811051894471L;
|
55 |
|
|
@SuppressWarnings("unused")
|
56 |
|
|
private static final Logger logger = Logger.getLogger(IdentificationKey.class);
|
57 |
b484eedb
|
Andreas Müller
|
|
58 |
ee91bcd9
|
ben.clark
|
/*
|
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 |
01b7ddbf
|
a.babadshanjan
|
@XmlElementWrapper(name = "CoveredTaxa")
|
63 |
|
|
@XmlElement(name = "CoveredTaxon")
|
64 |
|
|
@XmlIDREF
|
65 |
|
|
@XmlSchemaType(name = "IDREF")
|
66 |
ee91bcd9
|
ben.clark
|
@OneToMany(fetch = FetchType.LAZY)
|
67 |
03abbcde
|
Andreas Müller
|
private Set<Taxon> coveredTaxa = new HashSet<Taxon>();
|
68 |
9479da48
|
Andreas Müller
|
|
69 |
a2a36ad5
|
ben.clark
|
@XmlElementWrapper( name = "GeoScopes")
|
70 |
|
|
@XmlElement( name = "GeoScope")
|
71 |
96c08c19
|
ben.clark
|
@XmlIDREF
|
72 |
|
|
@XmlSchemaType(name = "IDREF")
|
73 |
ee91bcd9
|
ben.clark
|
@ManyToMany(fetch = FetchType.LAZY)
|
74 |
a2a36ad5
|
ben.clark
|
private Set<NamedArea> geoScopes = new HashSet<NamedArea>();
|
75 |
|
|
|
76 |
|
|
@XmlElementWrapper(name = "TaxonomicScope")
|
77 |
|
|
@XmlElement(name = "Taxon")
|
78 |
|
|
@XmlIDREF
|
79 |
|
|
@XmlSchemaType(name = "IDREF")
|
80 |
ee91bcd9
|
ben.clark
|
@ManyToMany(fetch = FetchType.LAZY)
|
81 |
|
|
@JoinTable(
|
82 |
|
|
name="IdentificationKey_Taxon",
|
83 |
|
|
joinColumns=@JoinColumn(name="identificationKey_fk"),
|
84 |
|
|
inverseJoinColumns=@JoinColumn(name="taxon_fk")
|
85 |
|
|
)
|
86 |
a2a36ad5
|
ben.clark
|
private Set<Taxon> taxonomicScope = new HashSet<Taxon>();
|
87 |
|
|
|
88 |
509b132a
|
m.geoffroy
|
/**
|
89 |
|
|
* Class constructor: creates a new empty identification key instance.
|
90 |
|
|
*/
|
91 |
b484eedb
|
Andreas Müller
|
protected IdentificationKey() {
|
92 |
|
|
super();
|
93 |
|
|
}
|
94 |
509b132a
|
m.geoffroy
|
|
95 |
|
|
/**
|
96 |
|
|
* Creates a new empty identification key instance.
|
97 |
|
|
*/
|
98 |
|
|
public static IdentificationKey NewInstance(){
|
99 |
|
|
return new IdentificationKey();
|
100 |
|
|
}
|
101 |
b484eedb
|
Andreas Müller
|
|
102 |
|
|
|
103 |
509b132a
|
m.geoffroy
|
/**
|
104 |
|
|
* Returns the set of possible {@link Taxon taxa} corresponding to
|
105 |
|
|
* <i>this</i> identification key.
|
106 |
|
|
*/
|
107 |
9479da48
|
Andreas Müller
|
public Set<Taxon> getCoveredTaxa() {
|
108 |
|
|
return coveredTaxa;
|
109 |
|
|
}
|
110 |
509b132a
|
m.geoffroy
|
/**
|
111 |
|
|
* @see #getCoveredTaxa()
|
112 |
|
|
*/
|
113 |
9479da48
|
Andreas Müller
|
protected void setCoveredTaxa(Set<Taxon> coveredTaxa) {
|
114 |
|
|
this.coveredTaxa = coveredTaxa;
|
115 |
|
|
}
|
116 |
a2a36ad5
|
ben.clark
|
|
117 |
509b132a
|
m.geoffroy
|
/**
|
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 |
9479da48
|
Andreas Müller
|
public void addCoveredTaxon(Taxon taxon) {
|
125 |
|
|
this.coveredTaxa.add(taxon);
|
126 |
|
|
}
|
127 |
a2a36ad5
|
ben.clark
|
|
128 |
509b132a
|
m.geoffroy
|
/**
|
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 |
9479da48
|
Andreas Müller
|
public void removeCoveredTaxon(Taxon taxon) {
|
137 |
|
|
this.coveredTaxa.remove(taxon);
|
138 |
|
|
}
|
139 |
|
|
|
140 |
a2a36ad5
|
ben.clark
|
/**
|
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 |
9479da48
|
Andreas Müller
|
}
|