use of org.jbpm.services.task.impl.model.OrganizationalEntityImpl 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