public Criteria createSubcriteria(Criteria parent, Iterable<CriteriaEvent> events) {
   // call the right overload to actually create the Criteria
   Criteria crit;
   switch (methodSig) {
     case ASSOCIATION:
       crit = parent.createCriteria(association);
       break;
     case ASSOCIATION_AND_JOIN_TYPE:
       crit = parent.createCriteria(association, joinType);
       break;
     case ASSOCIATION_AND_ALIAS:
       crit = parent.createCriteria(association, alias);
       break;
     case ASSOCIATION_AND_ALIAS_AND_JOIN_TYPE:
       crit = parent.createCriteria(association, alias, joinType);
       break;
     default:
       throw new ShardedSessionException(
           "Unknown constructor type for subcriteria creation: " + methodSig);
   }
   // apply the events
   for (CriteriaEvent event : events) {
     event.onEvent(crit);
   }
   return crit;
 }
  /**
   * Méthode en charge de traiter le critère posé sur le type de recherche par essai.
   *
   * @param criteria Criteria Hibernate.
   * @param crit Critère de recherche patient.
   */
  private void handleCriteriaByTypeInclusion(
      final Criteria criteria, final PatientSearchCriteria crit) {
    // Si seulelement l'énumération est sélectionnée
    if ((crit.getByEssai() != null) && (crit.getEssaiByType() == null)) {
      if (crit.getByEssai().equals(TypeRechercheParEssai.ACUTELLEMENT_INCLU)) {
        final Criteria critInclusion = criteria.createCriteria("inclusions", "inclusions");

        CriteriaMakerUtils.addCritere(critInclusion, "inclusions.actif", true);
      } else {
        criteria.add(Restrictions.isNotEmpty("inclusions"));
      }
    }

    // si un essai est saisi sans type d'inclusion.
    if ((crit.getByEssai() == null) && (crit.getEssaiByType() != null)) {
      final Criteria critInclusion = criteria.createCriteria("inclusions", "inclusions");

      CriteriaMakerUtils.addCritere(critInclusion, "inclusions.essai", crit.getEssaiByType());

      CriteriaMakerUtils.addCritere(critInclusion, "inclusions.actif", true);
    }

    // si un type est saisi et l'essai aussi
    if ((crit.getByEssai() != null) && (crit.getEssaiByType() != null)) {

      final Criteria critInclusion = criteria.createCriteria("inclusions", "inclusions");
      CriteriaMakerUtils.addCritere(critInclusion, "inclusions.essai", crit.getEssaiByType());

      if (crit.getByEssai().equals(TypeRechercheParEssai.ACUTELLEMENT_INCLU)) {
        CriteriaMakerUtils.addCritere(critInclusion, "inclusions.actif", true);
      }
    }
  }
示例#3
0
  public Map<String, Object> lista(Map<String, Object> params) {
    log.debug("Buscando lista de facturas con params {}", params);
    if (params == null) {
      params = new HashMap<>();
    }

    if (!params.containsKey("max")) {
      params.put("max", 10);
    } else {
      params.put("max", Math.min((Integer) params.get("max"), 100));
    }

    if (params.containsKey("pagina")) {
      Long pagina = (Long) params.get("pagina");
      Long offset = (pagina - 1) * (Integer) params.get("max");
      params.put("offset", offset.intValue());
    }

    if (!params.containsKey("offset")) {
      params.put("offset", 0);
    }
    Criteria criteria = currentSession().createCriteria(FacturaAlmacen.class);
    Criteria countCriteria = currentSession().createCriteria(FacturaAlmacen.class);

    if (params.containsKey("almacen")) {
      criteria.createCriteria("almacen").add(Restrictions.idEq(params.get("almacen")));
      countCriteria.createCriteria("almacen").add(Restrictions.idEq(params.get("almacen")));
    }

    if (params.containsKey("filtro")) {
      String filtro = (String) params.get("filtro");
      Disjunction propiedades = Restrictions.disjunction();
      propiedades.add(Restrictions.ilike("folio", filtro, MatchMode.ANYWHERE));
      criteria.add(propiedades);
      countCriteria.add(propiedades);
    }

    if (params.containsKey("order")) {
      String campo = (String) params.get("order");
      if (params.get("sort").equals("desc")) {
        criteria.addOrder(Order.desc(campo));
      } else {
        criteria.addOrder(Order.asc(campo));
      }
    } else {
      criteria.createCriteria("estatus").addOrder(Order.asc("prioridad"));
    }
    criteria.addOrder(Order.desc("fechaModificacion"));

    if (!params.containsKey("reporte")) {
      criteria.setFirstResult((Integer) params.get("offset"));
      criteria.setMaxResults((Integer) params.get("max"));
    }
    params.put("facturas", criteria.list());

    countCriteria.setProjection(Projections.rowCount());
    params.put("cantidad", (Long) countCriteria.list().get(0));

    return params;
  }
