1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity.phone;
17
18 import org.kuali.rice.kim.api.identity.phone.EntityPhone;
19 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
20
21 import javax.persistence.Column;
22 import javax.persistence.Entity;
23 import javax.persistence.FetchType;
24 import javax.persistence.GeneratedValue;
25 import javax.persistence.Id;
26 import javax.persistence.JoinColumn;
27 import javax.persistence.ManyToOne;
28 import javax.persistence.Table;
29
30 @Entity
31 @Table(name = "KRIM_ENTITY_PHONE_T")
32 public class EntityPhoneBo extends EntityPhoneBase {
33 private static final long serialVersionUID = 1L;
34
35 @Id
36 @GeneratedValue(generator = "KRIM_ENTITY_PHONE_ID_S")
37 @PortableSequenceGenerator(name = "KRIM_ENTITY_PHONE_ID_S")
38 @Column(name = "ENTITY_PHONE_ID")
39 private String id;
40
41 @ManyToOne(targetEntity = EntityPhoneTypeBo.class, fetch = FetchType.EAGER, cascade = {})
42 @JoinColumn(name = "PHONE_TYP_CD", insertable = false, updatable = false)
43 private EntityPhoneTypeBo phoneType;
44
45 public static EntityPhone to(EntityPhoneBo bo) {
46 if (bo == null) {
47 return null;
48 }
49
50 return EntityPhone.Builder.create(bo).build();
51 }
52
53
54
55
56
57
58
59 public static EntityPhoneBo from(EntityPhone immutable) {
60 if (immutable == null) {
61 return null;
62 }
63
64 EntityPhoneBo bo = new EntityPhoneBo();
65 bo.setId(immutable.getId());
66 bo.setActive(immutable.isActive());
67
68 bo.setEntityId(immutable.getEntityId());
69 bo.setEntityTypeCode(immutable.getEntityTypeCode());
70 if (immutable.getPhoneType() != null) {
71 bo.setPhoneTypeCode(immutable.getPhoneType().getCode());
72 }
73
74 bo.setPhoneType(EntityPhoneTypeBo.from(immutable.getPhoneType()));
75 bo.setDefaultValue(immutable.isDefaultValue());
76 bo.setCountryCode(immutable.getCountryCodeUnmasked());
77 bo.setPhoneNumber(immutable.getPhoneNumberUnmasked());
78 bo.setExtensionNumber(immutable.getExtensionNumberUnmasked());
79 bo.setVersionNumber(immutable.getVersionNumber());
80 bo.setObjectId(immutable.getObjectId());
81
82 return bo;
83 }
84
85 @Override
86 public String getId() {
87 return id;
88 }
89
90 public void setId(String id) {
91 this.id = id;
92 }
93
94 @Override
95 public EntityPhoneTypeBo getPhoneType() {
96 return this.phoneType;
97 }
98
99 public void setPhoneType(EntityPhoneTypeBo phoneType) {
100 this.phoneType = phoneType;
101 }
102
103
104 }