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 ItemOverdueFineAmountRuleFormulator 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/item-overdue-fine-limit.txt";
35      }
36  
37      @Override
38      protected void processExtraRules(DroolsRuleBo droolsRuleBo, Map map) {
39          FinesAndLimitsBo finesAndLimitsBo = droolsRuleBo.getFinesAndLimitsBo();
40          StringBuilder stringBuilder = new StringBuilder();
41          String borrowerTypes = droolsRuleBo.getBorrowerTypes();
42          stringBuilder.append(processDataByDelimiter(borrowerTypes));
43          map.put("borrowerTypes", stringBuilder.toString());
44          map.put("operator", "in");
45  
46  
47          stringBuilder = new StringBuilder();
48          Object patronReplacementAmountErrorMessage = droolsRuleBo.getErrorMessage();
49          stringBuilder.append("\"").append(patronReplacementAmountErrorMessage).append("\"");
50          map.put("errorMessage", stringBuilder.toString());
51  
52          stringBuilder = new StringBuilder();
53          Object patronReplacementAmount = finesAndLimitsBo.getLimitAmount();
54          stringBuilder.append(patronReplacementAmount);
55          map.put("overdueFineAmount", stringBuilder.toString());
56  
57      }
58  
59      @Override
60      public boolean isInterested(String value) {
61          return false;
62      }
63  
64      @Override
65      public boolean isInterestedForParameters(String value) {
66          return value.equals(DroolsConstants.GENERAL_CHECK_RULE_TYPE.OVERDUE_FINE_AMOUNT);
67      }
68  
69      @Override
70      public boolean isInterestedForThenCustomRules(String value) {
71          return false;
72      }
73  }