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.permission.Permission;
30 import org.kuali.rice.kim.api.services.KimApiServiceLocator;
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 @GenericGenerator(name="KRIM_ROLE_PERM_ID_S",strategy="org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator",parameters={
44 @Parameter(name="sequence_name",value="KRIM_ROLE_PERM_ID_S"),
45 @Parameter(name="value_column",value="id")
46 })
47 @Column(name="ROLE_PERM_ID")
48 protected String rolePermissionId;
49 @Column(name="ROLE_ID")
50 protected String roleId;
51 @Column(name="PERM_ID")
52 protected String permissionId;
53 @Transient
54 protected Permission permission;
55 @Transient
56 protected String name;
57 @Transient
58 protected String namespaceCode;
59
60
61 public String getPermissionId() {
62 return permissionId;
63 }
64
65 public String getRoleId() {
66 return roleId;
67 }
68
69 public String getRolePermissionId() {
70 return rolePermissionId;
71 }
72
73 public void setPermissionId(String permissionId) {
74 this.permissionId = permissionId;
75 }
76
77 public void setRoleId(String roleId) {
78 this.roleId = roleId;
79 }
80
81 public void setRolePermissionId(String rolePermissionId) {
82 this.rolePermissionId = rolePermissionId;
83 }
84
85
86
87
88 public Permission getPermission() {
89 if(null != permissionId){
90 if ( permission == null || !StringUtils.equals( permission.getId(), permissionId ) ) {
91 permission = KimApiServiceLocator.getPermissionService().getPermission(permissionId);
92 }
93 }
94 return permission;
95 }
96
97
98
99
100 public void setPermission(Permission permission) {
101 this.permission = permission;
102 }
103
104 public String getName(){
105 if( null == permission ) {
106 getPermission();
107 }
108
109 if (null == permission) {
110 return "";
111 }
112
113 return permission.getName();
114
115 }
116
117 public String getNamespaceCode(){
118
119 if( null == permission ) {
120 getPermission();
121 }
122
123 if (null == permission) {
124 return "";
125 }
126
127 return permission.getNamespaceCode();
128 }
129
130 }