@Test public void testLoadDefaultQueryDefinitions() { Date today = new Date(); KieServerEnvironment.setServerId(UUID.randomUUID().toString()); QueryService queryService = Mockito.mock(QueryService.class); KieServerRegistry context = new KieServerRegistryImpl(); context.registerStateRepository(new KieServerStateFileRepository(new File("target"))); JbpmKieServerExtension extension = new JbpmKieServerExtension(); extension.setQueryService(queryService); extension.setContext(context); extension.registerDefaultQueryDefinitions(); QueryDataServiceBase queryServiceBase = new QueryDataServiceBase(queryService,context); QueryResultMapper<?> resultMapper = QueryMapperRegistry.get().mapperFor("UserTasksWithPotOwners", null); List<UserTaskInstanceWithPotOwnerDesc> result = new ArrayList<UserTaskInstanceWithPotOwnerDesc>(); UserTaskInstanceWithPotOwnerDesc resultPO = new org.jbpm.kie.services.impl.model.UserTaskInstanceWithPotOwnerDesc( "mcivantos", "mcivantos", today, today, Long.valueOf(1), "test-task", 0, Long.valueOf(1), "processId", "Reserved", "salaboy", "formName", "correlation-123", "subject", "container-1","processDescription"); result.add(resultPO); Object resultQueryBase = queryServiceBase.transform(result, resultMapper); assertNotNull(resultQueryBase); }
@SuppressWarnings({"rawtypes", "unchecked"}) protected Object transform(Object result, QueryResultMapper resultMapper) { Object actualResult = null; if (result instanceof Collection) { if (ProcessInstanceCustomDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceCustomDesc to ProcessInstanceCustomList"); actualResult = convertToProcessInstanceCustomVarsList((Collection<ProcessInstanceCustomDesc>) result); } else if (ProcessInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceWithVarsDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceWithVarsList((Collection<ProcessInstanceWithVarsDesc>) result); } else if (ProcessInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceList((Collection<ProcessInstanceDesc>) result); } else if (UserTaskInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithVarsDesc to TaskInstanceList"); actualResult = convertToTaskInstanceWithVarsList((Collection<UserTaskInstanceWithVarsDesc>) result); } else if (UserTaskInstanceWithPotOwnerDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithPotOwnerDesc to TaskInstanceList"); actualResult = convertToTaskInstanceListPO((Collection<UserTaskInstanceWithPotOwnerDesc>) result); } else if (UserTaskInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceDesc to TaskInstanceList"); actualResult = convertToTaskInstanceList((Collection<UserTaskInstanceDesc>) result); } else if (TaskSummary.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of TaskSummary to TaskSummaryList"); actualResult = convertToTaskSummaryList((Collection<TaskSummary>) result); } else if (ExecutionError.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ExecutionError to ErrorInstanceList"); actualResult = convertToErrorInstanceList((List<ExecutionError>) result); } else if (List.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of List to ArrayList"); actualResult = new ArrayList((Collection) result); }else { logger.debug("Convert not supported for custom type {}", resultMapper.getType()); actualResult = result; } logger.debug("Actual result after converting is {}", actualResult); } else { logger.debug("Result is not a collection - {}, skipping any conversion", result); actualResult = result; } return actualResult; }
QueryDataServiceBase { @SuppressWarnings({"rawtypes", "unchecked"}) protected Object transform(Object result, QueryResultMapper resultMapper) { Object actualResult = null; if (result instanceof Collection) { if (ProcessInstanceCustomDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceCustomDesc to ProcessInstanceCustomList"); actualResult = convertToProcessInstanceCustomVarsList((Collection<ProcessInstanceCustomDesc>) result); } else if (ProcessInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceWithVarsDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceWithVarsList((Collection<ProcessInstanceWithVarsDesc>) result); } else if (ProcessInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceList((Collection<ProcessInstanceDesc>) result); } else if (UserTaskInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithVarsDesc to TaskInstanceList"); actualResult = convertToTaskInstanceWithVarsList((Collection<UserTaskInstanceWithVarsDesc>) result); } else if (UserTaskInstanceWithPotOwnerDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithPotOwnerDesc to TaskInstanceList"); actualResult = convertToTaskInstanceListPO((Collection<UserTaskInstanceWithPotOwnerDesc>) result); } else if (UserTaskInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceDesc to TaskInstanceList"); actualResult = convertToTaskInstanceList((Collection<UserTaskInstanceDesc>) result); } else if (TaskSummary.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of TaskSummary to TaskSummaryList"); actualResult = convertToTaskSummaryList((Collection<TaskSummary>) result); } else if (ExecutionError.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ExecutionError to ErrorInstanceList"); actualResult = convertToErrorInstanceList((List<ExecutionError>) result); } else if (List.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of List to ArrayList"); actualResult = new ArrayList((Collection) result); }else { logger.debug("Convert not supported for custom type {}", resultMapper.getType()); actualResult = result; } logger.debug("Actual result after converting is {}", actualResult); } else { logger.debug("Result is not a collection - {}, skipping any conversion", result); actualResult = result; } return actualResult; } }
QueryDataServiceBase { @SuppressWarnings({"rawtypes", "unchecked"}) protected Object transform(Object result, QueryResultMapper resultMapper) { Object actualResult = null; if (result instanceof Collection) { if (ProcessInstanceCustomDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceCustomDesc to ProcessInstanceCustomList"); actualResult = convertToProcessInstanceCustomVarsList((Collection<ProcessInstanceCustomDesc>) result); } else if (ProcessInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceWithVarsDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceWithVarsList((Collection<ProcessInstanceWithVarsDesc>) result); } else if (ProcessInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceList((Collection<ProcessInstanceDesc>) result); } else if (UserTaskInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithVarsDesc to TaskInstanceList"); actualResult = convertToTaskInstanceWithVarsList((Collection<UserTaskInstanceWithVarsDesc>) result); } else if (UserTaskInstanceWithPotOwnerDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithPotOwnerDesc to TaskInstanceList"); actualResult = convertToTaskInstanceListPO((Collection<UserTaskInstanceWithPotOwnerDesc>) result); } else if (UserTaskInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceDesc to TaskInstanceList"); actualResult = convertToTaskInstanceList((Collection<UserTaskInstanceDesc>) result); } else if (TaskSummary.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of TaskSummary to TaskSummaryList"); actualResult = convertToTaskSummaryList((Collection<TaskSummary>) result); } else if (ExecutionError.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ExecutionError to ErrorInstanceList"); actualResult = convertToErrorInstanceList((List<ExecutionError>) result); } else if (List.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of List to ArrayList"); actualResult = new ArrayList((Collection) result); }else { logger.debug("Convert not supported for custom type {}", resultMapper.getType()); actualResult = result; } logger.debug("Actual result after converting is {}", actualResult); } else { logger.debug("Result is not a collection - {}, skipping any conversion", result); actualResult = result; } return actualResult; } QueryDataServiceBase(QueryService queryService, KieServerRegistry context); }
QueryDataServiceBase { @SuppressWarnings({"rawtypes", "unchecked"}) protected Object transform(Object result, QueryResultMapper resultMapper) { Object actualResult = null; if (result instanceof Collection) { if (ProcessInstanceCustomDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceCustomDesc to ProcessInstanceCustomList"); actualResult = convertToProcessInstanceCustomVarsList((Collection<ProcessInstanceCustomDesc>) result); } else if (ProcessInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceWithVarsDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceWithVarsList((Collection<ProcessInstanceWithVarsDesc>) result); } else if (ProcessInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceList((Collection<ProcessInstanceDesc>) result); } else if (UserTaskInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithVarsDesc to TaskInstanceList"); actualResult = convertToTaskInstanceWithVarsList((Collection<UserTaskInstanceWithVarsDesc>) result); } else if (UserTaskInstanceWithPotOwnerDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithPotOwnerDesc to TaskInstanceList"); actualResult = convertToTaskInstanceListPO((Collection<UserTaskInstanceWithPotOwnerDesc>) result); } else if (UserTaskInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceDesc to TaskInstanceList"); actualResult = convertToTaskInstanceList((Collection<UserTaskInstanceDesc>) result); } else if (TaskSummary.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of TaskSummary to TaskSummaryList"); actualResult = convertToTaskSummaryList((Collection<TaskSummary>) result); } else if (ExecutionError.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ExecutionError to ErrorInstanceList"); actualResult = convertToErrorInstanceList((List<ExecutionError>) result); } else if (List.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of List to ArrayList"); actualResult = new ArrayList((Collection) result); }else { logger.debug("Convert not supported for custom type {}", resultMapper.getType()); actualResult = result; } logger.debug("Actual result after converting is {}", actualResult); } else { logger.debug("Result is not a collection - {}, skipping any conversion", result); actualResult = result; } return actualResult; } QueryDataServiceBase(QueryService queryService, KieServerRegistry context); QueryDefinition registerQuery(String queryName, String payload, String marshallingType); QueryDefinition replaceQuery(String queryName, String payload, String marshallingType); void unregisterQuery(String uniqueQueryName); QueryDefinition getQuery(String uniqueQueryName); QueryDefinitionList getQueries(Integer page, Integer pageSize); Object query(String queryName, String mapper, String orderBy, Integer page, Integer pageSize); Object queryFiltered(String queryName, String mapper, Integer page, Integer pageSize, String payload, String marshallingType); Object queryFiltered(String containerId, String queryName, String mapper, Integer page, Integer pageSize, String payload, String marshallingType); Object queryFilteredWithBuilder(String queryName, String mapper, String builder, Integer page, Integer pageSize, String payload, String marshallingType); @SuppressWarnings("unchecked") Object queryFilteredWithBuilder(String containerId, String queryName, String mapper, String builder, Integer page, Integer pageSize, String payload, String marshallingType); }
QueryDataServiceBase { @SuppressWarnings({"rawtypes", "unchecked"}) protected Object transform(Object result, QueryResultMapper resultMapper) { Object actualResult = null; if (result instanceof Collection) { if (ProcessInstanceCustomDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceCustomDesc to ProcessInstanceCustomList"); actualResult = convertToProcessInstanceCustomVarsList((Collection<ProcessInstanceCustomDesc>) result); } else if (ProcessInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceWithVarsDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceWithVarsList((Collection<ProcessInstanceWithVarsDesc>) result); } else if (ProcessInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ProcessInstanceDesc to ProcessInstanceList"); actualResult = convertToProcessInstanceList((Collection<ProcessInstanceDesc>) result); } else if (UserTaskInstanceWithVarsDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithVarsDesc to TaskInstanceList"); actualResult = convertToTaskInstanceWithVarsList((Collection<UserTaskInstanceWithVarsDesc>) result); } else if (UserTaskInstanceWithPotOwnerDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceWithPotOwnerDesc to TaskInstanceList"); actualResult = convertToTaskInstanceListPO((Collection<UserTaskInstanceWithPotOwnerDesc>) result); } else if (UserTaskInstanceDesc.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of UserTaskInstanceDesc to TaskInstanceList"); actualResult = convertToTaskInstanceList((Collection<UserTaskInstanceDesc>) result); } else if (TaskSummary.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of TaskSummary to TaskSummaryList"); actualResult = convertToTaskSummaryList((Collection<TaskSummary>) result); } else if (ExecutionError.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of ExecutionError to ErrorInstanceList"); actualResult = convertToErrorInstanceList((List<ExecutionError>) result); } else if (List.class.isAssignableFrom(resultMapper.getType())) { logger.debug("Converting collection of List to ArrayList"); actualResult = new ArrayList((Collection) result); }else { logger.debug("Convert not supported for custom type {}", resultMapper.getType()); actualResult = result; } logger.debug("Actual result after converting is {}", actualResult); } else { logger.debug("Result is not a collection - {}, skipping any conversion", result); actualResult = result; } return actualResult; } QueryDataServiceBase(QueryService queryService, KieServerRegistry context); QueryDefinition registerQuery(String queryName, String payload, String marshallingType); QueryDefinition replaceQuery(String queryName, String payload, String marshallingType); void unregisterQuery(String uniqueQueryName); QueryDefinition getQuery(String uniqueQueryName); QueryDefinitionList getQueries(Integer page, Integer pageSize); Object query(String queryName, String mapper, String orderBy, Integer page, Integer pageSize); Object queryFiltered(String queryName, String mapper, Integer page, Integer pageSize, String payload, String marshallingType); Object queryFiltered(String containerId, String queryName, String mapper, Integer page, Integer pageSize, String payload, String marshallingType); Object queryFilteredWithBuilder(String queryName, String mapper, String builder, Integer page, Integer pageSize, String payload, String marshallingType); @SuppressWarnings("unchecked") Object queryFilteredWithBuilder(String containerId, String queryName, String mapper, String builder, Integer page, Integer pageSize, String payload, String marshallingType); static final Logger logger; }