1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity.employment;
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.employment.EntityEmployment;
30 import org.kuali.rice.kim.impl.identity.affiliation.EntityAffiliationBo;
31 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
32
33 @Entity
34 @Table(name = "KRIM_ENTITY_EMP_INFO_T")
35 public class EntityEmploymentBo extends EntityEmploymentBase {
36
37 private static final long serialVersionUID = 1L;
38
39 @PortableSequenceGenerator(name = "KRIM_ENTITY_EMP_ID_S")
40 @GeneratedValue(generator = "KRIM_ENTITY_EMP_ID_S")
41 @Id
42 @Column(name = "ENTITY_EMP_ID")
43 private String id;
44
45 @JoinFetch(value= JoinFetchType.OUTER)
46 @ManyToOne(targetEntity = EntityEmploymentTypeBo.class, cascade = { CascadeType.REFRESH })
47 @JoinColumn(name = "EMP_TYP_CD", referencedColumnName = "EMP_TYP_CD", insertable = false, updatable = false)
48 private EntityEmploymentTypeBo employeeType;
49
50 @JoinFetch(value= JoinFetchType.OUTER)
51 @ManyToOne(targetEntity = EntityEmploymentStatusBo.class, cascade = { CascadeType.REFRESH })
52 @JoinColumn(name = "EMP_STAT_CD", referencedColumnName = "EMP_STAT_CD", insertable = false, updatable = false)
53 private EntityEmploymentStatusBo employeeStatus;
54
55 @JoinFetch(value= JoinFetchType.OUTER)
56 @ManyToOne(targetEntity = EntityAffiliationBo.class, cascade = { CascadeType.REFRESH })
57 @JoinColumn(name = "ENTITY_AFLTN_ID", referencedColumnName = "ENTITY_AFLTN_ID", insertable = false, updatable = false)
58 private EntityAffiliationBo entityAffiliation;
59
60 @Override
61 public EntityAffiliationBo getEntityAffiliation() {
62 return this.entityAffiliation;
63 }
64
65 @Override
66 public EntityEmploymentStatusBo getEmployeeStatus() {
67 return this.employeeStatus;
68 }
69
70 @Override
71 public EntityEmploymentTypeBo getEmployeeType() {
72 return this.employeeType;
73 }
74
75 public static EntityEmployment to(EntityEmploymentBo bo) {
76 if (bo == null) {
77 return null;
78 }
79 return EntityEmployment.Builder.create(bo).build();
80 }
81
82
83
84
85
86
87
88 public static EntityEmploymentBo from(EntityEmployment immutable) {
89 if (immutable == null) {
90 return null;
91 }
92 EntityEmploymentBo bo = new EntityEmploymentBo();
93 bo.id = immutable.getId();
94 bo.setActive(immutable.isActive());
95 bo.setEntityId(immutable.getEntityId());
96 if (immutable.getEmployeeType() != null) {
97 bo.setEmployeeTypeCode(immutable.getEmployeeType().getCode());
98 bo.setEmployeeType(EntityEmploymentTypeBo.from(immutable.getEmployeeType()));
99 }
100 if (immutable.getEmployeeStatus() != null) {
101 bo.setEmployeeStatusCode(immutable.getEmployeeStatus().getCode());
102 bo.setEmployeeStatus(EntityEmploymentStatusBo.from(immutable.getEmployeeStatus()));
103 }
104 if (immutable.getEntityAffiliation() != null) {
105 bo.setEntityAffiliationId(immutable.getEntityAffiliation().getId());
106 bo.setEntityAffiliation(EntityAffiliationBo.from(immutable.getEntityAffiliation()));
107 }
108 bo.setPrimaryDepartmentCode(immutable.getPrimaryDepartmentCode());
109 bo.setEmployeeId(immutable.getEmployeeId());
110 bo.setEmploymentRecordId(immutable.getEmploymentRecordId());
111 bo.setBaseSalaryAmount(immutable.getBaseSalaryAmount());
112 bo.setPrimary(immutable.isPrimary());
113 bo.setVersionNumber(immutable.getVersionNumber());
114 bo.setObjectId(immutable.getObjectId());
115 return bo;
116 }
117
118 @Override
119 public String getId() {
120 return id;
121 }
122
123 public void setId(String id) {
124 this.id = id;
125 }
126
127 public void setEmployeeType(EntityEmploymentTypeBo employeeType) {
128 this.employeeType = employeeType;
129 }
130
131 public void setEmployeeStatus(EntityEmploymentStatusBo employeeStatus) {
132 this.employeeStatus = employeeStatus;
133 }
134
135 public void setEntityAffiliation(EntityAffiliationBo entityAffiliation) {
136 this.entityAffiliation = entityAffiliation;
137 }
138 }