Project

General

Profile

Download (3.6 KB) Statistics
| Branch: | Tag: | Revision:
1
/**
2
* Copyright (C) 2009 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.common;
11

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

    
23
import org.apache.log4j.Logger;
24
import org.hibernate.annotations.Cascade;
25
import org.hibernate.annotations.CascadeType;
26
import org.hibernate.search.annotations.Field;
27
import org.hibernate.search.annotations.Index;
28
import org.hibernate.search.annotations.IndexedEmbedded;
29

    
30
import eu.etaxonomy.cdm.model.agent.AgentBase;
31

    
32
@XmlAccessorType(XmlAccessType.FIELD)
33
@XmlType(name = "EventBase", propOrder = {
34
    "timeperiod",
35
    "actor",
36
    "description"
37
})
38
@XmlRootElement(name = "EventBase")
39
@MappedSuperclass
40
public abstract class EventBase extends AnnotatableEntity implements IEvent {
41
	private static final long serialVersionUID = -1859035632758446593L;
42
	@SuppressWarnings("unused")
43
	private static final Logger logger = Logger.getLogger(EventBase.class);
44

    
45
	@XmlElement(name = "TimePeriod")
46
	private TimePeriod timeperiod = TimePeriod.NewInstance();
47
	
48
	@XmlElement(name = "Actor")
49
	@XmlIDREF
50
	@XmlSchemaType(name = "IDREF")
51
	@ManyToOne(fetch = FetchType.LAZY)
52
	@IndexedEmbedded
53
	@Cascade(CascadeType.SAVE_UPDATE)
54
	private AgentBase actor;
55
	
56
	@XmlElement(name = "Description")
57
	@Field(index=Index.TOKENIZED)
58
	private String description;
59
	
60
	
61
	/* (non-Javadoc)
62
	 * @see eu.etaxonomy.cdm.model.occurrence.IEvent#getTimeperiod()
63
	 */
64
	public TimePeriod getTimeperiod() {
65
		return timeperiod;
66
	}
67
	/* (non-Javadoc)
68
	 * @see eu.etaxonomy.cdm.model.occurrence.IEvent#setTimeperiod(eu.etaxonomy.cdm.model.common.TimePeriod)
69
	 */
70
	public void setTimeperiod(TimePeriod timeperiod) {
71
		this.timeperiod = timeperiod;
72
	}
73

    
74
	/* (non-Javadoc)
75
	 * @see eu.etaxonomy.cdm.model.occurrence.IEvent#getActor()
76
	 */
77
	public AgentBase getActor() {
78
		return actor;
79
	}
80
	/* (non-Javadoc)
81
	 * @see eu.etaxonomy.cdm.model.occurrence.IEvent#setActor(eu.etaxonomy.cdm.model.agent.Agent)
82
	 */
83
	public void setActor(AgentBase actor) {
84
		this.actor = actor;
85
	}
86
	
87
	/* (non-Javadoc)
88
	 * @see eu.etaxonomy.cdm.model.occurrence.IEvent#getDescription()
89
	 */
90
	public String getDescription() {
91
		return description;
92
	}
93
	/* (non-Javadoc)
94
	 * @see eu.etaxonomy.cdm.model.occurrence.IEvent#setDescription(java.lang.String)
95
	 */
96
	public void setDescription(String description) {
97
		this.description = description;
98
	}
99
	
100
	
101
//*********** CLONE **********************************/	
102
	
103
	/** 
104
	 * Clones <i>this</i> event base. This is a shortcut that enables to
105
	 * create a new instance that differs only slightly from <i>this</i> event base
106
	 * by modifying only some of the attributes.<BR>
107
	 * This method overrides the clone method from {@link AnnotatableEntity AnnotatableEntity}.
108
	 * 
109
	 * @see eu.etaxonomy.cdm.model.media.AnnotatableEntity#clone()
110
	 * @see java.lang.Object#clone()
111
	 */
112
	@Override
113
	public Object clone() throws CloneNotSupportedException{
114
		EventBase result = (EventBase)super.clone();
115
		//Actor
116
		result.setActor(this.getActor());
117
		//time period
118
		result.setTimeperiod((TimePeriod)this.getTimeperiod().clone());
119
		//no changes to: description
120
		return result;
121
	}
122
	
123

    
124
	
125
}
(11-11/63)