Search in sources :

Example 1 with TaskAttachmentList

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

the class UserTaskServicesClientImpl method getTaskAttachmentsByTaskId.

@Override
public List<TaskAttachment> getTaskAttachmentsByTaskId(String containerId, Long taskId) {
    TaskAttachmentList attachmentList = null;
    if (config.isRest()) {
        Map<String, Object> valuesMap = new HashMap<String, Object>();
        valuesMap.put(CONTAINER_ID, containerId);
        valuesMap.put(TASK_INSTANCE_ID, taskId);
        attachmentList = makeHttpGetRequestAndCreateCustomResponse(build(loadBalancer.getUrl(), TASK_URI + "/" + TASK_INSTANCE_ATTACHMENTS_GET_URI, valuesMap), TaskAttachmentList.class);
    } else {
        CommandScript script = new CommandScript(Collections.singletonList((KieServerCommand) new DescriptorCommand("UserTaskService", "getAttachmentsByTaskId", 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;
        }
        attachmentList = deserialize(response.getResult(), TaskAttachmentList.class);
        ;
    }
    if (attachmentList.getTasks() != null) {
        return Arrays.asList(attachmentList.getTasks());
    }
    return Collections.emptyList();
}
Also used : DescriptorCommand(org.kie.server.api.commands.DescriptorCommand) ServiceResponse(org.kie.server.api.model.ServiceResponse) KieServerCommand(org.kie.server.api.model.KieServerCommand) TaskAttachmentList(org.kie.server.api.model.instance.TaskAttachmentList) HashMap(java.util.HashMap) CommandScript(org.kie.server.api.commands.CommandScript)

Example 2 with TaskAttachmentList

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

the class UserTaskServiceBase method getAttachmentsByTaskId.

public String getAttachmentsByTaskId(String containerId, Number taskId, String marshallingType) {
    containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue()));
    List<Attachment> attachments = userTaskService.getAttachmentsByTaskId(containerId, taskId.longValue());
    TaskAttachment[] taskComments = new TaskAttachment[attachments.size()];
    int counter = 0;
    for (Attachment attachment : attachments) {
        TaskAttachment taskComment = TaskAttachment.builder().id(attachment.getId()).name(attachment.getName()).addedBy(attachment.getAttachedBy().getId()).addedAt(attachment.getAttachedAt()).contentType(attachment.getContentType()).attachmentContentId(attachment.getAttachmentContentId()).size(attachment.getSize()).build();
        taskComments[counter] = taskComment;
        counter++;
    }
    TaskAttachmentList result = new TaskAttachmentList(taskComments);
    logger.debug("About to marshal task '{}' attachments {}", taskId, result);
    String response = marshallerHelper.marshal(containerId, marshallingType, result);
    return response;
}
Also used : TaskAttachment(org.kie.server.api.model.instance.TaskAttachment) ByTaskIdContainerLocator(org.kie.server.services.jbpm.locator.ByTaskIdContainerLocator) TaskAttachmentList(org.kie.server.api.model.instance.TaskAttachmentList) TaskAttachment(org.kie.server.api.model.instance.TaskAttachment) Attachment(org.kie.api.task.model.Attachment)

Aggregations

TaskAttachmentList (org.kie.server.api.model.instance.TaskAttachmentList)2 HashMap (java.util.HashMap)1 Attachment (org.kie.api.task.model.Attachment)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 TaskAttachment (org.kie.server.api.model.instance.TaskAttachment)1 ByTaskIdContainerLocator (org.kie.server.services.jbpm.locator.ByTaskIdContainerLocator)1