use of org.jbpm.services.api.query.QueryResultMapper in project jbpm by kiegroup.
the class QueryRunCommand method execute.
public ExecutionResults execute(CommandContext ctx) {
BeanManager manager = CDIUtils.lookUpBeanManager(ctx);
String clazz = QueryService.class.getName();
try {
QueryService cdiBean = (QueryService) CDIUtils.createBean(Class.forName(clazz), manager);
logger.info("CDI bean created {}", cdiBean);
String mapperClass = (String) ctx.getData("mapper");
if (mapperClass == null) {
mapperClass = "org.jbpm.kie.services.impl.query.mapper.ProcessInstanceQueryMapper";
}
Method m = Class.forName(mapperClass).getMethod("get", new Class[0]);
QueryResultMapper<?> mapper = (QueryResultMapper<?>) m.invoke(null, new Object[0]);
Object queryR = cdiBean.query((String) ctx.getData("query"), mapper, new QueryContext());
logger.info("Result of the query is " + queryR);
} catch (Exception e) {
logger.error("Error while creating CDI bean from jbpm executor", e);
}
logger.info("Command executed on executor with data {}", ctx.getData());
ExecutionResults executionResults = new ExecutionResults();
return executionResults;
}
Aggregations