1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.kim.impl.permission |
18 | |
|
19 | |
import javax.persistence.CascadeType |
20 | |
import javax.persistence.Column |
21 | |
import javax.persistence.Entity |
22 | |
import javax.persistence.FetchType |
23 | |
import javax.persistence.Id |
24 | |
import javax.persistence.JoinColumn |
25 | |
import javax.persistence.OneToMany |
26 | |
import javax.persistence.OneToOne |
27 | |
import javax.persistence.Table |
28 | |
import org.hibernate.annotations.Fetch |
29 | |
import org.hibernate.annotations.FetchMode |
30 | |
import org.hibernate.annotations.Type |
31 | |
import org.kuali.rice.core.api.mo.common.Attributes |
32 | |
import org.kuali.rice.kim.api.permission.Permission |
33 | |
import org.kuali.rice.kim.api.permission.PermissionContract |
34 | |
import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo |
35 | |
import org.kuali.rice.kim.impl.role.RolePermissionBo |
36 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
37 | |
|
38 | |
@Entity |
39 | |
@Table(name="KRIM_PERM_T") |
40 | |
public class PermissionBo extends PersistableBusinessObjectBase implements PermissionContract { |
41 | |
private static final long serialVersionUID = 1L; |
42 | |
|
43 | |
@Id |
44 | |
@Column(name="PERM_ID") |
45 | |
String id |
46 | |
|
47 | |
@Column(name="NMSPC_CD") |
48 | |
String namespaceCode |
49 | |
|
50 | |
@Column(name="NM") |
51 | |
String name |
52 | |
|
53 | |
@Column(name="DESC_TXT", length=400) |
54 | |
String description; |
55 | |
|
56 | |
@Column(name="PERM_TMPL_ID") |
57 | |
String templateId |
58 | |
|
59 | |
@Column(name="ACTV_IND") |
60 | |
@Type(type="yes_no") |
61 | |
boolean active |
62 | |
|
63 | |
@OneToOne(targetEntity=PermissionTemplateBo.class,cascade=[],fetch=FetchType.EAGER) |
64 | |
@JoinColumn(name="PERM_TMPL_ID", insertable=false, updatable=false) |
65 | |
PermissionTemplateBo template; |
66 | |
|
67 | |
@OneToMany(targetEntity=PermissionAttributeBo.class,cascade=[CascadeType.ALL],fetch=FetchType.EAGER,mappedBy="id") |
68 | |
@Fetch(value = FetchMode.SELECT) |
69 | |
List<PermissionAttributeBo> attributeDetails |
70 | |
|
71 | |
@OneToMany(targetEntity=RolePermissionBo.class,cascade=[CascadeType.ALL],fetch=FetchType.EAGER,mappedBy="id") |
72 | |
@Fetch(value = FetchMode.SELECT) |
73 | |
List<RolePermissionBo> rolePermissions |
74 | |
|
75 | |
|
76 | |
Attributes attributes |
77 | |
|
78 | |
Attributes getAttributes() { |
79 | 1 | return attributeDetails != null ? KimAttributeDataBo.toAttributes(attributeDetails) : attributes |
80 | |
} |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
static Permission to(PermissionBo bo) { |
88 | 1 | if (bo == null) { |
89 | 0 | return null |
90 | |
} |
91 | |
|
92 | 1 | return Permission.Builder.create(bo).build(); |
93 | |
} |
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
static PermissionBo from(Permission im) { |
101 | 1 | if (im == null) { |
102 | 0 | return null |
103 | |
} |
104 | |
|
105 | 1 | PermissionBo bo = new PermissionBo() |
106 | 1 | bo.id = im.id |
107 | 1 | bo.namespaceCode = im.namespaceCode |
108 | 1 | bo.name = im.name |
109 | 1 | bo.description = im.description |
110 | 1 | bo.active = im.active |
111 | 1 | bo.templateId = im.template.getId() |
112 | 1 | bo.template = PermissionTemplateBo.from(im.template) |
113 | 1 | bo.attributes = im.attributes |
114 | 1 | bo.versionNumber = im.versionNumber |
115 | 1 | bo.objectId = im.objectId; |
116 | |
|
117 | 1 | return bo |
118 | |
} |
119 | |
|
120 | |
PermissionTemplateBo getTemplate() { |
121 | 1 | return template; |
122 | |
} |
123 | |
|
124 | |
} |