Use an exponential backoff strategy for retrying rolled back transactions.
[pithos] / src / gr / ebs / gss / server / domain / AuditInfo.java
1 /*\r
2  * Copyright 2007, 2008, 2009 Electronic Business Systems Ltd.\r
3  *\r
4  * This file is part of GSS.\r
5  *\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
10  *\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
15  *\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
18  */\r
19 package gr.ebs.gss.server.domain;\r
20 \r
21 import gr.ebs.gss.server.domain.dto.AuditInfoDTO;\r
22 \r
23 import java.io.Serializable;\r
24 import java.util.Date;\r
25 \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
32 \r
33 /**\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
37  */\r
38 @Embeddable\r
39 public class AuditInfo  implements Serializable{\r
40 \r
41         /**\r
42          * The date the associated object was created. We can never change it after\r
43          * creation.\r
44          */\r
45         @Temporal(TemporalType.TIMESTAMP)\r
46         @Column(updatable = false, nullable = false)\r
47         private Date creationDate;\r
48 \r
49         /**\r
50          * The user that created the associated object. We can never change it after\r
51          * creation.\r
52          */\r
53         @ManyToOne\r
54         @JoinColumn(updatable = false)\r
55         private User createdBy;\r
56 \r
57         /**\r
58          * The date the associated object was modified.\r
59          */\r
60         @Temporal(TemporalType.TIMESTAMP)\r
61         @Column(nullable = false)\r
62         private Date modificationDate;\r
63 \r
64         /**\r
65          * The user that modified the associated object.\r
66          */\r
67         @ManyToOne\r
68         private User modifiedBy;\r
69 \r
70         /**\r
71          * Retrieve the creation date for the associated object.\r
72          *\r
73          * @return the date of creation\r
74          */\r
75         public Date getCreationDate() {\r
76                 return creationDate;\r
77         }\r
78 \r
79         /**\r
80          * Modify the creation date for the associated object.\r
81          *\r
82          * @param _creationDate the new date of creation\r
83          */\r
84         public void setCreationDate(final Date _creationDate) {\r
85                 creationDate = _creationDate;\r
86         }\r
87 \r
88         /**\r
89          * Retrieve the user that created the associated object.\r
90          *\r
91          * @return the user that created the associated object\r
92          */\r
93         public User getCreatedBy() {\r
94                 return createdBy;\r
95         }\r
96 \r
97         /**\r
98          * Modify the user that created the associated object.\r
99          *\r
100          * @param _createdBy the new user that created the associated object\r
101          */\r
102         public void setCreatedBy(final User _createdBy) {\r
103                 createdBy = _createdBy;\r
104         }\r
105 \r
106         /**\r
107          * Retrieve the modification date for the associated object.\r
108          *\r
109          * @return the date of modification\r
110          */\r
111         public Date getModificationDate() {\r
112                 return modificationDate;\r
113         }\r
114 \r
115         /**\r
116          * Modify the modification date for the associated object.\r
117          *\r
118          * @param _modificationDate the new date of modification\r
119          */\r
120         public void setModificationDate(final Date _modificationDate) {\r
121                 modificationDate = _modificationDate;\r
122         }\r
123 \r
124         /**\r
125          * Retrieve the user that modified the associated object.\r
126          *\r
127          * @return the user that modified the associated object\r
128          */\r
129         public User getModifiedBy() {\r
130                 return modifiedBy;\r
131         }\r
132 \r
133         /**\r
134          * Modify the user that modified the associated object.\r
135          *\r
136          * @param _modifiedBy the new user that modified the associated object\r
137          */\r
138         public void setModifiedBy(final User _modifiedBy) {\r
139                 modifiedBy = _modifiedBy;\r
140         }\r
141 \r
142         /**\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
146          *\r
147          * @return a DTO object with audit info\r
148          */\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
155                 return dto;\r
156         }\r
157 }\r