Search in sources :

Example 1 with FlowExpressionBuilder

use of org.drools.modelcompiler.builder.generator.expression.FlowExpressionBuilder in project drools by kiegroup.

the class FlowAccumulateConstraint method buildPattern.

@Override
public void buildPattern() {
    for (BaseDescr constraint : constraintDescrs) {
        String expression = constraint.toString();
        final DrlxParseResult drlxParseResult = new ConstraintParser(context, packageModel).drlxParse(null, null, expression, false);
        drlxParseResult.accept(success -> {
            success.setSkipThisAsParam(true);
            new FlowExpressionBuilder(context).processExpression(success);
        });
    }
}
Also used : ConstraintParser(org.drools.modelcompiler.builder.generator.drlxparse.ConstraintParser) BaseDescr(org.drools.compiler.lang.descr.BaseDescr) DrlxParseResult(org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseResult) FlowExpressionBuilder(org.drools.modelcompiler.builder.generator.expression.FlowExpressionBuilder)

Example 2 with FlowExpressionBuilder

use of org.drools.modelcompiler.builder.generator.expression.FlowExpressionBuilder in project drools by kiegroup.

the class EvalVisitor method visit.

public void visit(EvalDescr descr) {
    String expression = descr.getContent().toString();
    DrlxParseResult drlxParseResult = new ConstraintParser(context, packageModel).drlxParse(null, null, expression);
    drlxParseResult.accept(drlxParseSuccess -> {
        Expression rewriteExprAsLambdaWithoutThisParam = DrlxParseUtil.generateLambdaWithoutParameters(drlxParseSuccess.getUsedDeclarations(), drlxParseSuccess.getExpr(), true);
        // rewrites the DrlxParserResult expr as directly the lambda to use
        drlxParseSuccess.setExpr(rewriteExprAsLambdaWithoutThisParam);
        drlxParseSuccess.setStatic(true);
        new FlowExpressionBuilder(context).processExpression(drlxParseSuccess);
    });
}
Also used : ConstraintParser(org.drools.modelcompiler.builder.generator.drlxparse.ConstraintParser) Expression(org.drools.javaparser.ast.expr.Expression) DrlxParseResult(org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseResult) FlowExpressionBuilder(org.drools.modelcompiler.builder.generator.expression.FlowExpressionBuilder)

Example 3 with FlowExpressionBuilder

use of org.drools.modelcompiler.builder.generator.expression.FlowExpressionBuilder in project drools by kiegroup.

the class FlowDSLSimpleConstraint method buildPattern.

@Override
public void buildPattern() {
    // need to augment the watch inside drlxParseResult with the look-ahead properties.
    drlxParseResult.addAllWatchedProperties(context.getRuleDescr().lookAheadFieldsOfIdentifier(pattern));
    drlxParseResult.addAllWatchedProperties(DrlxParseUtil.getPatternListenedProperties(pattern));
    if (pattern.isUnification()) {
        drlxParseResult.setPatternBindingUnification(true);
    }
    new FlowExpressionBuilder(context).processExpression(drlxParseResult);
}
Also used : FlowExpressionBuilder(org.drools.modelcompiler.builder.generator.expression.FlowExpressionBuilder)

Aggregations

FlowExpressionBuilder (org.drools.modelcompiler.builder.generator.expression.FlowExpressionBuilder)3 ConstraintParser (org.drools.modelcompiler.builder.generator.drlxparse.ConstraintParser)2 DrlxParseResult (org.drools.modelcompiler.builder.generator.drlxparse.DrlxParseResult)2 BaseDescr (org.drools.compiler.lang.descr.BaseDescr)1 Expression (org.drools.javaparser.ast.expr.Expression)1