1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity.affiliation;
17
18 import org.kuali.rice.kim.api.identity.affiliation.EntityAffiliation;
19 import org.kuali.rice.krad.data.jpa.eclipselink.PortableSequenceGenerator;
20
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.FetchType;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.Id;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.ManyToOne;
28 import javax.persistence.Table;
29
30 @Entity
31 @Table(name = "KRIM_ENTITY_AFLTN_T")
32 public class EntityAffiliationBo extends EntityAffiliationBase {
33 private static final long serialVersionUID = 0L;
34 @Id
35 @GeneratedValue(generator = "KRIM_ENTITY_AFLTN_ID_S")
36 @PortableSequenceGenerator(name = "KRIM_ENTITY_AFLTN_ID_S")
37 @Column(name = "ENTITY_AFLTN_ID")
38 private String id;
39
40 @ManyToOne(targetEntity = EntityAffiliationTypeBo.class, fetch = FetchType.EAGER, cascade = {})
41 @JoinColumn(
42 name = "AFLTN_TYP_CD", insertable = false, updatable = false)
43 private EntityAffiliationTypeBo affiliationType;
44
45 public static EntityAffiliation to(EntityAffiliationBo bo) {
46 if (bo == null) {
47 return null;
48 }
49
50 return EntityAffiliation.Builder.create(bo)
51 .build();
52 }
53
54
55
56
57
58
59
60 public static EntityAffiliationBo from(EntityAffiliation immutable) {
61 if (immutable == null) {
62 return null;
63 }
64
65 EntityAffiliationBo bo = new EntityAffiliationBo();
66 bo.setActive(immutable.isActive());
67 if (immutable.getAffiliationType() != null) {
68 bo.setAffiliationTypeCode(immutable.getAffiliationType().getCode());
69 bo.setAffiliationType(EntityAffiliationTypeBo.from(immutable.getAffiliationType()));
70 }
71
72 bo.setId(immutable.getId());
73 bo.setCampusCode(immutable.getCampusCode());
74 bo.setEntityId(immutable.getEntityId());
75 bo.setActive(immutable.isActive());
76 bo.setDefaultValue(immutable.isDefaultValue());
77 bo.setVersionNumber(immutable.getVersionNumber());
78
79 return bo;
80 }
81
82 @Override
83 public EntityAffiliationTypeBo getAffiliationType() {
84 return this.affiliationType;
85 }
86
87 public void setAffiliationType(EntityAffiliationTypeBo affiliationType) {
88 this.affiliationType = affiliationType;
89 }
90
91 @Override
92 public String getId() {
93 return id;
94 }
95
96 public void setId(String id) {
97 this.id = id;
98 }
99 }