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