1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity.citizenship;
17
18 import java.sql.Timestamp;
19
20 import javax.persistence.CascadeType;
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.GeneratedValue;
24 import javax.persistence.Id;
25 import javax.persistence.JoinColumn;
26 import javax.persistence.ManyToOne;
27 import javax.persistence.Table;
28 import javax.persistence.Transient;
29
30 import org.eclipse.persistence.annotations.JoinFetch;
31 import org.eclipse.persistence.annotations.JoinFetchType;
32 import org.kuali.rice.kim.api.identity.citizenship.EntityCitizenship;
33 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
34
35 @Entity
36 @Table(name = "KRIM_ENTITY_CTZNSHP_T")
37 public class EntityCitizenshipBo extends EntityCitizenshipBase {
38
39 private static final long serialVersionUID = 1L;
40
41 @PortableSequenceGenerator(name = "KRIM_ENTITY_CTZNSHP_ID_S")
42 @GeneratedValue(generator = "KRIM_ENTITY_CTZNSHP_ID_S")
43 @Id
44 @Column(name = "ENTITY_CTZNSHP_ID")
45 private String id;
46
47 @JoinFetch(value= JoinFetchType.OUTER)
48 @ManyToOne(targetEntity = EntityCitizenshipStatusBo.class, cascade = { CascadeType.REFRESH })
49 @JoinColumn(name = "CTZNSHP_STAT_CD", referencedColumnName = "CTZNSHP_STAT_CD", insertable = false, updatable = false)
50 private EntityCitizenshipStatusBo status;
51
52 @Transient
53 private EntityCitizenshipChangeTypeBo changeType;
54
55 public static EntityCitizenship to(EntityCitizenshipBo bo) {
56 if (bo == null) {
57 return null;
58 }
59 return EntityCitizenship.Builder.create(bo).build();
60 }
61
62
63
64
65
66
67
68 public static EntityCitizenshipBo from(EntityCitizenship immutable) {
69 if (immutable == null) {
70 return null;
71 }
72 EntityCitizenshipBo bo = new EntityCitizenshipBo();
73 bo.setActive(immutable.isActive());
74 if (immutable.getStatus() != null) {
75 bo.setStatusCode(immutable.getStatus().getCode());
76 bo.setStatus(EntityCitizenshipStatusBo.from(immutable.getStatus()));
77 }
78 bo.setId(immutable.getId());
79 bo.setEntityId(immutable.getEntityId());
80 bo.setCountryCode(immutable.getCountryCode());
81 if (immutable.getStartDate() != null) {
82 bo.setStartDateValue(new Timestamp(immutable.getStartDate().getMillis()));
83 }
84 if (immutable.getEndDate() != null) {
85 bo.setEndDateValue(new Timestamp(immutable.getEndDate().getMillis()));
86 }
87 bo.setActive(immutable.isActive());
88 bo.setVersionNumber(immutable.getVersionNumber());
89 bo.setObjectId(immutable.getObjectId());
90 return bo;
91 }
92
93 @Override
94 public EntityCitizenshipStatusBo getStatus() {
95 return this.status;
96 }
97
98 @Override
99 public String getId() {
100 return id;
101 }
102
103 public void setId(String id) {
104 this.id = id;
105 }
106
107 public void setStatus(EntityCitizenshipStatusBo status) {
108 this.status = status;
109 }
110 }