示例#4
0
 /**
  * Find a profile by email address, but only looking within the given organisation or subordinate
  * orgs
  *
  * @param email
  * @param org
  * @param session
  * @return
  */
 public static Profile findByEmail(String email, Organisation org, Session session) {
   Criteria crit = session.createCriteria(Profile.class);
   crit.setCacheable(true);
   // join to group membership, then subordinate, then restrict on org
   Criteria critMembership = crit.createCriteria("memberships");
   Criteria critSubordinate = critMembership.createCriteria("subordinates");
   crit.add(Restrictions.eq("email", email));
   critSubordinate.add(Restrictions.eq("withinOrg", org));
   return DbUtils.unique(crit);
 }
示例#5
0
  @Override
  protected Criteria createCriteria(Board template) {
    Criteria criteria = super.createCriteria(template);
    if (template.getBoardDef() != null) {
      criteria
          .createCriteria(Board.PROPERTY_priceAware)
          .add(Example.create(template.getBoardDef()));
    }

    if (template.getTexture() != null) {
      criteria.createCriteria(Board.PROPERTY_priced).add(Example.create(template.getTexture()));
    }
    return criteria;
  }
 public static void findChildCentreByAccessCriteria(Criteria criteria) {
   Integer centre = SecurityUtil.getInstance().getCentre();
   if (centre != null && centre != 0) {
     // have just country access to restrict to all centres in that country
     criteria.createCriteria("child.centre").add(Restrictions.eq("id", new Long(centre)));
   }
 }
 /**
  * Add order to criteria, creating necessary subCriteria if nested sort property (ie.
  * sort:'nested.property').
  */
 private static void addOrderPossiblyNested(
     AbstractHibernateDatastore datastore,
     Criteria c,
     Class<?> targetClass,
     String sort,
     String order,
     boolean ignoreCase) {
   int firstDotPos = sort.indexOf(".");
   if (firstDotPos == -1) {
     addOrder(c, sort, order, ignoreCase);
   } else { // nested property
     String sortHead = sort.substring(0, firstDotPos);
     String sortTail = sort.substring(firstDotPos + 1);
     PersistentProperty property = getGrailsDomainClassProperty(datastore, targetClass, sortHead);
     if (property instanceof Embedded) {
       // embedded objects cannot reference entities (at time of writing), so no more recursion
       // needed
       addOrder(c, sort, order, ignoreCase);
     } else if (property instanceof Association) {
       Criteria subCriteria = c.createCriteria(sortHead);
       Class<?> propertyTargetClass =
           ((Association) property).getAssociatedEntity().getJavaClass();
       GrailsHibernateUtil.cacheCriteriaByMapping(datastore, propertyTargetClass, subCriteria);
       addOrderPossiblyNested(
           datastore,
           subCriteria,
           propertyTargetClass,
           sortTail,
           order,
           ignoreCase); // Recurse on nested sort
     }
   }
 }
  protected Criteria buildProcessInstanceExtensionSearchCriteria(
      long companyId, Long userId, String assetClassName, Long assetClassPK, Boolean completed) {

    Criteria criteria = _session.createCriteria(ProcessInstanceExtensionImpl.class);

    criteria.add(Restrictions.eq("companyId", companyId));

    if (userId != null) {
      criteria.add(Restrictions.eq("userId", userId));
    }

    if (Validator.isNotNull(assetClassName)) {
      criteria.add(Restrictions.like("className", assetClassName));
    }

    if (Validator.isNotNull(assetClassPK)) {
      criteria.add(Restrictions.eq("classPK", assetClassPK));
    }

    if (completed != null) {
      Criteria completionCriteria = criteria.createCriteria("processInstance");

      if (completed) {
        completionCriteria.add(Restrictions.isNotNull("end"));
      } else {
        completionCriteria.add(Restrictions.isNull("end"));
      }
    }

    return criteria;
  }
