1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.coreservice.impl.component;
17
18 import org.kuali.rice.coreservice.api.component.Component;
19 import org.kuali.rice.coreservice.api.namespace.NamespaceService;
20 import org.kuali.rice.coreservice.framework.component.ComponentEbo;
21 import org.kuali.rice.coreservice.impl.namespace.NamespaceBo;
22 import org.kuali.rice.krad.bo.PersistableBusinessObjectBase;
23 import org.kuali.rice.krad.data.jpa.converters.BooleanYNConverter;
24
25 import javax.persistence.Column;
26 import javax.persistence.Convert;
27 import javax.persistence.Entity;
28 import javax.persistence.FetchType;
29 import javax.persistence.Id;
30 import javax.persistence.IdClass;
31 import javax.persistence.JoinColumn;
32 import javax.persistence.ManyToOne;
33 import javax.persistence.Table;
34
35 @IdClass(ComponentId.class)
36 @Entity
37 @Table(name = "KRCR_CMPNT_T")
38 public class ComponentBo extends PersistableBusinessObjectBase implements ComponentEbo {
39
40 private static final long serialVersionUID = 1L;
41
42 private static transient NamespaceService namespaceService;
43
44 @Id
45 @Column(name = "NMSPC_CD")
46 private String namespaceCode;
47
48 @Id
49 @Column(name = "CMPNT_CD")
50 private String code;
51
52 @Column(name = "NM")
53 private String name;
54
55 @Column(name = "ACTV_IND")
56 @Convert(converter = BooleanYNConverter.class)
57 private boolean active = true;
58
59 @ManyToOne(fetch = FetchType.LAZY)
60 @JoinColumn(name = "NMSPC_CD", insertable = false, updatable = false)
61 private NamespaceBo namespace;
62
63 public String getNamespaceCode() {
64 return namespaceCode;
65 }
66
67 public void setNamespaceCode(String namespaceCode) {
68 this.namespaceCode = namespaceCode;
69 }
70
71 @Override
72 public String getCode() {
73 return code;
74 }
75
76 public void setCode(String code) {
77 this.code = code;
78 }
79
80 @Override
81 public String getName() {
82 return name;
83 }
84
85 public void setName(String name) {
86 this.name = name;
87 }
88
89 @Override
90 public boolean isActive() {
91 return active;
92 }
93
94 public void setActive(boolean active) {
95 this.active = active;
96 }
97
98 public NamespaceBo getNamespace() {
99 return namespace;
100 }
101
102 public void setNamespace(NamespaceBo namespace) {
103 this.namespace = namespace;
104 }
105
106 @Override
107 public String getComponentSetId() {
108 return null;
109 }
110
111
112
113
114
115
116 public static Component to(ComponentBo bo) {
117 if (bo == null) {
118 return null;
119 }
120
121 return Component.Builder.create(bo).build();
122 }
123
124
125
126
127
128
129 public static ComponentBo from(Component im) {
130 if (im == null) {
131 return null;
132 }
133
134 ComponentBo bo = new ComponentBo();
135 bo.code = im.getCode();
136 bo.name = im.getName();
137 bo.active = im.isActive();
138 bo.namespaceCode = im.getNamespaceCode();
139 bo.versionNumber = im.getVersionNumber();
140 bo.objectId = im.getObjectId();
141
142 bo.namespace = NamespaceBo.from(namespaceService.getNamespace(bo.namespaceCode));
143 return bo;
144 }
145
146 public static void setNamespaceService(NamespaceService namespaceService) {
147 ComponentBo.namespaceService = namespaceService;
148 }
149
150 }