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