1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kim.impl.identity.address;
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.address.EntityAddress;
28 import org.kuali.rice.krad.data.jpa.PortableSequenceGenerator;
29
30
31
32
33 @Entity
34 @Table(name = "KRIM_ENTITY_ADDR_T")
35 public class EntityAddressBo extends EntityAddressBase {
36
37 private static final long serialVersionUID = 0L;
38
39 @PortableSequenceGenerator(name = "KRIM_ENTITY_ADDR_ID_S")
40 @GeneratedValue(generator = "KRIM_ENTITY_ADDR_ID_S")
41 @Id
42 @Column(name = "ENTITY_ADDR_ID")
43 private String id;
44
45 @ManyToOne(targetEntity = EntityAddressTypeBo.class, cascade = { CascadeType.REFRESH })
46 @JoinColumn(name = "ADDR_TYP_CD", referencedColumnName = "ADDR_TYP_CD", insertable = false, updatable = false)
47 private EntityAddressTypeBo addressType;
48
49 public static EntityAddress to(EntityAddressBo bo) {
50 if (bo == null) {
51 return null;
52 }
53 return EntityAddress.Builder.create(bo).build();
54 }
55
56
57
58
59
60
61
62 public static EntityAddressBo from(EntityAddress immutable) {
63 if (immutable == null) {
64 return null;
65 }
66 EntityAddressBo bo = new EntityAddressBo();
67 bo.setActive(immutable.isActive());
68 bo.setEntityTypeCode(immutable.getEntityTypeCode());
69 if (immutable.getAddressType() != null) {
70 bo.setAddressTypeCode(immutable.getAddressType().getCode());
71 }
72 bo.setAddressType(EntityAddressTypeBo.from(immutable.getAddressType()));
73 bo.setDefaultValue(immutable.isDefaultValue());
74 bo.setAttentionLine(immutable.getAttentionLineUnmasked());
75 bo.setLine1(immutable.getLine1Unmasked());
76 bo.setLine2(immutable.getLine2Unmasked());
77 bo.setLine3(immutable.getLine3Unmasked());
78 bo.setCity(immutable.getCityUnmasked());
79 bo.setStateProvinceCode(immutable.getStateProvinceCodeUnmasked());
80 bo.setCountryCode(immutable.getCountryCodeUnmasked());
81 bo.setPostalCode(immutable.getPostalCodeUnmasked());
82 bo.setAddressFormat(immutable.getAddressFormat());
83 bo.setModifiedDate(immutable.getModifiedDate());
84 bo.setValidatedDate(immutable.getValidatedDate());
85 bo.setValidated(immutable.isValidated());
86 bo.setNoteMessage(immutable.getNoteMessage());
87 bo.setId(immutable.getId());
88 bo.setEntityId(immutable.getEntityId());
89 bo.setActive(immutable.isActive());
90 bo.setVersionNumber(immutable.getVersionNumber());
91 return bo;
92 }
93
94 @Override
95 public EntityAddressTypeBo getAddressType() {
96 return addressType;
97 }
98
99 public void setAddressType(EntityAddressTypeBo addressType) {
100 this.addressType = addressType;
101 }
102
103 @Override
104 public String getId() {
105 return id;
106 }
107
108 public void setId(String id) {
109 this.id = id;
110 }
111 }