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 org.apache.commons.lang.StringUtils; |
19 | |
import org.hibernate.annotations.Type; |
20 | |
import org.kuali.rice.core.util.AttributeSet; |
21 | |
import org.kuali.rice.kim.bo.role.KimPermission; |
22 | |
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase; |
23 | |
|
24 | |
import javax.persistence.*; |
25 | |
import java.util.Iterator; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
@SuppressWarnings("unchecked") |
32 | |
@Entity |
33 | |
@Table(name="KRIM_PERM_T") |
34 | |
public class GenericPermission extends PersistableBusinessObjectBase { |
35 | |
|
36 | |
|
37 | |
private static final long serialVersionUID = 1L; |
38 | |
|
39 | |
@Id |
40 | |
@Column(name="PERM_ID") |
41 | |
protected String permissionId; |
42 | |
@Column(name="NMSPC_CD") |
43 | |
protected String namespaceCode; |
44 | |
@Column(name="NM") |
45 | |
protected String name; |
46 | |
@Column(name="DESC_TXT", length=400) |
47 | |
protected String description; |
48 | |
@Type(type="yes_no") |
49 | |
@Column(name="ACTV_IND") |
50 | |
protected boolean active; |
51 | |
@Column(name="PERM_TMPL_ID") |
52 | |
protected String templateId; |
53 | |
@Transient |
54 | |
protected String detailValues; |
55 | |
@Transient |
56 | |
protected AttributeSet details; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | 0 | public GenericPermission() { |
63 | 0 | } |
64 | |
|
65 | 0 | public GenericPermission( KimPermission perm ) { |
66 | 0 | loadFromKimPermission( perm ); |
67 | 0 | } |
68 | |
public void loadFromKimPermission( KimPermission perm ) { |
69 | 0 | setPermissionId( perm.getPermissionId() ); |
70 | 0 | setNamespaceCode( perm.getNamespaceCode() ); |
71 | 0 | setName( perm.getName() ); |
72 | 0 | setTemplateId( perm.getTemplateId() ); |
73 | 0 | setDescription( perm.getDescription() ); |
74 | 0 | setActive( perm.isActive() ); |
75 | 0 | setDetails( perm.getDetails() ); |
76 | 0 | } |
77 | |
|
78 | |
public String getDetailValues() { |
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | 0 | return detailValues; |
92 | |
} |
93 | |
|
94 | |
public void setDetailValues( String detailValues ) { |
95 | 0 | this.detailValues = detailValues; |
96 | 0 | String detailValuesTemp = detailValues; |
97 | 0 | AttributeSet details = new AttributeSet(); |
98 | 0 | if ( detailValuesTemp != null ) { |
99 | |
|
100 | 0 | detailValuesTemp = detailValuesTemp.replace( "\r\n", "\n" ); |
101 | 0 | detailValuesTemp = detailValuesTemp.replace( '\r', '\n' ); |
102 | 0 | if ( StringUtils.isNotBlank( detailValuesTemp ) ) { |
103 | 0 | String[] values = detailValuesTemp.split( "\n" ); |
104 | 0 | for ( String attrib : values ) { |
105 | 0 | if ( attrib.indexOf( '=' ) != -1 ) { |
106 | 0 | String[] keyValueArray = attrib.split( "=", 2 ); |
107 | 0 | details.put( keyValueArray[0].trim(), keyValueArray[1].trim() ); |
108 | |
} |
109 | |
} |
110 | |
} |
111 | |
} |
112 | 0 | this.details = details; |
113 | 0 | } |
114 | |
|
115 | |
public void setDetailValues( AttributeSet detailsAttribs ) { |
116 | 0 | StringBuffer sb = new StringBuffer(); |
117 | 0 | if ( detailsAttribs != null ) { |
118 | 0 | Iterator<String> keyIter = detailsAttribs.keySet().iterator(); |
119 | 0 | while ( keyIter.hasNext() ) { |
120 | 0 | String key = keyIter.next(); |
121 | 0 | sb.append( key ).append( '=' ).append( detailsAttribs.get( key ) ); |
122 | 0 | if ( keyIter.hasNext() ) { |
123 | 0 | sb.append( '\n' ); |
124 | |
} |
125 | 0 | } |
126 | |
} |
127 | 0 | detailValues = sb.toString(); |
128 | 0 | } |
129 | |
|
130 | |
|
131 | |
|
132 | |
|
133 | |
public boolean isActive() { |
134 | 0 | return active; |
135 | |
} |
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
public void setActive(boolean active) { |
141 | 0 | this.active = active; |
142 | 0 | } |
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
public String getDescription() { |
148 | 0 | return description; |
149 | |
} |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
public String getPermissionId() { |
155 | 0 | return permissionId; |
156 | |
} |
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
public String getName() { |
162 | 0 | return name; |
163 | |
} |
164 | |
|
165 | |
public void setDescription(String permissionDescription) { |
166 | 0 | this.description = permissionDescription; |
167 | 0 | } |
168 | |
|
169 | |
public void setName(String permissionName) { |
170 | 0 | this.name = permissionName; |
171 | 0 | } |
172 | |
|
173 | |
public void setDetails( AttributeSet details ) { |
174 | 0 | this.details = details; |
175 | 0 | setDetailValues(details); |
176 | 0 | } |
177 | |
|
178 | |
public String getTemplateId() { |
179 | 0 | return this.templateId; |
180 | |
} |
181 | |
|
182 | |
public void setTemplateId(String templateId) { |
183 | 0 | this.templateId = templateId; |
184 | 0 | } |
185 | |
|
186 | |
public AttributeSet getDetails() { |
187 | 0 | return details; |
188 | |
} |
189 | |
|
190 | |
public String getNamespaceCode() { |
191 | 0 | return this.namespaceCode; |
192 | |
} |
193 | |
|
194 | |
public void setNamespaceCode(String namespaceCode) { |
195 | 0 | this.namespaceCode = namespaceCode; |
196 | 0 | } |
197 | |
|
198 | |
public void setPermissionId(String permissionId) { |
199 | 0 | this.permissionId = permissionId; |
200 | 0 | } |
201 | |
|
202 | |
|
203 | |
public void refresh() { |
204 | |
|
205 | 0 | } |
206 | |
|
207 | |
@Override |
208 | |
public void refreshNonUpdateableReferences() { |
209 | |
|
210 | 0 | } |
211 | |
@Override |
212 | |
public void refreshReferenceObject(String referenceObjectName) { |
213 | |
|
214 | 0 | } |
215 | |
|
216 | |
@Override |
217 | |
protected void prePersist() { |
218 | 0 | throw new UnsupportedOperationException( "This object should never be persisted."); |
219 | |
} |
220 | |
|
221 | |
@Override |
222 | |
protected void preUpdate() { |
223 | 0 | throw new UnsupportedOperationException( "This object should never be persisted."); |
224 | |
} |
225 | |
|
226 | |
@Override |
227 | |
protected void preRemove() { |
228 | 0 | throw new UnsupportedOperationException( "This object should never be persisted."); |
229 | |
} |
230 | |
|
231 | |
} |