2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
10 package eu
.etaxonomy
.cdm
.model
.occurrence
;
14 import javax
.persistence
.Entity
;
15 import javax
.persistence
.ManyToOne
;
16 import javax
.persistence
.Transient
;
17 import javax
.xml
.bind
.annotation
.XmlAccessType
;
18 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
19 import javax
.xml
.bind
.annotation
.XmlElement
;
20 import javax
.xml
.bind
.annotation
.XmlIDREF
;
21 import javax
.xml
.bind
.annotation
.XmlRootElement
;
22 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
23 import javax
.xml
.bind
.annotation
.XmlType
;
25 import org
.hibernate
.annotations
.Cascade
;
26 import org
.hibernate
.annotations
.CascadeType
;
28 import eu
.etaxonomy
.cdm
.model
.name
.TaxonNameBase
;
31 * http://www.bgbm.org/biodivinf/docs/CollectionModel/ReprintTNR.pdf
32 * http://www.bgbm.org/biodivinf/docs/CollectionModel/
34 * Type figures are derived units with at least a figure object in media
39 @XmlAccessorType(XmlAccessType
.FIELD
)
40 @XmlType(name
= "DerivedUnitBase", propOrder
= {
46 @XmlRootElement(name
= "DerivedUnitBase")
48 public abstract class DerivedUnitBase
extends SpecimenOrObservationBase
{
50 @XmlElement(name
= "Collection")
52 @XmlSchemaType(name
= "IDREF")
53 private Collection collection
;
55 @XmlElement(name
= "CatalogNumber")
56 private String catalogNumber
;
58 @XmlElement(name
= "StoredUnder")
60 @XmlSchemaType(name
= "IDREF")
61 private TaxonNameBase storedUnder
;
63 @XmlElement(name
= "DerivedFrom")
65 @XmlSchemaType(name
= "IDREF")
66 private DerivationEvent derivedFrom
;
71 protected DerivedUnitBase() {
75 * create new unit derived from an existing field observation
76 * @param fieldObservation existing field observation from where this unit is derived
78 protected DerivedUnitBase(FieldObservation fieldObservation
) {
80 DerivationEvent derivedFrom
= new DerivationEvent();
81 // TODO: should be done in a more controlled way. Probably by making derivation event implement a general relationship interface (for bidirectional add/remove etc)
82 fieldObservation
.addDerivationEvent(derivedFrom
);
83 derivedFrom
.getOriginals().add(fieldObservation
);
84 derivedFrom
.getDerivatives().add(this);
85 this.setDerivedFrom(derivedFrom
);
88 * create new unit derived from an existing gathering event,
89 * thereby creating a new empty field observation
90 * @param gatheringEvent the gathering event this unit was collected at
92 protected DerivedUnitBase(GatheringEvent gatheringEvent
) {
93 this(new FieldObservation());
94 FieldObservation field
= (FieldObservation
) this.getOriginalUnit();
95 field
.setGatheringEvent(gatheringEvent
);
101 @Deprecated //only for bidirectional and persistence use
102 private DerivationEvent
getDerivationEvent() {
103 return getDerivedFrom();
105 @Deprecated //only for bidirectional and persistence use
106 private void setDerivationEvent(DerivationEvent derivationEvent
) {
107 this.derivedFrom
= derivationEvent
;
110 public DerivationEvent
getDerivedFrom() {
113 public void setDerivedFrom(DerivationEvent derivedFrom
){
114 if (getDerivedFrom() != null){
115 getDerivedFrom().getDerivatives().remove(derivedFrom
);
117 this.derivedFrom
= derivedFrom
;
118 if (derivedFrom
!= null){
119 derivedFrom
.getDerivatives().add(this);
124 public Set
<SpecimenOrObservationBase
> getOriginals(){
125 return this.getDerivedFrom().getOriginals();
131 public GatheringEvent
getGatheringEvent() {
132 // FIXME: implement efficient way of getting original gathering event
133 // keep link to original gathering event for performance mainly.
139 @Cascade({CascadeType
.SAVE_UPDATE
})
140 public Collection
getCollection(){
141 return this.collection
;
143 public void setCollection(Collection collection
){
144 this.collection
= collection
;
148 public String
getCatalogNumber() {
149 return catalogNumber
;
152 public void setCatalogNumber(String catalogNumber
) {
153 this.catalogNumber
= catalogNumber
;
157 @Cascade({CascadeType
.SAVE_UPDATE
})
158 public TaxonNameBase
getStoredUnder() {
161 public void setStoredUnder(TaxonNameBase storedUnder
) {
162 this.storedUnder
= storedUnder
;