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);
}
Aggregations