View Javadoc
1   package org.kuali.ole.deliver.drools.rules;
2   
3   import org.apache.commons.io.FileUtils;
4   import org.apache.commons.lang3.StringUtils;
5   import org.kuali.ole.deliver.bo.drools.DroolsRuleBo;
6   import org.kuali.ole.deliver.bo.drools.FinesAndLimitsBo;
7   import org.kuali.ole.deliver.drools.DroolsConstants;
8   
9   import java.io.File;
10  import java.io.IOException;
11  import java.net.URISyntaxException;
12  import java.net.URL;
13  import java.util.HashMap;
14  import java.util.Iterator;
15  import java.util.List;
16  import java.util.Map;
17  
18  /**
19   * Created by pvsubrah on 7/9/15.
20   */
21  public class PatronReplacementAmountRuleFormulator extends RuleFormulatorUtil implements RuleFormulator {
22      @Override
23      public Map formulateRuleMap(DroolsRuleBo droolsRuleBo) {
24          return super.formulateRule(droolsRuleBo);
25      }
26  
27      @Override
28      public String formulateRules(DroolsRuleBo droolsRuleBo) {
29          return "";
30      }
31  
32      @Override
33      protected String getTemplateFileName() {
34          return "general-checks/replacement-fine-amount-limit-check.txt";
35      }
36  
37      @Override
38      protected void processExtraRules(DroolsRuleBo droolsRuleBo, Map map) {
39          StringBuilder stringBuilder;
40          FinesAndLimitsBo finesAndLimitsBo = droolsRuleBo.getFinesAndLimitsBo();
41          stringBuilder = new StringBuilder();
42          Object patronReplacementAmount = finesAndLimitsBo.getLimitAmount();
43          stringBuilder.append(patronReplacementAmount);
44          map.put("replacementFineAmount", stringBuilder.toString());
45  
46          stringBuilder = new StringBuilder();
47          String borrowerTypes = finesAndLimitsBo.getBorrowerType();
48          if (StringUtils.isNotEmpty(borrowerTypes)) {
49              stringBuilder.append(processDataByDelimiter(borrowerTypes));
50              map.put("borrowerTypes", stringBuilder.toString());
51              map.put("operator", "in");
52          }
53      }
54  
55      @Override
56      public boolean isInterested(String value) {
57         return false;
58      }
59  
60      @Override
61      public boolean isInterestedForParameters(String value) {
62          return value.equals(DroolsConstants.GENERAL_CHECK_RULE_TYPE.REPLACEMENT_FEE_AMOUNT);
63      }
64  
65      @Override
66      public boolean isInterestedForThenCustomRules(String value) {
67          return false;
68      }
69  }