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