示例#9
0
 protected static void findChildCountryByAccessCriteria(Criteria criteria) {
   Integer country = SecurityUtil.getInstance().getCountry();
   if (country != null && country != 0) {
     // have just country access to restrict to all centres in that country
     criteria.createCriteria("child.country").add(Restrictions.eq("id", new Long(country)));
   }
 }
 @Override
 public <T extends GettableById> List<T> get(
     Class<T> bookEntityClass,
     int from,
     int to,
     Map<String, List<Criterion>> restrictions,
     OrderByFilter filter) {
   validateTransaction();
   Criteria criteria = getSession().createCriteria(bookEntityClass);
   criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);
   criteria.setFirstResult(from);
   if (to != 0) criteria.setMaxResults(to);
   for (String key : restrictions.keySet()) {
     if (key.equals(RestrictionsFields.MAIN_RESTRICTIONS)) {
       for (Criterion restriction : restrictions.get(RestrictionsFields.MAIN_RESTRICTIONS))
         criteria.add(restriction);
     } else if (restrictions.get(key).size() > 0) {
       Criteria c = criteria.createCriteria(key);
       for (Criterion restriction : restrictions.get(key)) c.add(restriction);
     }
   }
   if (filter != null) {
     if (filter.getDirection().equals(OrderByFilter.ASC))
       criteria.addOrder(Order.asc(filter.field));
     else criteria.addOrder(Order.desc(filter.field));
   }
   return criteria.list();
 }
