Committing large number of changes relating to versioning implementation (#108)
[cdmlib.git] / cdmlib-model / src / main / java / eu / etaxonomy / cdm / model / occurrence / Specimen.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 javax.persistence.Entity;
13 import javax.persistence.FetchType;
14 import javax.persistence.ManyToOne;
15 import javax.xml.bind.annotation.XmlAccessType;
16 import javax.xml.bind.annotation.XmlAccessorType;
17 import javax.xml.bind.annotation.XmlElement;
18 import javax.xml.bind.annotation.XmlIDREF;
19 import javax.xml.bind.annotation.XmlRootElement;
20 import javax.xml.bind.annotation.XmlSchemaType;
21 import javax.xml.bind.annotation.XmlType;
22
23 import org.apache.log4j.Logger;
24 import org.hibernate.envers.Audited;
25
26 /**
27 * A specimen is regarded as derived from an field observation,
28 * so locality and gathering related information is captured as a separate FieldObservation object
29 * related to a specimen via a derivation event
30 * @author m.doering
31 * @version 1.0
32 * @created 08-Nov-2007 13:06:52
33 */
34 @XmlAccessorType(XmlAccessType.FIELD)
35 @XmlType(name = "Specimen", propOrder = {
36 "preservation"
37 })
38 @XmlRootElement(name = "Specimen")
39 @Entity
40 @Audited
41 public class Specimen extends DerivedUnitBase implements Cloneable {
42 private static final Logger logger = Logger.getLogger(Specimen.class);
43
44 @XmlElement(name = "Preservation")
45 @XmlIDREF
46 @XmlSchemaType(name = "IDREF")
47 @ManyToOne(fetch = FetchType.LAZY)
48 private PreservationMethod preservation;
49
50 /**
51 * Factory method
52 * @return
53 */
54 public static Specimen NewInstance(){
55 return new Specimen();
56 }
57
58 /**
59 * Constructor
60 */
61 protected Specimen() {
62 super();
63 }
64
65 public PreservationMethod getPreservation(){
66 return this.preservation;
67 }
68
69 public void setPreservation(PreservationMethod preservation){
70 this.preservation = preservation;
71 }
72
73
74 //*********** CLONE **********************************/
75
76 /**
77 * Clones <i>this</i> specimen. This is a shortcut that enables to
78 * create a new instance that differs only slightly from <i>this</i> specimen
79 * by modifying only some of the attributes.<BR>
80 * This method overrides the clone method from {@link DerivedUnitBase DerivedUnitBase}.
81 *
82 * @see DerivedUnitBase#clone()
83 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
84 * @see java.lang.Object#clone()
85 */
86 @Override
87 public Object clone(){
88 try{
89 Specimen result = (Specimen)super.clone();
90 result.setPreservation(this.preservation);
91 //no changes to: -
92 return result;
93 } catch (CloneNotSupportedException e) {
94 logger.warn("Object does not implement cloneable");
95 e.printStackTrace();
96 return null;
97 }
98 }
99
100
101 }