1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity.email;
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.email.EntityEmail;
30 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
31
32
33
34
35 @Entity
36 @Table(name = "KRIM_ENTITY_EMAIL_T")
37 public class EntityEmailBo extends EntityEmailBase {
38
39 private static final long serialVersionUID = 1L;
40
41 @PortableSequenceGenerator(name = "KRIM_ENTITY_EMAIL_ID_S")
42 @GeneratedValue(generator = "KRIM_ENTITY_EMAIL_ID_S")
43 @Id
44 @Column(name = "ENTITY_EMAIL_ID")
45 private String id;
46
47 @JoinFetch(value= JoinFetchType.OUTER)
48 @ManyToOne(targetEntity = EntityEmailTypeBo.class, cascade = { CascadeType.REFRESH })
49 @JoinColumn(name = "EMAIL_TYP_CD", referencedColumnName = "EMAIL_TYP_CD", insertable = false, updatable = false)
50 private EntityEmailTypeBo emailType;
51
52 public static EntityEmail to(EntityEmailBo bo) {
53 if (bo == null) {
54 return null;
55 }
56 return EntityEmail.Builder.create(bo).build();
57 }
58
59
60
61
62
63
64
65 public static EntityEmailBo from(EntityEmail immutable) {
66 if (immutable == null) {
67 return null;
68 }
69 EntityEmailBo bo = new EntityEmailBo();
70 bo.setId(immutable.getId());
71 bo.setActive(immutable.isActive());
72 bo.setEntityId(immutable.getEntityId());
73 bo.setEntityTypeCode(immutable.getEntityTypeCode());
74 if (immutable.getEmailType() != null) {
75 bo.setEmailTypeCode(immutable.getEmailType().getCode());
76 }
77 bo.setEmailAddress(immutable.getEmailAddressUnmasked());
78 bo.setEmailType(EntityEmailTypeBo.from(immutable.getEmailType()));
79 bo.setDefaultValue(immutable.isDefaultValue());
80 bo.setVersionNumber(immutable.getVersionNumber());
81 bo.setObjectId(immutable.getObjectId());
82 return bo;
83 }
84
85 @Override
86 public EntityEmailTypeBo getEmailType() {
87 return this.emailType;
88 }
89
90 public void setEmailType(EntityEmailTypeBo emailType) {
91 this.emailType = emailType;
92 }
93
94 @Override
95 public String getId() {
96 return id;
97 }
98
99 public void setId(String id) {
100 this.id = id;
101 }
102 }