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
34 * This class holds audit information pertaining to the associated domain
\r
35 * object. This information includes the user that created the object, the
\r
36 * creation time, the user that modified the object and the modification date.
\r
39 public class AuditInfo implements Serializable{
\r
42 * The date the associated object was created. We can never change it after
\r
45 @Temporal(TemporalType.TIMESTAMP)
\r
46 @Column(updatable = false, nullable = false)
\r
47 private Date creationDate;
\r
50 * The user that created the associated object. We can never change it after
\r
54 @JoinColumn(updatable = false)
\r
55 private User createdBy;
\r
58 * The date the associated object was modified.
\r
60 @Temporal(TemporalType.TIMESTAMP)
\r
61 @Column(nullable = false)
\r
62 private Date modificationDate;
\r
65 * The user that modified the associated object.
\r
68 private User modifiedBy;
\r
71 * Retrieve the creation date for the associated object.
\r
73 * @return the date of creation
\r
75 public Date getCreationDate() {
\r
76 return creationDate;
\r
80 * Modify the creation date for the associated object.
\r
82 * @param _creationDate the new date of creation
\r
84 public void setCreationDate(final Date _creationDate) {
\r
85 creationDate = _creationDate;
\r
89 * Retrieve the user that created the associated object.
\r
91 * @return the user that created the associated object
\r
93 public User getCreatedBy() {
\r
98 * Modify the user that created the associated object.
\r
100 * @param _createdBy the new user that created the associated object
\r
102 public void setCreatedBy(final User _createdBy) {
\r
103 createdBy = _createdBy;
\r
107 * Retrieve the modification date for the associated object.
\r
109 * @return the date of modification
\r
111 public Date getModificationDate() {
\r
112 return modificationDate;
\r
116 * Modify the modification date for the associated object.
\r
118 * @param _modificationDate the new date of modification
\r
120 public void setModificationDate(final Date _modificationDate) {
\r
121 modificationDate = _modificationDate;
\r
125 * Retrieve the user that modified the associated object.
\r
127 * @return the user that modified the associated object
\r
129 public User getModifiedBy() {
\r
134 * Modify the user that modified the associated object.
\r
136 * @param _modifiedBy the new user that modified the associated object
\r
138 public void setModifiedBy(final User _modifiedBy) {
\r
139 modifiedBy = _modifiedBy;
\r
143 * Retrieve the Data Transfer Object for this audit info, that pays
\r
144 * particular attention to avoid any instances of java.sql.Timestamp in the
\r
145 * creation and modification dates.
\r
147 * @return a DTO object with audit info
\r
149 public AuditInfoDTO getDTO() {
\r
150 final AuditInfoDTO dto = new AuditInfoDTO();
\r
151 dto.setCreatedBy(createdBy.getDTO());
\r
152 dto.setCreationDate(new Date(creationDate.getTime()));
\r
153 dto.setModificationDate(new Date(modificationDate.getTime()));
\r
154 dto.setModifiedBy(modifiedBy.getDTO());
\r