コード例 #1
0
 @Override
 public Long countPatientFilteredByCdt(ImogJunction criterion, String cdtId) {
   CriteriaBuilder builder = em.getCriteriaBuilder();
   CriteriaQuery<Long> query = builder.createQuery(Long.class);
   Root<Patient> root = query.from(Patient.class);
   query.select(builder.count(root));
   Path<Object> join = root.join("centres", JoinType.LEFT).get("id");
   query.where(builder.equal(join, cdtId), DaoUtil.<Patient>toPredicate(criterion, builder, root));
   return em.createQuery(query).getSingleResult();
 }
コード例 #2
0
  @Override
  public List<Patient> listPatientFilteredByCdt(
      int first, int max, String property, boolean asc, ImogJunction criterion, String cdtId) {

    CriteriaBuilder builder = em.getCriteriaBuilder();
    CriteriaQuery<Patient> query = builder.createQuery(clazz);
    Root<Patient> root = query.from(Patient.class);
    query.select(root);
    Path<Object> join = root.join("centres", JoinType.LEFT).get("id");
    query.where(builder.equal(join, cdtId), DaoUtil.<Patient>toPredicate(criterion, builder, root));
    if (property == null) {
      property = "modified";
    }
    Order o =
        asc
            ? builder.asc(DaoUtil.getCascadeRoot(root, property))
            : builder.desc(DaoUtil.getCascadeRoot(root, property));
    query.orderBy(o, builder.desc(root.<String>get("id")));
    return em.createQuery(query).setFirstResult(first).setMaxResults(max).getResultList();
  }
コード例 #3
0
 @Override
 protected Predicate getFilter(Root<Patient> root, CriteriaBuilder builder) {
   ImogActor actor = ImogActorUtils.getCurrentActor();
   if (actor == null) {
     actor = HttpSessionUtil.getCurrentUser();
   }
   if (actor instanceof Personnel) {
     Personnel personnel = (Personnel) actor;
     String niveau = personnel.getNiveau();
     if ("1".equals(niveau)) {
       Path<?> join = DaoUtil.getCascadeRoot(root.join("centres", JoinType.LEFT), "region.id");
       return builder.equal(join, personnel.getRegion().getId());
     } else if ("2".equals(niveau)) {
       Path<?> join =
           DaoUtil.getCascadeRoot(root.join("centres", JoinType.LEFT), "districtSante.id");
       return builder.equal(join, personnel.getDistrictSante().getId());
     } else if ("3".equals(niveau)) {
       Path<?> join = root.join("centres", JoinType.LEFT).get("id");
       return builder.equal(join, personnel.getCDT().getId());
     }
   }
   return null;
 }