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 | |
|
19 | |
import javax.persistence.CascadeType |
20 | |
import javax.persistence.Column |
21 | |
import javax.persistence.Entity |
22 | |
import javax.persistence.FetchType |
23 | |
import javax.persistence.GeneratedValue |
24 | |
import javax.persistence.Id |
25 | |
import javax.persistence.JoinColumn |
26 | |
import javax.persistence.OneToMany |
27 | |
import javax.persistence.Table |
28 | |
import javax.persistence.Transient |
29 | |
import org.hibernate.annotations.GenericGenerator |
30 | |
import org.hibernate.annotations.Parameter |
31 | |
import org.kuali.rice.kim.api.role.Role |
32 | |
import org.kuali.rice.kim.api.role.RoleMember |
33 | |
import org.kuali.rice.kim.api.role.RoleMemberContract |
34 | |
import org.kuali.rice.kim.api.services.KimApiServiceLocator |
35 | |
import org.kuali.rice.kim.api.type.KimTypeInfoService |
36 | |
import org.kuali.rice.kim.impl.common.attribute.KimAttributeDataBo |
37 | |
import org.kuali.rice.kim.impl.membership.AbstractMemberBo |
38 | |
import org.springframework.util.AutoPopulatingList |
39 | |
|
40 | |
@Entity |
41 | |
@Table(name = "KRIM_ROLE_MBR_T") |
42 | |
public class RoleMemberBo extends AbstractMemberBo implements RoleMemberContract { |
43 | |
|
44 | |
private static final long serialVersionUID = 1L; |
45 | |
|
46 | |
@Id |
47 | |
@GeneratedValue(generator = "KRIM_ROLE_MBR_ID_S") |
48 | |
@GenericGenerator(name = "KRIM_ROLE_MBR_ID_S", strategy = "org.kuali.rice.core.jpa.spring.RiceNumericStringSequenceStyleGenerator", parameters = [ |
49 | |
@Parameter(name = "sequence_name", value = "KRIM_ROLE_MBR_ID_S"), |
50 | |
@Parameter(name = "value_column", value = "id") |
51 | |
]) |
52 | |
@Column(name = "ROLE_MBR_ID") |
53 | |
String roleMemberId; |
54 | |
|
55 | |
@Column(name = "ROLE_ID") |
56 | |
String roleId; |
57 | |
|
58 | |
@Column(name = "MBR_TYP_CD") |
59 | |
String memberTypeCode |
60 | |
|
61 | |
@OneToMany(targetEntity = RoleMemberAttributeDataBo.class, cascade = [CascadeType.ALL], fetch = FetchType.EAGER) |
62 | |
@JoinColumn(name = "ROLE_MBR_ID", insertable = false, updatable = false) |
63 | |
List<RoleMemberAttributeDataBo> attributeDetails; |
64 | |
|
65 | |
@Transient |
66 | |
List<RoleResponsibilityActionBo> roleRspActions; |
67 | |
|
68 | |
@Transient |
69 | |
Map<String,String> attributes |
70 | |
|
71 | |
|
72 | |
List<RoleMemberAttributeDataBo> getAttributeDetails() { |
73 | 0 | if (this.attributeDetails == null) { |
74 | 0 | return new AutoPopulatingList(RoleMemberAttributeDataBo.class); |
75 | |
} |
76 | 0 | return this.attributeDetails; |
77 | |
} |
78 | |
|
79 | |
void setAttributeDetails(List<RoleMemberAttributeDataBo> attributeDetails) { |
80 | 0 | this.attributeDetails = attributeDetails; |
81 | |
} |
82 | |
|
83 | |
Map<String,String> getAttributes() { |
84 | 0 | return attributeDetails != null ? KimAttributeDataBo.toAttributes(attributeDetails) : attributes |
85 | |
} |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
|
98 | |
|
99 | |
|
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
public static RoleMember to(RoleMemberBo bo) { |
108 | 0 | if (bo == null) {return null;} |
109 | 0 | return RoleMember.Builder.create(bo).build(); |
110 | |
} |
111 | |
|
112 | |
public static RoleMemberBo from(RoleMember immutable) { |
113 | 2 | if (immutable == null) { return null; } |
114 | |
|
115 | 2 | return new RoleMemberBo( |
116 | |
roleMemberId: immutable.roleMemberId, |
117 | |
roleId: immutable.roleId, |
118 | 2 | roleRspActions: immutable.roleRspActions.collect { RoleResponsibilityActionBo.from(it) }, |
119 | |
memberId: immutable.memberId, |
120 | |
memberTypeCode: immutable.memberTypeCode, |
121 | |
activeFromDate: immutable.activeFromDate, |
122 | |
activeToDate: immutable.activeToDate, |
123 | |
) |
124 | |
} |
125 | |
} |