示例#11
0
  /**
   * Perform a search over all child and sub orgs within the given organisation
   *
   * <p>If a search query is given it will be split by space and the key words searched in the
   * title, orgid, address, addressLine2 and postcode fields.
   *
   * @param q - search query, which is a space seperated list of key words. Optional
   * @param organisation - search is for orgs inside this
   * @param orgType - optional, if given results are limited to organisations of this type
   * @param session
   * @return
   */
  public static List<Organisation> search(
      String q, Organisation organisation, OrgType orgType, Session session) {
    Criteria crit = session.createCriteria(Organisation.class);
    crit.setCacheable(true);
    Disjunction notDeleted = Restrictions.disjunction();
    notDeleted.add(Restrictions.isNull("deleted"));
    notDeleted.add(Restrictions.eq("deleted", Boolean.FALSE));
    crit.add(notDeleted);

    if (q != null) {
      String[] arr = q.split(" ");
      Conjunction con = Restrictions.conjunction();
      for (String queryPart : arr) {
        Disjunction dis = Restrictions.disjunction();
        String s = "%" + queryPart + "%";
        dis.add(Restrictions.ilike("title", s));
        dis.add(Restrictions.ilike("orgId", s));
        dis.add(Restrictions.ilike("address", s));
        dis.add(Restrictions.ilike("addressLine2", s));
        dis.add(Restrictions.ilike("postcode", s));
        con.add(dis);
      }
      crit.add(con);
    }

    if (orgType != null) {
      crit.add(Restrictions.eq("orgType", orgType));
    }
    // TODO: add other properties like address
    Criteria critParentLink = crit.createCriteria("parentOrgLinks");
    critParentLink.add(Restrictions.eq("owner", organisation));
    crit.addOrder(Order.asc("title"));
    return DbUtils.toList(crit, Organisation.class);
  }
  /**
   * Méthode en charge de traiter les critères posés sur Essai.
   *
   * @param criteria Criteria Hibernate.
   * @param crit Critère de recherche Patient.
   */
  protected void handleCriteriaEssai(final Criteria criteria, final PatientSearchCriteria crit) {
    if (crit.getEssai() != null) {
      final Criteria critInclusion = criteria.createCriteria("inclusions", "inclusions");

      CriteriaMakerUtils.addCritere(critInclusion, "inclusions.essai", crit.getEssai());
    }
  }
  private Criteria buildCriteria(QueryModel queryModel) {
    Criteria criteria = getCurrentSession().createCriteria(persistentClass);

    if (queryModel.getConditions() != null) {
      for (Condition condition : queryModel.getConditions()) {
        criteria.add((Criterion) condition.getConstraint());
      }
    }

    for (Map.Entry<String, List<Condition>> associationCriteriaEntry :
        queryModel.getAssociationConditions().entrySet()) {
      Criteria associationCriteria = criteria.createCriteria(associationCriteriaEntry.getKey());

      criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

      for (Condition condition : associationCriteriaEntry.getValue()) {
        associationCriteria.add((Criterion) condition.getConstraint());
      }
    }

    if (queryModel.getProjection() != null) {
      ProjectionList projectionList = Projections.projectionList();

      projectionList.add(
          (org.hibernate.criterion.Projection) queryModel.getProjection().getDetails());

      criteria.setProjection(projectionList);
    }

    return criteria;
  }
示例#14
0
 /**
  * Find a user who has a membership in the given organisation
  *
  * @param org
  * @param name
  * @param session
  * @return
  */
 public static Profile find(Organisation org, String name, Session session) {
   Criteria crit = session.createCriteria(Profile.class);
   crit.setCacheable(true);
   // join to group membership, then subordinate, then restrict on org
   Criteria critMembership = crit.createCriteria("memberships");
   Criteria critSubordinate = critMembership.createCriteria("subordinates");
   crit.add(Restrictions.eq("name", name));
   critSubordinate.add(Restrictions.eq("withinOrg", org));
   List list = crit.list();
   if (list == null || list.isEmpty()) {
     log.warn("Profile not found: " + name + " in org: " + org.getOrgId());
     return null;
   } else {
     return (Profile) list.get(0);
   }
 }
  @Test
  @TestForIssue(jiraKey = "HHH-7767")
  public void testCriteriaRestrictionOnIdManyToOne() {
    Session s = openSession();
    s.beginTransaction();

    s.createQuery("from Course c join c.students cs join cs.student s where s.name = 'Foo'").list();

    Criteria criteria = s.createCriteria(Course.class);
    criteria
        .createCriteria("students")
        .createCriteria("student")
        .add(Restrictions.eq("name", "Foo"));
    criteria.list();

    Criteria criteria2 = s.createCriteria(Course.class);
    criteria2.createAlias("students", "cs");
    criteria2.add(Restrictions.eq("cs.value", "Bar"));
    criteria2.createAlias("cs.student", "s");
    criteria2.add(Restrictions.eq("s.name", "Foo"));
    criteria2.list();

    s.getTransaction().commit();
    s.close();
  }
