1 | |
package org.kuali.rice.kim.impl.common.delegate |
2 | |
|
3 | |
import javax.persistence.CascadeType |
4 | |
import javax.persistence.Column |
5 | |
import javax.persistence.Entity |
6 | |
import javax.persistence.FetchType |
7 | |
import javax.persistence.Id |
8 | |
import javax.persistence.JoinColumn |
9 | |
import javax.persistence.OneToMany |
10 | |
import javax.persistence.Table |
11 | |
import org.kuali.rice.kim.api.common.delegate.DelegateMember |
12 | |
import org.kuali.rice.kim.api.common.delegate.DelegateMemberContract |
13 | |
import org.kuali.rice.kim.impl.membership.AbstractMemberBo |
14 | |
import org.springframework.util.AutoPopulatingList |
15 | |
|
16 | |
@Entity |
17 | |
@Table(name = "KRIM_DLGN_MBR_T") |
18 | |
public class DelegateMemberBo extends AbstractMemberBo implements DelegateMemberContract { |
19 | |
|
20 | |
@Id |
21 | |
@Column(name = "DLGN_MBR_ID") |
22 | |
String delegationMemberId; |
23 | |
@Column(name = "DLGN_ID") |
24 | |
String delegationId; |
25 | |
@Column(name = "ROLE_MBR_ID") |
26 | |
String roleMemberId; |
27 | |
|
28 | |
@OneToMany(targetEntity = DelegateMemberAttributeDataBo.class, cascade = [CascadeType.ALL], fetch = FetchType.EAGER) |
29 | |
@JoinColumn(name = "DLGN_MBR_ID", referencedColumnName = "DLGN_MBR_ID", insertable = false, updatable = false) |
30 | 0 | List<DelegateMemberAttributeDataBo> attributes = new AutoPopulatingList(DelegateMemberAttributeDataBo.class); |
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
public Map<String,String> getQualifier() { |
38 | 0 | Map<String,String> attribs = new HashMap<String,String>(); |
39 | |
|
40 | 0 | if (attributes == null) { |
41 | 0 | return attribs; |
42 | |
} |
43 | 0 | for (DelegateMemberAttributeDataBo attr: attributes) { |
44 | 0 | attribs.put(attr.getKimAttribute().getAttributeName(), attr.getAttributeValue()); |
45 | |
} |
46 | 0 | return attribs |
47 | |
} |
48 | |
|
49 | |
|
50 | |
public static DelegateMember to(DelegateMemberBo bo) { |
51 | 0 | DelegateMember.Builder builder = DelegateMember.Builder.create() |
52 | 0 | builder.delegationMemberId = bo.delegationMemberId |
53 | 0 | builder.activeFromDate = bo.activeFromDate |
54 | 0 | builder.activeToDate = bo.activeToDate |
55 | 0 | builder.delegationId = bo.delegationId |
56 | 0 | builder.memberId = bo.memberId |
57 | 0 | builder.roleMemberId = bo.roleMemberId |
58 | 0 | builder.typeCode = bo.typeCode |
59 | |
} |
60 | |
|
61 | |
public static DelegateMemberBo from(Delegate immutable) { |
62 | 0 | return new DelegateMemberBo( |
63 | |
delegationMemberId: immutable.delegationMemberId, |
64 | |
activeFromDate: immutable.activeFromDate, |
65 | |
activeToDate: immutable.activeToDate, |
66 | |
delegationId: immutable.delegationId, |
67 | |
memberId: immutable.memberId, |
68 | |
roleMemberId: immutable.roleMemberId, |
69 | |
typeCode: immutable.memberTypeCode, |
70 | |
) |
71 | |
} |
72 | |
} |