1 package org.kuali.ole.deliver.keyvalue;
2
3 import org.kuali.ole.OLEConstants;
4 import org.kuali.ole.deliver.drools.DroolsKieEngine;
5 import org.kuali.rice.core.api.util.ConcreteKeyValue;
6 import org.kuali.rice.core.api.util.KeyValue;
7 import org.kuali.rice.krad.keyvalues.KeyValuesBase;
8 import org.kuali.rice.krad.service.KRADServiceLocator;
9 import org.kuali.rice.krms.impl.repository.RuleBo;
10
11 import java.util.*;
12
13
14
15
16 public class OleRuleKeyValueFinder extends KeyValuesBase {
17
18
19
20
21
22 @Override
23 public List getKeyValues() {
24 List<String> agendaGroups = new ArrayList<>();
25 agendaGroups.add("checkout validation");
26 agendaGroups.add("renewal validation");
27 List<String> allLoadedRules = DroolsKieEngine.getInstance().getRulesByAgendaGroup(agendaGroups);
28
29 List<KeyValue> keyValues = new ArrayList<KeyValue>();
30
31 List<ConcreteKeyValue> concreteKeyValues = new ArrayList<ConcreteKeyValue>();
32 keyValues.add(new ConcreteKeyValue("", ""));
33 for (Iterator<String> iterator = allLoadedRules.iterator(); iterator.hasNext(); ) {
34 String ruleName = iterator.next();
35 concreteKeyValues.add(new ConcreteKeyValue(ruleName, ruleName));
36 }
37 concreteKeyValues.add(new ConcreteKeyValue(OLEConstants.NO_CIRC_POLICY_FOUND, OLEConstants.NO_CIRC_POLICY_FOUND));
38 Collections.sort(concreteKeyValues);
39 keyValues.addAll(concreteKeyValues);
40 return keyValues;
41 }
42 }