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.taxon.Taxon;
|
14
|
|
15
|
import org.apache.log4j.Logger;
|
16
|
import org.hibernate.annotations.Cascade;
|
17
|
import org.hibernate.annotations.CascadeType;
|
18
|
import javax.persistence.*;
|
19
|
import javax.xml.bind.annotation.XmlAccessType;
|
20
|
import javax.xml.bind.annotation.XmlAccessorType;
|
21
|
import javax.xml.bind.annotation.XmlElement;
|
22
|
import javax.xml.bind.annotation.XmlIDREF;
|
23
|
import javax.xml.bind.annotation.XmlRootElement;
|
24
|
import javax.xml.bind.annotation.XmlSchemaType;
|
25
|
import javax.xml.bind.annotation.XmlType;
|
26
|
|
27
|
/**
|
28
|
* This class represents elementary distribution data for a {@link Taxon taxon}.
|
29
|
* Only {@link TaxonDescription taxon descriptions} may contain distributions.
|
30
|
* A distribution instance consist of a {@link NamedArea named area} and of a {@link PresenceAbsenceTermBase status}
|
31
|
* describing the absence or the presence of a taxon (like "extinct"
|
32
|
* or "introduced") in this named area.
|
33
|
* <P>
|
34
|
* This class corresponds partially to: <ul>
|
35
|
* <li> CodedDescriptionType according to the the SDD schema
|
36
|
* <li> Distribution according to the TDWG ontology
|
37
|
* </ul>
|
38
|
*
|
39
|
* @author m.doering
|
40
|
* @version 1.0
|
41
|
* @created 08-Nov-2007 13:06:21
|
42
|
*/
|
43
|
@XmlAccessorType(XmlAccessType.FIELD)
|
44
|
@XmlType(name = "Distribution", propOrder = {
|
45
|
"area",
|
46
|
"status"
|
47
|
})
|
48
|
@XmlRootElement(name = "Distribution")
|
49
|
@Entity
|
50
|
public class Distribution extends DescriptionElementBase {
|
51
|
static Logger logger = Logger.getLogger(Distribution.class);
|
52
|
|
53
|
@XmlElement(name = "NamedArea")
|
54
|
@XmlIDREF
|
55
|
@XmlSchemaType(name = "IDREF")
|
56
|
private NamedArea area;
|
57
|
|
58
|
@XmlElement(name = "PresenceAbsenceStatus")
|
59
|
private PresenceAbsenceTermBase status;
|
60
|
|
61
|
|
62
|
/**
|
63
|
* Class constructor: creates a new empty distribution instance.
|
64
|
* The corresponding {@link Feature feature} is set to {@link Feature#DISTRIBUTION() DISTRIBUTION}.
|
65
|
*/
|
66
|
protected Distribution(){
|
67
|
super(Feature.DISTRIBUTION());
|
68
|
}
|
69
|
|
70
|
|
71
|
/**
|
72
|
* Creates an empty distribution instance. The corresponding {@link Feature feature}
|
73
|
* is set to {@link Feature#DISTRIBUTION() DISTRIBUTION}.
|
74
|
*
|
75
|
* @see #NewInstance(NamedArea, PresenceAbsenceTermBase)
|
76
|
*/
|
77
|
public static Distribution NewInstance(){
|
78
|
Distribution result = new Distribution();
|
79
|
return result;
|
80
|
}
|
81
|
|
82
|
/**
|
83
|
* Creates a distribution instance with the given {@link NamedArea named area} and {@link PresenceAbsenceTermBase status}.
|
84
|
* The corresponding {@link Feature feature} is set to {@link Feature#DISTRIBUTION() DISTRIBUTION}.
|
85
|
*
|
86
|
* @param area the named area for the new distribution
|
87
|
* @param status the presence or absence term for the new distribution
|
88
|
* @see #NewInstance()
|
89
|
*/
|
90
|
public static Distribution NewInstance(NamedArea area, PresenceAbsenceTermBase status){
|
91
|
Distribution result = new Distribution();
|
92
|
result.setArea(area);
|
93
|
result.setStatus(status);
|
94
|
return result;
|
95
|
}
|
96
|
|
97
|
/**
|
98
|
* Deprecated because {@link Feature feature} should always be {@link Feature#DISTRIBUTION() DISTRIBUTION}
|
99
|
* for all distribution instances.
|
100
|
*/
|
101
|
/* (non-Javadoc)
|
102
|
* @see eu.etaxonomy.cdm.model.description.DescriptionElementBase#setFeature(eu.etaxonomy.cdm.model.description.Feature)
|
103
|
*/
|
104
|
@Override
|
105
|
@Deprecated
|
106
|
public void setFeature(Feature feature) {
|
107
|
super.setFeature(feature);
|
108
|
}
|
109
|
|
110
|
/**
|
111
|
* Returns the {@link NamedArea named area} <i>this</i> distribution applies to.
|
112
|
*/
|
113
|
@ManyToOne
|
114
|
@Cascade({CascadeType.SAVE_UPDATE})
|
115
|
public NamedArea getArea(){
|
116
|
return this.area;
|
117
|
}
|
118
|
/**
|
119
|
* @see #getArea()
|
120
|
*/
|
121
|
public void setArea(NamedArea area){
|
122
|
this.area = area;
|
123
|
}
|
124
|
|
125
|
/**
|
126
|
* Returns the {@link PresenceAbsenceTermBase presence or absence term} for <i>this</i> distribution.
|
127
|
*/
|
128
|
@ManyToOne
|
129
|
public PresenceAbsenceTermBase getStatus(){
|
130
|
return this.status;
|
131
|
}
|
132
|
/**
|
133
|
* @see #getStatus()
|
134
|
*/
|
135
|
public void setStatus(PresenceAbsenceTermBase status){
|
136
|
this.status = status;
|
137
|
}
|
138
|
|
139
|
}
|