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