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