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
|
|
13
|
import eu.etaxonomy.cdm.model.location.NamedArea;
|
14
|
import eu.etaxonomy.cdm.model.taxon.Taxon;
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.hibernate.annotations.Cascade;
|
17
|
import org.hibernate.annotations.CascadeType;
|
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.XmlRootElement;
|
27
|
import javax.xml.bind.annotation.XmlTransient;
|
28
|
import javax.xml.bind.annotation.XmlType;
|
29
|
|
30
|
/**
|
31
|
* A description that delimits this taxon.
|
32
|
* Equivalent to TCS /DataSet/TaxonConcepts/TaxonConcept/CharacterCircumscription
|
33
|
*
|
34
|
* @author m.doering
|
35
|
* @version 1.0
|
36
|
* @created 08-Nov-2007 13:06:20
|
37
|
*/
|
38
|
@XmlAccessorType(XmlAccessType.FIELD)
|
39
|
@XmlType(name = "TaxonDescription", propOrder = {
|
40
|
"scopes",
|
41
|
"geoScopes"
|
42
|
})
|
43
|
@Entity
|
44
|
public class TaxonDescription extends DescriptionBase {
|
45
|
|
46
|
static Logger logger = Logger.getLogger(TaxonDescription.class);
|
47
|
|
48
|
@XmlElementWrapper(name = "Scopes")
|
49
|
@XmlElement(name = "Scope")
|
50
|
private Set<Scope> scopes = new HashSet<Scope>();
|
51
|
|
52
|
@XmlElementWrapper( name = "GeoScopes")
|
53
|
@XmlElement( name = "GeoScope")
|
54
|
private Set<NamedArea> geoScopes = new HashSet<NamedArea>();
|
55
|
|
56
|
@XmlTransient
|
57
|
private Taxon taxon;
|
58
|
|
59
|
public static TaxonDescription NewInstance(){
|
60
|
return new TaxonDescription();
|
61
|
}
|
62
|
|
63
|
public static TaxonDescription NewInstance(Taxon taxon){
|
64
|
TaxonDescription description = new TaxonDescription();
|
65
|
taxon.addDescription(description);
|
66
|
return description;
|
67
|
}
|
68
|
|
69
|
public TaxonDescription(){
|
70
|
super();
|
71
|
}
|
72
|
|
73
|
|
74
|
@OneToMany
|
75
|
@Cascade({CascadeType.SAVE_UPDATE})
|
76
|
public Set<NamedArea> getGeoScopes(){
|
77
|
return this.geoScopes;
|
78
|
}
|
79
|
protected void setGeoScopes(Set<NamedArea> geoScopes){
|
80
|
this.geoScopes = geoScopes;
|
81
|
}
|
82
|
public void addGeoScope(NamedArea geoScope){
|
83
|
this.geoScopes.add(geoScope);
|
84
|
}
|
85
|
public void removeGeoScope(NamedArea geoScope){
|
86
|
this.geoScopes.remove(geoScope);
|
87
|
}
|
88
|
|
89
|
|
90
|
@OneToMany
|
91
|
public Set<Scope> getScopes(){
|
92
|
return this.scopes;
|
93
|
}
|
94
|
protected void setScopes(Set<Scope> scopes){
|
95
|
this.scopes = scopes;
|
96
|
}
|
97
|
public void addScope(Scope scope){
|
98
|
this.scopes.add(scope);
|
99
|
}
|
100
|
public void removeScope(Scope scope){
|
101
|
this.scopes.remove(scope);
|
102
|
}
|
103
|
|
104
|
|
105
|
@ManyToOne
|
106
|
@JoinColumn(name="taxon_fk")
|
107
|
@Cascade(CascadeType.SAVE_UPDATE)
|
108
|
public Taxon getTaxon() {
|
109
|
return taxon;
|
110
|
}
|
111
|
@Deprecated //for hibernate use only, use taxon.addDescription() instead
|
112
|
protected void setTaxon(Taxon taxon) {
|
113
|
this.taxon = taxon;
|
114
|
}
|
115
|
|
116
|
}
|