2 * Copyright (C) 2007 EDIT
3 * European Distributed Institute of Taxonomy
4 * http://www.e-taxonomy.eu
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.
9 package eu
.etaxonomy
.cdm
.model
.occurrence
;
11 import javax
.persistence
.Entity
;
12 import javax
.persistence
.FetchType
;
13 import javax
.persistence
.Inheritance
;
14 import javax
.persistence
.InheritanceType
;
15 import javax
.persistence
.ManyToOne
;
16 import javax
.persistence
.Transient
;
17 import javax
.xml
.bind
.annotation
.XmlAccessType
;
18 import javax
.xml
.bind
.annotation
.XmlAccessorType
;
19 import javax
.xml
.bind
.annotation
.XmlElement
;
20 import javax
.xml
.bind
.annotation
.XmlIDREF
;
21 import javax
.xml
.bind
.annotation
.XmlRootElement
;
22 import javax
.xml
.bind
.annotation
.XmlSchemaType
;
23 import javax
.xml
.bind
.annotation
.XmlType
;
25 import org
.apache
.log4j
.Logger
;
26 import org
.hibernate
.envers
.Audited
;
27 import org
.hibernate
.search
.annotations
.IndexedEmbedded
;
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 import eu
.etaxonomy
.cdm
.model
.term
.TermVocabulary
;
36 * A material or method event handles data on materials or methods used for handling specimen or derived units
37 * in general. It stores information on what material or method was used, who used it and when it was used.
38 * For reusable data on materials or methods it is best practice to define these first as {@link DefinedTerm
39 * defined terms} of type {@link TermType#MaterialOrMethod} TODO and then use this term as {@link #getDefinedMaterialOrMethod()
40 * material or method term}. If this is not possible or if additional data needs to be added one may also
41 * use {@link #getDescription() freetext} field inherited from {@link EventBase}. Actor and Date information
42 * are also handled via {@link EventBase} fields.
43 * This class may be extended by more specific classes which require structured handling of additional parameters.
45 * In general material or method data is not considered to be CDM core data. Therefore the decision was made to handle
46 * all the data with a common base class which is {@link MaterialOrMethodEvent} to reduce the number of tables required
47 * in the underlying databases.
53 @XmlAccessorType(XmlAccessType
.FIELD
)
54 @XmlType(name
= "MaterialOrMethod", propOrder
= {
55 "definedMaterialOrMethod"
57 @XmlRootElement(name
= "MaterialOrMethod")
59 @Inheritance(strategy
=InheritanceType
.SINGLE_TABLE
)
61 public class MaterialOrMethodEvent
extends EventBase
{
63 private static final long serialVersionUID
= -4799205199942053585L;
64 private static final Logger logger
= Logger
.getLogger(MaterialOrMethodEvent
.class);
66 @XmlElement(name
= "DefinedMaterialOrMethod")
68 @XmlSchemaType(name
= "IDREF")
69 @ManyToOne(fetch
=FetchType
.LAZY
)
70 @IndexedEmbedded // no depth for terms
71 private DefinedTerm definedMaterialOrMethod
;
73 //TODO citation / link
76 // ******************** FACTORY METHOD ******************/
78 public static MaterialOrMethodEvent
NewInstance(){
79 return new MaterialOrMethodEvent();
82 public static MaterialOrMethodEvent
NewInstance(DefinedTerm definedMaterialOrMethod
, String methodText
){
83 return new MaterialOrMethodEvent(definedMaterialOrMethod
, methodText
);
86 // ********************* CONSTRUCTOR ********************/
88 protected MaterialOrMethodEvent(){};
90 protected MaterialOrMethodEvent(DefinedTerm definedMaterialOrMethod
, String methodText
){
91 this.definedMaterialOrMethod
= definedMaterialOrMethod
;
92 this.setDescription(methodText
);
96 // ********************* GETTER / SETTER ********************/
100 * The {@link #getDescription()} method is inherited from {@link EventBase}.
101 * In this class it is used as freetext describing the material or method used
102 * or if a {@link #getDefinedMaterialOrMethod() defined method} is given as
103 * an additional information about how this defined method was used.
105 * @see #getMaterialMethodText()
108 public String
getDescription() {
109 return super.getDescription();
114 * @see #getDescription()
115 * @see #setMaterialMethodText(String)
118 public void setDescription(String materialMethodText
) {
119 super.setDescription(materialMethodText
);
125 * A freetext describing the material or method or if
126 * a {@link #getDefinedMaterialOrMethod() defined method} is given
127 * an additional information about how this method was used.
128 * In future this method could be removed to decrease the number
129 * of transient getters in the CDM.
132 public String
getMaterialMethodText() {
133 return this.getDescription();
138 * @see #getMaterialMethodText()
140 public void setMaterialMethodText(String materialMethodText
) {
141 this.setDescription(materialMethodText
);
146 * A defined material or method given as a defined term in a materialOrMethod
147 * {@link TermVocabulary term vocabulary}. If such a defined material or method is used
148 * the {@link #getDescription() description} should primarily focus on describing
149 * deviation from this method rather then repeating it.
151 * @see #getDescription()
152 * @see #getMaterialMethodText()
153 * @return the material or method term
155 public DefinedTerm
getDefinedMaterialOrMethod() {
156 return definedMaterialOrMethod
;
160 * @see #getDefinedMaterialOrMethod()
161 * @param materialMethodTerm
163 public void setDefinedMaterialOrMethod(DefinedTerm definedMaterialOrMethod
) {
164 this.definedMaterialOrMethod
= definedMaterialOrMethod
;
167 // ********************* CLONE ********************/
169 * Clones <i>this</i> {@link Cloning}. This is a shortcut that enables to create
170 * a new instance that differs only slightly from <i>this</i> cloning by
171 * modifying only some of the attributes.<BR><BR>
173 * @see EventBase#clone()
174 * @see java.lang.Object#clone()
177 public MaterialOrMethodEvent
clone() {
179 MaterialOrMethodEvent result
= (MaterialOrMethodEvent
)super.clone();
181 //don't change materialMethodTerm
183 }catch (CloneNotSupportedException e
) {
184 logger
.warn("Object does not implement cloneable");