1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.bo.role.impl;
17
18 import org.kuali.rice.core.util.AttributeSet;
19 import org.kuali.rice.kim.bo.impl.KimAbstractMemberImpl;
20 import org.kuali.rice.kim.bo.role.KimDelegationMember;
21 import org.kuali.rice.kim.bo.role.dto.DelegateMemberCompleteInfo;
22 import org.springframework.util.AutoPopulatingList;
23
24 import javax.persistence.*;
25 import java.sql.Timestamp;
26 import java.util.List;
27
28
29
30
31
32
33
34 @Entity
35 @Table(name="KRIM_DLGN_MBR_T")
36 public class KimDelegationMemberImpl extends KimAbstractMemberImpl implements KimDelegationMember {
37
38 private static final long serialVersionUID = 6278392972043721961L;
39
40 @Id
41 @Column(name="DLGN_MBR_ID")
42 protected String delegationMemberId;
43 @Column(name="DLGN_ID")
44 protected String delegationId;
45 @Column(name="ROLE_MBR_ID")
46 protected String roleMemberId;
47
48 @OneToMany(targetEntity=KimDelegationMemberAttributeDataImpl.class,cascade={CascadeType.ALL},fetch=FetchType.EAGER)
49 @JoinColumn(name="DLGN_MBR_ID", referencedColumnName="DLGN_MBR_ID", insertable=false, updatable=false )
50 protected List<KimDelegationMemberAttributeDataImpl> attributes = new AutoPopulatingList(KimDelegationMemberAttributeDataImpl.class);
51
52 public boolean isActive() {
53 long now = System.currentTimeMillis();
54 return (activeFromDate == null || activeFromDate.getTime() < now) && (activeToDate == null || activeToDate.getTime() > now);
55 }
56
57 public void setActiveFromDate(Timestamp from) {
58 this.activeFromDate = from;
59 }
60
61 public void setActiveToDate(Timestamp to) {
62 this.activeToDate = to;
63 }
64
65 public String getDelegationMemberId() {
66 return this.delegationMemberId;
67 }
68
69 public void setDelegationMemberId(String delegationMemberId) {
70 this.delegationMemberId = delegationMemberId;
71 }
72
73 public String getDelegationId() {
74 return this.delegationId;
75 }
76
77 public void setDelegationId(String delegationId) {
78 this.delegationId = delegationId;
79 }
80
81 public List<KimDelegationMemberAttributeDataImpl> getAttributes() {
82 return this.attributes;
83 }
84
85 public void setAttributes(List<KimDelegationMemberAttributeDataImpl> attributes) {
86 this.attributes = attributes;
87 }
88
89
90
91
92 public AttributeSet getQualifier() {
93 AttributeSet attribs = new AttributeSet();
94
95 if ( attributes == null ) {
96 return attribs;
97 }
98 for ( KimDelegationMemberAttributeDataImpl attr : attributes ) {
99 attribs.put( attr.getKimAttribute().getAttributeName(), attr.getAttributeValue() );
100 }
101 return attribs;
102 }
103
104
105
106
107 public String getRoleMemberId() {
108 return this.roleMemberId;
109 }
110
111
112
113
114 public void setRoleMemberId(String roleMemberId) {
115 this.roleMemberId = roleMemberId;
116 }
117
118 public DelegateMemberCompleteInfo toSimpleInfo(){
119 DelegateMemberCompleteInfo delegateMemberCompleteInfo = new DelegateMemberCompleteInfo();
120 delegateMemberCompleteInfo.setDelegationMemberId(delegationMemberId);
121 delegateMemberCompleteInfo.setActiveFromDate(activeFromDate);
122 delegateMemberCompleteInfo.setActiveToDate(activeToDate);
123 delegateMemberCompleteInfo.setDelegationId(delegationId);
124 delegateMemberCompleteInfo.setMemberId(memberId);
125 delegateMemberCompleteInfo.setMemberTypeCode(memberTypeCode);
126 delegateMemberCompleteInfo.setQualifier(getQualifier());
127 delegateMemberCompleteInfo.setRoleMemberId(roleMemberId);
128 return delegateMemberCompleteInfo;
129 }
130 }