use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class UserTaskInstanceQueryMapper method map.
@Override
public List<UserTaskInstanceDesc> map(Object result) {
if (result instanceof DataSet) {
DataSet dataSetResult = (DataSet) result;
List<UserTaskInstanceDesc> mappedResult = new ArrayList<UserTaskInstanceDesc>();
if (dataSetResult != null) {
for (int i = 0; i < dataSetResult.getRowCount(); i++) {
UserTaskInstanceDesc ut = buildInstance(dataSetResult, i);
mappedResult.add(ut);
}
}
return mappedResult;
}
throw new IllegalArgumentException("Unsupported result for mapping " + result);
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc 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.services.api.model.UserTaskInstanceDesc 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;
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class QueryServiceEJBIntegrationTest method testGetTaskInstancesAsBA.
@Test
public void testGetTaskInstancesAsBA() {
query = new SqlQueryDefinition("getBATaskInstances", "java:jboss/datasources/ExampleDS", Target.BA_TASK);
query.setExpression("select ti.*, oe.id OEID from AuditTaskImpl ti," + "PeopleAssignments_BAs bas, " + "OrganizationalEntity oe " + "where ti.taskId = bas.task_id and bas.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);
List<UserTaskInstanceDesc> taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext());
assertNotNull(taskInstanceLogs);
assertEquals(0, taskInstanceLogs.size());
identityProvider.setName("Administrator");
taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext());
assertNotNull(taskInstanceLogs);
assertEquals(1, taskInstanceLogs.size());
identityProvider.setName("salaboy");
identityProvider.setRoles(Arrays.asList("Administrators"));
taskInstanceLogs = queryService.query(query.getName(), UserTaskInstanceQueryMapper.get(), new QueryContext());
assertNotNull(taskInstanceLogs);
assertEquals(1, taskInstanceLogs.size());
processService.abortProcessInstance(processInstanceId);
processInstanceId = null;
}
use of org.jbpm.services.api.model.UserTaskInstanceDesc in project jbpm by kiegroup.
the class RuntimeDataServiceEJBIntegrationTest method testGetTaskById.
@Test
public void testGetTaskById() {
processInstanceId = processService.startProcess(deploymentUnit.getIdentifier(), "org.jbpm.writedocument");
assertNotNull(processInstanceId);
ProcessInstance instance = processService.getProcessInstance(processInstanceId);
assertNotNull(instance);
List<Long> taskIds = runtimeDataService.getTasksByProcessInstanceId(processInstanceId);
assertNotNull(taskIds);
assertEquals(1, taskIds.size());
Long taskId = taskIds.get(0);
UserTaskInstanceDesc userTask = runtimeDataService.getTaskById(taskId);
assertNotNull(userTask);
assertEquals(processInstanceId, userTask.getProcessInstanceId());
assertEquals("Write a Document", userTask.getName());
}
Aggregations