1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
package org.kuali.rice.location.impl.county |
17 | |
|
18 | |
import javax.persistence.Column |
19 | |
import javax.persistence.Entity |
20 | |
import javax.persistence.FetchType |
21 | |
import javax.persistence.Id |
22 | |
import javax.persistence.IdClass |
23 | |
import javax.persistence.JoinColumn |
24 | |
import javax.persistence.ManyToOne |
25 | |
import javax.persistence.Table |
26 | |
import org.hibernate.annotations.Type |
27 | |
|
28 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
29 | |
import org.kuali.rice.location.api.county.County |
30 | |
import org.kuali.rice.location.api.county.CountyContract |
31 | |
import org.kuali.rice.location.impl.country.CountryBo |
32 | |
import org.kuali.rice.location.impl.state.StateBo |
33 | |
import org.kuali.rice.core.api.mo.common.active.MutableInactivatable |
34 | |
|
35 | |
@IdClass(CountyId.class) |
36 | |
@Entity |
37 | |
@Table(name = "KRLC_CNTY_T") |
38 | |
class CountyBo extends PersistableBusinessObjectBase implements CountyContract, MutableInactivatable { |
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 | 0 | if (bo == null) { |
75 | 0 | return null |
76 | |
} |
77 | |
|
78 | 0 | return County.Builder.create(bo).build(); |
79 | |
} |
80 | |
|
81 | |
|
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
static CountyBo from(County im) { |
88 | 0 | if (im == null) { |
89 | 0 | return null |
90 | |
} |
91 | |
|
92 | 0 | CountyBo bo = new CountyBo() |
93 | 0 | bo.code = im.code |
94 | 0 | bo.name = im.name |
95 | 0 | bo.countryCode = im.countryCode |
96 | 0 | bo.stateCode = im.stateCode |
97 | 0 | bo.active = im.active |
98 | 0 | bo.versionNumber = im.versionNumber |
99 | |
|
100 | 0 | return bo |
101 | |
} |
102 | |
} |