1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.ole.sys.businessobject;
17
18 import java.sql.Timestamp;
19 import java.util.Date;
20
21 import org.apache.commons.lang.StringUtils;
22 import org.kuali.ole.sys.context.SpringContext;
23 import org.kuali.rice.kim.api.identity.Person;
24 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
25 import org.kuali.rice.krad.util.GlobalVariables;
26
27 public abstract class TimestampedBusinessObjectBase extends PersistableBusinessObjectBase implements TimestampedBusinessObject {
28 private static org.apache.log4j.Logger LOG = org.apache.log4j.Logger.getLogger(TimestampedBusinessObjectBase.class);
29
30 private Timestamp lastUpdate;
31 private String lastUpdateUserId;
32
33
34
35
36 public Timestamp getLastUpdate() {
37 return this.lastUpdate;
38 }
39
40
41
42
43 public Person getLastUpdateUser() {
44 Person user = null;
45 if (StringUtils.isNotBlank(lastUpdateUserId)) {
46 user = SpringContext.getBean(org.kuali.rice.kim.api.identity.PersonService.class).getPersonByPrincipalName(lastUpdateUserId);
47 }
48
49 return user;
50 }
51
52
53
54
55 public String getLastUpdateUserId() {
56 return this.lastUpdateUserId;
57 }
58
59
60
61
62 public void setLastUpdateUserId(String lastUpdateUserId) {
63 this.lastUpdateUserId = lastUpdateUserId;
64 }
65
66
67
68
69 public void setLastUpdate(Timestamp lastUpdate) {
70 this.lastUpdate = lastUpdate;
71 }
72
73 @Override protected void prePersist() {
74 super.prePersist();
75
76 lastUpdate = new Timestamp((new Date()).getTime());
77 lastUpdateUserId = GlobalVariables.getUserSession().getPerson().getPrincipalName();
78 }
79
80 @Override protected void preUpdate() {
81 super.preUpdate();
82
83 lastUpdate = new Timestamp((new Date()).getTime());
84 lastUpdateUserId = GlobalVariables.getUserSession().getPerson().getPrincipalName();
85 }
86 }