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