Search in sources :

Example 1 with TaskCommentList

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

the class UserTaskServicesClientImpl method getTaskCommentsByTaskId.

@Override
public List<TaskComment> getTaskCommentsByTaskId(String containerId, Long taskId) {
    TaskCommentList commentList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(TASK_INSTANCE_ID, taskId);
        commentList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_COMMENTS_GET_URI, valuesMap), TaskCommentList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getCommentsByTaskId", marshaller.getFormat().getType(), new Object[] { containerId, taskId })));
        ServiceResponse<String> response = (ServiceResponse<String>) executeJmsCommand(script, DescriptorCommand.class.getName(), "BPM", containerId).getResponses().get(0);
        throwExceptionOnFailure(response);
        if (shouldReturnWithNullResponse(response)) {
            return null;
        }
        commentList = deserialize(response.getResult(), TaskCommentList.class);
    }
    if (commentList.getTasks() != null) {
        return Arrays.asList(commentList.getTasks());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) TaskCommentList(org.kie.server.api.model.instance.TaskCommentList) KieServerCommand(org.kie.server.api.model.KieServerCommand) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 2 with TaskCommentList

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

the class UserTaskServiceBase method getCommentsByTaskId.

public String getCommentsByTaskId(String containerId, Number taskId, String marshallingType) {
    containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue()));
    List<Comment> comments = userTaskService.getCommentsByTaskId(containerId, taskId.longValue());
    TaskComment[] taskComments = new TaskComment[comments.size()];
    int counter = 0;
    for (Comment comment : comments) {
        TaskComment taskComment = TaskComment.builder().id(comment.getId()).text(comment.getText()).addedBy(comment.getAddedBy().getId()).addedAt(comment.getAddedAt()).build();
        taskComments[counter] = taskComment;
        counter++;
    }
    TaskCommentList result = new TaskCommentList(taskComments);
    logger.debug("About to marshal task '{}' comments {}", taskId, result);
    String response = marshallerHelper.marshal(containerId, marshallingType, result);
    return response;
}
Also used : TaskComment(org.kie.server.api.model.instance.TaskComment) Comment(org.kie.api.task.model.Comment) ByTaskIdContainerLocator(org.kie.server.services.jbpm.locator.ByTaskIdContainerLocator) TaskComment(org.kie.server.api.model.instance.TaskComment) TaskCommentList(org.kie.server.api.model.instance.TaskCommentList)

Aggregations

TaskCommentList (org.kie.server.api.model.instance.TaskCommentList)2 HashMap (java.util.HashMap)1 Comment (org.kie.api.task.model.Comment)1 CommandScript (org.kie.server.api.commands.CommandScript)1 DescriptorCommand (org.kie.server.api.commands.DescriptorCommand)1 KieServerCommand (org.kie.server.api.model.KieServerCommand)1 ServiceResponse (org.kie.server.api.model.ServiceResponse)1 TaskComment (org.kie.server.api.model.instance.TaskComment)1 ByTaskIdContainerLocator (org.kie.server.services.jbpm.locator.ByTaskIdContainerLocator)1