Search in sources :

Example 16 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class ConvertUtils method convertToProcessInstance.

public static org.kie.server.api.model.instance.ProcessInstance convertToProcessInstance(ProcessInstanceDesc pi) {
    if (pi == null) {
        return null;
    }
    org.kie.server.api.model.instance.ProcessInstance instance = org.kie.server.api.model.instance.ProcessInstance.builder().id(pi.getId()).processId(pi.getProcessId()).processName(pi.getProcessName()).processVersion(pi.getProcessVersion()).containerId(pi.getDeploymentId()).processInstanceDescription(pi.getProcessInstanceDescription()).correlationKey(pi.getCorrelationKey()).parentInstanceId(pi.getParentId()).date(pi.getDataTimeStamp()).initiator(pi.getInitiator()).state(pi.getState()).slaCompliance(pi.getSlaCompliance()).slaDueDate(pi.getSlaDueDate()).build();
    if (pi.getActiveTasks() != null && !pi.getActiveTasks().isEmpty()) {
        org.kie.server.api.model.instance.TaskSummary[] tasks = new org.kie.server.api.model.instance.TaskSummary[pi.getActiveTasks().size()];
        int counter = 0;
        for (UserTaskInstanceDesc taskSummary : pi.getActiveTasks()) {
            org.kie.server.api.model.instance.TaskSummary task = org.kie.server.api.model.instance.TaskSummary.builder().id(taskSummary.getTaskId()).name(taskSummary.getName()).description(taskSummary.getDescription()).activationTime(taskSummary.getActivationTime()).actualOwner(taskSummary.getActualOwner()).containerId(taskSummary.getDeploymentId()).createdBy(taskSummary.getCreatedBy()).createdOn(taskSummary.getCreatedOn()).priority(taskSummary.getPriority()).processId(taskSummary.getProcessId()).processInstanceId(taskSummary.getProcessInstanceId()).status(taskSummary.getStatus()).subject(taskSummary.getSubject()).build();
            tasks[counter] = task;
            counter++;
        }
        instance.setActiveUserTasks(new TaskSummaryList(tasks));
    }
    return instance;
}
Also used : ProcessInstance(org.kie.server.api.model.instance.ProcessInstance) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) TaskSummary(org.kie.api.task.model.TaskSummary) UserTaskInstanceDesc(org.jbpm.services.api.model.UserTaskInstanceDesc)

Example 17 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceBase method getTasksAssignedAsBusinessAdministratorByStatus.

