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