1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
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 | |
|
29 | |
|
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 | |
} |