use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.
the class TaskQueryServiceBaseTest method testGetTasksByStatusByProcessIdByTaskName.
@Test
public void testGetTasksByStatusByProcessIdByTaskName() {
// One potential owner, should go straight to state Reserved
String str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) {processInstanceId = 99 } ), ";
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));
String otherProcessId = "org.process.task.other";
((TaskDataImpl) task.getTaskData()).setProcessId(otherProcessId);
;
taskService.addTask(task, new HashMap<String, Object>());
str = "(with (new Task()) { priority = 55, taskData = (with( new TaskData()) {processInstanceId = 100 } ), ";
str += "peopleAssignments = (with ( new PeopleAssignments() ) { potentialOwners = [new User('Bobba Fet')],businessAdministrators = [ new User('Administrator') ], }),";
str += "name = 'Another name' })";
task = TaskFactory.evalTask(new StringReader(str));
String processId = "org.process.task.test";
((TaskDataImpl) task.getTaskData()).setProcessId(processId);
taskService.addTask(task, new HashMap<String, Object>());
List<Status> statuses = new ArrayList<Status>();
statuses.add(Status.Reserved);
List<TaskSummary> tasks = taskService.getTasksByStatusByProcessInstanceIdByTaskName(99L, statuses, "This is my task name");
assertEquals(1, tasks.size());
tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", processId);
assertEquals(1, tasks.size());
tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Administrator", processId);
assertEquals(0, tasks.size());
tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", otherProcessId);
assertEquals(1, tasks.size());
tasks = taskService.getTasksAssignedAsPotentialOwnerByProcessId("Bobba Fet", "bad.process.id");
assertEquals(0, tasks.size());
}
use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.
the class FormProviderServiceImplTest method testGetFormDisplayTaskWithoutProcess.
@Test
public void testGetFormDisplayTaskWithoutProcess() {
long taskId = 1;
final TaskImpl task = new TaskImpl();
task.setId(taskId);
task.setName("TaskName");
task.setTaskData(new TaskDataImpl());
when(taskService.getTaskById(taskId)).thenReturn(task);
final String form = formProviderService.getFormDisplayTask(1);
assertEquals("", form);
verify(dataService, never()).getProcessesByDeploymentIdProcessId(anyString(), anyString());
verify(formProvider).render(eq(task.getName()), eq(task), isNull(ProcessDefinition.class), anyMap());
}
use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.
the class FormProviderServiceImplTest method testGetFormDisplayTask.
@Test
public void testGetFormDisplayTask() {
long taskId = 1;
final TaskImpl task = new TaskImpl();
task.setId(taskId);
task.setName("TaskName");
final TaskDataImpl taskData = new TaskDataImpl();
final String deploymentId = "org.jbpm";
taskData.setDeploymentId(deploymentId);
final String processId = "org.jbpm.evaluation";
taskData.setProcessId(processId);
task.setTaskData(taskData);
when(taskService.getTaskById(taskId)).thenReturn(task);
final ProcessDefinition processDefinition = mock(ProcessDefinition.class);
when(dataService.getProcessesByDeploymentIdProcessId(deploymentId, processId)).thenReturn(processDefinition);
final String form = formProviderService.getFormDisplayTask(1);
assertEquals("", form);
verify(dataService).getProcessesByDeploymentIdProcessId(deploymentId, processId);
verify(formProvider).render(eq(task.getName()), eq(task), eq(processDefinition), anyMap());
}
use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.
the class TaskImpl method readExternal.
public void readExternal(ObjectInput in) throws IOException, ClassNotFoundException {
id = in.readLong();
priority = in.readInt();
archived = in.readShort();
taskType = in.readUTF();
formName = in.readUTF();
names = CollectionUtils.readI18NTextList(in);
subjects = CollectionUtils.readI18NTextList(in);
descriptions = CollectionUtils.readI18NTextList(in);
if (in.readBoolean()) {
subTaskStrategy = SubTasksStrategy.valueOf(in.readUTF());
}
if (in.readBoolean()) {
peopleAssignments = new PeopleAssignmentsImpl();
peopleAssignments.readExternal(in);
}
if (in.readBoolean()) {
delegation = new DelegationImpl();
delegation.readExternal(in);
}
if (in.readBoolean()) {
taskData = new TaskDataImpl();
taskData.readExternal(in);
}
if (in.readBoolean()) {
deadlines = new DeadlinesImpl();
deadlines.readExternal(in);
}
}
use of org.jbpm.services.task.impl.model.TaskDataImpl in project jbpm by kiegroup.
the class DistincVsJoinPerformanceTest method doJoinQuery.
private long doJoinQuery(EntityManager em, String userId, List<String> groupIds, int total) {
CriteriaBuilder builder = em.getCriteriaBuilder();
CriteriaQuery<TaskImpl> joinQuery = builder.createQuery(TaskImpl.class);
Root<TaskImpl> taskRoot = joinQuery.from(TaskImpl.class);
Join<TaskImpl, TaskDataImpl> join = taskRoot.join(TaskImpl_.taskData);
Selection select = getTaskSummarySelect(builder, taskRoot);
joinQuery.select(select);
Join<TaskImpl, PeopleAssignmentsImpl> peopleAssign = taskRoot.join(TaskImpl_.peopleAssignments);
ListJoin<PeopleAssignmentsImpl, OrganizationalEntityImpl> busAdmins = peopleAssign.join(PeopleAssignmentsImpl_.businessAdministrators, JoinType.LEFT);
ListJoin<PeopleAssignmentsImpl, OrganizationalEntityImpl> potOwners = peopleAssign.join(PeopleAssignmentsImpl_.potentialOwners, JoinType.LEFT);
ListJoin<PeopleAssignmentsImpl, OrganizationalEntityImpl> stakeHols = peopleAssign.join(PeopleAssignmentsImpl_.taskStakeholders, JoinType.LEFT);
List<Predicate> predicates = new ArrayList<Predicate>();
predicates.add(builder.equal(taskRoot.get(TaskImpl_.taskData).get(TaskDataImpl_.actualOwner).get(UserImpl_.id), userId));
predicates.add(builder.equal(taskRoot.get(TaskImpl_.taskData).get(TaskDataImpl_.createdBy).get(UserImpl_.id), userId));
predicates.add(builder.or(builder.equal(busAdmins.get(OrganizationalEntityImpl_.id), userId), busAdmins.get(OrganizationalEntityImpl_.id).in(groupIds)));
predicates.add(builder.or(builder.equal(potOwners.get(OrganizationalEntityImpl_.id), userId), potOwners.get(OrganizationalEntityImpl_.id).in(groupIds)));
predicates.add(builder.or(builder.equal(stakeHols.get(OrganizationalEntityImpl_.id), userId), stakeHols.get(OrganizationalEntityImpl_.id).in(groupIds)));
if (!predicates.isEmpty()) {
joinQuery.where(builder.or(predicates.toArray(new Predicate[predicates.size()])));
}
return timeQueryExecution(em, joinQuery, null, total);
}
Aggregations