1 package org.kuali.student.core.bo;
2
3 import java.util.Date;
4
5 import javax.persistence.Column;
6 import javax.persistence.Temporal;
7 import javax.persistence.TemporalType;
8
9 import org.apache.ojb.broker.PersistenceBroker;
10 import org.apache.ojb.broker.PersistenceBrokerException;
11 import org.kuali.student.common.util.UUIDHelper;
12
13 public abstract class KsVersionBusinessObjectBase extends KsMetaBusinessObjectBase implements KsVersionBusinessObject {
14
15 private static final long serialVersionUID = -1307889585226114528L;
16
17 @Column(name = "VER_IND_ID")
18 private String versionIndId;
19
20 @Column(name = "SEQ_NUM")
21 private Long sequenceNumber;
22
23 @Temporal(TemporalType.TIMESTAMP)
24 @Column(name = "CURR_VER_START")
25 private Date currentVersionStart;
26
27 @Temporal(TemporalType.TIMESTAMP)
28 @Column(name = "CURR_VER_END")
29 private Date currentVersionEnd;
30
31 @Column(name = "VER_FROM_ID")
32 private String versionedFromId;
33
34 @Column(name = "VER_CMT")
35 private String versionComment;
36
37
38 @Override
39 public void beforeInsert(PersistenceBroker persistenceBroker) throws PersistenceBrokerException {
40 super.beforeInsert(persistenceBroker);
41
42 if(this.getSequenceNumber() == null){
43 this.setSequenceNumber(Long.valueOf(1));
44 }
45
46 this.setVersionIndId(UUIDHelper.genStringUUID(this.getVersionIndId()));
47 }
48
49
50
51
52
53
54 @Override
55 public Version getVersion() {
56 Version version = new Version();
57
58 version.setVersionIndId(versionIndId);
59 version.setSequenceNumber(sequenceNumber);
60 version.setVersionedFromId(versionedFromId);
61 version.setVersionComment(versionComment);
62 version.setCurrentVersionStart(currentVersionStart);
63 version.setCurrentVersionEnd(currentVersionEnd);
64
65 return version;
66 }
67
68
69
70
71
72
73
74
75 @Override
76 public void setVersion(Version version) {
77 this.setVersionIndId(version.getVersionIndId());
78 this.setSequenceNumber(version.getSequenceNumber());
79 this.setVersionedFromId(version.getVersionedFromId());
80 this.setVersionComment(version.getVersionComment());
81 this.setCurrentVersionStart(version.getCurrentVersionStart());
82 this.setCurrentVersionEnd(version.getCurrentVersionEnd());
83 }
84
85 @Override
86 public String getVersionIndId() {
87 return versionIndId;
88 }
89
90 @Override
91 public void setVersionIndId(String versionIndId) {
92 this.versionIndId = versionIndId;
93 }
94
95 @Override
96 public Long getSequenceNumber() {
97 return sequenceNumber;
98 }
99
100 @Override
101 public void setSequenceNumber(Long sequenceNumber) {
102 this.sequenceNumber = sequenceNumber;
103 }
104
105 @Override
106 public Date getCurrentVersionStart() {
107 return currentVersionStart;
108 }
109
110 @Override
111 public void setCurrentVersionStart(Date currentVersionStart) {
112 this.currentVersionStart = currentVersionStart;
113 }
114
115 @Override
116 public Date getCurrentVersionEnd() {
117 return currentVersionEnd;
118 }
119
120 @Override
121 public void setCurrentVersionEnd(Date currentVersionEnd) {
122 this.currentVersionEnd = currentVersionEnd;
123 }
124
125 @Override
126 public String getVersionedFromId() {
127 return versionedFromId;
128 }
129
130 @Override
131 public void setVersionedFromId(String versionedFromId) {
132 this.versionedFromId = versionedFromId;
133 }
134
135 @Override
136 public String getVersionComment() {
137 return versionComment;
138 }
139
140 @Override
141 public void setVersionComment(String versionComment) {
142 this.versionComment = versionComment;
143 }
144
145 }