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