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
.DefinedTerm
;
30 import eu
.etaxonomy
.cdm
.model
.common
.EventBase
;
31 import eu
.etaxonomy
.cdm
.model
.common
.TermType
;
32 import eu
.etaxonomy
.cdm
.model
.common
.TermVocabulary
;
33 import eu
.etaxonomy
.cdm
.model
.molecular
.Cloning
;
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
implements Cloneable
{
62 private static final long serialVersionUID
= -4799205199942053585L;
63 private static final Logger logger
= Logger
.getLogger(MaterialOrMethodEvent
.class);
65 @XmlElement(name
= "DefinedMaterialOrMethod")
67 @XmlSchemaType(name
= "IDREF")
68 @ManyToOne(fetch
=FetchType
.LAZY
)
69 @IndexedEmbedded // no depth for terms
70 private DefinedTerm definedMaterialOrMethod
;
72 //TODO citation / link
75 // ******************** FACTORY METHOD ******************/
77 public static MaterialOrMethodEvent
NewInstance(){
78 return new MaterialOrMethodEvent();
81 public static MaterialOrMethodEvent
NewInstance(DefinedTerm definedMaterialOrMethod
, String methodText
){
82 return new MaterialOrMethodEvent(definedMaterialOrMethod
, methodText
);
85 // ********************* CONSTRUCTOR ********************/
87 protected MaterialOrMethodEvent(){};
89 protected MaterialOrMethodEvent(DefinedTerm definedMaterialOrMethod
, String methodText
){
90 this.definedMaterialOrMethod
= definedMaterialOrMethod
;
91 this.setDescription(methodText
);
95 // ********************* GETTER / SETTER ********************/
99 * The {@link #getDescription()} method is inherited from {@link EventBase}.
100 * In this class it is used as freetext describing the material or method used
101 * or if a {@link #getDefinedMaterialOrMethod() defined method} is given as
102 * an additional information about how this defined method was used.
104 * @see #getMaterialMethodText()
107 public String
getDescription() {
108 return super.getDescription();
113 * @see #getDescription()
114 * @see #setMaterialMethodText(String)
117 public void setDescription(String materialMethodText
) {
118 super.setDescription(materialMethodText
);
124 * A freetext describing the material or method or if
125 * a {@link #getDefinedMaterialOrMethod() defined method} is given
126 * an additional information about how this method was used.
127 * In future this method could be removed to decrease the number
128 * of transient getters in the CDM.
131 public String
getMaterialMethodText() {
132 return this.getDescription();
137 * @see #getMaterialMethodText()
139 public void setMaterialMethodText(String materialMethodText
) {
140 this.setDescription(materialMethodText
);
145 * A defined material or method given as a defined term in a materialOrMethod
146 * {@link TermVocabulary term vocabulary}. If such a defined material or method is used
147 * the {@link #getDescription() description} should primarily focus on describing
148 * deviation from this method rather then repeating it.
150 * @see #getDescription()
151 * @see #getMaterialMethodText()
152 * @return the material or method term
154 public DefinedTerm
getDefinedMaterialOrMethod() {
155 return definedMaterialOrMethod
;
159 * @see #getDefinedMaterialOrMethod()
160 * @param materialMethodTerm
162 public void setDefinedMaterialOrMethod(DefinedTerm definedMaterialOrMethod
) {
163 this.definedMaterialOrMethod
= definedMaterialOrMethod
;
166 // ********************* CLONE ********************/
168 * Clones <i>this</i> {@link Cloning}. This is a shortcut that enables to create
169 * a new instance that differs only slightly from <i>this</i> cloning by
170 * modifying only some of the attributes.<BR><BR>
172 * @see EventBase#clone()
173 * @see java.lang.Object#clone()
176 public Object
clone() {
178 MaterialOrMethodEvent result
= (MaterialOrMethodEvent
)super.clone();
180 //don't change materialMethodTerm
182 }catch (CloneNotSupportedException e
) {
183 logger
.warn("Object does not implement cloneable");