use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class ConvertUtils method convertToTaskInstanceList.
public static TaskInstanceList convertToTaskInstanceList(Collection<UserTaskInstanceDesc> instances) {
if (instances == null) {
return new TaskInstanceList(new org.kie.server.api.model.instance.TaskInstance[0]);
}
List<TaskInstance> taskInstances = new ArrayList<TaskInstance>(instances.size());
for (UserTaskInstanceDesc task : instances) {
org.kie.server.api.model.instance.TaskInstance instance = convertToTask(task);
taskInstances.add(instance);
}
return new TaskInstanceList(taskInstances);
}
use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskServiceBase method getTask.
public String getTask(String containerId, Number taskId, boolean withInput, boolean withOutput, boolean withAssignments, String marshallingType) {
containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue()));
Task task = userTaskService.getTask(containerId, taskId.longValue());
if (task == null) {
throw new TaskNotFoundException("No task found with id " + taskId);
}
TaskInstance.Builder builder = TaskInstance.builder();
builder.id(task.getId()).name(task.getName()).subject(task.getSubject()).description(task.getDescription()).priority(task.getPriority()).taskType(task.getTaskType()).formName(((InternalTask) task).getFormName()).status(task.getTaskData().getStatus().name()).actualOwner(getOrgEntityIfNotNull(task.getTaskData().getActualOwner())).createdBy(getOrgEntityIfNotNull(task.getTaskData().getCreatedBy())).createdOn(task.getTaskData().getCreatedOn()).activationTime(task.getTaskData().getActivationTime()).expirationTime(task.getTaskData().getExpirationTime()).skippable(task.getTaskData().isSkipable()).workItemId(task.getTaskData().getWorkItemId()).processInstanceId(task.getTaskData().getProcessInstanceId()).parentId(task.getTaskData().getParentId()).processId(task.getTaskData().getProcessId()).containerId(task.getTaskData().getDeploymentId());
if (Boolean.TRUE.equals(withInput)) {
Map<String, Object> variables = userTaskService.getTaskInputContentByTaskId(containerId, taskId.longValue());
builder.inputData(variables);
}
if (Boolean.TRUE.equals(withOutput)) {
Map<String, Object> variables = userTaskService.getTaskOutputContentByTaskId(containerId, taskId.longValue());
builder.outputData(variables);
}
if (Boolean.TRUE.equals(withAssignments)) {
builder.potentialOwners(orgEntityAsList(task.getPeopleAssignments().getPotentialOwners()));
builder.excludedOwners(orgEntityAsList(((InternalPeopleAssignments) task.getPeopleAssignments()).getExcludedOwners()));
builder.businessAdmins(orgEntityAsList(task.getPeopleAssignments().getBusinessAdministrators()));
}
TaskInstance taskInstance = builder.build();
logger.debug("About to marshal task '{}' representation {}", taskId, taskInstance);
String response = marshallerHelper.marshal(containerId, marshallingType, taskInstance);
return response;
}
use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class UserTaskServiceBase method update.
public void update(String containerId, Number taskId, String userId, String payload, String marshallerType) {
containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue()));
userId = getUser(userId);
logger.debug("About to unmarshal task instances from payload: '{}'", payload);
TaskInstance updatedTask = marshallerHelper.unmarshal(containerId, payload, marshallerType, TaskInstance.class);
logger.debug("About to update task with id '{}' as user '{}' with data {}", taskId, userId, updatedTask);
UserTaskInstanceDesc task = new UserTaskInstanceDesc(taskId.longValue(), updatedTask.getName(), updatedTask.getDescription(), updatedTask.getPriority(), updatedTask.getExpirationDate(), updatedTask.getFormName());
userTaskService.updateTask(containerId, taskId.longValue(), userId, task, updatedTask.getInputData(), updatedTask.getOutputData());
}
use of org.kie.server.api.model.instance.TaskInstance in project businessautomation-cop by redhat-cop.
the class KieQueryTest method testGetAllTaskInputInstancesWithVariables.
/**
* Basic AdvancedQuery Example Finding Tasks with a InputVariable + Value
*/
@Test
public void testGetAllTaskInputInstancesWithVariables() {
// Source File : src/main/resources/query-definitions.json
QueryDefinition query = queryServicesClient.getQuery(TestWorkflowConstant.QUERIES.ALL_TASKS_WITH_INPUT_VARS);
assertNotNull(query);
assertTrue(StringUtils.isNotBlank(query.getExpression()));
// start process instance
Long processInstanceId = processServicesClient.startProcess(containerId, TestWorkflowConstant.PROCESS_ID.SAMPLE_PROCESS_ID, this.getParams());
assertNotNull(processInstanceId);
TaskSummary task = this.assertTaskInstance(processInstanceId, 1, TestWorkflowConstant.SAMPLE_PROCESS_DATA.TASK_OWNER, "Test Task");
// Obtain Task Instances via the Internal Java API
List<UserTaskInstanceWithVarsDesc> tins = queryService.query(TestWorkflowConstant.QUERIES.ALL_TASKS_WITH_INPUT_VARS, UserTaskInstanceWithVarsQueryMapper.get(), new QueryContext(), QueryParam.in(COLUMN_TASK_STATUS, TestWorkflowConstant.getActiveTaskStatuses()));
assertNotNull(tins);
assertEquals(1, tins.size());
assertEquals(this.getParams().get("myVar"), tins.get(0).getVariables().get("myTaskInputVar"));
// User FilterSpec builder to filter SQL results
QueryFilterSpecBuilder builder = new QueryFilterSpecBuilder();
builder.in(COLUMN_TASK_STATUS, TestWorkflowConstant.getActiveTaskStatuses());
// Obtain Task Instances via the External Java API QueryServices
List<TaskInstance> taskInstanceLogs = queryServicesClient.query(TestWorkflowConstant.QUERIES.ALL_TASKS_WITH_INPUT_VARS, QUERY_MAP_TASK_WITH_VARS, builder.get(), 0, 1000, TaskInstance.class);
assertNotNull(taskInstanceLogs);
assertEquals(1, taskInstanceLogs.size());
assertEquals(this.getParams().get("myVar"), taskInstanceLogs.get(0).getInputData().get("myTaskInputVar"));
}
use of org.kie.server.api.model.instance.TaskInstance in project droolsjbpm-integration by kiegroup.
the class RuntimeDataServiceIntegrationTest method testFindTasks.
@Test
public void testFindTasks() throws Exception {
Map<String, Object> parameters = new HashMap<String, Object>();
parameters.put("stringData", "waiting for signal");
parameters.put("personData", createPersonInstance(USER_JOHN));
Long processInstanceId = processClient.startProcess(CONTAINER_ID, PROCESS_ID_USERTASK, parameters);
ProcessInstance desc = processClient.getProcessInstance(CONTAINER_ID, processInstanceId);
try {
List<TaskSummary> tasks = taskClient.findTasks(USER_YODA, 0, 50);
assertNotNull(tasks);
TaskSummary taskSummary = null;
for (TaskSummary t : tasks) {
if (t.getProcessInstanceId().equals(processInstanceId)) {
taskSummary = t;
break;
}
}
TaskSummary expectedTaskSummary = createDefaultTaskSummary(processInstanceId);
assertTaskSummary(expectedTaskSummary, taskSummary);
List<WorkItemInstance> workItems = processClient.getWorkItemByProcessInstance(CONTAINER_ID, processInstanceId);
assertNotNull(workItems);
assertEquals(1, workItems.size());
Long workItemId = workItems.get(0).getId();
TaskInstance expectedTaskInstance = TaskInstance.builder().name("First task").status(Status.Reserved.toString()).priority(0).actualOwner(USER_YODA).createdBy(USER_YODA).processId(PROCESS_ID_USERTASK).containerId(CONTAINER_ID).processInstanceId(processInstanceId).processType(WorkflowProcess.PROCESS_TYPE).correlationKey(desc.getCorrelationKey()).build();
TaskInstance taskById = taskClient.findTaskById(taskSummary.getId());
assertTaskInstance(expectedTaskInstance, taskById);
assertEquals(workItemId, taskById.getWorkItemId());
assertNull(taskById.getSlaCompliance());
taskById = taskClient.findTaskById(taskSummary.getId(), true);
assertTaskInstance(expectedTaskInstance, taskById);
assertTrue(taskById.getSlaCompliance() == 0);
assertEquals(workItemId, taskById.getWorkItemId());
taskById = taskClient.findTaskByWorkItemId(workItems.get(0).getId());
assertTaskInstance(expectedTaskInstance, taskById);
} finally {
processClient.abortProcessInstance(CONTAINER_ID, processInstanceId);
}
}
Aggregations