root/trunk/cdmlib/cdmlib-model/src/main/java/eu/etaxonomy/cdm/model/occurrence/Specimen.java

Revision 10919, 3.8 kB (checked in by a.mueller, 18 months ago)

merge 3.0.2 to trunk

  • Property svn:keywords set to Id
Line 
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
10package eu.etaxonomy.cdm.model.occurrence;
11
12import javax.persistence.Entity;
13import javax.persistence.FetchType;
14import javax.persistence.ManyToOne;
15import javax.validation.constraints.Size;
16import javax.xml.bind.annotation.XmlAccessType;
17import javax.xml.bind.annotation.XmlAccessorType;
18import javax.xml.bind.annotation.XmlElement;
19import javax.xml.bind.annotation.XmlIDREF;
20import javax.xml.bind.annotation.XmlRootElement;
21import javax.xml.bind.annotation.XmlSchemaType;
22import javax.xml.bind.annotation.XmlType;
23
24import org.apache.log4j.Logger;
25import org.hibernate.envers.Audited;
26import org.hibernate.search.annotations.Field;
27import org.hibernate.search.annotations.Index;
28import org.hibernate.search.annotations.Indexed;
29import org.springframework.beans.factory.annotation.Configurable;
30
31import eu.etaxonomy.cdm.strategy.cache.common.IIdentifiableEntityCacheStrategy;
32import eu.etaxonomy.cdm.strategy.cache.common.IdentifiableEntityDefaultCacheStrategy;
33import eu.etaxonomy.cdm.validation.annotation.NullOrNotEmpty;
34
35/**
36 * A specimen is regarded as derived from an field observation,
37 * so locality and gathering related information is captured as a separate FieldObservation object
38 * related to a specimen via a derivation event
39 * @author m.doering
40 * @version 1.0
41 * @created 08-Nov-2007 13:06:52
42 */
43@XmlAccessorType(XmlAccessType.FIELD)
44@XmlType(name = "Specimen", propOrder = {
45                "preservation",
46                "exsiccatum"
47})
48@XmlRootElement(name = "Specimen")
49@Entity
50@Indexed(index = "eu.etaxonomy.cdm.model.occurrence.SpecimenOrObservationBase")
51@Audited
52@Configurable
53public class Specimen extends DerivedUnitBase<IIdentifiableEntityCacheStrategy<Specimen>> implements Cloneable {
54        private static final long serialVersionUID = -504050482700773061L;
55        private static final Logger logger = Logger.getLogger(Specimen.class);
56       
57        @XmlElement(name = "Preservation")
58        @XmlIDREF
59        @XmlSchemaType(name = "IDREF")
60        @ManyToOne(fetch = FetchType.LAZY)
61        private PreservationMethod preservation;
62       
63       
64        @XmlElement(name = "Exsiccatum")
65        @NullOrNotEmpty
66        @Field(index=Index.TOKENIZED)
67        @Size(max = 255)
68    private String exsiccatum;
69       
70       
71        /**
72         * Factory method
73         * @return
74         */
75        public static Specimen NewInstance(){
76                return new Specimen();
77        }
78       
79        /**
80         * Constructor
81         */
82        protected Specimen() {
83                super();
84                this.cacheStrategy = new IdentifiableEntityDefaultCacheStrategy<Specimen>();
85        }
86
87//***************************** GETTER / SETTER ************************************** 
88       
89        public PreservationMethod getPreservation(){
90                return this.preservation;
91        }
92       
93        public void setPreservation(PreservationMethod preservation){
94                this.preservation = preservation;
95        }
96
97
98        public void setExsiccatum(String exsiccatum) {
99                this.exsiccatum = exsiccatum;
100        }
101
102        public String getExsiccatum() {
103                return exsiccatum;
104        }
105       
106       
107//*********** CLONE **********************************/
108       
109        /**
110         * Clones <i>this</i> specimen. This is a shortcut that enables to
111         * create a new instance that differs only slightly from <i>this</i> specimen
112         * by modifying only some of the attributes.<BR>
113         * This method overrides the clone method from {@link DerivedUnitBase DerivedUnitBase}.
114         *
115         * @see DerivedUnitBase#clone()
116         * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
117         * @see java.lang.Object#clone()
118         */
119        @Override
120        public Object clone(){
121                try{
122                        Specimen result = (Specimen)super.clone();
123                        result.setPreservation(this.preservation);
124                        //no changes to: -
125                        return result;
126                } catch (CloneNotSupportedException e) {
127                        logger.warn("Object does not implement cloneable");
128                        e.printStackTrace();
129                        return null;
130                }
131        }
132
133       
134
135}
Note: See TracBrowser for help on using the browser.