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.hibernate.annotations.Fetch |
12 | |
import org.hibernate.annotations.FetchMode |
13 | |
import org.hibernate.annotations.Type |
14 | |
import org.kuali.rice.kim.api.common.delegate.DelegateType |
15 | |
import org.kuali.rice.kim.api.common.delegate.DelegateTypeContract |
16 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
17 | |
import org.springframework.util.AutoPopulatingList |
18 | |
|
19 | |
@Entity |
20 | |
@Table(name = "KRIM_DLGN_T") |
21 | |
public class DelegateBo extends PersistableBusinessObjectBase implements DelegateTypeContract { |
22 | |
private static final long serialVersionUID = 1L; |
23 | |
|
24 | |
@Id |
25 | |
@Column(name = "DLGN_ID") |
26 | |
String delegationId; |
27 | |
|
28 | |
@Column(name = "ROLE_ID") |
29 | |
String roleId; |
30 | |
|
31 | |
@Type(type = "yes_no") |
32 | |
@Column(name = "ACTV_IND") |
33 | |
boolean active = true; |
34 | |
|
35 | |
@Column(name = "KIM_TYP_ID") |
36 | |
String kimTypeId; |
37 | |
|
38 | |
@Column(name = "DLGN_TYP_CD") |
39 | |
String delegationTypeCode; |
40 | |
|
41 | |
@OneToMany(targetEntity = DelegateMemberBo.class, cascade = [CascadeType.ALL], fetch = FetchType.EAGER) |
42 | |
@Fetch(value = FetchMode.SELECT) |
43 | |
@JoinColumn(name = "DLGN_ID", insertable = false, updatable = false) |
44 | 0 | List<DelegateMemberBo> members = new AutoPopulatingList(DelegateMemberBo.class); |
45 | |
|
46 | |
|
47 | |
|
48 | |
public static DelegateType to(DelegateBo bo) { |
49 | 0 | return DelegateType.Builder.create(bo).build() |
50 | |
} |
51 | |
|
52 | |
public static DelegateBo from(DelegateType immutable) { |
53 | 0 | return new DelegateBo( |
54 | |
delegationId: immutable.delegationId, |
55 | |
roleId: immutable.roleId, |
56 | |
active: immutable.active, |
57 | |
kimTypeId: immutable.kimTypeId, |
58 | |
delegationTypeCode: immutable.delegationTypeCode, |
59 | |
); |
60 | |
} |
61 | |
} |