Refine search
protected String getActualOwner(Task ti) { String userId = ""; if (ti.getTaskData().getActualOwner() != null) { userId = ti.getTaskData().getActualOwner().getId(); } return userId; }
protected String getActualOwner(Task ti) { String userId = ""; if (ti.getTaskData().getActualOwner() != null) { userId = ti.getTaskData().getActualOwner().getId(); } return userId; }
protected AuditTaskImpl createAuditTask(Task ti, Date date) { AuditTaskImpl auditTaskImpl = new AuditTaskImpl( ti.getId(), ti.getName(), ti.getTaskData().getStatus().name(), ti.getTaskData().getActivationTime(), (ti.getTaskData().getActualOwner() != null) ? ti.getTaskData().getActualOwner().getId() : "", ti.getDescription(), ti.getPriority(), (ti.getTaskData().getCreatedBy() != null) ? ti.getTaskData().getCreatedBy().getId() : "", ti.getTaskData().getCreatedOn(), ti.getTaskData().getExpirationTime(), ti.getTaskData().getProcessInstanceId(), ti.getTaskData().getProcessId(), ti.getTaskData().getProcessSessionId(), ti.getTaskData().getDeploymentId(), ti.getTaskData().getParentId(), ti.getTaskData().getWorkItemId(), date ); return auditTaskImpl; }
protected void assertActualOwner(Task task, String expectedActualOwner) { User actualOwner = task.getTaskData().getActualOwner(); assertThat(actualOwner).as("No actual owner when expected").isNotNull(); assertThat(actualOwner.getId()).as("Not matching actual owner").isEqualTo(expectedActualOwner); }
protected void assertNoActualOwner(Task task) { assertThat(task.getTaskData().getActualOwner()).as("Actual owner present when not expected").isNull(); }
public void processTaskState(Task task) { long workItemId = task.getTaskData().getWorkItemId(); long processInstanceId = task.getTaskData().getProcessInstanceId(); RuntimeManager manager = getManager(task); RuntimeEngine runtime = manager.getRuntimeEngine(ProcessInstanceIdContext.get(processInstanceId)); KieSession session = runtime.getKieSession(); if (task.getTaskData().getStatus() == Status.Completed) { String userId = task.getTaskData().getActualOwner().getId(); Map<String, Object> results = new HashMap<String, Object>(); Map<String, Object> taskOutcome = task.getTaskData().getTaskOutputVariables(); if (taskOutcome != null) { results.putAll(taskOutcome); // results.put("Result", taskOutcome); } results.put("ActorId", userId); session.getWorkItemManager().completeWorkItem(workItemId, results); } else { session.getWorkItemManager().abortWorkItem(workItemId); } }
protected void completeTask(Task task) { taskService.start(task.getId(), task.getTaskData().getActualOwner().getId()); taskService.complete(task.getId(), task.getTaskData().getActualOwner().getId(), new HashMap<String,Object>()); }
protected void completeTask(long taskId, long delay) { Task task = taskService.getTaskById(taskId); String owner = task.getTaskData().getActualOwner().getId(); logger.debug("Starting task {} with user {}",taskId,owner); taskService.start(taskId, owner); if (delay > 0) { try { Thread.sleep(delay); } catch (InterruptedException e) { // swallowing this exception } } taskService.complete(taskId, owner, data); } }
@Test public void testAssignmentsWhenNoRuleWasFired() throws Exception { String str = "(with (new Task()) { priority = 51, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Ben Dover') ],businessAdministrators = [ new User('Administrator') ],}),"; str += "name = 'Not Bobbas tasks' })"; Task task = TaskFactory.evalTask(new StringReader(str)); assertPotentialOwners(task, 1); long taskId = taskService.addTask(task, Collections.emptyMap()); task = taskService.getTaskById(taskId); assertPotentialOwners(task, 0); User actualOwner = task.getTaskData().getActualOwner(); Assertions.assertThat(actualOwner).isNull(); }
@Test public void testNewTaskWithNoPotentialOwners() { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { businessAdministrators = [ new User('Administrator') ],}),"; str += "name = 'This is my task name' })"; Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); // Task should remain in Created state with no actual owner Task task1 = taskService.getTaskById(taskId); assertEquals(task1.getTaskData().getStatus(), Status.Created); assertNull(task1.getTaskData().getActualOwner()); }
@Test public void testSkipFromReady() { String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { skipable = true} ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ],businessAdministrators = [ new User('Administrator') ], }),"; str += "name = 'This is my task name' })"; Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); // Check is Complete taskService.skip(taskId, "Darth Vader"); Task task1 = taskService.getTaskById(taskId); assertEquals(Status.Obsolete, task1.getTaskData().getStatus()); assertNull(task1.getTaskData().getActualOwner()); }
@Test public void testNominateToUser() { String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { businessAdministrators = [ new User('Darth Vader'), new User('Bobba Fet') ] } ),"; str += "name = 'This is my task name' })"; Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>(1); User user = createUser("Jabba Hutt"); potentialOwners.add(user); taskService.nominate(taskId, "Darth Vader", potentialOwners); //shouldn't affect the assignments Task task1 = taskService.getTaskById(taskId); assertEquals(task1.getTaskData().getActualOwner().getId(), "Jabba Hutt"); assertEquals(task1.getTaskData().getStatus(), Status.Reserved); }
protected long createAndAssertTask(TaskFluent tf, String expectedOwner) { Task task = tf.getTask(); taskService.addTask(task, data); long taskId = task.getId(); assertEquals("Owner mismatch",expectedOwner,taskService.getTaskById(taskId).getTaskData().getActualOwner().getId()); return taskId; }
protected void testCompleteWithContentAndVarListener(TaskLifeCycleEventListener listener) { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ],businessAdministrators = [ new User('Administrator') ], }),"; str += "name = 'This is my task name' })"; ((EventService<TaskLifeCycleEventListener>)taskService).registerTaskEventListener(listener); Map<String, Object> params = new HashMap<String, Object>(); params.put("input", "simple input"); Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, params); long taskId = task.getId(); // start task taskService.start(taskId, "Darth Vader"); Task task1 = taskService.getTaskById(taskId); assertEquals(Status.InProgress, task1.getTaskData().getStatus()); assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId()); // complete task with output params = new HashMap<String, Object>(); params.put("content", "content"); taskService.complete(taskId, "Darth Vader", params); }
private void testTaskWithExpectedDescription(final Task task, final String expectedDescription) { assertEquals("TaskName " + task.getTaskData().getProcessInstanceId(), task.getName()); assertEquals(10, task.getPriority().intValue()); assertEquals(expectedDescription, task.getDescription()); assertEquals(Status.Reserved, task.getTaskData().getStatus()); assertEquals("Darth Vader", task.getTaskData().getActualOwner().getId()); assertEquals(10L, task.getTaskData().getProcessInstanceId()); }
public void testReleaseFromReserved() { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ],businessAdministrators = [ new User('Administrator') ], }),"; str += "name = 'This is my task name'})"; Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); // Go straight from Ready to Inprogress taskService.claim(taskId, "Darth Vader"); Task task1 = taskService.getTaskById(taskId); assertEquals(Status.Reserved, task1.getTaskData().getStatus()); assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId()); // Check is Released taskService.release(taskId, "Darth Vader"); Task task2 = taskService.getTaskById(taskId); assertEquals(Status.Ready, task2.getTaskData().getStatus()); assertNull(task2.getTaskData().getActualOwner()); }
@Test public void testStartFromReserved() throws Exception { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ], businessAdministrators = [ new User('Administrator') ],}),"; str += "name = 'This is my task name' })"; Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); // Task should be assigned to the single potential owner and state set to Reserved Task task1 = taskService.getTaskById(taskId); assertEquals(Status.Reserved, task1.getTaskData().getStatus()); assertEquals("Bobba Fet", task1.getTaskData().getActualOwner().getId()); // Should change to InProgress taskService.start(taskId, "Bobba Fet"); Task task2 = taskService.getTaskById(taskId); assertEquals(Status.InProgress, task2.getTaskData().getStatus()); assertEquals("Bobba Fet", task1.getTaskData().getActualOwner().getId()); }
@Test public void testSuspendFromReady() { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ],businessAdministrators = [ new User('Administrator') ], }),"; str += "name = 'This is my task name'})"; Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); // Check is Ready taskService.getTaskById(taskId); Task task1 = taskService.getTaskById(taskId); assertEquals(Status.Ready, task1.getTaskData().getStatus()); assertNull(task1.getTaskData().getActualOwner()); // Check is Suspended taskService.suspend(taskId, "Darth Vader"); Task task2 = taskService.getTaskById(taskId); assertEquals(Status.Suspended, task2.getTaskData().getStatus()); assertEquals(Status.Ready, task2.getTaskData().getPreviousStatus()); assertNull(task1.getTaskData().getActualOwner()); }
@Test public void testNewTaskWithSinglePotentialOwner() { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet') ],businessAdministrators = [ new User('Administrator') ], }),"; str += "name = 'This is my task name' })"; Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); // Task should be assigned to the single potential owner and state set to Reserved Task task1 = taskService.getTaskById(taskId); assertEquals(Status.Reserved, task1.getTaskData().getStatus()); String potOwner = "Bobba Fet"; assertEquals(potOwner, task1.getTaskData().getActualOwner().getId()); taskService.getTasksAssignedAsPotentialOwner(potOwner, "en-UK"); }
@Test public void testComplete() { // One potential owner, should go straight to state Reserved String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), "; str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet'), new User('Darth Vader') ],businessAdministrators = [ new User('Administrator') ], }),"; str += "name = 'This is my task name' })"; Task task = TaskFactory.evalTask(new StringReader(str)); taskService.addTask(task, new HashMap<String, Object>()); long taskId = task.getId(); // Go straight from Ready to Inprogress taskService.start(taskId, "Darth Vader"); Task task1 = taskService.getTaskById(taskId); assertEquals(Status.InProgress, task1.getTaskData().getStatus()); assertEquals("Darth Vader", task1.getTaskData().getActualOwner().getId()); // Check is Complete taskService.complete(taskId, "Darth Vader", null); Task task2 = taskService.getTaskById(taskId); assertEquals(Status.Completed, task2.getTaskData().getStatus()); assertEquals("Darth Vader", task2.getTaskData().getActualOwner().getId()); }