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