public JaxbAttachment(Attachment attachment) { super(attachment, Attachment.class); User attacher = attachment.getAttachedBy(); if( attacher != null ) { this.attachedBy = attacher.getId(); } }
protected void doCallbackOperationForAttachment(Attachment attachment, TaskContext context) { if (attachment != null) { if (attachment.getAttachedBy() != null) { User entity = doCallbackAndReturnUserOperation(attachment.getAttachedBy().getId(), context); if (entity != null) { ((InternalAttachment)attachment).setAttachedBy(entity); } } } }
public String getAttachmentById(String containerId, Number taskId, Number attachmentId, String marshallingType) { containerId = context.getContainerId(containerId, new ByTaskIdContainerLocator(taskId.longValue())); Attachment attachment = userTaskService.getAttachmentById(containerId, taskId.longValue(), attachmentId.longValue()); TaskAttachment taskAttachment = TaskAttachment.builder() .id(attachment.getId()) .name(attachment.getName()) .addedBy(attachment.getAttachedBy().getId()) .addedAt(attachment.getAttachedAt()) .attachmentContentId(attachment.getAttachmentContentId()) .contentType(attachment.getContentType()) .size(attachment.getSize()) .build(); logger.debug("About to marshal task '{}' attachment {} with content {}", taskId, attachmentId, taskAttachment); String response = marshallerHelper.marshal(containerId, marshallingType, taskAttachment); return response; }
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; }
assertEquals("john", attachment.getAttachedBy().getId()); assertEquals("my attachment", attachment.getName()); assertNotNull(attachment.getAttachmentContentId());
genAttach.setContentType(attach.getContentType()); genAttach.setAttachedAt(convertDateToXmlGregorianCalendar(attach.getAttachedAt())); genAttach.setAttachedBy(attach.getAttachedBy().getId()); genAttach.setSize(attach.getSize()); genAttach.setAttachmentContentId(attach.getAttachmentContentId());