use of fi.otavanopisto.muikku.model.base.BooleanPredicate in project muikku by otavanopisto.
the class WorkspaceFolderDAO method listByHiddenAndParentAndFolderType.
public List<WorkspaceFolder> listByHiddenAndParentAndFolderType(BooleanPredicate hidden, WorkspaceNode parent, WorkspaceFolderType folderType) {
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<WorkspaceFolder> criteria = criteriaBuilder.createQuery(WorkspaceFolder.class);
Root<WorkspaceFolder> root = criteria.from(WorkspaceFolder.class);
criteria.select(root);
List<Predicate> predicates = new ArrayList<>();
predicates.add(criteriaBuilder.equal(root.get(WorkspaceFolder_.parent), parent));
predicates.add(criteriaBuilder.equal(root.get(WorkspaceFolder_.folderType), folderType));
if (hidden != BooleanPredicate.IGNORE) {
predicates.add(criteriaBuilder.equal(root.get(WorkspaceFolder_.hidden), hidden.asBoolean()));
}
criteria.where(criteriaBuilder.and(predicates.toArray(new Predicate[0])));
return entityManager.createQuery(criteria).getResultList();
}
use of fi.otavanopisto.muikku.model.base.BooleanPredicate in project muikku by otavanopisto.
the class WorkspaceMaterialDAO method listByHiddenAndAssignmentTypeAndParents.
public List<WorkspaceMaterial> listByHiddenAndAssignmentTypeAndParents(BooleanPredicate hidden, WorkspaceMaterialAssignmentType assignmentType, List<WorkspaceNode> parents) {
if (parents == null || parents.isEmpty()) {
return Collections.emptyList();
}
EntityManager entityManager = getEntityManager();
CriteriaBuilder criteriaBuilder = entityManager.getCriteriaBuilder();
CriteriaQuery<WorkspaceMaterial> criteria = criteriaBuilder.createQuery(WorkspaceMaterial.class);
Root<WorkspaceMaterial> root = criteria.from(WorkspaceMaterial.class);
criteria.select(root);
List<Predicate> predicates = new ArrayList<>();
predicates.add(criteriaBuilder.equal(root.get(WorkspaceMaterial_.assignmentType), assignmentType));
predicates.add(root.get(WorkspaceMaterial_.parent).in(parents));
if (hidden != BooleanPredicate.IGNORE) {
predicates.add(criteriaBuilder.equal(root.get(WorkspaceMaterial_.hidden), hidden.asBoolean()));
}
criteria.where(criteriaBuilder.and(predicates.toArray(new Predicate[0])));
return entityManager.createQuery(criteria).getResultList();
}
Aggregations