2 * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.
\r
4 * This file is part of GSS.
\r
6 * GSS is free software: you can redistribute it and/or modify
\r
7 * it under the terms of the GNU General Public License as published by
\r
8 * the Free Software Foundation, either version 3 of the License, or
\r
9 * (at your option) any later version.
\r
11 * GSS is distributed in the hope that it will be useful,
\r
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
\r
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
\r
14 * GNU General Public License for more details.
\r
16 * You should have received a copy of the GNU General Public License
\r
17 * along with GSS. If not, see <http://www.gnu.org/licenses/>.
\r
19 package gr.ebs.gss.server.domain;
\r
21 import gr.ebs.gss.server.domain.dto.AuditInfoDTO;
\r
23 import java.io.Serializable;
\r
24 import java.util.Date;
\r
26 import javax.persistence.Column;
\r
27 import javax.persistence.Embeddable;
\r
28 import javax.persistence.JoinColumn;
\r
29 import javax.persistence.ManyToOne;
\r
30 import javax.persistence.Temporal;
\r
31 import javax.persistence.TemporalType;
\r
33 import org.hibernate.annotations.Cache;
\r
34 import org.hibernate.annotations.CacheConcurrencyStrategy;
\r
37 * This class holds audit information pertaining to the associated domain
\r
38 * object. This information includes the user that created the object, the
\r
39 * creation time, the user that modified the object and the modification date.
\r
42 @Cache(usage=CacheConcurrencyStrategy.READ_WRITE)
\r
43 public class AuditInfo implements Serializable{
\r
46 * The date the associated object was created. We can never change it after
\r
49 @Temporal(TemporalType.TIMESTAMP)
\r
50 @Column(updatable = false, nullable = false)
\r
51 private Date creationDate;
\r
54 * The user that created the associated object. We can never change it after
\r
58 @JoinColumn(updatable = false)
\r
59 private User createdBy;
\r
62 * The date the associated object was modified.
\r
64 @Temporal(TemporalType.TIMESTAMP)
\r
65 @Column(nullable = false)
\r
66 private Date modificationDate;
\r
69 * The user that modified the associated object.
\r
72 private User modifiedBy;
\r
75 * Retrieve the creation date for the associated object.
\r
77 * @return the date of creation
\r
79 public Date getCreationDate() {
\r
80 return creationDate;
\r
84 * Modify the creation date for the associated object.
\r
86 * @param _creationDate the new date of creation
\r
88 public void setCreationDate(final Date _creationDate) {
\r
89 creationDate = _creationDate;
\r
93 * Retrieve the user that created the associated object.
\r
95 * @return the user that created the associated object
\r
97 public User getCreatedBy() {
\r
102 * Modify the user that created the associated object.
\r
104 * @param _createdBy the new user that created the associated object
\r
106 public void setCreatedBy(final User _createdBy) {
\r
107 createdBy = _createdBy;
\r
111 * Retrieve the modification date for the associated object.
\r
113 * @return the date of modification
\r
115 public Date getModificationDate() {
\r
116 return modificationDate;
\r
120 * Modify the modification date for the associated object.
\r
122 * @param _modificationDate the new date of modification
\r
124 public void setModificationDate(final Date _modificationDate) {
\r
125 modificationDate = _modificationDate;
\r
129 * Retrieve the user that modified the associated object.
\r
131 * @return the user that modified the associated object
\r
133 public User getModifiedBy() {
\r
138 * Modify the user that modified the associated object.
\r
140 * @param _modifiedBy the new user that modified the associated object
\r
142 public void setModifiedBy(final User _modifiedBy) {
\r
143 modifiedBy = _modifiedBy;
\r
147 * Retrieve the Data Transfer Object for this audit info, that pays
\r
148 * particular attention to avoid any instances of java.sql.Timestamp in the
\r
149 * creation and modification dates.
\r
151 * @return a DTO object with audit info
\r
153 public AuditInfoDTO getDTO() {
\r
154 final AuditInfoDTO dto = new AuditInfoDTO();
\r
155 dto.setCreatedBy(createdBy.getDTO());
\r
156 dto.setCreationDate(new Date(creationDate.getTime()));
\r
157 dto.setModificationDate(new Date(modificationDate.getTime()));
\r
158 dto.setModifiedBy(modifiedBy.getDTO());
\r