use of org.drools.modelcompiler.builder.generator.DslMethodNames.QUERY_INVOCATION_CALL in project drools by kiegroup.
the class QueryCall method buildPattern.
@Override
public void buildPattern() {
MethodCallExpr callMethod = new MethodCallExpr(new NameExpr(queryDef), QUERY_INVOCATION_CALL);
callMethod.addArgument("" + !pattern.isQuery());
String queryName = context.getQueryName().orElseThrow(RuntimeException::new);
List<QueryParameter> parameters = packageModel.getQueryDefWithType().get(queryDef).getContext().getQueryParameters();
for (int i = 0; i < parameters.size(); i++) {
String variableName = getVariableName(i);
Expression parameter = context.getQueryParameterByName(variableName).map(qp -> (Expression) new MethodCallExpr(new NameExpr(queryName), QueryGenerator.toQueryArg(qp.getIndex()))).orElseGet(() -> context.getUnificationId(variableName).map(name -> context.getVarExpr(name)).orElseGet(() -> context.getVarExpr(variableName)));
callMethod.addArgument(parameter);
}
context.addExpression(callMethod);
}
Aggregations