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 java.util.HashSet;
|
13
|
import java.util.Set;
|
14
|
|
15
|
import javax.persistence.Entity;
|
16
|
import javax.persistence.FetchType;
|
17
|
import javax.persistence.Inheritance;
|
18
|
import javax.persistence.InheritanceType;
|
19
|
|
20
|
import javax.persistence.OneToMany;
|
21
|
import javax.persistence.Transient;
|
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.XmlElements;
|
27
|
import javax.xml.bind.annotation.XmlType;
|
28
|
|
29
|
import org.apache.log4j.Logger;
|
30
|
import org.hibernate.annotations.Cascade;
|
31
|
import org.hibernate.annotations.CascadeType;
|
32
|
|
33
|
import eu.etaxonomy.cdm.model.agent.Institution;
|
34
|
import eu.etaxonomy.cdm.model.agent.Person;
|
35
|
import eu.etaxonomy.cdm.model.agent.Team;
|
36
|
import eu.etaxonomy.cdm.model.common.IdentifiableEntity;
|
37
|
import eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase;
|
38
|
import eu.etaxonomy.cdm.model.reference.ReferenceBase;
|
39
|
|
40
|
/**
|
41
|
* The upmost (abstract) class for the whole description with possibly several
|
42
|
* feature data of a specimen or of a taxon.
|
43
|
*
|
44
|
* @author m.doering
|
45
|
* @version 1.0
|
46
|
* @created 08-Nov-2007 13:06:24
|
47
|
*/
|
48
|
|
49
|
@XmlAccessorType(XmlAccessType.FIELD)
|
50
|
@XmlType(name = "DescriptionBase", propOrder = {
|
51
|
"describedSpecimenOrObservations",
|
52
|
"descriptionSources",
|
53
|
"descriptionElements"
|
54
|
})
|
55
|
@Entity
|
56
|
@Inheritance(strategy=InheritanceType.SINGLE_TABLE)
|
57
|
public abstract class DescriptionBase extends IdentifiableEntity {
|
58
|
|
59
|
private static final Logger logger = Logger.getLogger(DescriptionBase.class);
|
60
|
|
61
|
@XmlElementWrapper(name = "DescribedSpecimenOrObservations")
|
62
|
@XmlElement(name = "DescribedSpecimenOrObservation")
|
63
|
private Set<SpecimenOrObservationBase> describedSpecimenOrObservations = new HashSet<SpecimenOrObservationBase>();
|
64
|
|
65
|
@XmlElementWrapper(name = "DescriptionSources")
|
66
|
@XmlElement(name = "DescriptionSource")
|
67
|
private Set<ReferenceBase> descriptionSources = new HashSet<ReferenceBase>();
|
68
|
|
69
|
@XmlElementWrapper(name = "DescriptionElements")
|
70
|
@XmlElements({
|
71
|
@XmlElement(name = "CategorialData", namespace = "http://etaxonomy.eu/cdm/model/description/1.0", type = CategoricalData.class),
|
72
|
@XmlElement(name = "CommonTaxonName", namespace = "http://etaxonomy.eu/cdm/model/description/1.0", type = CommonTaxonName.class),
|
73
|
@XmlElement(name = "Distribution", namespace = "http://etaxonomy.eu/cdm/model/description/1.0", type = Distribution.class),
|
74
|
@XmlElement(name = "IndividualsAssociation", namespace = "http://etaxonomy.eu/cdm/model/description/1.0", type = IndividualsAssociation.class),
|
75
|
@XmlElement(name = "QuantitativeData", namespace = "http://etaxonomy.eu/cdm/model/description/1.0", type = QuantitativeData.class),
|
76
|
@XmlElement(name = "TaxonInteraction", namespace = "http://etaxonomy.eu/cdm/model/description/1.0", type = TaxonInteraction.class),
|
77
|
@XmlElement(name = "TextData", namespace = "http://etaxonomy.eu/cdm/model/description/1.0", type = TextData.class)
|
78
|
})
|
79
|
private Set<DescriptionElementBase> descriptionElements = new HashSet<DescriptionElementBase>();
|
80
|
|
81
|
/**
|
82
|
* Returns the set of specimens or observations involved in this description
|
83
|
* as a whole. Also taxon descriptions are often based on concrete specimens
|
84
|
* or observations.
|
85
|
*
|
86
|
* @return the set of of specimens or observations
|
87
|
*/
|
88
|
//@ManyToMany //FIXME
|
89
|
@Transient
|
90
|
public Set<SpecimenOrObservationBase> getDescribedSpecimenOrObservations() {
|
91
|
return describedSpecimenOrObservations;
|
92
|
}
|
93
|
public void setDescribedSpecimenOrObservations(
|
94
|
Set<SpecimenOrObservationBase> describedSpecimenOrObservations) {
|
95
|
this.describedSpecimenOrObservations = describedSpecimenOrObservations;
|
96
|
}
|
97
|
public void addDescribedSpecimenOrObservations(SpecimenOrObservationBase describedSpecimenOrObservation) {
|
98
|
this.describedSpecimenOrObservations.add(describedSpecimenOrObservation);
|
99
|
}
|
100
|
public void removeDescribedSpecimenOrObservations(SpecimenOrObservationBase describedSpecimenOrObservation) {
|
101
|
this.describedSpecimenOrObservations.remove(describedSpecimenOrObservation);
|
102
|
}
|
103
|
|
104
|
/**
|
105
|
* Returns the set of references used as sources for this description as a
|
106
|
* whole. More than one source can be used for a general description without
|
107
|
* assigning for each data element of the description one of those sources.
|
108
|
*
|
109
|
* @return the set of references
|
110
|
*/
|
111
|
// @ManyToMany //FIXME
|
112
|
// @Cascade( { CascadeType.SAVE_UPDATE })
|
113
|
@Transient
|
114
|
public Set<ReferenceBase> getDescriptionSources() {
|
115
|
return this.descriptionSources;
|
116
|
}
|
117
|
protected void setDescriptionSources(Set<ReferenceBase> descriptionSources) {
|
118
|
this.descriptionSources = descriptionSources;
|
119
|
}
|
120
|
public void addDescriptionSource(ReferenceBase descriptionSource) {
|
121
|
this.descriptionSources.add(descriptionSource);
|
122
|
}
|
123
|
public void removeDescriptionSource(ReferenceBase descriptionSource) {
|
124
|
this.descriptionSources.remove(descriptionSource);
|
125
|
}
|
126
|
|
127
|
|
128
|
@OneToMany(fetch=FetchType.LAZY)
|
129
|
@Cascade( { CascadeType.SAVE_UPDATE })
|
130
|
public Set<DescriptionElementBase> getElements() {
|
131
|
return this.descriptionElements;
|
132
|
}
|
133
|
|
134
|
protected void setElements(Set<DescriptionElementBase> element) {
|
135
|
this.descriptionElements = element;
|
136
|
}
|
137
|
|
138
|
public void addElement(DescriptionElementBase element) {
|
139
|
this.descriptionElements.add(element);
|
140
|
}
|
141
|
|
142
|
public void removeElement(DescriptionElementBase element) {
|
143
|
this.descriptionElements.remove(element);
|
144
|
}
|
145
|
|
146
|
@Override
|
147
|
public String generateTitle() {
|
148
|
//TODO generate title "generate Title not yet implemented"
|
149
|
return this.toString();
|
150
|
}
|
151
|
}
|