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