1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.bo.impl;
17
18 import java.util.Iterator;
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.PrePersist;
25 import javax.persistence.PreUpdate;
26 import javax.persistence.Table;
27
28 import org.apache.commons.lang.StringUtils;
29 import org.apache.ojb.broker.PersistenceBroker;
30 import org.apache.ojb.broker.PersistenceBrokerException;
31 import org.kuali.rice.kim.bo.role.KimPermission;
32 import org.kuali.rice.kim.bo.types.dto.AttributeSet;
33 import org.kuali.rice.kns.bo.PersistableBusinessObjectBase;
34
35
36
37
38 @Entity
39 @Table(name="KRIM_PERM_T")
40 public class GenericPermission extends PersistableBusinessObjectBase {
41
42
43 private static final long serialVersionUID = 1L;
44
45 @Id
46 @Column(name="PERM_ID")
47 protected String permissionId;
48 protected String namespaceCode;
49 protected String name;
50 protected String description;
51 protected boolean active;
52 protected String templateId;
53 protected String detailValues;
54 protected AttributeSet details;
55
56
57
58
59
60 public GenericPermission() {
61 }
62
63 public GenericPermission( KimPermission perm ) {
64 loadFromKimPermission( perm );
65 }
66 public void loadFromKimPermission( KimPermission perm ) {
67 setPermissionId( perm.getPermissionId() );
68 setNamespaceCode( perm.getNamespaceCode() );
69 setName( perm.getName() );
70 setTemplateId( perm.getTemplateId() );
71 setDescription( perm.getDescription() );
72 setActive( perm.isActive() );
73 setDetails( perm.getDetails() );
74 }
75
76 public String getDetailValues() {
77
78
79
80
81
82
83
84
85
86
87
88
89 return detailValues;
90 }
91
92 public void setDetailValues( String detailValues ) {
93 this.detailValues = detailValues;
94 String detailValuesTemp = detailValues;
95 AttributeSet details = new AttributeSet();
96 if ( detailValuesTemp != null ) {
97
98 detailValuesTemp = detailValuesTemp.replace( "\r\n", "\n" );
99 detailValuesTemp = detailValuesTemp.replace( '\r', '\n' );
100 if ( StringUtils.isNotBlank( detailValuesTemp ) ) {
101 String[] values = detailValuesTemp.split( "\n" );
102 for ( String attrib : values ) {
103 if ( attrib.indexOf( '=' ) != -1 ) {
104 String[] keyValueArray = attrib.split( "=", 2 );
105 details.put( keyValueArray[0].trim(), keyValueArray[1].trim() );
106 }
107 }
108 }
109 }
110 this.details = details;
111 }
112
113 public void setDetailValues( AttributeSet detailsAttribs ) {
114 StringBuffer sb = new StringBuffer();
115 if ( detailsAttribs != null ) {
116 Iterator<String> keyIter = detailsAttribs.keySet().iterator();
117 while ( keyIter.hasNext() ) {
118 String key = keyIter.next();
119 sb.append( key ).append( '=' ).append( detailsAttribs.get( key ) );
120 if ( keyIter.hasNext() ) {
121 sb.append( '\n' );
122 }
123 }
124 }
125 detailValues = sb.toString();
126 }
127
128
129
130
131 public boolean isActive() {
132 return active;
133 }
134
135
136
137
138 public void setActive(boolean active) {
139 this.active = active;
140 }
141
142
143
144
145 public String getDescription() {
146 return description;
147 }
148
149
150
151
152 public String getPermissionId() {
153 return permissionId;
154 }
155
156
157
158
159 public String getName() {
160 return name;
161 }
162
163 public void setDescription(String permissionDescription) {
164 this.description = permissionDescription;
165 }
166
167 public void setName(String permissionName) {
168 this.name = permissionName;
169 }
170
171
172
173
174 @SuppressWarnings("unchecked")
175 @Override
176 protected LinkedHashMap toStringMapper() {
177 LinkedHashMap m = new LinkedHashMap();
178 m.put( "permissionId", permissionId );
179 m.put( "name", name );
180 m.put( "details", getDetails() );
181 return m;
182 }
183
184 public void setDetails( AttributeSet details ) {
185 this.details = details;
186 setDetailValues(details);
187 }
188
189 public String getTemplateId() {
190 return this.templateId;
191 }
192
193 public void setTemplateId(String templateId) {
194 this.templateId = templateId;
195 }
196
197 public AttributeSet getDetails() {
198 return details;
199 }
200
201 public String getNamespaceCode() {
202 return this.namespaceCode;
203 }
204
205 public void setNamespaceCode(String namespaceCode) {
206 this.namespaceCode = namespaceCode;
207 }
208
209 public void setPermissionId(String permissionId) {
210 this.permissionId = permissionId;
211 }
212
213
214 public void refresh() {
215
216 }
217
218 @Override
219 public void refreshNonUpdateableReferences() {
220
221 }
222 @Override
223 public void refreshReferenceObject(String referenceObjectName) {
224
225 }
226
227
228
229
230
231
232 @Override
233 @PrePersist
234 public void beforeInsert() {
235 throw new UnsupportedOperationException( "This object should never be persisted.");
236 }
237
238
239
240
241
242
243 @Override
244 @PreUpdate
245 public void beforeUpdate() {
246 throw new UnsupportedOperationException( "This object should never be persisted.");
247 }
248
249
250
251
252
253
254 @Override
255 public void beforeInsert(PersistenceBroker persistenceBroker)
256 throws PersistenceBrokerException {
257 throw new UnsupportedOperationException( "This object should never be persisted.");
258 }
259
260
261
262
263
264
265 @Override
266 public void beforeUpdate(PersistenceBroker persistenceBroker) {
267 throw new UnsupportedOperationException( "This object should never be persisted.");
268 }
269
270
271
272
273
274
275 @Override
276 public void beforeDelete(PersistenceBroker persistenceBroker)
277 throws PersistenceBrokerException {
278 throw new UnsupportedOperationException( "This object should never be persisted.");
279 }
280
281 }