1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.location.impl.state;
17
18 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
19 import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
20 import org.kuali.rice.location.api.state.State;
21 import org.kuali.rice.location.framework.state.StateEbo;
22 import org.kuali.rice.location.impl.country.CountryBo;
23
24 import javax.persistence.Column;
25 import javax.persistence.Convert;
26 import javax.persistence.Entity;
27 import javax.persistence.FetchType;
28 import javax.persistence.Id;
29 import javax.persistence.IdClass;
30 import javax.persistence.JoinColumn;
31 import javax.persistence.ManyToOne;
32 import javax.persistence.Table;
33
34 @IdClass(StateId.class)
35 @Entity
36 @Table(name = "KRLC_ST_T")
37 public class StateBo extends PersistableBusinessObjectBase implements StateEbo {
38
39 private static final long serialVersionUID = 6755670624476337736L;
40
41 @Id
42 @Column(name = "POSTAL_STATE_CD")
43 private String code;
44
45 @Id
46 @Column(name = "POSTAL_CNTRY_CD")
47 private String countryCode;
48
49 @Column(name = "POSTAL_STATE_NM")
50 private String name;
51
52 @Column(name = "ACTV_IND")
53 @Convert(converter = BooleanYNConverter.class)
54 private boolean active;
55
56 @ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER)
57 @JoinColumn(name = "POSTAL_CNTRY_CD", insertable = false, updatable = false)
58 private CountryBo country;
59
60 @Override
61 public String getCode() {
62 return code;
63 }
64
65 public void setCode(String code) {
66 this.code = code;
67 }
68
69 @Override
70 public String getCountryCode() {
71 return countryCode;
72 }
73
74 public void setCountryCode(String countryCode) {
75 this.countryCode = countryCode;
76 }
77
78 @Override
79 public String getName() {
80 return name;
81 }
82
83 public void setName(String name) {
84 this.name = name;
85 }
86
87 @Override
88 public boolean isActive() {
89 return active;
90 }
91
92 @Override
93 public void setActive(boolean active) {
94 this.active = active;
95 }
96
97 public CountryBo getCountry() {
98 return country;
99 }
100
101 public void setCountry(CountryBo country) {
102 this.country = country;
103 }
104
105
106
107
108
109
110
111 public static State to(StateBo bo) {
112 if (bo == null) {
113 return null;
114 }
115
116 return State.Builder.create(bo).build();
117 }
118
119
120
121
122
123
124
125 public static StateBo from(State im) {
126 if (im == null) {
127 return null;
128 }
129
130 StateBo bo = new StateBo();
131 bo.code = im.getCode();
132 bo.countryCode = im.getCountryCode();
133 bo.name = im.getName();
134 bo.active = im.isActive();
135 bo.versionNumber = im.getVersionNumber();
136
137 return bo;
138 }
139
140 }
141