Downloads Documentation Community Contribute Demo






Show Sidebar
Login | Register
Show
Ignore:
Timestamp:
02/29/08 19:16:14 (10 months ago)
Author:
tmdugan
Message:

-- dss

* added processPackagePrefix method to Util class

* added defaultPackagePrefix processing to load rule. If a rule token cannot be loaded as passed or from the dynamic rule directory the default package prefix is checked

* fixed an error when checking module class loaders for loaded classes in CompilingClassLoader

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • openmrs-modules/dss/src/org/openmrs/module/dss/impl/DssServiceImpl.java

    r3386 r3513  
    1010import org.openmrs.Patient; 
    1111import org.openmrs.api.APIException; 
     12import org.openmrs.api.AdministrationService; 
    1213import org.openmrs.api.context.Context; 
    1314import org.openmrs.logic.LogicService; 
     
    1819import org.openmrs.module.dss.hibernateBeans.Rule; 
    1920import org.openmrs.module.dss.service.DssService; 
     21import org.openmrs.module.dss.util.Util; 
    2022import org.springframework.transaction.annotation.Transactional; 
    2123 
     
    5254         
    5355        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); 
    5760        } 
    5861         
    5962        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); 
    6367                String reply = ""; 
    6468                 
     
    7882        } 
    7983         
    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) 
    8692        { 
    8793                ArrayList<Rule> ruleList = new ArrayList<Rule>(); 
     
    8995                 
    9096                ArrayList<Result> results =  
    91                         this.runRules(p, ruleList, logicService); 
     97                        this.runRules(p, ruleList, logicService,defaultPackagePrefix); 
    9298                 
    9399                if(results != null && results.size()>0) 
     
    99105        } 
    100106         
    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); 
    104112        } 
    105113         
    106114        public ArrayList<Result> runRules(Patient p, 
    107                         ArrayList<Rule> ruleList,LogicService logicSvc) 
     115                        ArrayList<Rule> ruleList,LogicService logicSvc, 
     116                        String defaultRulePrefix) 
    108117        { 
    109118                ArrayList<Result> results = new ArrayList<Result>(); 
     
    122131                                try 
    123132                                { 
    124                                         this.loadRule(ruleName); 
     133                                        this.loadRule(ruleName,defaultRulePrefix); 
    125134                                } catch (Exception e1) 
    126135                                { 
     
    156165        } 
    157166         
    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 
    159173        { 
    160174                // Create a CompilingClassLoader 
    161175                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                 
    162184                // Load the main class through our CCL 
    163185 
    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                 
    166199                if (clas == null) 
    167200                {