示例#16
0
 @Override
 public List<ThesaurusConcept> getAllRootChildren(ThesaurusConcept concept) {
   Criteria criteria = getCurrentSession().createCriteria(ThesaurusConcept.class, "tc");
   criteria
       .createCriteria("tc.rootConcepts", "rc")
       .add(Restrictions.eq("rc.identifier", concept.getIdentifier()));
   return criteria.list();
 }
  /**
   * Run a query to calculate the total number of records that match the search criteria.
   *
   * @param criterion used to create the search criteria
   * @param conjunction used to create the search criteria
   * @return the total number of matches for the search criteria
   */
  private int calculateMaxListSize(Example criterion, Conjunction conjunction) {
    Criteria criteria = getSession().createCriteria(Keyword.class);
    criteria.add(criterion);
    if (conjunction != null) criteria.createCriteria(FIELD_TRANSLATIONS).add(conjunction);
    criteria.setProjection(Projections.countDistinct(FIELD_ID));

    return (Integer) criteria.uniqueResult();
  }
示例#18
0
 public static List<Profile> findByGroup(Group group, Session session) {
   Criteria crit = session.createCriteria(Profile.class);
   crit.setCacheable(true);
   // join to group membership, then subordinate, then restrict on org
   Criteria critMembership = crit.createCriteria("memberships");
   critMembership.add(Restrictions.eq("groupEntity", group));
   return DbUtils.toList(crit, Profile.class);
 }
示例#19
0
 public static List<Profile> findByBusinessUnit(Organisation organisation, Session session) {
   Criteria crit = session.createCriteria(Profile.class);
   crit.setCacheable(true);
   // join to group membership, then subordinate, then restrict on org
   Criteria critMembership = crit.createCriteria("memberships");
   critMembership.add(Restrictions.eq("withinOrg", organisation));
   return DbUtils.toList(crit, Profile.class);
 }
  private void attachRootFilters(
      Criteria projectCrit,
      Criteria iterationCrit,
      Criteria standaloneIterationCrit,
      int projectId) {
    LogicalExpression parentInProductBacklog =
        Restrictions.and(
            Restrictions.isNotNull("parent"),
            Restrictions.eqProperty("parentStory.backlog", "project.parent"));
    // stories attached to the project
    projectCrit.add(Restrictions.eq("backlog.id", projectId));
    projectCrit.createAlias("backlog", "project");

    projectCrit.createAlias("parent", "parentStory", CriteriaSpecification.LEFT_JOIN);
    Criterion parentFilter = Restrictions.or(Restrictions.isNull("parent"), parentInProductBacklog);

    projectCrit.add(parentFilter);
    projectCrit.add(Restrictions.isNull("iteration"));

    // Stories attached to iterations under the project
    iterationCrit.createAlias("parent", "parentStory", CriteriaSpecification.LEFT_JOIN);
    iterationCrit
        .createCriteria("iteration")
        .add(Restrictions.eq("parent.id", projectId))
        .createAlias("parent", "project");
    iterationCrit.add(parentFilter);

    // Stories in standalone iterations and this project
    if (standaloneIterationCrit != null) {
      // story's backlog is this project
      standaloneIterationCrit.add(Restrictions.eq("backlog.id", projectId));

      // story's iteration is not null
      standaloneIterationCrit.add(Restrictions.isNotNull("iteration"));

      // story's iteration doesn't have a parent
      standaloneIterationCrit.createCriteria("iteration").add(Restrictions.isNull("parent"));

      standaloneIterationCrit.createAlias("backlog", "project");

      // story doesn't have a parent OR parent in product
      standaloneIterationCrit.createAlias("parent", "parentStory", CriteriaSpecification.LEFT_JOIN);
      standaloneIterationCrit.add(parentFilter);
    }
  }
  /**
   * Gets a list of all calendars available sorted by primary key.
   *
   * @return List of Calendar
   * @throws Exception
   */
  public Set getCalendarList(List roles, List groups, Session session) throws Exception {
    List result = null;

    Query q = session.createQuery("from Calendar calendar order by calendar.id");

    Criteria criteria = session.createCriteria(Calendar.class);
    criteria.createCriteria("owningRoles").add(Expression.in("name", roles.toArray()));
    if (groups.size() > 0)
      criteria.createCriteria("owningGroups").add(Expression.in("name", groups.toArray()));
    criteria.addOrder(Order.asc("name"));

    // result = criteria.list();
    // return result;
    Set set = new LinkedHashSet();
    set.addAll(criteria.list());

    return set;
  }
 public static void findReportCentreByAccessCriteria(Criteria criteria) {
   Integer centre = SecurityUtil.getInstance().getCentre();
   if (centre != null && centre != 0) {
     // have just country access to restrict to all centres in that country
     criteria
         .createCriteria("centre", CriteriaSpecification.LEFT_JOIN)
         .add(Restrictions.or(Restrictions.eq("id", new Long(centre)), Restrictions.isNull("id")));
   }
 }
