Project

General

Profile

Download (4.38 KB) Statistics
| Branch: | Tag: | Revision:
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
package eu.etaxonomy.cdm.model.occurrence;
10

    
11
import javax.persistence.Entity;
12
import javax.persistence.FetchType;
13
import javax.persistence.ManyToOne;
14
import javax.xml.bind.annotation.XmlAccessType;
15
import javax.xml.bind.annotation.XmlAccessorType;
16
import javax.xml.bind.annotation.XmlElement;
17
import javax.xml.bind.annotation.XmlIDREF;
18
import javax.xml.bind.annotation.XmlRootElement;
19
import javax.xml.bind.annotation.XmlSchemaType;
20
import javax.xml.bind.annotation.XmlType;
21

    
22
import org.apache.log4j.Logger;
23
import org.hibernate.envers.Audited;
24
import org.hibernate.search.annotations.Analyze;
25
import org.hibernate.search.annotations.Field;
26
import org.hibernate.search.annotations.IndexedEmbedded;
27
import org.hibernate.search.annotations.NumericField;
28

    
29
import eu.etaxonomy.cdm.model.common.EventBase;
30
import eu.etaxonomy.cdm.model.molecular.Cloning;
31
import eu.etaxonomy.cdm.model.term.DefinedTerm;
32
import eu.etaxonomy.cdm.model.term.TermType;
33

    
34
/**
35
 * This class is a specialization of {@link MaterialOrMethodEvent} which allows to
36
 * specifically store temperature and XXX which are common parameters for preparation.
37
 *
38
 * {@link #getDefinedMaterialOrMethod() Defined methods} taken to describe a Preservation Method
39
 * should be taken from a vocabulary of type {@link TermType#PreservationMethod}
40
 *
41
 * http://rs.tdwg.org/ontology/voc/Collection.rdf#SpecimenPreservationMethodTypeTerm
42
 *
43
 * @author a.mueller
44
 * @since 2013-09-11
45
 *
46
 */
47
@XmlAccessorType(XmlAccessType.FIELD)
48
@XmlType(name = "PreservationMethod", propOrder = {
49
	"medium",
50
	"temperature"
51
})
52
@XmlRootElement(name = "PreservationMethod")
53
@Entity
54
//TODO @Indexed(index = "eu.etaxonomy.cdm.model.term.DefinedTermBase")
55
@Audited
56
public class PreservationMethod extends MaterialOrMethodEvent implements Cloneable {
57
	private static final long serialVersionUID = 2366116167028862401L;
58
	@SuppressWarnings("unused")
59
	private static final Logger logger = Logger.getLogger(PreservationMethod.class);
60

    
61
    @XmlElement(name = "Medium")
62
    @XmlIDREF
63
    @XmlSchemaType(name = "IDREF")
64
    @ManyToOne(fetch = FetchType.LAZY)
65
    @IndexedEmbedded // no depth for terms
66
    private DefinedTerm medium;
67

    
68
	@XmlElement(name = "Temperature")
69
	@Field(analyze = Analyze.NO)
70
	@NumericField
71
	private Double temperature;
72

    
73
	// ******************** FACTORY METHOD ******************/
74

    
75
	public static PreservationMethod NewInstance(){
76
		return new PreservationMethod();
77
	}
78

    
79
    public static PreservationMethod NewInstance(DefinedTerm definedMaterialOrMethod, String methodText){
80
    	return new PreservationMethod(definedMaterialOrMethod, methodText, null, null);
81
    }
82

    
83
	public static PreservationMethod NewInstance(DefinedTerm definedMaterialOrMethod, String methodText, DefinedTerm preservationMedium, Double temperature){
84
		return new PreservationMethod(definedMaterialOrMethod, methodText, preservationMedium, temperature);
85
	}
86

    
87
	// ********************* CONSTRUCTOR ********************/
88

    
89
	//for hibernate use only
90
	protected PreservationMethod(){};
91

    
92
    private PreservationMethod(DefinedTerm definedMaterialOrMethod, String methodText, DefinedTerm medium, Double temperature){
93
    	super(definedMaterialOrMethod, methodText);
94
    	this.medium = medium;
95
    	this.temperature = temperature;
96
    }
97

    
98
	// ********************* GETTER / SETTER ********************/
99

    
100
	public DefinedTerm getMedium() {
101
		return medium;
102
	}
103
	public void setMedium(DefinedTerm medium) {
104
		this.medium = medium;
105
	}
106

    
107
	public Double getTemperature() {
108
		return temperature;
109
	}
110
	public void setTemperature(Double temperature) {
111
		this.temperature = temperature;
112
	}
113

    
114
// ************************** CLONE ********************/
115

    
116
	/**
117
	 * Clones <i>this</i> {@link Cloning}. This is a shortcut that enables to create
118
	 * a new instance that differs only slightly from <i>this</i> cloning by
119
	 * modifying only some of the attributes.<BR><BR>
120
	 *
121
	 * @see EventBase#clone()
122
	 * @see java.lang.Object#clone()
123
	 */
124
	@Override
125
	public PreservationMethod clone()  {
126
		PreservationMethod result = (PreservationMethod)super.clone();
127

    
128
		//don't change medium, temperature
129
		return result;
130
	}
131
}
(10-10/14)