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