1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.kns.document.authorization; |
17 | |
|
18 | |
import java.sql.Timestamp; |
19 | |
import java.util.LinkedHashMap; |
20 | |
|
21 | |
import javax.persistence.Column; |
22 | |
import javax.persistence.Entity; |
23 | |
import javax.persistence.Id; |
24 | |
import javax.persistence.Table; |
25 | |
import javax.persistence.Transient; |
26 | |
|
27 | |
import org.kuali.rice.kim.bo.Person; |
28 | |
import org.kuali.rice.kim.bo.impl.PersonImpl; |
29 | |
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
30 | |
import org.kuali.rice.kns.service.KNSServiceLocator; |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
@Entity |
43 | |
@Table(name="KRNS_PESSIMISTIC_LOCK_T") |
44 | |
public class PessimisticLock extends PersistableBusinessObjectBase { |
45 | |
|
46 | |
private static final long serialVersionUID = -5210762282545093555L; |
47 | |
|
48 | 0 | public static final String DEFAULT_LOCK_DESCRIPTOR = null; |
49 | |
|
50 | |
|
51 | |
@Id |
52 | |
@Column(name="PESSIMISTIC_LOCK_ID") |
53 | |
private Long id; |
54 | |
|
55 | |
@Column(name="PRNCPL_ID") |
56 | |
private String ownedByPrincipalIdentifier; |
57 | |
|
58 | |
@Column(name="LOCK_DESC_TXT") |
59 | |
private String lockDescriptor; |
60 | |
|
61 | |
@Column(name="GNRT_DT") |
62 | |
private Timestamp generatedTimestamp; |
63 | |
|
64 | |
@Column(name="DOC_HDR_ID") |
65 | |
private String documentNumber; |
66 | |
|
67 | |
@Transient |
68 | |
private Person ownedByUser; |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
@Deprecated |
77 | 0 | public PessimisticLock() {} |
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | 0 | public PessimisticLock(String documentNumber, String lockDescriptor, Person user) { |
83 | 0 | this.documentNumber = documentNumber; |
84 | 0 | this.ownedByPrincipalIdentifier = user.getPrincipalId(); |
85 | 0 | this.lockDescriptor = lockDescriptor; |
86 | 0 | this.generatedTimestamp = KNSServiceLocator.getDateTimeService().getCurrentTimestamp(); |
87 | 0 | } |
88 | |
|
89 | |
public boolean isOwnedByUser(Person user) { |
90 | 0 | return user.getPrincipalId().equals(getOwnedByPrincipalIdentifier()); |
91 | |
} |
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
public Long getId() { |
97 | 0 | return this.id; |
98 | |
} |
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
public void setId(Long id) { |
104 | 0 | this.id = id; |
105 | 0 | } |
106 | |
|
107 | |
|
108 | |
|
109 | |
|
110 | |
public String getOwnedByPrincipalIdentifier() { |
111 | 0 | return this.ownedByPrincipalIdentifier; |
112 | |
} |
113 | |
|
114 | |
|
115 | |
|
116 | |
|
117 | |
public void setOwnedByPrincipalIdentifier(String ownedByPrincipalIdentifier) { |
118 | 0 | this.ownedByPrincipalIdentifier = ownedByPrincipalIdentifier; |
119 | 0 | } |
120 | |
|
121 | |
|
122 | |
|
123 | |
|
124 | |
public String getLockDescriptor() { |
125 | 0 | return this.lockDescriptor; |
126 | |
} |
127 | |
|
128 | |
|
129 | |
|
130 | |
|
131 | |
public void setLockDescriptor(String lockDescriptor) { |
132 | 0 | this.lockDescriptor = lockDescriptor; |
133 | 0 | } |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public Timestamp getGeneratedTimestamp() { |
139 | 0 | return this.generatedTimestamp; |
140 | |
} |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public void setGeneratedTimestamp(Timestamp generatedTimestamp) { |
146 | 0 | this.generatedTimestamp = generatedTimestamp; |
147 | 0 | } |
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
public String getDocumentNumber() { |
153 | 0 | return this.documentNumber; |
154 | |
} |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
public void setDocumentNumber(String documentNumber) { |
160 | 0 | this.documentNumber = documentNumber; |
161 | 0 | } |
162 | |
|
163 | |
|
164 | |
|
165 | |
|
166 | |
public Person getOwnedByUser() { |
167 | 0 | ownedByUser = org.kuali.rice.kim.service.KIMServiceLocator.getPersonService().updatePersonIfNecessary(ownedByPrincipalIdentifier, ownedByUser); |
168 | 0 | return ownedByUser; |
169 | |
} |
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
public void setOwnedByUser(Person ownedByUser) { |
175 | 0 | this.ownedByUser = ownedByUser; |
176 | 0 | } |
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
|
184 | |
@Override |
185 | |
protected LinkedHashMap toStringMapper() { |
186 | 0 | LinkedHashMap m = new LinkedHashMap(); |
187 | 0 | m.put("id", this.id); |
188 | 0 | m.put("ownedByPrincipalIdentifier", this.ownedByPrincipalIdentifier); |
189 | 0 | m.put("lockDescriptor", this.lockDescriptor); |
190 | 0 | m.put("generatedTimestamp", this.generatedTimestamp); |
191 | 0 | m.put("documentNumber", this.documentNumber); |
192 | 0 | return m; |
193 | |
} |
194 | |
} |
195 | |
|