use of org.jbpm.kie.services.impl.query.SqlQueryDefinition in project jbpm by kiegroup.
the class QueryServiceImplTest method testGetProcessInstancesWithRawMapper.
@Test
public void testGetProcessInstancesWithRawMapper() {
query = new SqlQueryDefinition("getAllProcessInstances", dataSourceJNDIname);
query.setExpression("select * from processinstancelog");
queryService.registerQuery(query);
List<QueryDefinition> queries = queryService.getQueries(new QueryContext());
assertNotNull(queries);
assertEquals(1, queries.size());
QueryDefinition registeredQuery = queries.get(0);
assertNotNull(registeredQuery);
assertEquals(query.getName(), registeredQuery.getName());
assertEquals(query.getSource(), registeredQuery.getSource());
assertEquals(query.getExpression(), registeredQuery.getExpression());
assertEquals(query.getTarget(), registeredQuery.getTarget());
registeredQuery = queryService.getQuery(query.getName());
assertNotNull(registeredQuery);
assertEquals(query.getName(), registeredQuery.getName());
assertEquals(query.getSource(), registeredQuery.getSource());
assertEquals(query.getExpression(), registeredQuery.getExpression());
assertEquals(query.getTarget(), registeredQuery.getTarget());
List<List<Object>> instances = queryService.query(query.getName(), RawListQueryMapper.get(), new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
instances = queryService.query(query.getName(), RawListQueryMapper.get(), new QueryContext());
assertNotNull(instances);
assertEquals(1, instances.size());
List<Object> firstRow = instances.get(0);
assertNotNull(firstRow);
assertEquals(18, firstRow.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.jbpm.kie.services.impl.query.SqlQueryDefinition in project jbpm by kiegroup.
the class QueryServiceImplTest method testGetProcessInstancesByState.
@Test
public void testGetProcessInstancesByState() {
query = new SqlQueryDefinition("getAllProcessInstances", dataSourceJNDIname);
query.setExpression("select * from processinstancelog");
queryService.registerQuery(query);
Collection<ProcessInstanceDesc> instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext());
assertNotNull(instances);
assertEquals(0, instances.size());
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
// search for aborted only
instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3));
assertNotNull(instances);
assertEquals(0, instances.size());
// aborted and active
instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3, 1));
assertNotNull(instances);
assertEquals(1, instances.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
// aborted only
instances = queryService.query(query.getName(), ProcessInstanceQueryMapper.get(), new QueryContext(), QueryParam.equalsTo(COLUMN_STATUS, 3));
assertNotNull(instances);
assertEquals(1, instances.size());
assertEquals(3, (int) instances.iterator().next().getState());
}
use of org.jbpm.kie.services.impl.query.SqlQueryDefinition in project jbpm by kiegroup.
the class QueryDefinitionEntity method toQueryDefinition.
public QueryDefinition toQueryDefinition() {
SqlQueryDefinition queryDefinition = new SqlQueryDefinition(name, source);
queryDefinition.setExpression(expression);
queryDefinition.setTarget(Target.valueOf(target));
return queryDefinition;
}
use of org.jbpm.kie.services.impl.query.SqlQueryDefinition in project jbpm by kiegroup.
the class QueryServiceEJBIntegrationTest method testGetTaskInstances.
@Test
public void testGetTaskInstances() {
query = new SqlQueryDefinition("getAllTaskInstances", "java:jboss/datasources/ExampleDS");
query.setExpression("select ti.* from AuditTaskImpl ti ");
queryService.registerQuery(query);
Map<String, Object> params = new HashMap<String, Object>();
params.put("approval_document", "initial content");
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
assertNotNull(processInstanceId);
List<UserTaskInstanceDesc> taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext());
assertNotNull(taskInstanceLogs);
assertEquals(1, taskInstanceLogs.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.jbpm.kie.services.impl.query.SqlQueryDefinition in project jbpm by kiegroup.
the class QueryServiceEJBIntegrationTest method testGetTaskInstancesAsPotOwners.
@Test
public void testGetTaskInstancesAsPotOwners() {
query = new SqlQueryDefinition("getMyTaskInstances", "java:jboss/datasources/ExampleDS", Target.PO_TASK);
query.setExpression("select ti.*, oe.id OEID from AuditTaskImpl ti," + "PeopleAssignments_PotOwners po, " + "OrganizationalEntity oe " + "where ti.taskId = po.task_id and po.entity_id = oe.id ");
queryService.registerQuery(query);
List<QueryDefinition> queries = queryService.getQueries(new QueryContext());
assertNotNull(queries);
assertEquals(1, queries.size());
QueryDefinition registeredQuery = queries.get(0);
assertNotNull(registeredQuery);
assertEquals(query.getName(), registeredQuery.getName());
assertEquals(query.getSource(), registeredQuery.getSource());
assertEquals(query.getExpression(), registeredQuery.getExpression());
assertEquals(query.getTarget(), registeredQuery.getTarget());
registeredQuery = queryService.getQuery(query.getName());
assertNotNull(registeredQuery);
assertEquals(query.getName(), registeredQuery.getName());
assertEquals(query.getSource(), registeredQuery.getSource());
assertEquals(query.getExpression(), registeredQuery.getExpression());
assertEquals(query.getTarget(), registeredQuery.getTarget());
Map<String, Object> params = new HashMap<String, Object>();
params.put("approval_document", "initial content");
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument", params);
assertNotNull(processInstanceId);
identityProvider.setName("notvalid");
List<UserTaskInstanceDesc> taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext());
assertNotNull(taskInstanceLogs);
assertEquals(0, taskInstanceLogs.size());
identityProvider.setName("salaboy");
taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext());
assertNotNull(taskInstanceLogs);
assertEquals(1, taskInstanceLogs.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
Aggregations