use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class DefaultChecklistManager method addTask.
public ChecklistItem addTask(String userId, String[] actorIds, String[] groupIds, String name, String orderingId, long processInstanceId) {
RuntimeEngine runtime = getRuntime();
InternalTask task = (InternalTask) TaskModelProvider.getFactory().newTask();
;
setTaskName(task, name);
setTaskDescription(task, orderingId);
// task.setPriority(priority);
InternalTaskData taskData = (InternalTaskData) TaskModelProvider.getFactory().newTaskData();
taskData.setProcessInstanceId(processInstanceId);
// taskData.setProcessSessionId(sessionId);
taskData.setSkipable(false);
taskData.setDeploymentId("default-singleton");
User cuser = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) cuser).setId(userId);
taskData.setCreatedBy(cuser);
task.setTaskData(taskData);
InternalPeopleAssignments peopleAssignments = (InternalPeopleAssignments) task.getPeopleAssignments();
if (peopleAssignments == null) {
peopleAssignments = (InternalPeopleAssignments) TaskModelProvider.getFactory().newPeopleAssignments();
peopleAssignments.setPotentialOwners(new ArrayList<OrganizationalEntity>());
peopleAssignments.setBusinessAdministrators(new ArrayList<OrganizationalEntity>());
peopleAssignments.setExcludedOwners(new ArrayList<OrganizationalEntity>());
peopleAssignments.setRecipients(new ArrayList<OrganizationalEntity>());
peopleAssignments.setTaskStakeholders(new ArrayList<OrganizationalEntity>());
task.setPeopleAssignments(peopleAssignments);
}
List<OrganizationalEntity> potentialOwners = new ArrayList<OrganizationalEntity>();
for (String actorId : actorIds) {
User user = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) user).setId(actorId);
potentialOwners.add(user);
}
for (String groupId : groupIds) {
Group group = TaskModelProvider.getFactory().newGroup();
((InternalOrganizationalEntity) group).setId(groupId);
potentialOwners.add(group);
}
setTaskPotentialOwners(task, potentialOwners);
List<OrganizationalEntity> businessAdministrators = peopleAssignments.getBusinessAdministrators();
User administrator = TaskModelProvider.getFactory().newUser();
((InternalOrganizationalEntity) administrator).setId("Administrator");
businessAdministrators.add(administrator);
TaskService taskService = runtime.getTaskService();
long taskId = taskService.addTask(task, (Map<String, Object>) null);
manager.disposeRuntimeEngine(runtime);
return ChecklistItemFactory.createChecklistItem(taskService.getTaskById(taskId));
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class TaskAuditBaseTest method testLifeCycleWithBAMEndWithObsolete.
@Test
public void testLifeCycleWithBAMEndWithObsolete() {
Task task = new TaskFluent().setName("This is my task name").addPotentialGroup("Knights Templer").setAdminUser("Administrator").getTask();
((InternalTaskData) task.getTaskData()).setSkipable(true);
taskService.addTask(task, new HashMap<String, Object>());
long taskId = task.getId();
List<AuditTask> allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
taskService.release(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllGroupAuditTasksByUser("Knights Templer", new QueryFilter());
assertEquals(1, allGroupAuditTasks.size());
assertTrue(allGroupAuditTasks.get(0).getStatus().equals("Ready"));
assertBAMTask(taskId, "Ready");
taskService.claim(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Reserved", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Reserved");
// Go straight from Ready to Inprogress
taskService.start(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("InProgress", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "InProgress");
taskService.skip(taskId, "Darth Vader");
allGroupAuditTasks = taskAuditService.getAllAuditTasksByUser("Darth Vader", new QueryFilter());
;
assertEquals(1, allGroupAuditTasks.size());
assertEquals("Obsolete", allGroupAuditTasks.get(0).getStatus());
assertBAMTask(taskId, "Obsolete");
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class DistincVsJoinPerformanceTest method addTask.
private TaskImpl addTask(long workItemId, long procInstId, String busAdmin, String potOwner, String name, String deploymentId) {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
String potOwnerType = potOwner.equals("Hideo") ? "User" : "Group";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { " + "taskStakeholders = [new User('" + stakeHolder + "')]," + "businessAdministrators = [new User('" + busAdmin + "')]," + "potentialOwners = [new " + potOwnerType + "('" + potOwner + "')]" + " }),";
str += "name = '" + name + "' })";
Task taskImpl = TaskFactory.evalTask(new StringReader(str));
((InternalTaskData) taskImpl.getTaskData()).setWorkItemId(workItemId);
((InternalTaskData) taskImpl.getTaskData()).setProcessInstanceId(procInstId);
((InternalTaskData) taskImpl.getTaskData()).setDeploymentId(deploymentId);
taskService.addTask(taskImpl, new HashMap<String, Object>());
assertNotNull("Null task id", taskImpl.getId());
return (TaskImpl) taskImpl;
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class TaskQueryBuilderLocalTest method addTask.
private TaskImpl addTask(long workItemId, long procInstId, String busAdmin, String potOwner, String name, String deploymentId) {
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { " + "taskStakeholders = [new User('" + stakeHolder + "')]," + "businessAdministrators = [new User('" + busAdmin + "')]," + "potentialOwners = [new User('" + potOwner + "')]" + " }),";
str += "name = '" + name + "' })";
Task taskImpl = TaskFactory.evalTask(new StringReader(str));
((InternalTaskData) taskImpl.getTaskData()).setWorkItemId(workItemId);
((InternalTaskData) taskImpl.getTaskData()).setProcessInstanceId(procInstId);
((InternalTaskData) taskImpl.getTaskData()).setDeploymentId(deploymentId);
taskService.addTask(taskImpl, new HashMap<String, Object>());
assertNotNull("Null task id", taskImpl.getId());
return (TaskImpl) taskImpl;
}
use of org.kie.internal.task.api.model.InternalTaskData in project jbpm by kiegroup.
the class TaskQueryBuilderLocalTest method testGetTasksByVariousFieldsWithUserGroupCallbackAdmin.
@Test
public void testGetTasksByVariousFieldsWithUserGroupCallbackAdmin() {
String potOwner = "Administrator";
List<String> busAdmins = new ArrayList<String>();
busAdmins.add(potOwner);
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) { } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { " + "businessAdministrators = [new Group('Administrators')]," + "potentialOwners = [new Group('Crusaders')]" + " }),";
str += "name = 'This is my task name' })";
Task task = TaskFactory.evalTask(new StringReader(str));
((InternalTaskData) task.getTaskData()).setWorkItemId(1);
((InternalTaskData) task.getTaskData()).setProcessInstanceId(1);
taskService.addTask(task, new HashMap<String, Object>());
List<TaskSummary> results = taskService.taskSummaryQuery(potOwner).businessAdmin(busAdmins.toArray(new String[0])).build().getResultList();
assertNotNull(results);
assertEquals(1, results.size());
}
Aggregations