Coverage Report - org.kuali.rice.krms.impl.type.RuleTypeServiceBase
 
Classes in this File Line Coverage Branch Coverage Complexity
RuleTypeServiceBase
0%
0/10
0%
0/6
2.667
 
 1  
 /**
 2  
  * Copyright 2005-2011 The Kuali Foundation
 3  
  *
 4  
  * Licensed under the Educational Community License, Version 2.0 (the "License");
 5  
  * you may not use this file except in compliance with the License.
 6  
  * You may obtain a copy of the License at
 7  
  *
 8  
  * http://www.opensource.org/licenses/ecl2.php
 9  
  *
 10  
  * Unless required by applicable law or agreed to in writing, software
 11  
  * distributed under the License is distributed on an "AS IS" BASIS,
 12  
  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 13  
  * See the License for the specific language governing permissions and
 14  
  * limitations under the License.
 15  
  */
 16  
 package org.kuali.rice.krms.impl.type;
 17  
 
 18  
 import org.kuali.rice.core.api.exception.RiceIllegalArgumentException;
 19  
 import org.kuali.rice.krms.api.repository.rule.RuleDefinition;
 20  
 import org.kuali.rice.krms.framework.engine.BasicRule;
 21  
 import org.kuali.rice.krms.framework.engine.Rule;
 22  
 import org.kuali.rice.krms.framework.type.RuleTypeService;
 23  
 import org.kuali.rice.krms.impl.provider.repository.RepositoryToEngineTranslator;
 24  
 import org.kuali.rice.krms.impl.repository.KrmsRepositoryServiceLocator;
 25  
 import org.kuali.rice.krms.impl.util.KRMSServiceLocatorInternal;
 26  
 
 27  
 /**
 28  
  * Base class for {@link org.kuali.rice.krms.framework.type.RuleTypeService} implementations, providing
 29  
  * boilerplate for attribute building and merging from various sources.
 30  
  */
 31  0
 public class RuleTypeServiceBase extends KrmsTypeServiceBase implements RuleTypeService {
 32  
 
 33  0
     public static final RuleTypeService defaultRuleTypeService = new RuleTypeServiceBase();
 34  
 
 35  
     private RepositoryToEngineTranslator translator;
 36  
 
 37  
     @Override
 38  
     public Rule loadRule(RuleDefinition ruleDefinition) {
 39  0
             if (ruleDefinition == null) { throw new RiceIllegalArgumentException("ruleDefinition must not be null"); }
 40  0
             if (ruleDefinition.getAttributes() == null) { throw new RiceIllegalArgumentException("ruleDefinition must not be null");}
 41  
 
 42  0
         return new BasicRule(ruleDefinition.getName(),
 43  
                 getTranslator().translatePropositionDefinition(ruleDefinition.getProposition()),
 44  
                 getTranslator().translateActionDefinitions(ruleDefinition.getActions()));
 45  
     }
 46  
 
 47  
     public RepositoryToEngineTranslator getTranslator() {
 48  0
         if (translator == null) {
 49  0
             translator = KrmsRepositoryServiceLocator.getKrmsRepositoryToEngineTranslator();
 50  
         }
 51  0
         return translator;
 52  
     }
 53  
 
 54  
     public void setTranslator(RepositoryToEngineTranslator translator) {
 55  0
         this.translator = translator;
 56  0
     }
 57  
 }