1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.bo.ui;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.kuali.rice.kim.api.KimConstants;
20 import org.kuali.rice.kim.api.permission.Permission;
21 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
22
23 import javax.persistence.Column;
24 import javax.persistence.Entity;
25 import javax.persistence.GeneratedValue;
26 import javax.persistence.Id;
27 import javax.persistence.IdClass;
28 import javax.persistence.Table;
29 import javax.persistence.Transient;
30 import java.util.Iterator;
31
32
33
34
35 @IdClass(KimDocumentRolePermissionId.class)
36 @Entity
37 @Table(name="KRIM_PND_ROLE_PERM_T")
38 public class KimDocumentRolePermission extends KimDocumentBoActivatableBase {
39
40 private static final long serialVersionUID = 1L;
41 @Id
42 @GeneratedValue(generator="KRIM_ROLE_PERM_ID_S")
43 @Column(name="ROLE_PERM_ID")
44 protected String rolePermissionId;
45 @Column(name="ROLE_ID")
46 protected String roleId;
47 @Column(name="PERM_ID")
48 protected String permissionId;
49 @Transient
50 protected Permission permission;
51 @Transient
52 protected String name;
53 @Transient
54 protected String namespaceCode;
55
56
57 public String getPermissionId() {
58 return permissionId;
59 }
60
61 public String getRoleId() {
62 return roleId;
63 }
64
65 public String getRolePermissionId() {
66 return rolePermissionId;
67 }
68
69 public void setPermissionId(String permissionId) {
70 this.permissionId = permissionId;
71 }
72
73 public void setRoleId(String roleId) {
74 this.roleId = roleId;
75 }
76
77 public void setRolePermissionId(String rolePermissionId) {
78 this.rolePermissionId = rolePermissionId;
79 }
80
81
82
83
84 public Permission getPermission() {
85 if(null != permissionId){
86 if ( permission == null || !StringUtils.equals( permission.getId(), permissionId ) ) {
87 permission = KimApiServiceLocator.getPermissionService().getPermission(permissionId);
88 }
89 }
90 return permission;
91 }
92
93 public String getPermissionDetailValues() {
94 Permission perm = getPermission();
95 StringBuffer sb = new StringBuffer();
96 if ( perm.getAttributes() != null ) {
97 Iterator<String> keyIter = perm.getAttributes().keySet().iterator();
98 while ( keyIter.hasNext() ) {
99 String key = keyIter.next();
100 sb.append( key ).append( '=' ).append( perm.getAttributes().get(key) );
101 if (keyIter.hasNext()) {
102 sb.append(KimConstants.KimUIConstants.COMMA_SEPARATOR).append(" ");
103 }
104 }
105 }
106 return sb.toString();
107 }
108
109
110
111
112 public void setPermission(Permission permission) {
113 this.permission = permission;
114 }
115
116 public String getName(){
117 if( null == permission ) {
118 getPermission();
119 }
120
121 if (null == permission) {
122 return "";
123 }
124
125 return permission.getName();
126
127 }
128
129 public String getNamespaceCode(){
130
131 if( null == permission ) {
132 getPermission();
133 }
134
135 if (null == permission) {
136 return "";
137 }
138
139 return permission.getNamespaceCode();
140 }
141
142 }