@Override public Attachment persistAttachment(Attachment attachment) { check(); this.em.persist( attachment ); if( this.pessimisticLocking ) { this.em.flush(); return this.em.find(AttachmentImpl.class, attachment.getId(), LockModeType.PESSIMISTIC_WRITE ); } return attachment; }
/** * Removes the Attachment specified by the attachmentId. * * @param attachmentId id of attachment to remove * @return removed Attachment or null if one was not found with the id */ public Attachment removeAttachment(final long attachmentId) { Attachment removedAttachment = null; if (attachments != null) { for (int index = attachments.size() - 1; index >= 0; --index) { Attachment currentAttachment = attachments.get(index); if (currentAttachment.getId() == attachmentId) { removedAttachment = attachments.remove(index); break; } } } return removedAttachment; }
public long addAttachment(long taskId, Attachment attachment, Content content) { Task task = persistenceContext.findTask(taskId); persistenceContext.persistAttachment(attachment); persistenceContext.persistContent(content); ((InternalAttachment) attachment).setContent(content); persistenceContext.addAttachmentToTask(attachment, task); return attachment.getId(); }
/** * Removes the Attachment specified by the attachmentId. * * @param attachmentId id of attachment to remove * @return removed Attachment or null if one was not found with the id */ public Attachment removeAttachment(final long attachmentId) { Attachment removedAttachment = null; if (attachments != null) { for (int index = attachments.size() - 1; index >= 0; --index) { Attachment currentAttachment = attachments.get(index); if (currentAttachment.getId() == attachmentId) { removedAttachment = attachments.remove(index); break; } } } return removedAttachment; }
@Override public Attachment persistAttachment(Attachment attachment) { check(); this.em.persist( attachment ); if( this.pessimisticLocking ) { this.em.flush(); return this.em.find(AttachmentImpl.class, attachment.getId(), LockModeType.PESSIMISTIC_WRITE ); } return attachment; }
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; }
for( Attachment attach : attachs ) { org.kie.remote.jaxb.gen.Attachment genAttach = new org.kie.remote.jaxb.gen.Attachment(); genAttach.setId(attach.getId()); genAttach.setName(attach.getName()); genAttach.setContentType(attach.getContentType());