Search in sources :

Example 1 with MVELConsequence

use of org.drools.modelcompiler.consequence.MVELConsequence in project drools by kiegroup.

the class KiePackagesBuilder method processConsequence.

private void processConsequence(RuleContext ctx, Consequence consequence, String name) {
    if (name.equals(RuleImpl.DEFAULT_CONSEQUENCE_NAME)) {
        if ("java".equals(consequence.getLanguage())) {
            ctx.getRule().setConsequence(new LambdaConsequence(consequence, ctx));
        } else if ("mvel".equals(consequence.getLanguage())) {
            ctx.getRule().setConsequence(new MVELConsequence(consequence, ctx));
        } else {
            throw new UnsupportedOperationException("Unknown script language for consequence: " + consequence.getLanguage());
        }
    } else {
        ctx.getRule().addNamedConsequence(name, new LambdaConsequence(consequence, ctx));
    }
    Variable[] consequenceVars = consequence.getDeclarations();
    String[] requiredDeclarations = new String[consequenceVars.length];
    for (int i = 0; i < consequenceVars.length; i++) {
        requiredDeclarations[i] = consequenceVars[i].getName();
    }
    ctx.getRule().setRequiredDeclarationsForConsequence(name, requiredDeclarations);
}
Also used : LambdaConsequence(org.drools.modelcompiler.consequence.LambdaConsequence) PrototypeVariable(org.drools.model.PrototypeVariable) Variable(org.drools.model.Variable) MVELConsequence(org.drools.modelcompiler.consequence.MVELConsequence) SingleConstraint(org.drools.model.SingleConstraint) QueryNameConstraint(org.drools.core.rule.constraint.QueryNameConstraint) LambdaConstraint(org.drools.modelcompiler.constraints.LambdaConstraint) FlowDSL.entryPoint(org.drools.model.FlowDSL.entryPoint) UnificationConstraint(org.drools.modelcompiler.constraints.UnificationConstraint) EntryPoint(org.drools.model.EntryPoint) Constraint(org.drools.model.Constraint)

Aggregations

QueryNameConstraint (org.drools.core.rule.constraint.QueryNameConstraint)1 Constraint (org.drools.model.Constraint)1 EntryPoint (org.drools.model.EntryPoint)1 FlowDSL.entryPoint (org.drools.model.FlowDSL.entryPoint)1 PrototypeVariable (org.drools.model.PrototypeVariable)1 SingleConstraint (org.drools.model.SingleConstraint)1 Variable (org.drools.model.Variable)1 LambdaConsequence (org.drools.modelcompiler.consequence.LambdaConsequence)1 MVELConsequence (org.drools.modelcompiler.consequence.MVELConsequence)1 LambdaConstraint (org.drools.modelcompiler.constraints.LambdaConstraint)1 UnificationConstraint (org.drools.modelcompiler.constraints.UnificationConstraint)1