public long addTask(Task task, ContentData contentData) { doCallbackOperationForPeopleAssignments(task.getPeopleAssignments()); doCallbackOperationForTaskData(task.getTaskData()); doCallbackOperationForTaskDeadlines(task.getDeadlines()); em.persist(task); if (contentData != null) { Content content = new Content(contentData.getContent()); em.persist(content); task.getTaskData().setDocument(content.getId(), contentData); } return task.getId(); }
public long addTask(Task task, Map<String, Object> params) { doCallbackOperationForPeopleAssignments(task.getPeopleAssignments()); doCallbackOperationForTaskData(task.getTaskData()); doCallbackOperationForTaskDeadlines(task.getDeadlines()); if (params != null) { ContentData contentData = ContentMarshallerHelper.marshal(params, null); Content content = new Content(contentData.getContent()); em.persist(content); task.getTaskData().setDocument(content.getId(), contentData); } em.persist(task); return task.getId(); }
public long newTask(String name, Map<String, Object> params) { TaskDef taskDef = taskDefService.getTaskDefById(name); Task task = TaskFactory.newTask(taskDef); em.persist(task); if (params != null) { ContentData contentData = ContentMarshallerHelper.marshal(params, null); Content content = new Content(contentData.getContent()); em.persist(content); task.getTaskData().setDocument(content.getId(), contentData); } return task.getId(); }
public long newTask(TaskDef taskDef, Map<String, Object> params, boolean deploy) { // TODO: need to deal with the params for the content if (deploy) { taskDefService.deployTaskDef(taskDef); } Task task = TaskFactory.newTask(taskDef); em.persist(task); if (params != null) { ContentData contentData = ContentMarshallerHelper.marshal(params, null); Content content = new Content(contentData.getContent()); em.persist(content); task.getTaskData().setDocument(content.getId(), contentData); } return task.getId(); }
public void testAddRemoveAttachment() throws Exception { Map vars = new HashMap(); vars.put("users", users); vars.put("groups", groups); vars.put("now", new Date()); String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { createdOn = now, activationTime = now}), "; str += "deadlines = new Deadlines(),"; str += "delegation = new Delegation(),"; str += "peopleAssignments = new PeopleAssignments(),"; str += "names = [ new I18NText( 'en-UK', 'This is my task name')] })"; Task task = (Task) eval(new StringReader(str), vars); client.addTask(task, null); long taskId = task.getId(); Attachment attachment = new Attachment(); Date attachedAt = new Date(System.currentTimeMillis()); attachment.setAttachedAt(attachedAt); attachment.setAttachedBy(users.get("luke")); attachment.setName("file1.txt"); attachment.setAccessType(AccessType.Inline); attachment.setContentType("txt"); byte[] bytes = "Ths is my attachment text1".getBytes(); Content content = new Content(); content.setContent(bytes); client.addAttachment(taskId, attachment, content); Task task1 = client.getTask(taskId); // For local clients this will be the same.. that's why is commented // assertNotSame(task, task1); // assertFalse(task.equals(task1)); List<Attachment> attachments1 = task1.getTaskData().getAttachments(); assertEquals(1, attachments1.size()); Attachment returnedAttachment = attachments1.get(0); assertEquals(attachedAt, returnedAttachment.getAttachedAt()); assertEquals(users.get("luke"), returnedAttachment.getAttachedBy()); assertEquals(AccessType.Inline, returnedAttachment.getAccessType()); assertEquals("txt", returnedAttachment.getContentType()); assertEquals("file1.txt", returnedAttachment.getName()); assertEquals(bytes.length, returnedAttachment.getSize()); assertEquals((long) attachment.getId(), (long) returnedAttachment.getId()); assertEquals((long) content.getId(), (long) returnedAttachment.getAttachmentContentId()); // Make the same as the returned tasks, so we can test equals task.getTaskData().setAttachments(attachments1); task.getTaskData().setStatus(Status.Created); assertEquals(task, task1); content = client.getContent(returnedAttachment.getAttachmentContentId()); assertEquals("Ths is my attachment text1", new String(content.getContent())); // test we can have multiple attachments attachment = new Attachment(); attachedAt = new Date(System.currentTimeMillis()); attachment.setAttachedAt(attachedAt); attachment.setAttachedBy(users.get("tony")); attachment.setName("file2.txt"); attachment.setAccessType(AccessType.Inline); attachment.setContentType("txt"); bytes = "Ths is my attachment text2".getBytes(); content = new Content(); content.setContent(bytes); client.addAttachment(taskId, attachment, content); task1 = client.getTask(taskId); // In local clients this will be the same object and we are reusing the tests // assertNotSame(task, task1); // assertFalse(task.equals(task1)); List<Attachment> attachments2 = task1.getTaskData().getAttachments(); assertEquals(2, attachments2.size()); content = client.getContent(content.getId()); assertEquals("Ths is my attachment text2", new String(content.getContent())); // make two collections the same and compare attachment.setSize(26); attachment.setAttachmentContentId(content.getId()); attachments1.add(attachment); assertTrue(CollectionUtils.equals(attachments2, attachments1)); client.deleteAttachment(taskId, attachment.getId(), content.getId()); task1 = client.getTask(taskId); attachments2 = task1.getTaskData().getAttachments(); assertEquals(1, attachments2.size()); assertEquals("file1.txt", attachments2.get(0).getName()); }