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 java
.util
.HashSet
;
17 import javax
.persistence
.Entity
;
18 import javax
.persistence
.FetchType
;
19 import javax
.persistence
.ManyToMany
;
20 import javax
.persistence
.ManyToOne
;
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
.XmlIDREF
;
27 import javax
.xml
.bind
.annotation
.XmlRootElement
;
28 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
29 import javax
.xml
.bind
.annotation
.XmlType
;
31 import org
.apache
.log4j
.Logger
;
32 import org
.hibernate
.annotations
.Cascade
;
33 import org
.hibernate
.annotations
.CascadeType
;
34 import org
.hibernate
.envers
.Audited
;
35 import org
.hibernate
.search
.annotations
.Indexed
;
36 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
37 import org
.joda
.time
.Partial
;
39 import eu
.etaxonomy
.cdm
.model
.agent
.AgentBase
;
40 import eu
.etaxonomy
.cdm
.model
.common
.DefinedTerm
;
41 import eu
.etaxonomy
.cdm
.model
.common
.EventBase
;
42 import eu
.etaxonomy
.cdm
.model
.reference
.Reference
;
43 import eu
.etaxonomy
.cdm
.model
.taxon
.Taxon
;
44 import eu
.etaxonomy
.cdm
.model
.taxon
.TaxonBase
;
49 * @created 08-Nov-2007 13:06:21
51 @XmlAccessorType(XmlAccessType
.FIELD
)
52 @XmlType(name
= "DeterminationEvent", propOrder
= {
59 @XmlRootElement(name
= "DeterminationEvent")
63 public class DeterminationEvent
extends EventBase
{
64 private static final Logger logger
= Logger
.getLogger(DeterminationEvent
.class);
66 @XmlElement(name
= "IdentifiedUnit")
68 @XmlSchemaType(name
= "IDREF")
69 @ManyToOne(fetch
= FetchType
.LAZY
)
70 @Cascade(CascadeType
.SAVE_UPDATE
)
71 private SpecimenOrObservationBase identifiedUnit
;
73 @XmlElement(name
= "Taxon")
75 @XmlSchemaType(name
= "IDREF")
76 @ManyToOne(fetch
= FetchType
.LAZY
)
78 @Cascade(CascadeType
.SAVE_UPDATE
)
79 private TaxonBase taxon
;
81 @XmlElement(name
= "Modifier")
83 @XmlSchemaType(name
= "IDREF")
84 @ManyToOne(fetch
= FetchType
.LAZY
)
85 private DefinedTerm modifier
;
87 @XmlElement(name
= "PreferredFlag")
88 private boolean preferredFlag
;
90 @XmlElementWrapper(name
= "SetOfReferences")
91 @XmlElement(name
= "Reference")
93 @XmlSchemaType(name
= "IDREF")
94 @ManyToMany(fetch
= FetchType
.LAZY
)
95 private Set
<Reference
> setOfReferences
= new HashSet
<Reference
>();
103 public static DeterminationEvent
NewInstance(){
104 return new DeterminationEvent();
111 public static DeterminationEvent
NewInstance(Taxon taxon
, SpecimenOrObservationBase identifiedUnit
){
112 DeterminationEvent result
= new DeterminationEvent();
113 result
.setTaxon(taxon
);
114 result
.setIdentifiedUnit(identifiedUnit
);
115 identifiedUnit
.addDetermination(result
);
122 protected DeterminationEvent() {
126 public DefinedTerm
getModifier() {
130 public void setModifier(DefinedTerm modifier
) {
131 this.modifier
= modifier
;
134 public TaxonBase
getTaxon(){
142 public void setTaxon(TaxonBase taxon
){
147 public Partial
getIdentificationDate(){
148 return this.getTimeperiod().getStart();
153 * @param identificationDate identificationDate
155 public void setIdentificationDate(Partial identificationDate
){
156 this.getTimeperiod().setStart(identificationDate
);
160 public AgentBase
getDeterminer() {
161 return this.getActor();
164 public void setDeterminer(AgentBase determiner
) {
165 this.setActor(determiner
);
168 public SpecimenOrObservationBase
getIdentifiedUnit() {
169 return identifiedUnit
;
172 public void setIdentifiedUnit(SpecimenOrObservationBase identifiedUnit
) {
173 this.identifiedUnit
= identifiedUnit
;
176 public boolean getPreferredFlag() {
177 return preferredFlag
;
180 public void setPreferredFlag(boolean preferredFlag
) {
181 this.preferredFlag
= preferredFlag
;
184 public Set
<Reference
> getReferences() {
185 return setOfReferences
;
188 public void setReferences(Set
<Reference
> references
) {
189 this.setOfReferences
= references
;
192 public void addReference(Reference reference
) {
193 this.setOfReferences
.add(reference
);
196 //*********** CLONE **********************************/
199 * Clones <i>this</i> determination event. This is a shortcut that enables to
200 * create a new instance that differs only slightly from <i>this</i> determination event
201 * by modifying only some of the attributes.<BR>
202 * This method overrides the clone method from {@link EventBase EventBase}.
204 * @see EventBase#clone()
205 * @see java.lang.Object#clone()
208 public DeterminationEvent
clone(){
210 DeterminationEvent result
= (DeterminationEvent
)super.clone();
212 result
.setIdentifiedUnit(this.getIdentifiedUnit());
214 result
.setModifier(this.getModifier());
216 result
.setTaxon(this.getTaxon()); //TODO
217 //no changes to: preferredFlag
219 } catch (CloneNotSupportedException e
) {
220 logger
.warn("Object does not implement cloneable");