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
;
12 import java
.util
.HashSet
;
15 import javax
.persistence
.Entity
;
16 import javax
.persistence
.ManyToMany
;
17 import javax
.persistence
.ManyToOne
;
18 import javax
.persistence
.OneToMany
;
20 import org
.apache
.log4j
.Logger
;
21 import org
.hibernate
.annotations
.Cascade
;
22 import org
.hibernate
.annotations
.CascadeType
;
24 import eu
.etaxonomy
.cdm
.model
.common
.EventBase
;
27 public class DerivationEvent
extends EventBase
{
28 static Logger logger
= Logger
.getLogger(DerivationEvent
.class);
30 private Set
<SpecimenOrObservationBase
> originals
= new HashSet
<SpecimenOrObservationBase
>();
31 protected Set
<DerivedUnitBase
> derivatives
= new HashSet
<DerivedUnitBase
>();
32 private DerivationEventType type
;
38 public static DerivationEvent
NewInstance(){
39 return new DerivationEvent();
45 protected DerivationEvent() {
49 @ManyToMany(mappedBy
="derivationEvents")
50 @Cascade({CascadeType
.SAVE_UPDATE
})
51 public Set
<SpecimenOrObservationBase
> getOriginals() {
54 protected void setOriginals(Set
<SpecimenOrObservationBase
> originals
) {
55 this.originals
= originals
;
57 public void addOriginal(SpecimenOrObservationBase original
) {
58 if (! this.originals
.contains(original
)){
59 this.originals
.add(original
);
60 original
.addDerivationEvent(this);
63 public void removeOriginal(SpecimenOrObservationBase original
) {
64 this.originals
.remove(original
);
68 @OneToMany(mappedBy
="derivationEvent")
69 @Cascade({CascadeType
.SAVE_UPDATE
})
70 public Set
<DerivedUnitBase
> getDerivatives() {
73 protected void setDerivatives(Set
<DerivedUnitBase
> derivatives
) {
74 this.derivatives
= derivatives
;
76 public void addDerivative(DerivedUnitBase derivative
) {
77 if (derivative
!= null){
78 derivative
.setDerivedFrom(this);
81 public void removeDerivative(DerivedUnitBase derivative
) {
82 if (derivative
!= null){
83 derivative
.setDerivedFrom(null);
89 public DerivationEventType
getType() {
92 public void setType(DerivationEventType type
) {