Search in sources :

Example 1 with PatternBuilder

use of org.drools.compiler.rule.builder.PatternBuilder in project drools by kiegroup.

the class LegacyAccumulate method build.

public void build() {
    new PatternBuilder().build(ruleBuildContext, basePattern);
    final Set<String> imports = ruleBuildContext.getPkg().getImports().keySet();
    final String packageName = ruleBuildContext.getPkg().getName();
    GeneratedClassWithPackage generatedClassWithPackage = createAllAccumulateClass(imports, packageName);
    packageModel.addGeneratedAccumulateClasses(generatedClassWithPackage);
    GeneratedClassWithPackage invokerGenerated = createInvokerClass(imports, packageName);
    packageModel.addGeneratedAccumulateClasses(invokerGenerated);
    final String typeWithPackage = String.format("%s.%s", packageName, invokerGenerated.getGeneratedClass().getName().asString());
    final ClassExpr accFunctionName = new ClassExpr(JavaParser.parseType(typeWithPackage));
    final MethodCallExpr accFunctionCall = new MethodCallExpr(null, "accFunction", nodeList(accFunctionName));
    final NameExpr bindingVariable = new NameExpr(toVar(basePattern.getIdentifier()));
    final MethodCallExpr asDSL = new MethodCallExpr(accFunctionCall, "as", nodeList(bindingVariable));
    context.addExpression(asDSL);
}
Also used : GeneratedClassWithPackage(org.drools.modelcompiler.builder.GeneratedClassWithPackage) NameExpr(org.drools.javaparser.ast.expr.NameExpr) ClassExpr(org.drools.javaparser.ast.expr.ClassExpr) PatternBuilder(org.drools.compiler.rule.builder.PatternBuilder) MethodCallExpr(org.drools.javaparser.ast.expr.MethodCallExpr)

Aggregations

PatternBuilder (org.drools.compiler.rule.builder.PatternBuilder)1 ClassExpr (org.drools.javaparser.ast.expr.ClassExpr)1 MethodCallExpr (org.drools.javaparser.ast.expr.MethodCallExpr)1 NameExpr (org.drools.javaparser.ast.expr.NameExpr)1 GeneratedClassWithPackage (org.drools.modelcompiler.builder.GeneratedClassWithPackage)1