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