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 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 | |
import org.kuali.rice.core.api.mo.common.active.MutableInactivatable |
28 | |
import org.kuali.rice.krad.bo.PersistableBusinessObjectBase |
29 | |
import org.kuali.rice.location.api.state.State |
30 | |
import org.kuali.rice.location.api.state.StateContract |
31 | |
import org.kuali.rice.location.impl.country.CountryBo |
32 | |
|
33 | |
@IdClass(StateId.class) |
34 | |
@Entity |
35 | |
@Table(name = "KRLC_ST_T") |
36 | |
class StateBo extends PersistableBusinessObjectBase implements StateContract, MutableInactivatable { |
37 | |
|
38 | |
@Id |
39 | |
@Column(name = "POSTAL_STATE_CD") |
40 | |
def String code; |
41 | |
|
42 | |
@Id |
43 | |
@Column(name = "POSTAL_CNTRY_CD") |
44 | |
def String countryCode; |
45 | |
|
46 | |
@Column(name = "POSTAL_STATE_NM") |
47 | |
def String name; |
48 | |
|
49 | |
@Type(type = "yes_no") |
50 | |
@Column(name = "ACTV_IND") |
51 | |
def boolean active; |
52 | |
|
53 | |
@ManyToOne(targetEntity = CountryBo.class, fetch = FetchType.EAGER) |
54 | |
@JoinColumn(name = "POSTAL_CNTRY_CD", insertable = false, updatable = false) |
55 | |
def CountryBo country; |
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
static State to(StateBo bo) { |
64 | 0 | if (bo == null) { |
65 | 0 | return null |
66 | |
} |
67 | |
|
68 | 0 | return State.Builder.create(bo).build(); |
69 | |
} |
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
|
75 | |
|
76 | |
|
77 | |
static StateBo from(State im) { |
78 | 0 | if (im == null) { |
79 | 0 | return null |
80 | |
} |
81 | |
|
82 | 0 | StateBo bo = new StateBo() |
83 | 0 | bo.code = im.code |
84 | 0 | bo.countryCode = im.countryCode |
85 | 0 | bo.name = im.name |
86 | 0 | bo.active = im.active |
87 | 0 | bo.versionNumber = im.versionNumber |
88 | |
|
89 | 0 | return bo |
90 | |
} |
91 | |
} |