示例#23
0
  /**
   * Find the given orgId within an administrative org
   *
   * @param adminOrg
   * @param orgId
   * @param session
   * @return
   */
  public static Organisation findByOrgId(Organisation adminOrg, String orgId, Session session) {
    Criteria crit = session.createCriteria(Organisation.class);
    Criteria critSubOrg = crit.createCriteria("parentOrgLinks");

    crit.setCacheable(true);
    crit.add(Restrictions.eq("orgId", orgId));
    critSubOrg.add(Restrictions.eq("owner", adminOrg));
    return DbUtils.unique(crit);
  }
 @SuppressWarnings("unchecked")
 @Override
 public List<ItemCompra> listarComprasProdutoPorPeriodo(
     final Produto produto, final Date dataInicial, final Date dataFinal) {
   Criteria criteria = criarCriteria();
   criteria.add(Restrictions.eq("produto", produto));
   return criteria
       .createCriteria("compra")
       .add(Restrictions.between("dataCompra", dataInicial, dataFinal))
       .list();
 }
  public List<TaskInstance> findTaskInstances(
      long processInstanceId,
      long tokenId,
      String[] actorIds,
      boolean pooledActors,
      Boolean completed,
      int start,
      int end,
      OrderByComparator orderByComparator) {

    if ((actorIds != null) && (actorIds.length == 0)) {
      return Collections.emptyList();
    }

    try {
      Criteria criteria = _session.createCriteria(TaskInstance.class);

      criteria.setResultTransformer(Criteria.DISTINCT_ROOT_ENTITY);

      if (processInstanceId > 0) {
        criteria.add(Restrictions.eq("processInstance.id", processInstanceId));
      } else if (tokenId > 0) {
        criteria.add(Restrictions.eq("token.id", tokenId));
      }

      if (actorIds != null) {
        if (pooledActors) {
          Criteria subcriteria = criteria.createCriteria("pooledActors");

          subcriteria.add(Restrictions.in("actorId", actorIds));

          criteria.add(Restrictions.isNull("actorId"));
        } else {
          criteria.add(Restrictions.in("actorId", actorIds));
        }
      }

      if (completed != null) {
        if (completed.booleanValue()) {
          criteria.add(Restrictions.isNotNull("end"));
        } else {
          criteria.add(Restrictions.isNull("end"));
        }
      }

      addPagination(criteria, start, end);
      addOrder(criteria, orderByComparator);

      return criteria.list();
    } catch (Exception e) {
      throw new JbpmException(e);
    }
  }
示例#26
0
 /**
  * Locates a <code>Criteria</code> for a <code>childEntityName</code>. If a <code>Criteria</code>
  * exists for the <code>childEntityName</code>, it is returned. If not, one is created and
  * referenced in the <code>childCriteriaMap</code> under the <code>childEntityName</code>.
  *
  * @param childEntityName
  * @param parentCriteria
  * @return criteria The Criteria for the childEntityName.
  * @throws org.hibernate.HibernateException
  */
 private org.hibernate.Criteria locateCriteria(
     String childEntityName, org.hibernate.Criteria parentCriteria)
     throws org.hibernate.HibernateException {
   if (this.childCriteriaMap.containsKey(childEntityName)) {
     return (org.hibernate.Criteria) this.childCriteriaMap.get(childEntityName);
   }
   org.hibernate.Criteria childCriteria = parentCriteria.createCriteria(childEntityName);
   if (this.configuration.isForceEagerLoading()) {
     parentCriteria.setFetchMode(childEntityName, org.hibernate.FetchMode.JOIN);
   }
   this.childCriteriaMap.put(childEntityName, childCriteria);
   return childCriteria;
 }
