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
|
package eu.etaxonomy.cdm.model.common;
|
10
|
|
11
|
import javax.persistence.FetchType;
|
12
|
import javax.persistence.ManyToOne;
|
13
|
import javax.persistence.MappedSuperclass;
|
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.logging.log4j.LogManager;import org.apache.logging.log4j.Logger;
|
23
|
import org.hibernate.annotations.Cascade;
|
24
|
import org.hibernate.annotations.CascadeType;
|
25
|
import org.hibernate.envers.Audited;
|
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
|
@Audited
|
41
|
public abstract class EventBase extends AnnotatableEntity implements IEvent {
|
42
|
private static final long serialVersionUID = -1859035632758446593L;
|
43
|
@SuppressWarnings("unused")
|
44
|
private static final Logger logger = LogManager.getLogger(EventBase.class);
|
45
|
|
46
|
@XmlElement(name = "TimePeriod")
|
47
|
private TimePeriod timeperiod = TimePeriod.NewInstance();
|
48
|
|
49
|
@XmlElement(name = "Actor")
|
50
|
@XmlIDREF
|
51
|
@XmlSchemaType(name = "IDREF")
|
52
|
@ManyToOne(fetch = FetchType.LAZY)
|
53
|
@IndexedEmbedded
|
54
|
@Cascade({CascadeType.SAVE_UPDATE,CascadeType.MERGE})
|
55
|
private AgentBase<?> actor;
|
56
|
|
57
|
@XmlElement(name = "Description")
|
58
|
@Field(index=Index.YES)
|
59
|
private String description;
|
60
|
|
61
|
//******************** GETTER / SETTER *******************/
|
62
|
|
63
|
@Override
|
64
|
public TimePeriod getTimeperiod() {
|
65
|
return timeperiod;
|
66
|
}
|
67
|
@Override
|
68
|
public void setTimeperiod(TimePeriod timeperiod) {
|
69
|
if (timeperiod == null){
|
70
|
timeperiod = TimePeriod.NewInstance();
|
71
|
}
|
72
|
this.timeperiod = timeperiod;
|
73
|
}
|
74
|
|
75
|
@Override
|
76
|
public AgentBase getActor() {
|
77
|
return actor;
|
78
|
}
|
79
|
@Override
|
80
|
public void setActor(AgentBase actor) {
|
81
|
this.actor = actor;
|
82
|
}
|
83
|
|
84
|
/**
|
85
|
* The description of this event. Implementing classes may use this field for different purposes.
|
86
|
* @return
|
87
|
*/
|
88
|
public String getDescription() {
|
89
|
return description;
|
90
|
}
|
91
|
|
92
|
/**
|
93
|
* @see #getDescription()
|
94
|
* @param description
|
95
|
*/
|
96
|
public void setDescription(String description) {
|
97
|
this.description = description;
|
98
|
}
|
99
|
|
100
|
//*********** CLONE **********************************/
|
101
|
|
102
|
/**
|
103
|
* Clones <i>this</i> event base. This is a shortcut that enables to
|
104
|
* create a new instance that differs only slightly from <i>this</i> event base
|
105
|
* by modifying only some of the attributes.<BR>
|
106
|
* This method overrides the clone method from {@link AnnotatableEntity AnnotatableEntity}.
|
107
|
*
|
108
|
* @see java.lang.Object#clone()
|
109
|
*/
|
110
|
@Override
|
111
|
public EventBase clone() throws CloneNotSupportedException{
|
112
|
|
113
|
EventBase result = (EventBase)super.clone();
|
114
|
//Actor //is this needed??
|
115
|
result.setActor(this.getActor());
|
116
|
//time period
|
117
|
if(this.getTimeperiod()!=null){
|
118
|
result.setTimeperiod(this.getTimeperiod().clone());
|
119
|
}
|
120
|
//no changes to: description
|
121
|
return result;
|
122
|
}
|
123
|
}
|