1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package org.kuali.rice.kew.impl.rule;
17
18 import org.apache.commons.lang.StringUtils;
19 import org.apache.log4j.Logger;
20 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
21 import org.kuali.rice.kew.api.rule.Rule;
22 import org.kuali.rice.kew.api.rule.RuleReportCriteria;
23 import org.kuali.rice.kew.api.rule.RuleService;
24 import org.kuali.rice.kew.rule.RuleBaseValues;
25 import org.kuali.rice.kew.service.KEWServiceLocator;
26
27 import java.util.ArrayList;
28 import java.util.Collection;
29 import java.util.List;
30
31
32
33
34
35
36 public class RuleServiceImpl implements RuleService {
37 private static final Logger LOG = Logger.getLogger(RuleServiceImpl.class);
38
39 @Override
40 public List<Rule> ruleReport(RuleReportCriteria ruleReportCriteria) {
41 incomingParamCheck(ruleReportCriteria, "ruleReportCriteria");
42 if ( LOG.isDebugEnabled() ) {
43 LOG.debug("Executing rule report [responsibleUser=" + ruleReportCriteria.getResponsiblePrincipalId() + ", responsibleWorkgroup=" +
44 ruleReportCriteria.getResponsibleGroupId() + "]");
45 }
46 Collection<RuleBaseValues> rulesFound = KEWServiceLocator.getRuleService().searchByTemplate(
47 ruleReportCriteria.getDocumentTypeName(), ruleReportCriteria.getRuleTemplateName(),
48 ruleReportCriteria.getRuleDescription(), ruleReportCriteria.getResponsibleGroupId(),
49 ruleReportCriteria.getResponsiblePrincipalId(), Boolean.valueOf(ruleReportCriteria.isConsiderGroupMembership()),
50 Boolean.valueOf(ruleReportCriteria.isIncludeDelegations()), Boolean.valueOf(ruleReportCriteria.isActive()), ruleReportCriteria.getRuleExtensions(),
51 ruleReportCriteria.getActionRequestCodes());
52 List<org.kuali.rice.kew.api.rule.Rule> returnableRules = new ArrayList<Rule>(rulesFound.size());
53 for (RuleBaseValues rule : rulesFound) {
54 returnableRules.add(RuleBaseValues.to(rule));
55 }
56 return returnableRules;
57 }
58
59 private void incomingParamCheck(Object object, String name) {
60 if (object == null) {
61 throw new RiceIllegalArgumentException(name + " was null");
62 } else if (object instanceof String
63 && StringUtils.isBlank((String) object)) {
64 throw new RiceIllegalArgumentException(name + " was blank");
65 }
66 }
67 }