Source:
public Object queryFilteredWithBuilder(String queryName, String mapper, String builder, Integer page, Integer pageSize, String payload, String marshallingType) { Map<String, String> columnMapping = null; AdvancedQueryContext queryContext = new AdvancedQueryContext(buildQueryContext(page, pageSize)); Map<String, Object> queryParameters = new HashMap<String, Object>(); if (payload != null && !payload.isEmpty()) { logger.debug("About to unmarshal query params from payload: '{}'", payload); queryParameters = marshallerHelper.unmarshal(payload, marshallingType, Map.class); String orderByClause = (String) queryParameters.remove(KieServerConstants.QUERY_ORDER_BY_CLAUSE); columnMapping = (Map<String, String>) queryParameters.remove(KieServerConstants.QUERY_COLUMN_MAPPING); if (orderByClause != null) { queryContext.setOrderByClause(orderByClause); } } QueryResultMapper<?> resultMapper = QueryMapperRegistry.get().mapperFor(mapper, columnMapping); QueryParamBuilderFactory paramBuilderFactory = QueryParamBuilderManager.get().find(builder); if (paramBuilderFactory == null) { throw new RuntimeException("No query param builder found for " + builder); } logger.debug("About to perform query '{}' with page and page size {}", queryName, page, pageSize); Object result = queryService.query(queryName, resultMapper, queryContext, paramBuilderFactory.newInstance(queryParameters)); logger.debug("Result returned from the query mapped with {}", result, resultMapper); return transform(result, resultMapper); }

Target:
public Object queryFilteredWithBuilder(String queryName, String mapper, String builder, Integer page, Integer pageSize, String payload, String marshallingType) { Map<String, String> columnMapping = null; QueryContext queryContext = buildQueryContext(page, pageSize); Map<String, Object> queryParameters = new HashMap<String, Object>(); String orderBy = null; Boolean ascending = null; String orderByClause = null; if (payload != null && !payload.isEmpty()) { logger.debug("About to unmarshal query params from payload: '{}'", payload); queryParameters = marshallerHelper.unmarshal(payload, marshallingType, Map.class); orderBy = (String) queryParameters.remove(KieServerConstants.QUERY_ORDER_BY); ascending = (Boolean) queryParameters.remove(KieServerConstants.QUERY_ASCENDING); orderByClause = (String) queryParameters.remove(KieServerConstants.QUERY_ORDER_BY_CLAUSE); columnMapping = (Map<String, String>) queryParameters.remove(KieServerConstants.QUERY_COLUMN_MAPPING); } QueryResultMapper<?> resultMapper = QueryMapperRegistry.get().mapperFor(mapper, columnMapping); QueryParamBuilderFactory paramBuilderFactory = QueryParamBuilderManager.get().find(builder); if (paramBuilderFactory == null) { throw new RuntimeException("No query param builder found for " + builder); } if (orderByClause != null) { queryContext = new AdvancedQueryContext(queryContext, orderByClause); } else { if (orderBy != null) { queryContext.setOrderBy(orderBy); } if (ascending != null) { queryContext.setAscending(ascending); } } logger.debug("About to perform query '{}' with page and page size {}", queryName, page, pageSize); Object result = queryService.query(queryName, resultMapper, queryContext, paramBuilderFactory.newInstance(queryParameters)); logger.debug("Result returned from the query mapped with {}", result, resultMapper); return transform(result, resultMapper); }