Search in sources :

Example 1 with OrganizationalEntityImpl

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);
}
Also used : CriteriaBuilder(javax.persistence.criteria.CriteriaBuilder) OrganizationalEntityImpl(org.jbpm.services.task.impl.model.OrganizationalEntityImpl) TaskImpl(org.jbpm.services.task.impl.model.TaskImpl) Selection(javax.persistence.criteria.Selection) ArrayList(java.util.ArrayList) TaskDataImpl(org.jbpm.services.task.impl.model.TaskDataImpl) Predicate(javax.persistence.criteria.Predicate) PeopleAssignmentsImpl(org.jbpm.services.task.impl.model.PeopleAssignmentsImpl)

Aggregations

ArrayList (java.util.ArrayList)1 CriteriaBuilder (javax.persistence.criteria.CriteriaBuilder)1 Predicate (javax.persistence.criteria.Predicate)1 Selection (javax.persistence.criteria.Selection)1 OrganizationalEntityImpl (org.jbpm.services.task.impl.model.OrganizationalEntityImpl)1 PeopleAssignmentsImpl (org.jbpm.services.task.impl.model.PeopleAssignmentsImpl)1 TaskDataImpl (org.jbpm.services.task.impl.model.TaskDataImpl)1 TaskImpl (org.jbpm.services.task.impl.model.TaskImpl)1