use of pro.taskana.Attachment in project taskana by Taskana.
the class TaskAttachmentTest method testAddNullValue.
@Test
public void testAddNullValue() {
Attachment attachment1 = createAttachment("ID1", "taskId1");
Attachment attachment2 = null;
cut.addAttachment(attachment1);
cut.addAttachment(attachment2);
assertThat(cut.getAttachments().size(), equalTo(1));
}
use of pro.taskana.Attachment in project taskana by Taskana.
the class TaskAttachmentTest method testRemoveLoopStopsAtResult.
@Test
public void testRemoveLoopStopsAtResult() {
Attachment attachment1 = createAttachment("ID2", "taskId1");
// adding same uncommon way to test that the loop will stop.
cut.getAttachments().add(attachment1);
cut.getAttachments().add(attachment1);
cut.getAttachments().add(attachment1);
assertThat(cut.getAttachments().size(), equalTo(3));
Attachment actual = cut.removeAttachment(attachment1.getId());
assertThat(cut.getAttachments().size(), equalTo(2));
assertThat(actual, equalTo(attachment1));
}
use of pro.taskana.Attachment in project taskana by Taskana.
the class AbstractAccTest method createAttachment.
protected Attachment createAttachment(String classificationKey, ObjectReference objRef, String channel, String receivedDate, Map<String, String> customAttributes) throws ClassificationNotFoundException, NotAuthorizedException {
Attachment attachment = taskanaEngine.getTaskService().newAttachment();
attachment.setClassificationSummary(taskanaEngine.getClassificationService().getClassification(classificationKey, "DOMAIN_A").asSummary());
attachment.setObjectReference(objRef);
attachment.setChannel(channel);
Instant receivedTimestamp = null;
if (receivedDate != null && receivedDate.length() < 11) {
// contains only the date, not the time
LocalDate date = LocalDate.parse(receivedDate);
receivedTimestamp = date.atStartOfDay().toInstant(ZoneOffset.UTC);
} else {
receivedTimestamp = Instant.parse(receivedDate);
}
attachment.setReceived(receivedTimestamp);
attachment.setCustomAttributes(customAttributes);
return attachment;
}
use of pro.taskana.Attachment in project taskana by Taskana.
the class TaskImpl method removeAttachment.
@Override
public Attachment removeAttachment(String attachmentId) {
Attachment result = null;
Iterator<Attachment> i = attachments.iterator();
while (i.hasNext()) {
Attachment attachment = i.next();
if (attachment.getId().equals(attachmentId)) {
if (attachments.remove(attachment)) {
result = attachment;
break;
}
}
}
return result;
}
use of pro.taskana.Attachment in project taskana by Taskana.
the class TaskImpl method asSummary.
@Override
public TaskSummary asSummary() {
TaskSummaryImpl taskSummary = new TaskSummaryImpl();
List<AttachmentSummary> attSummaries = new ArrayList<>();
for (Attachment att : attachments) {
attSummaries.add(att.asSummary());
}
taskSummary.setAttachmentSummaries(attSummaries);
taskSummary.setBusinessProcessId(this.businessProcessId);
taskSummary.setClaimed(claimed);
if (classificationSummary != null) {
taskSummary.setClassificationSummary(classificationSummary);
}
taskSummary.setCompleted(completed);
taskSummary.setCreated(created);
taskSummary.setCustom1(custom1);
taskSummary.setCustom2(custom2);
taskSummary.setCustom3(custom3);
taskSummary.setCustom4(custom4);
taskSummary.setCustom5(custom5);
taskSummary.setCustom6(custom6);
taskSummary.setCustom7(custom7);
taskSummary.setCustom8(custom8);
taskSummary.setCustom9(custom9);
taskSummary.setCustom10(custom10);
taskSummary.setDue(due);
taskSummary.setTaskId(id);
taskSummary.setModified(modified);
taskSummary.setName(name);
taskSummary.setCreator(creator);
taskSummary.setNote(note);
taskSummary.setOwner(owner);
taskSummary.setParentBusinessProcessId(parentBusinessProcessId);
taskSummary.setPlanned(planned);
taskSummary.setPrimaryObjRef(primaryObjRef);
taskSummary.setPriority(priority);
taskSummary.setRead(isRead);
taskSummary.setState(state);
taskSummary.setTransferred(isTransferred);
taskSummary.setWorkbasketSummary(workbasketSummary);
return taskSummary;
}
Aggregations