1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.krms.impl.repository;
17
18 import org.kuali.rice.core.api.criteria.GenericQueryResults;
19 import org.kuali.rice.core.api.criteria.Predicate;
20 import org.kuali.rice.core.api.criteria.QueryByCriteria;
21 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
22 import org.kuali.rice.krad.service.BusinessObjectService;
23 import org.kuali.rice.krms.api.repository.RuleManagementService;
24 import org.kuali.rice.krms.api.repository.agenda.AgendaDefinition;
25 import org.kuali.rice.krms.api.repository.agenda.AgendaItemDefinition;
26 import org.kuali.rice.krms.api.repository.language.NaturalLanguageTemplate;
27 import org.kuali.rice.krms.api.repository.language.NaturalLanguageUsage;
28 import org.kuali.rice.krms.api.repository.proposition.PropositionDefinition;
29 import org.kuali.rice.krms.api.repository.reference.ReferenceObjectBinding;
30 import org.kuali.rice.krms.api.repository.rule.RuleDefinition;
31
32 import javax.jws.WebParam;
33 import java.util.ArrayList;
34 import java.util.Collections;
35 import java.util.LinkedList;
36 import java.util.List;
37 import java.util.Set;
38
39 import static org.kuali.rice.core.api.criteria.PredicateFactory.in;
40
41
42
43
44
45
46
47 public class RuleManagementServiceImpl extends RuleRepositoryServiceImpl implements RuleManagementService {
48
49 ReferenceObjectBindingBoServiceImpl referenceObjectBindingBoServiceImpl = new ReferenceObjectBindingBoServiceImpl();
50 AgendaBoServiceImpl agendaBoServiceImpl = new AgendaBoServiceImpl();
51
52 RuleBoServiceImpl ruleBoServiceImpl = new RuleBoServiceImpl();
53 PropositionBoServiceImpl propositionBoServiceImpl = new PropositionBoServiceImpl();
54 NaturalLanguageUsageBoServiceImpl naturalLanguageUsageBoService = new NaturalLanguageUsageBoServiceImpl();
55 NaturalLanguageTemplateBoServiceImpl naturalLanguageTemplateBoService = new NaturalLanguageTemplateBoServiceImpl();
56
57 public void setReferenceObjectBindingBoServiceImpl(
58 ReferenceObjectBindingBoServiceImpl referenceObjectBindingBoServiceImpl) {
59 this.referenceObjectBindingBoServiceImpl = referenceObjectBindingBoServiceImpl;
60 }
61
62 public void setAgendaBoServiceImpl(AgendaBoServiceImpl agendaBoServiceImpl) {
63 this.agendaBoServiceImpl = agendaBoServiceImpl;
64 }
65
66 public void setRuleBoServiceImpl(RuleBoServiceImpl ruleBoServiceImpl) {
67 this.ruleBoServiceImpl = ruleBoServiceImpl;
68 }
69
70 public void setPropositionBoServiceImpl(PropositionBoServiceImpl propositionBoServiceImpl) {
71 this.propositionBoServiceImpl = propositionBoServiceImpl;
72 }
73
74 public void setNaturalLanguageUsageBoService(NaturalLanguageUsageBoServiceImpl naturalLanguageUsageBoService) {
75 this.naturalLanguageUsageBoService = naturalLanguageUsageBoService;
76 }
77
78 public void setNaturalLanguageTemplateBoService(
79 NaturalLanguageTemplateBoServiceImpl naturalLanguageTemplateBoService) {
80 this.naturalLanguageTemplateBoService = naturalLanguageTemplateBoService;
81 }
82
83 @Override
84 public ReferenceObjectBinding createReferenceObjectBinding(@WebParam(
85 name = "referenceObjectDefinition") ReferenceObjectBinding referenceObjectDefinition) throws RiceIllegalArgumentException {
86 return referenceObjectBindingBoServiceImpl.createReferenceObjectBinding(referenceObjectDefinition);
87 }
88
89 @Override
90 public ReferenceObjectBinding getReferenceObjectBinding(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
91 return referenceObjectBindingBoServiceImpl.getReferenceObjectBinding(id);
92 }
93
94 @Override
95 public List<ReferenceObjectBinding> getReferenceObjectBindings(
96 @WebParam(name = "ids") List<String> ids) throws RiceIllegalArgumentException {
97 if (ids == null) throw new IllegalArgumentException("reference binding object ids must not be null");
98
99
100 List<ReferenceObjectBindingBo> bos = null;
101 if (ids.size() == 0) {
102 bos = Collections.emptyList();
103 } else {
104 QueryByCriteria.Builder qBuilder = QueryByCriteria.Builder.create();
105 List<Predicate> pList = new ArrayList<Predicate>();
106 qBuilder.setPredicates(in("id", ids.toArray()));
107 GenericQueryResults<ReferenceObjectBindingBo> results = getCriteriaLookupService().lookup(ReferenceObjectBindingBo.class, qBuilder.build());
108
109 bos = results.getResults();
110 }
111
112
113 List<ReferenceObjectBinding> bindings = new LinkedList<ReferenceObjectBinding>();
114 for (ReferenceObjectBindingBo bo : bos) {
115 ReferenceObjectBinding binding = ReferenceObjectBindingBo.to(bo);
116 bindings.add(binding);
117 }
118 return Collections.unmodifiableList(bindings);
119 }
120
121
122 public List<ReferenceObjectBinding> findReferenceObjectBindingsByReferenceDiscriminatorType(@WebParam(
123 name = "referenceObjectReferenceDiscriminatorType") String referenceObjectReferenceDiscriminatorType) throws RiceIllegalArgumentException {
124 return referenceObjectBindingBoServiceImpl.findReferenceObjectBindingsByReferenceDiscriminatorType(referenceObjectReferenceDiscriminatorType);
125 }
126
127
128 public List<ReferenceObjectBinding> findReferenceObjectBindingsByKrmsDiscriminatorType(@WebParam(
129 name = "referenceObjectKrmsDiscriminatorType") String referenceObjectKrmsDiscriminatorType) throws RiceIllegalArgumentException {
130 return referenceObjectBindingBoServiceImpl.findReferenceObjectBindingsByKrmsDiscriminatorType(referenceObjectKrmsDiscriminatorType);
131 }
132
133
134 public List<ReferenceObjectBinding> findReferenceObjectBindingsByKrmsObject(
135 @WebParam(name = "krmsObjectId") String krmsObjectId) throws RiceIllegalArgumentException {
136 return referenceObjectBindingBoServiceImpl.findReferenceObjectBindingsByKrmsObject(krmsObjectId);
137 }
138
139 @Override
140 public void updateReferenceObjectBinding(
141 ReferenceObjectBinding referenceObjectBindingDefinition) throws RiceIllegalArgumentException {
142 referenceObjectBindingBoServiceImpl.updateReferenceObjectBinding(referenceObjectBindingDefinition);
143 }
144
145 @Override
146 public void deleteReferenceObjectBinding(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
147 referenceObjectBindingBoServiceImpl.deleteReferenceObjectBinding(id);
148 }
149
150 @Override
151 public List<String> findReferenceObjectBindingIds(
152 @WebParam(name = "query") QueryByCriteria queryByCriteria) throws RiceIllegalArgumentException {
153 return referenceObjectBindingBoServiceImpl.findReferenceObjectBindingIds(queryByCriteria);
154 }
155
156 @Override
157 public AgendaDefinition createAgenda(@WebParam(
158 name = "AgendaDefinition") AgendaDefinition agendaDefinition) throws RiceIllegalArgumentException {
159 return agendaBoServiceImpl.createAgenda(agendaDefinition);
160 }
161
162 @Override
163 public AgendaDefinition getAgenda(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
164 return agendaBoServiceImpl.getAgendaByAgendaId(id);
165 }
166
167 @Override
168 public List<AgendaDefinition> getAgendasByContext(
169 @WebParam(name = "contextId") String contextId) throws RiceIllegalArgumentException {
170 return agendaBoServiceImpl.getAgendasByContextId(contextId);
171 }
172
173 @Override
174 public void updateAgenda(@WebParam(
175 name = "agendaDefinition") AgendaDefinition agendaDefinition) throws RiceIllegalArgumentException {
176 agendaBoServiceImpl.updateAgenda(agendaDefinition);
177 }
178
179 @Override
180 public void deleteAgenda(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
181 agendaBoServiceImpl.deleteAgenda(id);
182 }
183
184 @Override
185 public AgendaItemDefinition createAgendaItem(@WebParam(
186 name = "AgendaItemDefinition") AgendaItemDefinition agendaItemDefinition) throws RiceIllegalArgumentException {
187 return agendaBoServiceImpl.createAgendaItem(agendaItemDefinition);
188 }
189
190 @Override
191 public AgendaItemDefinition getAgendaItem(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
192 return agendaBoServiceImpl.getAgendaItemById(id);
193 }
194
195 @Override
196 public List<AgendaDefinition> getAgendasByType(
197 @WebParam(name = "typeId") String typeId) throws RiceIllegalArgumentException {
198 return agendaBoServiceImpl.getAgendasByType(typeId);
199 }
200
201 @Override
202 public List<AgendaDefinition> getAgendasByTypeAndContext(@WebParam(name = "typeId") String typeId,
203 @WebParam(name = "contextId") String contextId) throws RiceIllegalArgumentException {
204 return agendaBoServiceImpl.getAgendasByTypeAndContext(typeId, contextId);
205 }
206
207 @Override
208 public List<AgendaItemDefinition> getAgendaItemsByType(
209 @WebParam(name = "typeId") String typeId) throws RiceIllegalArgumentException {
210 return agendaBoServiceImpl.getAgendaItemsByType(typeId);
211 }
212
213 @Override
214 public List<AgendaItemDefinition> getAgendaItemsByContext(
215 @WebParam(name = "contextId") String contextId) throws RiceIllegalArgumentException {
216 return agendaBoServiceImpl.getAgendaItemsByContext(contextId);
217 }
218
219 @Override
220 public List<AgendaItemDefinition> getAgendaItemsByTypeAndContext(@WebParam(name = "typeId") String typeId,
221 @WebParam(name = "contextId") String contextId) throws RiceIllegalArgumentException {
222 return agendaBoServiceImpl.getAgendaItemsByTypeAndContext(typeId, contextId);
223 }
224
225 @Override
226 public void deleteAgendaItem(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
227 agendaBoServiceImpl.deleteAgendaItem(id);
228 }
229
230 @Override
231 public void updateAgendaItem(@WebParam(
232 name = "agendaItemDefinition") AgendaItemDefinition agendaItemDefinition) throws RiceIllegalArgumentException {
233 agendaBoServiceImpl.updateAgendaItem(agendaItemDefinition);
234 }
235
236 @Override
237 public RuleDefinition createRule(
238 @WebParam(name = "ruleDefinition") RuleDefinition ruleDefinition) throws RiceIllegalArgumentException {
239 return ruleBoServiceImpl.createRule(ruleDefinition);
240 }
241
242 @Override
243 public void updateRule(
244 @WebParam(name = "ruleDefinition") RuleDefinition ruleDefinition) throws RiceIllegalArgumentException {
245 ruleBoServiceImpl.updateRule(ruleDefinition);
246 }
247
248 @Override
249 public void deleteRule(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
250 ruleBoServiceImpl.deleteRule(id);
251 }
252
253 @Override
254 public PropositionDefinition createProposition(@WebParam(
255 name = "propositionDefinition") PropositionDefinition propositionDefinition) throws RiceIllegalArgumentException {
256 return propositionBoServiceImpl.createProposition(propositionDefinition);
257 }
258
259 @Override
260 public PropositionDefinition getProposition(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
261 return propositionBoServiceImpl.getPropositionById(id);
262 }
263
264 @Override
265 public Set<PropositionDefinition> getPropositionsByType(
266 @WebParam(name = "typeId") String typeId) throws RiceIllegalArgumentException {
267 return propositionBoServiceImpl.getPropositionsByType(typeId);
268 }
269
270 @Override
271 public Set<PropositionDefinition> getPropositionsByRule(
272 @WebParam(name = "ruleId") String ruleId) throws RiceIllegalArgumentException {
273 return propositionBoServiceImpl.getPropositionsByRule(ruleId);
274 }
275
276 @Override
277 public void updateProposition(@WebParam(
278 name = "propositionDefinition") PropositionDefinition propositionDefinition) throws RiceIllegalArgumentException {
279 propositionBoServiceImpl.updateProposition(propositionDefinition);
280 }
281
282 @Override
283 public void deleteProposition(@WebParam(name = "id") String id) throws RiceIllegalArgumentException {
284 propositionBoServiceImpl.deleteProposition(id);
285 }
286
287 @Override
288 public NaturalLanguageUsage createNaturalLanguageUsage(@WebParam(
289 name = "naturalLanguageUsage") NaturalLanguageUsage naturalLanguageUsage) throws RiceIllegalArgumentException {
290 return naturalLanguageUsageBoService.createNaturalLanguageUsage(naturalLanguageUsage);
291 }
292
293 @Override
294 public NaturalLanguageUsage getNaturalLanguageUsage(
295 @WebParam(name = "id") String id) throws RiceIllegalArgumentException {
296 return naturalLanguageUsageBoService.getNaturalLanguageUsage(id);
297 }
298
299 @Override
300 public void updateNaturalLanguageUsage(@WebParam(
301 name = "naturalLanguageUsage") NaturalLanguageUsage naturalLanguageUsage) throws RiceIllegalArgumentException {
302 naturalLanguageUsageBoService.updateNaturalLanguageUsage(naturalLanguageUsage);
303 }
304
305 @Override
306 public void deleteNaturalLanguageUsageType(@WebParam(
307 name = "naturalLanguageUsageId") String naturalLanguageUsageId) throws RiceIllegalArgumentException {
308 naturalLanguageUsageBoService.deleteNaturalLanguageUsage(naturalLanguageUsageId);
309 }
310
311 @Override
312 public String getNaturalLanguageForType(@WebParam(name = "naturalLanguageUsageId") String naturalLanguageUsageId,
313 @WebParam(name = "typeId") String typeId, @WebParam(name = "krmsObjectId") String krmsObjectId,
314 @WebParam(name = "languageCode") String languageCode) throws RiceIllegalArgumentException {
315 NaturalLanguageTemplate naturalLanguageTemplate = naturalLanguageTemplateBoService.findNaturalLanguageTemplateByLanguageCodeTypeIdAndNluId(languageCode, typeId, naturalLanguageUsageId);
316 return naturalLanguageTemplateBoService.template(naturalLanguageTemplate);
317 }
318
319 @Override
320 public Set<NaturalLanguageUsage> getNaturalLanguageUsages() {
321 return null;
322 }
323
324
325
326
327
328
329
330 @Override
331 public void setBusinessObjectService(final BusinessObjectService businessObjectService) {
332 super.setBusinessObjectService(businessObjectService);
333 referenceObjectBindingBoServiceImpl.setBusinessObjectService(businessObjectService);
334 agendaBoServiceImpl.setBusinessObjectService(businessObjectService);
335 ruleBoServiceImpl.setBusinessObjectService(businessObjectService);
336 propositionBoServiceImpl.setBusinessObjectService(businessObjectService);
337 naturalLanguageUsageBoService.setBusinessObjectService(businessObjectService);
338 naturalLanguageTemplateBoService.setBusinessObjectService(businessObjectService);
339 }
340 }