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 java.util.Iterator;
19
20 import javax.persistence.Column;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.Id;
24 import javax.persistence.Table;
25 import javax.persistence.Transient;
26
27 import org.apache.commons.lang.StringUtils;
28 import org.kuali.rice.kim.api.KimConstants;
29 import org.kuali.rice.kim.api.permission.Permission;
30 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
31 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
32
33
34
35
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
42 @PortableSequenceGenerator(name = "KRIM_ROLE_PERM_ID_S")
43 @GeneratedValue(generator = "KRIM_ROLE_PERM_ID_S")
44 @Id
45 @Column(name = "ROLE_PERM_ID")
46 protected String rolePermissionId;
47
48 @Column(name = "ROLE_ID")
49 protected String roleId;
50
51 @Column(name = "PERM_ID")
52 protected String permissionId;
53
54 @Transient
55 protected Permission permission;
56
57 @Transient
58 protected String name;
59
60 @Transient
61 protected String namespaceCode;
62
63 public String getPermissionId() {
64 return permissionId;
65 }
66
67 public String getRoleId() {
68 return roleId;
69 }
70
71 public String getRolePermissionId() {
72 return rolePermissionId;
73 }
74
75 public void setPermissionId(String permissionId) {
76 this.permissionId = permissionId;
77 }
78
79 public void setRoleId(String roleId) {
80 this.roleId = roleId;
81 }
82
83 public void setRolePermissionId(String rolePermissionId) {
84 this.rolePermissionId = rolePermissionId;
85 }
86
87 public Permission getPermission() {
88 if (null != permissionId) {
89 if (permission == null || !StringUtils.equals(permission.getId(), permissionId)) {
90 permission = KimApiServiceLocator.getPermissionService().getPermission(permissionId);
91 }
92 }
93 return permission;
94 }
95
96 public String getPermissionDetailValues() {
97 Permission perm = getPermission();
98 StringBuilder sb = new StringBuilder();
99 if (perm.getAttributes() != null) {
100 Iterator<String> keyIter = perm.getAttributes().keySet().iterator();
101 while (keyIter.hasNext()) {
102 String key = keyIter.next();
103 sb.append(key).append('=').append(perm.getAttributes().get(key));
104 if (keyIter.hasNext()) {
105 sb.append(KimConstants.KimUIConstants.COMMA_SEPARATOR).append(" ");
106 }
107 }
108 }
109 return sb.toString();
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 if (null == permission) {
121 return "";
122 }
123 return permission.getName();
124 }
125
126 public String getNamespaceCode() {
127 if (null == permission) {
128 getPermission();
129 }
130 if (null == permission) {
131 return "";
132 }
133 return permission.getNamespaceCode();
134 }
135 }