1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
package org.kuali.rice.shareddata.impl.county |
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 | |
|
29 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
30 | |
import org.kuali.rice.shareddata.api.county.County |
31 | |
import org.kuali.rice.shareddata.api.county.CountyContract |
32 | |
import org.kuali.rice.shareddata.impl.country.CountryBo |
33 | |
import org.kuali.rice.shareddata.impl.state.StateBo |
34 | |
import org.kuali.rice.krad.bo.MutableInactivatable |
35 | |
|
36 | |
@IdClass(CountyId.class) |
37 | |
@Entity |
38 | |
@Table(name = "KRLC_CNTY_T") |
39 | |
class CountyBo extends PersistableBusinessObjectBase implements CountyContract, MutableInactivatable { |
40 | |
|
41 | |
@Id |
42 | |
@Column(name = "COUNTY_CD") |
43 | |
def String code |
44 | |
|
45 | |
@Id |
46 | |
@Column(name = "POSTAL_CNTRY_CD") |
47 | |
def String countryCode |
48 | |
|
49 | |
@Id |
50 | |
@Column(name = "STATE_CD") |
51 | |
def String stateCode |
52 | |
|
53 | |
@Column(name = "COUNTY_NM") |
54 | |
def String name |
55 | |
|
56 | |
@Type(type = "yes_no") |
57 | |
@Column(name = "ACTV_IND") |
58 | |
def boolean active |
59 | |
|
60 | |
@ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER) |
61 | |
@JoinColumn(name = "POSTAL_CNTRY_CD", insertable = false, updatable = false) |
62 | |
def CountryBo country; |
63 | |
|
64 | |
@ManyToOne(targetEntity = StateBo.class, fetch = FetchType.EAGER) |
65 | |
@JoinColumn(name = "STATE_CD", insertable = false, updatable = false) |
66 | |
def StateBo state; |
67 | |
|
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
static County to(CountyBo bo) { |
75 | 7 | if (bo == null) { |
76 | 5 | return null |
77 | |
} |
78 | |
|
79 | 2 | return County.Builder.create(bo).build(); |
80 | |
} |
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
static CountyBo from(County im) { |
89 | 1 | if (im == null) { |
90 | 0 | return null |
91 | |
} |
92 | |
|
93 | 1 | CountyBo bo = new CountyBo() |
94 | 1 | bo.code = im.code |
95 | 1 | bo.name = im.name |
96 | 1 | bo.countryCode = im.countryCode |
97 | 1 | bo.stateCode = im.stateCode |
98 | 1 | bo.active = im.active |
99 | 1 | bo.versionNumber = im.versionNumber |
100 | |
|
101 | 1 | return bo |
102 | |
} |
103 | |
} |