1
2
3
4
5
6 package com.hack23.cia.model.application.impl.common;
7
8 import java.util.Date;
9
10 import javax.persistence.DiscriminatorColumn;
11 import javax.persistence.DiscriminatorType;
12 import javax.persistence.DiscriminatorValue;
13 import javax.persistence.Entity;
14 import javax.persistence.GeneratedValue;
15 import javax.persistence.GenerationType;
16 import javax.persistence.Id;
17 import javax.persistence.Inheritance;
18 import javax.persistence.InheritanceType;
19 import javax.persistence.ManyToOne;
20 import javax.persistence.Temporal;
21 import javax.persistence.TemporalType;
22 import javax.persistence.Transient;
23 import javax.persistence.Version;
24
25 import org.hibernate.annotations.Cache;
26 import org.hibernate.annotations.CacheConcurrencyStrategy;
27
28 import com.hack23.cia.model.core.impl.BaseEntity;
29
30 /***
31 * The Class AbstractActionEvent.
32 */
33 @Entity
34 @Inheritance(strategy = InheritanceType.SINGLE_TABLE)
35 @DiscriminatorColumn(name = "actioneventtype", discriminatorType = DiscriminatorType.STRING)
36 @DiscriminatorValue("AbstractActionEvent")
37 @Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
38 public abstract class AbstractActionEvent extends BaseEntity implements
39 ActionEvent {
40
41 /*** The Constant serialVersionUID. */
42 private static final long serialVersionUID = 1L;
43
44 /*** The created date. */
45 private Date createdDate;
46
47 /*** The execution time. */
48 private Long executionTime;
49
50 /*** The id. */
51 private Long id;
52
53 /*** The user session. */
54 private UserSession userSession;
55
56 /*** The version. */
57 private Long version=1L;
58
59 /***
60 * Instantiates a new abstract action event.
61 */
62 public AbstractActionEvent() {
63 }
64
65 /***
66 * Instantiates a new abstract action event.
67 *
68 * @param createdDate the created date
69 * @param userSession the user session
70 */
71 public AbstractActionEvent(final Date createdDate,
72 final UserSession userSession) {
73 this.createdDate = createdDate;
74 this.userSession = userSession;
75 }
76
77
78
79
80
81
82 @Override
83 @Transient
84 public void computeExutionTime() {
85 setExecutionTime(new Date().getTime() - getCreatedDate().getTime());
86 }
87
88
89
90
91
92
93 @Override
94 @Temporal(TemporalType.TIMESTAMP)
95 public Date getCreatedDate() {
96 return createdDate;
97 }
98
99
100
101
102
103
104 @Override
105 public Long getExecutionTime() {
106 return executionTime;
107 }
108
109
110
111
112
113
114 @Override
115 @Id
116 @GeneratedValue(strategy = GenerationType.AUTO)
117 public Long getId() {
118 return id;
119 }
120
121
122
123
124
125
126 @Override
127 @ManyToOne
128 public UserSession getUserSession() {
129 return userSession;
130 }
131
132
133
134
135 @Override
136 @Version
137 public Long getVersion() {
138 return version;
139 }
140
141 /***
142 * Sets the created date.
143 *
144 * @param createdDate the new created date
145 */
146 public void setCreatedDate(final Date createdDate) {
147 this.createdDate = createdDate;
148 }
149
150 /***
151 * Sets the execution time.
152 *
153 * @param executionTime the new execution time
154 */
155 public void setExecutionTime(final Long executionTime) {
156 this.executionTime = executionTime;
157 }
158
159 /***
160 * Sets the id.
161 *
162 * @param id the new id
163 */
164 public void setId(final Long id) {
165 this.id = id;
166 }
167
168 /***
169 * Sets the user session.
170 *
171 * @param userSession the new user session
172 */
173 public void setUserSession(final UserSession userSession) {
174 this.userSession = userSession;
175 }
176
177 /***
178 * Sets the version.
179 *
180 * @param version the new version
181 */
182 public void setVersion(final Long version) {
183 this.version = version;
184 }
185 }