Search in sources :

Example 1 with Direct

use of org.kie.api.definition.rule.Direct in project drools by kiegroup.

the class RuleBuilder method parseAnnotation.

private static void parseAnnotation(RuleBuildContext context, RuleImpl rule, RuleDescr ruleDescr, boolean enforceEager) {
    try {
        ActivationListener activationListener = ruleDescr.getTypedAnnotation(ActivationListener.class);
        if (activationListener != null) {
            rule.setActivationListener(MVELSafeHelper.getEvaluator().evalToString(activationListener.value()));
        }
        if (enforceEager) {
            rule.setEager(true);
        } else {
            Propagation propagation = ruleDescr.getTypedAnnotation(Propagation.class);
            if (propagation != null) {
                if (propagation.value() == Propagation.Type.IMMEDIATE) {
                    rule.setDataDriven(true);
                } else if (propagation.value() == Propagation.Type.EAGER) {
                    rule.setEager(true);
                }
            }
        }
        Direct direct = ruleDescr.getTypedAnnotation(Direct.class);
        if (direct != null && direct.value()) {
            rule.setActivationListener("direct");
        }
        rule.setAllMatches(ruleDescr.hasAnnotation(All.class));
    } catch (Exception e) {
        DroolsError err = new RuleBuildError(rule, context.getParentDescr(), null, e.getMessage());
        context.addError(err);
    }
}
Also used : All(org.kie.api.definition.rule.All) DroolsError(org.drools.compiler.compiler.DroolsError) Propagation(org.kie.api.definition.rule.Propagation) RuleBuildError(org.drools.compiler.compiler.RuleBuildError) ParseException(java.text.ParseException) ActivationListener(org.kie.api.definition.rule.ActivationListener) Direct(org.kie.api.definition.rule.Direct)

Aggregations

ParseException (java.text.ParseException)1 DroolsError (org.drools.compiler.compiler.DroolsError)1 RuleBuildError (org.drools.compiler.compiler.RuleBuildError)1 ActivationListener (org.kie.api.definition.rule.ActivationListener)1 All (org.kie.api.definition.rule.All)1 Direct (org.kie.api.definition.rule.Direct)1 Propagation (org.kie.api.definition.rule.Propagation)1