(no commit message)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / occurrence / DerivationEvent.java
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.occurrence;
11
12 import java.util.HashSet;
13 import java.util.Set;
14
15 import javax.persistence.Entity;
16 import javax.persistence.ManyToMany;
17 import javax.persistence.ManyToOne;
18 import javax.persistence.OneToMany;
19
20 import org.apache.log4j.Logger;
21 import org.hibernate.annotations.Cascade;
22 import org.hibernate.annotations.CascadeType;
23
24 import eu.etaxonomy.cdm.model.common.EventBase;
25
26 @Entity
27 public class DerivationEvent extends EventBase{
28 static Logger logger = Logger.getLogger(DerivationEvent.class);
29
30 private Set<SpecimenOrObservationBase> originals = new HashSet();
31 private Set<DerivedUnit> derivatives = new HashSet();
32 private DerivationEventType type;
33
34 /**
35 * Factory method
36 * @return
37 */
38 public static DerivationEvent NewInstance(){
39 return new DerivationEvent();
40 }
41
42 /**
43 * Constructor
44 */
45 protected DerivationEvent() {
46 super();
47 }
48
49 @ManyToMany(mappedBy="derivationEvents")
50 @Cascade({CascadeType.SAVE_UPDATE})
51 public Set<SpecimenOrObservationBase> getOriginals() {
52 return originals;
53 }
54 protected void setOriginals(Set<SpecimenOrObservationBase> originals) {
55 this.originals = originals;
56 }
57 public void addOriginal(SpecimenOrObservationBase original) {
58 this.originals.add(original);
59 }
60 public void removeOriginal(SpecimenOrObservationBase original) {
61 this.originals.remove(original);
62 }
63
64
65 @OneToMany(mappedBy="derivedFrom")
66 @Cascade({CascadeType.SAVE_UPDATE})
67 public Set<DerivedUnit> getDerivatives() {
68 return derivatives;
69 }
70 protected void setDerivatives(Set<DerivedUnit> derivatives) {
71 this.derivatives = derivatives;
72 }
73 public void addDerivative(DerivedUnit derivative) {
74 this.derivatives.add(derivative);
75 }
76 public void removeDerivative(DerivedUnit derivative) {
77 this.derivatives.remove(derivative);
78 }
79
80
81 @ManyToOne
82 public DerivationEventType getType() {
83 return type;
84 }
85 public void setType(DerivationEventType type) {
86 this.type = type;
87 }
88 }