示例#27
0
  public Collection<StoryRank> getIterationRanksForStories(Collection<Story> stories) {
    if (stories.isEmpty()) {
      return new ArrayList<StoryRank>();
    }
    Criteria filter = this.createCriteria(StoryRank.class);
    filter.add(Restrictions.in("story", stories));

    // Iteration crit
    Criteria iterFilter = filter.createCriteria("backlog");
    iterFilter.add(Restrictions.eq("class", "Iteration"));

    return asCollection(filter);
  }
示例#28
0
  @Override
  public User getUserbyLogin(String login) throws HibernateException {
    Criteria criteria = sessionFactory.getCurrentSession().createCriteria(clazz);
    User user =
        (User)
            criteria
                .createCriteria("authen", JoinType.RIGHT_OUTER_JOIN)
                .add(Restrictions.eq("login", login))
                .list()
                .get(0);

    return user;
  }
示例#29
0
  public List<DmAccount> getListOwnerByPermittedAccount(
      String accountId, Integer permissionLevelStart) {
    DmAccount permittedAccount = null;
    if (accountId != null) {
      permittedAccount = new DmAccount();
      permittedAccount.setId(accountId);
    }

    List<DmAccount> ownerList = null;
    if (permittedAccount != null) {
      Criteria crit = getSession().createCriteria(DmFolder.class);
      crit.setProjection(Projections.distinct(Projections.property("owner")));
      crit.add(Restrictions.ne("owner", permittedAccount));
      //            crit.setProjection(Projections.property("owner"));

      //            crit.add(Restrictions.eq("owner", accountOwner));
      //            crit.add(Restrictions.isNull("parent"));
      //            crit.addOrder(Order.asc("name"));
      //            if (permissionLevelStart != null) {
      //                crit.createCriteria("permissionList").add(Restrictions.ge("permissionType",
      // permissionLevelStart));
      //            }
      //            Criterion permissionCrit = null;

      Conjunction conjunction = Restrictions.conjunction();
      if (permissionLevelStart != null) {
        conjunction.add(Restrictions.ge("permissionType", permissionLevelStart));
      }
      conjunction.add(Restrictions.eq("account", permittedAccount));

      crit.createCriteria("permissionList").add(conjunction);

      ownerList = crit.list();

      //            if (ownerList != null) {
      //                for (DmAccount owner : ownerList) {
      //                    System.out.println("name = " + owner.getName());
      //                }
      //            }
      // start - get children for each child (trigger lazy fetch)
      //            for (DmFolder folderTmp : folderList) {
      //                if (folderTmp.getChildList() != null) {
      //                    folderTmp.getChildList().size();
      //                }
      //            }
      // end - get children for each child (trigger lazy fetch)
    }

    return ownerList;
    //        return null;
  }
示例#30
0
 /**
  * Get count of available observation for this time series
  *
  * @param series Time series
  * @param request GetDataAvailability request
  * @param session Hibernate session
  * @return Count of available observations
  */
 private Long getCountFor(Series series, GetDataAvailabilityRequest request, Session session) {
   Criteria criteria =
       session
           .createCriteria(SeriesObservationInfo.class)
           .add(Restrictions.eq(AbstractObservation.DELETED, false));
   criteria.add(Restrictions.eq(SeriesObservationInfo.SERIES, series));
   if (request.isSetOfferings()) {
     criteria
         .createCriteria(SeriesObservationTime.OFFERINGS)
         .add(Restrictions.in(Offering.IDENTIFIER, request.getOfferings()));
   }
   criteria.setProjection(Projections.rowCount());
   return (Long) criteria.uniqueResult();
 }