use of org.kie.internal.task.query.TaskSummaryQueryBuilder in project jbpm by kiegroup.
the class RuntimeDataServiceImpl method getTasksByVariable.
@Override
public List<TaskSummary> getTasksByVariable(String userId, String variableName, List<Status> statuses, QueryContext queryContext) {
TaskSummaryQueryBuilder queryBuilder = new TaskSummaryQueryBuilderImpl(userId, taskService).intersect();
addVariableNameAndVariableValueParameters(queryBuilder, variableName);
if (statuses != null && !statuses.isEmpty()) {
queryBuilder.status(statuses.toArray(new Status[statuses.size()]));
}
setQueryContextOptions(queryContext, queryBuilder);
return queryBuilder.build().getResultList();
}
use of org.kie.internal.task.query.TaskSummaryQueryBuilder in project jbpm by kiegroup.
the class RuntimeDataServiceImpl method getTasksByVariableAndValue.
@Override
public List<TaskSummary> getTasksByVariableAndValue(String userId, String variableName, String variableValue, List<Status> statuses, QueryContext queryContext) {
TaskSummaryQueryBuilder queryBuilder = new TaskSummaryQueryBuilderImpl(userId, taskService).intersect();
addVariableNameAndVariableValueParameters(queryBuilder, variableName, variableValue);
if (statuses != null && !statuses.isEmpty()) {
queryBuilder.status(statuses.toArray(new Status[statuses.size()]));
}
setQueryContextOptions(queryContext, queryBuilder);
return queryBuilder.build().getResultList();
}
use of org.kie.internal.task.query.TaskSummaryQueryBuilder in project jbpm by kiegroup.
the class TaskQueryBuilderLocalTest method testTaskQueryBuilder.
@Test
public void testTaskQueryBuilder() {
Task[] tasks = new Task[12];
List<Long> workItemIds = new ArrayList<Long>();
List<Long> procInstIds = new ArrayList<Long>();
List<Long> taskIds = new ArrayList<Long>();
List<String> busAdmins = new ArrayList<String>();
List<String> potOwners = new ArrayList<String>();
List<Status> statuses = new ArrayList<Status>();
statuses.add(Status.Reserved);
TaskImpl taskImpl;
Long firstTaskId;
{
long workItemId = 231;
long procInstId = 1011;
String busAdmin = "Parzival";
String potOwner = "Art3mis";
String name = "EggHunting";
taskImpl = addTask(workItemId, procInstId, busAdmin, potOwner, name, null);
firstTaskId = taskImpl.getId();
taskIds.add(firstTaskId);
assertEquals(potOwner, taskImpl.getTaskData().getActualOwner().getId());
tasks[0] = taskImpl;
procInstIds.add(procInstId);
workItemIds.add(workItemId);
busAdmins.add(busAdmin);
potOwners.add(potOwner);
// as much as possible
TaskSummaryQueryBuilder queryBuilder = taskService.taskSummaryQuery(stakeHolder).intersect().workItemId(workItemId).processInstanceId(procInstId).businessAdmin(busAdmin).potentialOwner(potOwner).taskId(taskImpl.getId()).ascending(OrderBy.taskId);
List<TaskSummary> results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
queryBuilder.clear();
results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
}
{
long workItemId = 251;
long procInstId = 1031;
String busAdmin = "Neuromancer";
String potOwner = "Hideo";
taskImpl = addTask(workItemId, procInstId, busAdmin, potOwner, "This is my task name", null);
taskIds.add(taskImpl.getId());
assertEquals(potOwner, taskImpl.getTaskData().getActualOwner().getId());
// start task
taskService.start(taskImpl.getId(), potOwner);
tasks[1] = (Task) taskService.getTaskById(taskImpl.getId());
statuses.add(tasks[1].getTaskData().getStatus());
procInstIds.add(procInstId);
workItemIds.add(workItemId);
busAdmins.add(busAdmin);
potOwners.add(potOwner);
// as much as possible
TaskSummaryQueryBuilder queryBuilder = taskService.taskSummaryQuery(stakeHolder).intersect().workItemId(workItemId).processInstanceId(procInstId).businessAdmin(busAdmin).potentialOwner(potOwner).taskId(taskImpl.getId());
List<TaskSummary> results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
queryBuilder.clear();
results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 2, results.size());
queryBuilder.clear();
queryBuilder.workItemId(workItemId);
results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
assertEquals("Incorrect task retrieved", tasks[1].getId(), results.get(0).getId());
queryBuilder.clear();
queryBuilder.processInstanceId(procInstId);
results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
assertEquals("Incorrect task retrieved", tasks[1].getId(), results.get(0).getId());
queryBuilder.clear();
queryBuilder.businessAdmin(busAdmin);
results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
assertEquals("Incorrect task retrieved", tasks[1].getId(), results.get(0).getId());
queryBuilder.clear();
queryBuilder.potentialOwner(potOwner);
results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
assertEquals("Incorrect task retrieved", tasks[1].getId(), results.get(0).getId());
queryBuilder.clear();
queryBuilder.taskId(taskImpl.getId());
results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
assertEquals("Incorrect task retrieved", tasks[1].getId(), results.get(0).getId());
}
{
// Add one more task, just to make sure things are working wel
long workItemId = 57;
long procInstId = 11111;
String busAdmin = "reviewer";
String potOwner = "translator";
String deploymentId = "armitage";
String name = "Koude Bevel";
taskImpl = addTask(workItemId, procInstId, busAdmin, potOwner, name, deploymentId);
procInstIds.add(procInstId);
workItemIds.add(workItemId);
busAdmins.add(busAdmin);
potOwners.add(potOwner);
assertEquals(potOwner, taskImpl.getTaskData().getActualOwner().getId());
taskService.start(taskImpl.getId(), potOwner);
taskService.fail(taskImpl.getId(), busAdmin, null);
TaskSummaryQueryBuilder queryBuilder = taskService.taskSummaryQuery(stakeHolder).maxResults(1);
List<TaskSummary> results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
queryBuilder.clear();
results = queryBuilder.build().getResultList();
assertFalse("Empty List of tasks", results.isEmpty() || results.size() == 1);
testOrderByTaskIdAscending(results);
queryBuilder.clear();
queryBuilder.descending(OrderBy.processInstanceId);
results = queryBuilder.build().getResultList();
assertFalse("List of tasks too small", results.isEmpty() || results.size() == 1);
for (int i = 1; i < results.size(); ++i) {
Long aVal = results.get(i - 1).getProcessInstanceId();
Long bVal = results.get(i).getProcessInstanceId();
assertTrue("Tasks not correctly ordered: " + aVal + " ?>? " + bVal, aVal > bVal);
}
queryBuilder.offset(results.size() - 1).ascending(OrderBy.taskId);
results = queryBuilder.build().getResultList();
assertFalse("Empty List of tasks", results.isEmpty());
assertEquals("List of tasks", 1, results.size());
assertEquals("Task id", taskImpl.getId(), results.get(0).getId());
}
TaskSummaryQueryBuilder queryBuilder = taskService.taskSummaryQuery(stakeHolder);
List<TaskSummary> results = queryBuilder.businessAdmin(busAdmins.toArray(new String[busAdmins.size()])).build().getResultList();
assertEquals(3, results.size());
// pagination
{
// Add two more tasks, in order to have a quorum
long workItemId = 59;
long procInstId = 12111;
String busAdmin = "Wintermute";
String potOwner = "molly";
String deploymentId = "Dixie Flatline";
String name = "Complete Mission";
taskImpl = addTask(workItemId, procInstId, busAdmin, potOwner, name, deploymentId);
// Add two more tasks, in order to have a quorum
++workItemId;
++procInstId;
busAdmin = "Neuromancer";
potOwner = "case";
deploymentId = "Linda Lee";
name = "Resurrect";
taskImpl = addTask(workItemId, procInstId, busAdmin, potOwner, name, deploymentId);
}
results = queryBuilder.clear().build().getResultList();
assertTrue("Result list too small to test: " + results.size(), results.size() == 5);
results = queryBuilder.clear().offset(1).build().getResultList();
assertTrue("Expected 4, not " + results.size() + " results", results.size() == 4);
results = queryBuilder.clear().offset(1).maxResults(3).build().getResultList();
assertTrue("Expected 3, not " + results.size() + " results", results.size() == 3);
results = queryBuilder.clear().offset(3).maxResults(3).build().getResultList();
assertTrue("Expected 2, not " + results.size() + " results", results.size() == 2);
// pot owner (and no "user-group limiting" clause)
{
// Add two more tasks, in order to have a quorum
long workItemId = 104;
long procInstId = 1766;
String busAdmin = stakeHolder;
String potOwner = stakeHolder;
String deploymentId = "Louis de Ponte du Lac";
String name = "Interview";
taskImpl = addTask(workItemId, procInstId, busAdmin, potOwner, name, deploymentId);
}
queryBuilder.clear();
queryBuilder = taskService.taskSummaryQuery(stakeHolder).intersect().potentialOwner(stakeHolder);
results = queryBuilder.build().getResultList();
assertEquals("List of tasks", 1, results.size());
}
use of org.kie.internal.task.query.TaskSummaryQueryBuilder in project jbpm by kiegroup.
the class TaskQueryBuilderLocalTest method testTaskQueryBuilderSimply.
@Test
public void testTaskQueryBuilderSimply() {
TaskSummaryQueryBuilder queryBuilder = taskService.taskSummaryQuery(stakeHolder);
queryBuilder.build().getResultList();
}
use of org.kie.internal.task.query.TaskSummaryQueryBuilder in project jbpm by kiegroup.
the class TaskSummaryQueryBuilderCoverageTest method taskQueryBuilderCoverageTest.
@Test
public void taskQueryBuilderCoverageTest() {
TaskSummaryQueryBuilder queryBuilder = taskService.taskSummaryQuery("userId");
Class builderClass = TaskSummaryQueryBuilder.class;
queryBuilderCoverageTest(queryBuilder, builderClass, inputFiller, "variableName", "variableValue");
}
Aggregations