- Timestamp:
- 02/29/08 19:16:14 (10 months ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
openmrs-modules/dss/src/org/openmrs/module/dss/impl/DssServiceImpl.java
r3386 r3513 10 10 import org.openmrs.Patient; 11 11 import org.openmrs.api.APIException; 12 import org.openmrs.api.AdministrationService; 12 13 import org.openmrs.api.context.Context; 13 14 import org.openmrs.logic.LogicService; … … 18 19 import org.openmrs.module.dss.hibernateBeans.Rule; 19 20 import org.openmrs.module.dss.service.DssService; 21 import org.openmrs.module.dss.util.Util; 20 22 import org.springframework.transaction.annotation.Transactional; 21 23 … … 52 54 53 55 public String runRulesAsString(Patient p, 54 ArrayList<Rule> ruleList) 55 { 56 return this.runRulesAsString(p, ruleList, Context.getLogicService()); 56 ArrayList<Rule> ruleList,String defaultPackagePrefix) 57 { 58 return this.runRulesAsString(p, ruleList, 59 Context.getLogicService(),defaultPackagePrefix); 57 60 } 58 61 59 62 public String runRulesAsString(Patient p, 60 ArrayList<Rule> ruleList, LogicService logicService) 61 { 62 ArrayList<Result> results = this.runRules(p, ruleList); 63 ArrayList<Rule> ruleList, LogicService logicService, 64 String defaultPackagePrefix) 65 { 66 ArrayList<Result> results = this.runRules(p, ruleList,defaultPackagePrefix); 63 67 String reply = ""; 64 68 … … 78 82 } 79 83 80 public Result runRule(Patient p, Rule rule) 81 { 82 return this.runRule(p, rule, Context.getLogicService()); 83 } 84 85 public Result runRule(Patient p, Rule rule, LogicService logicService) 84 public Result runRule(Patient p, Rule rule,String defaultPackagePrefix) 85 { 86 return this.runRule(p, rule, 87 Context.getLogicService(),defaultPackagePrefix); 88 } 89 90 public Result runRule(Patient p, Rule rule, 91 LogicService logicService, String defaultPackagePrefix) 86 92 { 87 93 ArrayList<Rule> ruleList = new ArrayList<Rule>(); … … 89 95 90 96 ArrayList<Result> results = 91 this.runRules(p, ruleList, logicService );97 this.runRules(p, ruleList, logicService,defaultPackagePrefix); 92 98 93 99 if(results != null && results.size()>0) … … 99 105 } 100 106 101 public ArrayList<Result> runRules(Patient p, ArrayList<Rule> ruleList) 102 { 103 return this.runRules(p, ruleList, Context.getLogicService()); 107 public ArrayList<Result> runRules(Patient p, 108 ArrayList<Rule> ruleList, String defaultPackagePrefix) 109 { 110 return this.runRules(p, ruleList, Context.getLogicService(), 111 defaultPackagePrefix); 104 112 } 105 113 106 114 public ArrayList<Result> runRules(Patient p, 107 ArrayList<Rule> ruleList,LogicService logicSvc) 115 ArrayList<Rule> ruleList,LogicService logicSvc, 116 String defaultRulePrefix) 108 117 { 109 118 ArrayList<Result> results = new ArrayList<Result>(); … … 122 131 try 123 132 { 124 this.loadRule(ruleName );133 this.loadRule(ruleName,defaultRulePrefix); 125 134 } catch (Exception e1) 126 135 { … … 156 165 } 157 166 158 private void loadRule(String rule) throws Exception 167 public void loadRule(String rule) throws Exception 168 { 169 this.loadRule(rule,null); 170 } 171 172 public void loadRule(String rule, String defaultPackagePrefix) throws Exception 159 173 { 160 174 // Create a CompilingClassLoader 161 175 CompilingClassLoader ccl = new CompilingClassLoader(); 176 177 AdministrationService adminService = 178 Context.getAdministrationService(); 179 String rulePackagePrefix = Util.processPackagePrefix( 180 adminService.getGlobalProperty("dss.rulePackagePrefix")); 181 182 Class clas = null; 183 162 184 // Load the main class through our CCL 163 185 164 Class clas = ccl.loadClass(rule); 165 186 if(!rule.contains(rulePackagePrefix)) 187 { 188 clas = ccl.loadClass(rulePackagePrefix+rule); 189 }else 190 { 191 clas = ccl.loadClass(rule); 192 } 193 194 if (clas == null&&defaultPackagePrefix!=null) 195 { 196 clas = ccl.loadClass(defaultPackagePrefix+rule); 197 } 198 166 199 if (clas == null) 167 200 {