Project

General

Profile

Download (3.28 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

    
10
package eu.etaxonomy.cdm.model.occurrence;
11

    
12

    
13
import org.apache.log4j.Logger;
14
import org.hibernate.annotations.Cascade;
15
import org.hibernate.annotations.CascadeType;
16

    
17
import javax.persistence.*;
18
import javax.xml.bind.annotation.XmlAccessType;
19
import javax.xml.bind.annotation.XmlAccessorType;
20
import javax.xml.bind.annotation.XmlElement;
21
import javax.xml.bind.annotation.XmlIDREF;
22
import javax.xml.bind.annotation.XmlRootElement;
23
import javax.xml.bind.annotation.XmlSchemaType;
24
import javax.xml.bind.annotation.XmlType;
25

    
26
/**
27
 * In situ observation of a taxon in the field. If a specimen exists, 
28
 * in most cases a parallel field observation object should be instantiated and the specimen then is "derived" from the field unit
29
 * @author m.doering
30
 * @version 1.0
31
 * @created 08-Nov-2007 13:06:40
32
 */
33
@XmlAccessorType(XmlAccessType.FIELD)
34
@XmlType(name = "FieldObservation", propOrder = {
35
    "fieldNumber",
36
    "fieldNotes",
37
    "gatheringEvent"
38
})
39
@XmlRootElement(name = "FieldObservation")
40
@Entity
41
public class FieldObservation extends SpecimenOrObservationBase implements Cloneable{
42
	private static final Logger logger = Logger.getLogger(FieldObservation.class);
43

    
44
	@XmlElement(name = "FieldNumber")
45
	private String fieldNumber;
46
	
47
	@XmlElement(name = "FieldNotes")
48
	private String fieldNotes;
49
	
50
	@XmlElement(name = "GatheringEvent")
51
	@XmlIDREF
52
	@XmlSchemaType(name = "IDREF")
53
	private GatheringEvent gatheringEvent;
54

    
55
	/**
56
	 * Factory method
57
	 * @return
58
	 */
59
	public static FieldObservation NewInstance(){
60
		return new FieldObservation();
61
	}
62
	
63
	
64
	/**
65
	 * Constructor
66
	 */
67
	protected FieldObservation(){
68
		super();
69
	}
70
	
71
	@Override
72
	@ManyToOne
73
	@Cascade( { CascadeType.SAVE_UPDATE })
74
	public GatheringEvent getGatheringEvent() {
75
		return this.gatheringEvent;
76
	}
77
	public void setGatheringEvent(GatheringEvent gatheringEvent) {
78
		this.gatheringEvent = gatheringEvent;
79
	}	
80
	
81

    
82
	public String getFieldNumber() {
83
		return fieldNumber;
84
	}
85
	public void setFieldNumber(String fieldNumber) {
86
		this.fieldNumber = fieldNumber;
87
	}
88

    
89

    
90
	public String getFieldNotes() {
91
		return fieldNotes;
92
	}
93
	public void setFieldNotes(String fieldNotes) {
94
		this.fieldNotes = fieldNotes;
95
	}
96
	
97
	
98
	//*********** CLONE **********************************/	
99
	
100
	/** 
101
	 * Clones <i>this</i> field observation. This is a shortcut that enables to
102
	 * create a new instance that differs only slightly from <i>this</i> field observation
103
	 * by modifying only some of the attributes.<BR>
104
	 * This method overrides the clone method from {@link SpecimenOrObservationBase SpecimenOrObservationBase}.
105
	 * 
106
	 * @see SpecimenOrObservationBase#clone()
107
	 * @see eu.etaxonomy.cdm.model.media.IdentifiableMediaEntity#clone()
108
	 * @see java.lang.Object#clone()
109
	 */
110
	@Override
111
	public FieldObservation clone(){
112
		try{
113
			FieldObservation result = (FieldObservation)super.clone();
114
			result.setGatheringEvent(this.gatheringEvent);  //TODO ?
115
			//no changes to: fieldNotes, fieldNumber
116
			return result;
117
		} catch (CloneNotSupportedException e) {
118
			logger.warn("Object does not implement cloneable");
119
			e.printStackTrace();
120
			return null;
121
		}
122
		
123
	}
124

    
125

    
126
}
(8-8/16)