public TaskSummaryList getTasksAssignedAsBusinessAdministratorByStatus(List<String> status, String userId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    userId = getUser(userId);
    logger.debug("About to search for task assigned as business admin for user '{}'", userId);
    List<TaskSummary> tasks;
    if (status == null || status.isEmpty()) {
        tasks = runtimeDataService.getTasksAssignedAsBusinessAdministrator(userId, buildQueryFilter(page, pageSize, sort, sortOrder));
    } else {
        List<Status> taskStatuses = buildTaskStatuses(status);
        tasks = runtimeDataService.getTasksAssignedAsBusinessAdministratorByStatus(userId, taskStatuses, buildQueryFilter(page, pageSize, sort, sortOrder));
    }
    logger.debug("Found {} tasks for user '{}' assigned as business admin", tasks.size(), userId);
    TaskSummaryList result = convertToTaskSummaryList(tasks);
    return result;
}
Also used : Status(org.kie.api.task.model.Status) TaskSummary(org.kie.api.task.model.TaskSummary) ConvertUtils.convertToTaskSummaryList(org.kie.server.services.jbpm.ConvertUtils.convertToTaskSummaryList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 18 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceBase method getTasksByStatusByProcessInstanceId.

public TaskSummaryList getTasksByStatusByProcessInstanceId(Number processInstanceId, List<String> status, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    List<Status> taskStatuses = buildTaskStatuses(status);
    if (taskStatuses == null) {
        taskStatuses = new ArrayList<Status>();
        taskStatuses.add(Status.Ready);
        taskStatuses.add(Status.Reserved);
        taskStatuses.add(Status.InProgress);
    }
    logger.debug("About to search for tasks attached to process instance with id '{}'", processInstanceId);
    List<TaskSummary> tasks = runtimeDataService.getTasksByStatusByProcessInstanceId(processInstanceId.longValue(), taskStatuses, buildQueryFilter(page, pageSize, sort, sortOrder));
    logger.debug("Found {} tasks attached to process instance with id '{}'", tasks.size(), processInstanceId);
    TaskSummaryList result = convertToTaskSummaryList(tasks);
    return result;
}
Also used : Status(org.kie.api.task.model.Status) TaskSummary(org.kie.api.task.model.TaskSummary) ConvertUtils.convertToTaskSummaryList(org.kie.server.services.jbpm.ConvertUtils.convertToTaskSummaryList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 19 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceBase method getTasksOwnedByStatus.

public TaskSummaryList getTasksOwnedByStatus(List<String> status, String userId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    List<Status> taskStatuses = buildTaskStatuses(status);
    userId = getUser(userId);
    logger.debug("About to search for task owned user '{}'", userId);
    List<TaskSummary> tasks;
    if (taskStatuses != null) {
        tasks = runtimeDataService.getTasksOwnedByStatus(userId, taskStatuses, buildQueryFilter(page, pageSize, sort, sortOrder));
    } else {
        tasks = runtimeDataService.getTasksOwned(userId, buildQueryFilter(page, pageSize, sort, sortOrder));
    }
    logger.debug("Found {} tasks owned by user '{}'", tasks.size(), userId);
    TaskSummaryList result = convertToTaskSummaryList(tasks);
    return result;
}
Also used : Status(org.kie.api.task.model.Status) TaskSummary(org.kie.api.task.model.TaskSummary) ConvertUtils.convertToTaskSummaryList(org.kie.server.services.jbpm.ConvertUtils.convertToTaskSummaryList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList)

Example 20 with TaskSummaryList

use of org.kie.server.api.model.instance.TaskSummaryList in project droolsjbpm-integration by kiegroup.

the class RuntimeDataServiceBase method getAllAuditTask.

public TaskSummaryList getAllAuditTask(String userId, Integer page, Integer pageSize, String sort, boolean sortOrder) {
    userId = getUser(userId);
    logger.debug("About to search for tasks available for user '{}'", userId);
    List<AuditTask> tasks = runtimeDataService.getAllAuditTask(userId, buildQueryFilter(page, pageSize, sort, sortOrder));
    logger.debug("Found {} tasks available for user '{}'", tasks.size(), userId);
    TaskSummaryList result = null;
    if (tasks == null) {
        result = new TaskSummaryList(new org.kie.server.api.model.instance.TaskSummary[0]);
    } else {
        org.kie.server.api.model.instance.TaskSummary[] instances = new org.kie.server.api.model.instance.TaskSummary[tasks.size()];
        int counter = 0;
        for (AuditTask taskSummary : tasks) {
            org.kie.server.api.model.instance.TaskSummary task = org.kie.server.api.model.instance.TaskSummary.builder().id(taskSummary.getTaskId()).name(taskSummary.getName()).description(taskSummary.getDescription()).taskParentId(taskSummary.getParentId()).activationTime(taskSummary.getActivationTime()).actualOwner(taskSummary.getActualOwner()).containerId(taskSummary.getDeploymentId()).createdBy(taskSummary.getCreatedBy()).createdOn(taskSummary.getCreatedOn()).expirationTime(taskSummary.getDueDate()).priority(taskSummary.getPriority()).processId(taskSummary.getProcessId()).processInstanceId(taskSummary.getProcessInstanceId()).status(taskSummary.getStatus()).build();
            instances[counter] = task;
            counter++;
        }
        result = new TaskSummaryList(instances);
    }
    return result;
}
Also used : AuditTask(org.kie.internal.task.api.AuditTask) ConvertUtils.convertToTaskSummaryList(org.kie.server.services.jbpm.ConvertUtils.convertToTaskSummaryList) TaskSummaryList(org.kie.server.api.model.instance.TaskSummaryList) TaskSummary(org.kie.api.task.model.TaskSummary)

Aggregations

TaskSummaryList (org.kie.server.api.model.instance.TaskSummaryList)37 HashMap (java.util.HashMap)14 ServiceResponse (org.kie.server.api.model.ServiceResponse)14 CommandScript (org.kie.server.api.commands.CommandScript)13 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)13 KieServerCommand (org.kie.server.api.model.KieServerCommand)13 TaskSummary (org.kie.api.task.model.TaskSummary)12 ApiOperation (io.swagger.annotations.ApiOperation)9 ApiResponses (io.swagger.annotations.ApiResponses)9 GET (javax.ws.rs.GET)9 Path (javax.ws.rs.Path)9 Produces (javax.ws.rs.Produces)9 Variant (javax.ws.rs.core.Variant)9 Header (org.kie.server.remote.rest.common.Header)9 RestUtils.buildConversationIdHeader (org.kie.server.remote.rest.common.util.RestUtils.buildConversationIdHeader)9 RestUtils.createCorrectVariant (org.kie.server.remote.rest.common.util.RestUtils.createCorrectVariant)9 RestUtils.getVariant (org.kie.server.remote.rest.common.util.RestUtils.getVariant)9 Status (org.kie.api.task.model.Status)8 DeploymentNotFoundException (org.jbpm.services.api.DeploymentNotFoundException)6 ProcessInstanceNotFoundException (org.jbpm.services.api.ProcessInstanceNotFoundException)6