1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.role;
17
18 import javax.persistence.CascadeType;
19 import javax.persistence.Column;
20 import javax.persistence.Convert;
21 import javax.persistence.Entity;
22 import javax.persistence.GeneratedValue;
23 import javax.persistence.Id;
24 import javax.persistence.JoinColumn;
25 import javax.persistence.ManyToOne;
26 import javax.persistence.Table;
27
28 import org.kuali.rice.kim.api.role.RolePermission;
29 import org.kuali.rice.kim.api.role.RolePermissionContract;
30 import org.kuali.rice.kim.impl.permission.PermissionBo;
31 import org.kuali.rice.krad.bo.DataObjectBase;
32 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
33 import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
34
35 @Entity
36 @Table(name = "KRIM_ROLE_PERM_T")
37 public class RolePermissionBo extends DataObjectBase implements RolePermissionContract {
38
39 private static final long serialVersionUID = 1L;
40
41 @PortableSequenceGenerator(name = "KRIM_ROLE_PERM_ID_S")
42 @GeneratedValue(generator = "KRIM_ROLE_PERM_ID_S")
43 @Id
44 @Column(name = "ROLE_PERM_ID")
45 private String id;
46
47 @Column(name = "ROLE_ID")
48 private String roleId;
49
50 @Column(name = "PERM_ID")
51 private String permissionId;
52
53 @Column(name = "ACTV_IND")
54 @Convert(converter = BooleanYNConverter.class)
55 private boolean active;
56
57 @ManyToOne(targetEntity = PermissionBo.class, cascade = { CascadeType.REFRESH })
58 @JoinColumn(name = "PERM_ID", referencedColumnName = "PERM_ID", insertable = false, updatable = false)
59 private PermissionBo permission;
60
61
62
63
64
65
66
67 public static RolePermission to(RolePermissionBo bo) {
68 if (bo == null) {
69 return null;
70 }
71 return RolePermission.Builder.create(bo).build();
72 }
73
74
75
76
77
78
79
80 public static RolePermissionBo from(RolePermission im) {
81 if (im == null) {
82 return null;
83 }
84 RolePermissionBo bo = new RolePermissionBo();
85 bo.id = im.getId();
86 bo.roleId = im.getRoleId();
87 bo.permissionId = im.getPermissionId();
88 bo.active = im.isActive();
89 bo.setVersionNumber(im.getVersionNumber());
90 bo.setObjectId(im.getObjectId());
91 return bo;
92 }
93
94 @Override
95 public String getId() {
96 return id;
97 }
98
99 public void setId(String id) {
100 this.id = id;
101 }
102
103 @Override
104 public String getRoleId() {
105 return roleId;
106 }
107
108 public void setRoleId(String roleId) {
109 this.roleId = roleId;
110 }
111
112 @Override
113 public String getPermissionId() {
114 return permissionId;
115 }
116
117 public void setPermissionId(String permissionId) {
118 this.permissionId = permissionId;
119 }
120
121 public boolean getActive() {
122 return active;
123 }
124
125 @Override
126 public boolean isActive() {
127 return active;
128 }
129
130 public void setActive(boolean active) {
131 this.active = active;
132 }
133
134 public PermissionBo getPermission() {
135 return permission;
136 }
137
138 public void setPermission(PermissionBo permission) {
139 this.permission = permission;
140 }
141 }