1
|
package eu.etaxonomy.cdm.model.view;
|
2
|
|
3
|
import java.io.Serializable;
|
4
|
import java.util.UUID;
|
5
|
|
6
|
import javax.persistence.Basic;
|
7
|
import javax.persistence.Entity;
|
8
|
import javax.persistence.FetchType;
|
9
|
import javax.persistence.GeneratedValue;
|
10
|
import javax.persistence.Id;
|
11
|
|
12
|
import org.hibernate.annotations.Type;
|
13
|
import org.hibernate.envers.RevisionEntity;
|
14
|
import org.hibernate.envers.RevisionNumber;
|
15
|
import org.hibernate.envers.RevisionTimestamp;
|
16
|
import org.joda.time.DateTime;
|
17
|
|
18
|
@Entity
|
19
|
@RevisionEntity
|
20
|
public class AuditEvent implements Serializable {
|
21
|
/**
|
22
|
*
|
23
|
*/
|
24
|
private static final long serialVersionUID = 6584537382484488953L;
|
25
|
|
26
|
public static final AuditEvent CURRENT_VIEW;
|
27
|
|
28
|
static {
|
29
|
CURRENT_VIEW = new AuditEvent();
|
30
|
CURRENT_VIEW.setUuid(UUID.fromString("966728f0-ae51-11dd-ad8b-0800200c9a66"));
|
31
|
};
|
32
|
|
33
|
@Type(type="uuidUserType")
|
34
|
private UUID uuid;
|
35
|
|
36
|
public UUID getUuid() {
|
37
|
return uuid;
|
38
|
}
|
39
|
|
40
|
public Long getTimestamp() {
|
41
|
return timestamp;
|
42
|
}
|
43
|
|
44
|
public AuditEvent() {
|
45
|
this.uuid = UUID.randomUUID();
|
46
|
this.date = new DateTime();
|
47
|
}
|
48
|
|
49
|
@Type(type="dateTimeUserType")
|
50
|
@Basic(fetch = FetchType.LAZY)
|
51
|
private DateTime date;
|
52
|
|
53
|
public DateTime getDate() {
|
54
|
return date;
|
55
|
}
|
56
|
|
57
|
@Id
|
58
|
@GeneratedValue
|
59
|
@RevisionNumber
|
60
|
private Integer revisionNumber;
|
61
|
|
62
|
@RevisionTimestamp
|
63
|
private Long timestamp;
|
64
|
|
65
|
public Integer getRevisionNumber() {
|
66
|
return revisionNumber;
|
67
|
}
|
68
|
|
69
|
public void setUuid(UUID uuid) {
|
70
|
this.uuid = uuid;
|
71
|
}
|
72
|
|
73
|
public boolean equals(Object obj) {
|
74
|
if(this == obj)
|
75
|
return true;
|
76
|
|
77
|
if((obj == null) || (obj.getClass() != this.getClass()))
|
78
|
return false;
|
79
|
|
80
|
AuditEvent auditEvent = (AuditEvent) obj;
|
81
|
return uuid == auditEvent.uuid || (uuid != null && uuid.equals(auditEvent.uuid));
|
82
|
}
|
83
|
|
84
|
public int hashCode() {
|
85
|
int hash = 7;
|
86
|
hash = 31 * hash + (null == uuid ? 0 : uuid.hashCode());
|
87
|
return hash;
|
88
|
}
|
89
|
|
90
|
public void setRevisionNumber(Integer revisionNumber) {
|
91
|
this.revisionNumber = revisionNumber;
|
92
|
}
|
93
|
}
|