1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.shareddata.impl.postalcode |
18 | |
|
19 | |
import javax.persistence.Column |
20 | |
import javax.persistence.Entity |
21 | |
import javax.persistence.FetchType |
22 | |
import javax.persistence.Id |
23 | |
import javax.persistence.IdClass |
24 | |
import javax.persistence.JoinColumn |
25 | |
import javax.persistence.ManyToOne |
26 | |
import javax.persistence.Table |
27 | |
import org.hibernate.annotations.Type |
28 | |
import org.kuali.rice.kns.bo.Inactivateable |
29 | |
import org.kuali.rice.kns.bo.PersistableBusinessObjectBase |
30 | |
import org.kuali.rice.shareddata.api.postalcode.PostalCode |
31 | |
import org.kuali.rice.shareddata.api.postalcode.PostalCodeContract |
32 | |
import org.kuali.rice.shareddata.impl.country.CountryBo |
33 | |
import org.kuali.rice.shareddata.impl.county.CountyBo |
34 | |
import org.kuali.rice.shareddata.impl.state.StateBo |
35 | |
|
36 | |
@IdClass(PostalCodeId.class) |
37 | |
@Entity |
38 | |
@Table(name = "KRLC_PSTL_CD_T") |
39 | |
class PostalCodeBo extends PersistableBusinessObjectBase implements PostalCodeContract, Inactivateable { |
40 | |
|
41 | |
@Id |
42 | |
@Column(name = "POSTAL_CD") |
43 | |
def String code; |
44 | |
|
45 | |
@Id |
46 | |
@Column(name = "POSTAL_CNTRY_CD") |
47 | |
def String countryCode; |
48 | |
|
49 | |
@Column(name = "POSTAL_CITY_NM") |
50 | |
def String cityName; |
51 | |
|
52 | |
@Column(name = "POSTAL_STATE_NM") |
53 | |
def String stateCode; |
54 | |
|
55 | |
@Column(name = "COUNTY_NM") |
56 | |
def String countyCode; |
57 | |
|
58 | |
@Type(type = "yes_no") |
59 | |
@Column(name = "ACTV_IND") |
60 | |
def boolean active; |
61 | |
|
62 | |
@ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER) |
63 | |
@JoinColumn(name = "POSTAL_CNTRY_CD", insertable = false, updatable = false) |
64 | |
def CountryBo country; |
65 | |
|
66 | |
@ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER) |
67 | |
@JoinColumn(name = "POSTAL_STATE_NM", insertable = false, updatable = false) |
68 | |
def StateBo state; |
69 | |
|
70 | |
|
71 | |
@ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER) |
72 | |
@JoinColumn(name = "COUNTY_NM", insertable = false, updatable = false) |
73 | |
def CountyBo county; |
74 | |
|
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
static PostalCode to(PostalCodeBo bo) { |
82 | 9 | if (bo == null) { |
83 | 5 | return null |
84 | |
} |
85 | |
|
86 | 4 | return PostalCode.Builder.create(bo).build(); |
87 | |
} |
88 | |
|
89 | |
|
90 | |
|
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
static PostalCodeBo from(PostalCode im) { |
96 | 1 | if (im == null) { |
97 | 0 | return null |
98 | |
} |
99 | |
|
100 | 1 | PostalCodeBo bo = new PostalCodeBo() |
101 | 1 | bo.code = im.code |
102 | 1 | bo.countryCode = im.countryCode |
103 | 1 | bo.cityName = im.cityName |
104 | 1 | bo.active = im.active |
105 | 1 | bo.stateCode = im.stateCode |
106 | 1 | bo.cityName = im.cityName |
107 | 1 | bo.versionNumber = im.versionNumber |
108 | |
|
109 | 1 | return bo |
110 | |
} |
111 | |
} |