コード例 #1
0
  @Override
  public Long verificarConflitoHorario(Horario model) {
    Criteria criteria = getSession().createCriteria(Horario.class);

    // Removendo da pesquisa o proprio registro quando for edição
    if (model.getId() != null && !model.getId().equals(0)) {
      List<Integer> listaIds = new ArrayList<Integer>();
      listaIds.add(model.getId());
      criteria.add(Restrictions.not(Restrictions.in("id", listaIds)));
    }

    criteria.add(Restrictions.eq("curso.id", model.getCurso().getId()));
    criteria.add(
        Restrictions.or(
            Restrictions.or(
                Restrictions.between(
                    "datHoraInicio", model.getDatHoraInicio(), model.getDatHoraFim()),
                Restrictions.between(
                    "datHoraFim", model.getDatHoraInicio(), model.getDatHoraFim())),
            Restrictions.and(
                Restrictions.and(
                    Restrictions.le("datHoraInicio", model.getDatHoraInicio()),
                    Restrictions.ge("datHoraFim", model.getDatHoraInicio())),
                Restrictions.and(
                    Restrictions.le("datHoraInicio", model.getDatHoraFim()),
                    Restrictions.ge("datHoraFim", model.getDatHoraFim())))));
    criteria.setProjection(Projections.rowCount());

    Long result = (Long) criteria.list().get(0);
    return result;
  }
コード例 #2
0
  @Scheduled(fixedDelay = 60000)
  public void changeSessionStatus() {

    List<CurrentUsersDTO> allList = null;
    List<CurrentUsersDTO> activeList = null;

    String currentTime = getTime();
    String beforeTime = getBeforeTime();
    String beforeHeartBeatTime = getBeforeHeartBeatTime();

    Session session = getSession();
    session.getTransaction().begin();

    Criteria criteria =
        session
            .createCriteria(SessionDetails.class, "sessionDetails")
            .add(
                Restrictions.between(
                    "sessionDetails.heartBeatTime", beforeHeartBeatTime, currentTime))
            .add(Restrictions.between("sessionDetails.lastAccessTime", beforeTime, currentTime));
    criteria.addOrder(Order.asc("SID"));
    criteria.setProjection(
        Projections.projectionList()
            .add(Projections.property("SID").as("sid"))
            .add(Projections.property("lastAccessTime").as("lastAccessTime")));
    activeList =
        criteria.setResultTransformer(Transformers.aliasToBean(CurrentUsersDTO.class)).list();

    Criteria criteria1 = session.createCriteria(SessionDetails.class, "sessionDetails");
    criteria1.addOrder(Order.asc("SID"));
    criteria1.setProjection(
        Projections.projectionList()
            .add(Projections.property("SID").as("sid"))
            .add(Projections.property("lastAccessTime").as("lastAccessTime")));
    allList =
        criteria1.setResultTransformer(Transformers.aliasToBean(CurrentUsersDTO.class)).list();

    for (CurrentUsersDTO dto : allList) {
      try {
        SessionDetails sd = getById(dto.getSid());
        sd.setStatus("INACTIVE");
        saveSessionDetails(sd);
      } catch (Exception e) {
        System.out.println("E :" + e);
      }
    }

    for (CurrentUsersDTO dto : activeList) {
      try {
        SessionDetails sd = getById(dto.getSid());
        sd.setStatus("ACTIVE");
        saveSessionDetails(sd);
      } catch (Exception e) {
        System.out.println("E :" + e);
      }
    }
    session.getTransaction().commit();
    session.close();
  }
コード例 #3
0
 public List<GameEntity> findByNearDays(LocalDateTime gameTime) {
   return getSession()
       .createCriteria(GameEntity.class)
       .setFetchMode("odds", FetchMode.SELECT)
       .add(Restrictions.between("gameTime", gameTime, gameTime.plusDays(1)))
       .list();
 }
コード例 #4
0
 @Override
 public List<AprimoFileImportLogModel> getAprimoFileLogSearchList(
     java.util.Date fromDate, java.util.Date toDate) {
   Session session = null;
   List<AprimoFileImportLogModel> aprimoFileImportLogModelList =
       new ArrayList<AprimoFileImportLogModel>();
   LOGGER.info(
       "Fetching search logs from Aprimo Import log started in between ("
           + fromDate
           + ") and ("
           + toDate
           + ")");
   try {
     session = sessionFactory.openSession();
     Criteria criteria =
         session
             .createCriteria(AprimoFileImportLogModel.class)
             .add(Restrictions.between("importTime", fromDate, toDate));
     aprimoFileImportLogModelList = criteria.list();
   } catch (HibernateException e) {
     LOGGER.error(
         "HibernateException while searching logs from aprimo import log table : "
             + e.getMessage());
   } finally {
     session.close();
   }
   LOGGER.info(
       "All aprimo search log data are fetched successfully (size : "
           + aprimoFileImportLogModelList.size()
           + ")");
   return aprimoFileImportLogModelList;
 }
コード例 #5
0
ファイル: Helper.java プロジェクト: iworksrc/improvegroup
  public List getSearchResult(
      String category, String prodname, String pricestart, String priceend) {
    List<Prod> lst = null;

    if ("".equals(pricestart) && "".equals(priceend)) {
      List pMM = getProdMaxMinPraces();
      pricestart = ((BigDecimal) pMM.get(1)).toString();
      priceend = ((BigDecimal) pMM.get(0)).toString();
    }
    if ("".equals(pricestart)) pricestart = getProdMinPrice().toString();
    if ("".equals(priceend)) priceend = getProdMaxPrice().toString();

    try {
      // -------------------------------------------------------------------------------
      lst =
          session
              .createCriteria(Prod.class)
              .add(
                  Restrictions.between(
                      "price", new BigDecimal(pricestart), new BigDecimal(priceend)))
              .add(Restrictions.like("name", "%" + prodname + "%"))
              .createCriteria("cat")
              .add(Restrictions.like("name", "%" + category + "%"))
              .list();
      // -------------------------------------------------------------------------------
    } catch (HibernateException he) {
      he.printStackTrace();
    }
    return lst;
  }
コード例 #6
0
  public Page<Log> find(Page<Log> page, Map<String, Object> paramMap) {
    DetachedCriteria dc = logDao.createDetachedCriteria();

    Long createById = StringUtils.toLong(paramMap.get("createById"));
    if (createById > 0) {
      dc.add(Restrictions.eq("createBy.id", createById));
    }

    String requestUri = ObjectUtils.toString(paramMap.get("requestUri"));
    if (StringUtils.isNotBlank(requestUri)) {
      dc.add(Restrictions.like("requestUri", "%" + requestUri + "%"));
    }

    String exception = ObjectUtils.toString(paramMap.get("exception"));
    if (StringUtils.isNotBlank(exception)) {
      dc.add(Restrictions.eq("type", Log.TYPE_EXCEPTION));
    }

    Date beginDate = DateUtils.parseDate(paramMap.get("beginDate"));
    if (beginDate == null) {
      beginDate = DateUtils.setDays(new Date(), 1);
      paramMap.put("beginDate", DateUtils.formatDate(beginDate, "yyyy-MM-dd"));
    }
    Date endDate = DateUtils.parseDate(paramMap.get("endDate"));
    if (endDate == null) {
      endDate = DateUtils.addDays(DateUtils.addMonths(beginDate, 1), -1);
      paramMap.put("endDate", DateUtils.formatDate(endDate, "yyyy-MM-dd"));
    }
    dc.add(Restrictions.between("createDate", beginDate, endDate));

    dc.addOrder(Order.desc("id"));
    return logDao.find(page, dc);
  }
  @Override
  @SuppressWarnings("unchecked")
  public List<ProgramInstance> getByStatus(
      ProgramStatus status,
      Program program,
      Collection<Integer> orgunitIds,
      Date startDate,
      Date endDate,
      Integer min,
      Integer max) {
    Criteria criteria =
        getCriteria(
                Restrictions.eq("program", program),
                Restrictions.between("enrollmentDate", startDate, endDate))
            .createAlias("entityInstance", "entityInstance")
            .createAlias("entityInstance.organisationUnit", "organisationUnit")
            .add(Restrictions.in("organisationUnit.id", orgunitIds))
            .add(Restrictions.eq("status", status));

    if (min != null) {
      criteria.setFirstResult(min);
    }

    if (max != null) {
      criteria.setMaxResults(max);
    }

    return criteria.list();
  }
コード例 #8
0
  public String consultarCompras() {
    //		if("".equals(status) && cuenta.isEmpty() && folio.isEmpty()){
    //			sendErrorMessageToUser("Favor de ingresar cuenta, folio o estatus de promocion");
    //			return null;
    //		}
    DetachedCriteria criteria = DetachedCriteria.forClass(Compra.class);

    if (!"".equals(status)) {
      criteria.add(Restrictions.eq("idEdoPromocion", status));
      if (fechaInicio == null || fechaFin == null) {
        sendErrorMessageToUser("Fecha de Inicio y fecha Final son requeridas");
        return null;

      } else {
        Date maxDate = new Date(fechaFin.getTime() + TimeUnit.DAYS.toMillis(1));
        criteria.add(Restrictions.between("fechaAplicacionPromocion", getFechaInicio(), maxDate));
      }
    }
    if (cuenta != null && !cuenta.isEmpty()) {
      criteria.add(Restrictions.eq("cuenta", cuenta));
      if (fechaInicio == null || fechaFin == null) {
        sendErrorMessageToUser("Fecha de Inicio y fecha Final son requeridas");
        return null;

      } else {
        Date maxDate = new Date(fechaFin.getTime() + TimeUnit.DAYS.toMillis(1));
        criteria.add(Restrictions.between("fechaAplicacionPromocion", getFechaInicio(), maxDate));
      }
    }
    if (folio != null && !folio.isEmpty()) {
      criteria.add(Restrictions.eq("folio", new Integer(folio)));
    }
    criteria.addOrder(Order.desc("fechaCompra"));
    compras = compraService.findByCriteria(criteria);

    if (compras == null || compras.isEmpty()) {
      sendErrorMessageToUser("No se encontraron resultados");
      return null;
    }
    logger.info("num compras compras " + compras.size());
    for (Compra compra : compras) {
      compra.setCuenta(
          "***********" + compra.getCuenta().substring(compra.getCuenta().length() - 4));
    }
    return "RepComprasList2";
  }
コード例 #9
0
ファイル: DiscountDaoImpl.java プロジェクト: rbrea/lobo01
  @Override
  @SuppressWarnings("unchecked")
  public List<Discount> find(Date dateFrom, Date dateTo) {
    Criteria criteria = super.createCriteria();
    criteria.add(Restrictions.between("date", dateFrom, dateTo));

    return criteria.list();
  }
コード例 #10
0
 public List<GameEntity> findGameOnComing() {
   LocalDateTime today = LocalDate.now().toLocalDateTime(new LocalTime(0, 0));
   return getSession()
       .createCriteria(GameEntity.class)
       .setFetchMode("odds", FetchMode.SELECT)
       .add(Restrictions.between("gameTime", today, today.plusDays(3)))
       .list();
 }
コード例 #11
0
 public List<DailySummary> getDailySummarys(String[] para) {
   DetachedCriteria criteria = DetachedCriteria.forClass(DailySummary.class);
   criteria.add(Restrictions.eq("stockSymbol", para[0]));
   criteria.add(Restrictions.between("date", para[1], para[2]));
   if (para[3].equalsIgnoreCase("desc")) criteria.addOrder(Order.desc("date"));
   else criteria.addOrder(Order.asc("date"));
   return (List<DailySummary>) dao.getHibernateTemplate().findByCriteria(criteria);
 }
コード例 #12
0
ファイル: Restrict.java プロジェクト: joeantony4u/Sm
  @SuppressWarnings("rawtypes")
  public List<Criterion> restrict(Object[]... values) {

    List<Criterion> criterions = new ArrayList<Criterion>();
    switch (valueOf(type)) {
      case IN:
        for (Object[] value : values)
          criterions.add(Restrictions.in((String) value[0], (Collection) value[1]));

        break;
      case NOTIN:
        for (Object[] value : values)
          criterions.add(
              Restrictions.not(Restrictions.in((String) value[0], (Collection) value[1])));
        break;
      case EQ:
        for (Object[] value : values) criterions.add(Restrictions.eq((String) value[0], value[1]));
        break;
      case NOTEQ:
        for (Object[] value : values) criterions.add(Restrictions.ne((String) value[0], value[1]));
        break;
      case GE:
        for (Object[] value : values) criterions.add(Restrictions.ge((String) value[0], value[1]));
        break;
      case LE:
        for (Object[] value : values) criterions.add(Restrictions.le((String) value[0], value[1]));
        break;
      case BETWEEN:
        for (Object[] value : values)
          criterions.add(Restrictions.between((String) value[0], value[1], value[2]));
        break;
      case GT:
        for (Object[] value : values) criterions.add(Restrictions.gt((String) value[0], value[1]));
        break;
      case LT:
        for (Object[] value : values) criterions.add(Restrictions.lt((String) value[0], value[1]));
        break;
      case AND:
        for (Object[] value : values)
          criterions.add(Restrictions.and((Criterion) value[0], (Criterion) value[1]));
        break;
      case OR:
        for (Object[] value : values)
          criterions.add(Restrictions.or((Criterion) value[0], (Criterion) value[1]));
        break;
      case NULL:
        for (Object[] value : values) criterions.add(Restrictions.isNull((String) value[0]));
        break;
      case NOTNULL:
        for (Object[] value : values) criterions.add(Restrictions.isNotNull((String) value[0]));
        break;
      case LIKE:
        for (Object[] value : values)
          criterions.add(Restrictions.like((String) value[0], value[1]));
        break;
    }
    return criterions;
  }
コード例 #13
0
  public void doDownload() throws Throwable {
    if (StringUtils.isBlank(selectedDateFrom) || StringUtils.isBlank(selectedDateTo)) {
      MessageUtils.getInstance().addErrorMessage("msgDialogDL", "Please select date");
      return;
    }

    if (selectedDateFrom.compareTo(selectedDateTo) < 0) {
      try {
        Date cycleFrom = DateUtil.convStringToDate(SIMPLE_DATE_PATTERN, selectedDateFrom);
        Date cycleTo = DateUtil.convStringToDate(SIMPLE_DATE_PATTERN, selectedDateTo);

        DetachedCriteria criteria = DetachedCriteria.forClass(ConfirmationRecord.class);
        criteria.add(Restrictions.between("cycleFrom", cycleFrom, cycleTo));
        criteria.add(Restrictions.between("cycleTo", cycleFrom, cycleTo));
        criteria.addOrder(Order.asc("cycleFrom"));
        criteria.addOrder(Order.asc("id"));
        List<ConfirmationRecord> list = confirmationRecordService.findByCriteria(criteria);

        Workbook wb = createExcel(list);

        if (wb != null) {
          wb.removeSheetAt(0);
          FileTransfer ft = new FileTransfer();
          String fileName =
              EXCEL_NAME_PATTERN
                  + TEMPLATE_EXCEL_CONF_REPORT_PATH.substring(
                      TEMPLATE_EXCEL_CONF_REPORT_PATH.lastIndexOf("."),
                      TEMPLATE_EXCEL_CONF_REPORT_PATH.length());
          fileName =
              fileName.replaceAll(
                  "#fdd-MMM-yyyy", DateUtil.convDateToString(DISPLAY_DATE_PATTERN, maxCycleFrom));
          fileName =
              fileName.replaceAll(
                  "#tdd-MMM-yyyy", DateUtil.convDateToString(DISPLAY_DATE_PATTERN, maxCycleTo));
          ft.fileDownload(fileName, wb);
        }

        init();
      } catch (Exception e) {
        e.printStackTrace();
      }
    } else {
      MessageUtils.getInstance().addErrorMessage("msgDialogDL", "Invalid date");
    }
  }
コード例 #14
0
 public void addFilterCriteriaForObject(
     final Map<String, List> params, final Criteria c, final String... orderbyFields) {
   for (final Map.Entry<String, List> entry : params.entrySet())
     if (entry.getKey().contains("date") || entry.getKey().contains("Date"))
       c.add(
           Restrictions.between(entry.getKey(), entry.getValue().get(0), entry.getValue().get(1)));
     else c.add(Restrictions.eq(entry.getKey(), entry.getValue().get(0)));
   for (final String orderBy : orderbyFields) c.addOrder(Order.asc(orderBy).ignoreCase());
 }
コード例 #15
0
  @Override
  public Condition buildCondition(
      String conditionField, ConditionType conditionType, Iterator argsIterator) {
    Condition condition = new Condition();

    condition.setField(conditionField);

    switch (conditionType) {
      case Between:
        condition.setConstraint(
            Restrictions.between(conditionField, argsIterator.next(), argsIterator.next()));
        break;

      case Equal:
        condition.setConstraint(Restrictions.eq(conditionField, argsIterator.next()));
        break;

      case GreaterThan:
        condition.setConstraint(Restrictions.gt(conditionField, argsIterator.next()));
        break;

      case GreaterThanEqual:
        condition.setConstraint(Restrictions.ge(conditionField, argsIterator.next()));
        break;

      case IsNotNull:
        condition.setConstraint(Restrictions.isNotNull(conditionField));
        break;

      case IsNull:
        condition.setConstraint(Restrictions.isNull(conditionField));
        break;

      case LessThan:
        condition.setConstraint(Restrictions.lt(conditionField, argsIterator.next()));
        break;

      case LessThanEqual:
        condition.setConstraint(Restrictions.le(conditionField, argsIterator.next()));
        break;

      case NotEqual:
        condition.setConstraint(Restrictions.ne(conditionField, argsIterator.next()));
        break;

      case NotWithin:
        condition.setConstraint(
            Restrictions.not(Restrictions.in(conditionField, (Collection) argsIterator.next())));
        break;

      case Within:
        condition.setConstraint(Restrictions.in(conditionField, (Collection) argsIterator.next()));
        break;
    }

    return condition;
  }
コード例 #16
0
  @SuppressWarnings("unchecked")
  public List<Pedido> findByDateBetween(Date dataInicial, Date dataFinal) {
    Session session = getSession();

    Criteria crit = session.createCriteria(Pedido.class);
    crit.add(Restrictions.between("dataHora", dataInicial, dataFinal));
    crit.addOrder(Order.desc("id"));

    return crit.list();
  }
コード例 #17
0
 public List<GameEntity> findFinishedGameToday() {
   LocalDateTime today = LocalDate.now().toLocalDateTime(new LocalTime(0, 0));
   Criterion isEnd = Restrictions.eq("isEnd", true);
   Criterion gameStatus = Restrictions.eq("gameStatus", 2L);
   return getSession()
       .createCriteria(GameEntity.class)
       .setFetchMode("odds", FetchMode.SELECT)
       .add(Restrictions.between("gameTime", today, today.plusDays(1)))
       .add(Restrictions.or(isEnd, gameStatus))
       .list();
 }
コード例 #18
0
 @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();
 }
コード例 #19
0
  // 找出當天比賽所有的投注一個list 是一場比賽的投注集合,list<list...>是多場比賽的投注集合
  public List<GameEntity> findGameByLocalDate(LocalDate gameTime) {
    LocalDateTime gameTimeLocalDateTime = gameTime.toLocalDateTime(new LocalTime(0, 0));

    Criterion lessEqualGameTime =
        Restrictions.between("gameTime", gameTimeLocalDateTime, gameTimeLocalDateTime.plusDays(1));
    return getSession()
        .createCriteria(GameEntity.class)
        .setFetchMode("odds", FetchMode.SELECT)
        .add(lessEqualGameTime)
        /*.setProjection(Projections.property("odds"))*/
        .list();
  }
コード例 #20
0
ファイル: CriteriaQuery.java プロジェクト: tiankun/gfdzoa
  /**
   * 设置between(之间)查询条件
   *
   * @param keyname
   * @param keyvalue1
   * @param keyvalue2
   */
  public void between(String keyname, Object keyvalue1, Object keyvalue2) {
    Criterion c = null; // 写入between查询条件

    if (!keyvalue1.equals(null) && !keyvalue2.equals(null)) {
      c = Restrictions.between(keyname, keyvalue1, keyvalue2);
    } else if (!keyvalue1.equals(null)) {
      c = Restrictions.ge(keyname, keyvalue1);
    } else if (!keyvalue2.equals(null)) {
      c = Restrictions.le(keyname, keyvalue2);
    }
    criterionList.add(c);
  }
コード例 #21
0
ファイル: DaoConsulta.java プロジェクト: yadder/odonto-ekip
 public List<Consulta> pesquisarTodosConsultaStatusDataIniDataFim(
     Date dataini, Date datafim, String status) throws Exception {
   List<Consulta> lista = null;
   Criteria cr =
       session
           .createCriteria(Consulta.class)
           .add(Restrictions.between("dataConsulta", dataini, datafim))
           .add(Restrictions.eq("statusConsulta", status));
   lista = (ArrayList) cr.list();
   closeSession();
   return lista;
 }
コード例 #22
0
    @Override
    public void buildUnordered(Criteria criteria) {

      // Type check
      if (showEventTypesM.getObject().size() < numberOfEventTypes)
        criteria.add(Restrictions.in("type", showEventTypesM.getObject()));
      else log.debug("Not filtering by event type");

      criteria.createAlias("user", "user");

      // Site Check
      List<Site> siteList = showSitesM.getObject();
      if (siteList.size() < numberOfSites || inAPeriod.getObject()) {
        criteria.createAlias("user.periods", "period", JoinType.LEFT_OUTER_JOIN);
        Disjunction siteRestriction = Restrictions.disjunction();
        if (!inAPeriod.getObject())
          siteRestriction.add(Restrictions.isEmpty("user.periods")); // Show users with no periods
        if (!siteList.isEmpty())
          siteRestriction.add(
              Restrictions.in("period.site", siteList)); // Show users with matching periods
        if (inAPeriod.getObject() && siteList.isEmpty()) {
          siteRestriction.add(Restrictions.idEq(-1L)); // Halt query early; don't show anyone.
          criteria.setMaxResults(0);
        }
        criteria.add(siteRestriction);
      } else {
        log.debug("Not filtering by period/site");
      }

      if (fromDateM.getObject() != null && toDateM.getObject() != null) {
        Date startDate = midnightStart(fromDateM.getObject());
        Date endDate = midnightEnd(toDateM.getObject());
        log.debug("Considering events between {} and {}", startDate, endDate);
        criteria.add(Restrictions.between("insertTime", startDate, endDate));
      }

      // set permission check
      if (showPermissionUsers.getObject()) {
        criteria.add(Restrictions.eq("user.permission", true));
      }

      // Also load ResponseData elements in the same query, to avoid thousands of subsequent
      // queries.
      criteria.setFetchMode("responseData", FetchMode.JOIN);

      // The join with periods results in multiple rows for multi-period users.
      // Unfortunately, this confuses the dataprovider, which still counts the duplicates
      // and therefore doesn't return a full page full of items each time.
      criteria.setResultTransformer(
          CriteriaSpecification
              .DISTINCT_ROOT_ENTITY); // Remove duplicate rows as a result of the INNER JOIN
    }
コード例 #23
0
  @SuppressWarnings("unchecked")
  public List<ValorTercero_v> buscarEnValoresTerceByFiltros(
      FiltroValTercerosBean filtro, String campoOrder, boolean orderByAsc) {

    Criteria criteria = getSession().createCriteria(getEntityClass());

    if (filtro.getAdministracionId() != null)
      criteria.add(Restrictions.eq("administracionId", filtro.getAdministracionId()));
    if (filtro.getBancoId() != null && filtro.getBancoId() > 0)
      criteria.add(Restrictions.eq("bancoId", filtro.getBancoId()));
    if (filtro.getCuentaId() != null && filtro.getCuentaId() > 0)
      criteria.add(Restrictions.eq("cuentaId", filtro.getCuentaId()));
    if (filtro.getTipoEntidadId() != null && filtro.getTipoEntidadId() > 0)
      criteria.add(Restrictions.eq("tipoEntidadId", filtro.getTipoEntidadId()));
    if (filtro.getEntidadId() != null && filtro.getEntidadId() > 0)
      criteria.add(Restrictions.eq("entidadId", filtro.getEntidadId()));
    if (filtro.getMonedaId() != null && filtro.getMonedaId() > 0)
      criteria.add(Restrictions.eq("monedaId", filtro.getMonedaId()));
    if (StringUtils.isNotBlank(filtro.getNumeroFormateado()))
      criteria.add(
          Restrictions.like("numeroFormateado", filtro.getNumeroFormateado(), MatchMode.ANYWHERE)
              .ignoreCase());

    if (filtro.isEnCartera())
      criteria.add(Restrictions.eq("tipomovimiento", Constants.TIPODOCUMENTO_VALORTERCE_INGRESO));
    if (filtro.isDepositados())
      criteria.add(Restrictions.eq("tipomovimiento", Constants.TIPODOCUMENTO_VALORTERCE_EGRESO));

    if (filtro.getImporteDesde() != null && filtro.getImporteHasta() != null) {
      criteria.add(
          Restrictions.between("importeValor", filtro.getImporteDesde(), filtro.getImporteHasta()));
    } else if (filtro.getImporteDesde() != null) {
      criteria.add(Restrictions.ge("importeValor", filtro.getImporteDesde()));
    } else if (filtro.getImporteHasta() != null) {
      criteria.add(Restrictions.le("importeValor", filtro.getImporteHasta()));
    }
    if (StringUtils.isNotBlank(filtro.getFechaVencimientoDesde()))
      criteria.add(
          Restrictions.ge(
              "fechaVencimiento", DateUtil.convertStringToDate(filtro.getFechaVencimientoDesde())));
    if (StringUtils.isNotBlank(filtro.getFechaVencimientoHasta()))
      criteria.add(
          Restrictions.le(
              "fechaVencimiento", DateUtil.convertStringToDate(filtro.getFechaVencimientoHasta())));

    /* Agrega el orden */
    setOrderBy(criteria, campoOrder, orderByAsc);

    List<ValorTercero_v> list = criteria.list();

    return list;
  }
  private BigDecimal calcularCompraPessoal(
      Usuario usuario, DateTime dataInicial, DateTime dataFinal) {

    List<Criterion> restricoes = new ArrayList<Criterion>();
    restricoes.add(
        Restrictions.between(
            "pedData", dataInicial.toGregorianCalendar(), dataFinal.toGregorianCalendar()));

    ControlePedido controlePedidoFiltro = new ControlePedido();
    controlePedidoFiltro.setId_Codigo(usuario.getId_Codigo());

    return this.hibernateUtil.somar(controlePedidoFiltro, restricoes, null, "BaseCalculo");
  }
コード例 #25
0
  @SuppressWarnings("unchecked")
  public List<Pedido> findByEmpresaAndDateBetween(
      Empresa empresa, Date dataInicial, Date dataFinal) {
    Session session = getSession();

    Criteria crit = session.createCriteria(Pedido.class);
    crit.createAlias("empresa", "empresa");
    crit.add(Restrictions.eq("empresa.id", empresa.getId()));
    crit.add(Restrictions.between("dataHora", dataInicial, dataFinal));
    crit.addOrder(Order.desc("id"));

    return crit.list();
  }
コード例 #26
0
  public List<ClientEntity> findClientsByRoomNumbersOnDate(
      int roomNumberStarting, int roomNumberEnding, LocalDate interestedDate) {
    Criteria criteria =
        getSession()
            .createCriteria(ClientEntity.class, "client")
            .createCriteria("client.requestsById", "requests")
            .createCriteria("requests.bookingsById", "booking")
            .createCriteria("booking.roomByRoomId", "room")
            .add(Restrictions.between("room.number", roomNumberStarting, roomNumberEnding))
            .add(Restrictions.ge("requests.checkOut", interestedDate))
            .add(Restrictions.le("requests.checkIn", interestedDate));

    return (List<ClientEntity>) criteria.list();
  }
コード例 #27
0
  public void addBetweenRestriction(
      Criteria crit, String propertyName, Integer valueFrom, Integer valueTo) {
    if (valueFrom == null && valueTo != null) {
      crit.add(Restrictions.le(propertyName, valueTo));
      return;
    }
    if (valueFrom != null && valueTo == null) {
      crit.add(Restrictions.ge(propertyName, valueFrom));
    }

    if (valueFrom != null && valueTo != null) {

      crit.add(Restrictions.between(propertyName, valueFrom, valueTo));
    }
  }
コード例 #28
0
 public List<Deviation> getDeviations(String devType) {
   List<Deviation> list;
   session = HibernateUtil.getSessionFactory().openSession();
   list =
       session
           .createCriteria(Deviation.class)
           .add(Restrictions.eq("direction", ii.getDirection()))
           .add(Restrictions.eq("line", ii.getLine()))
           .add(
               Restrictions.between(
                   "coordinate", ii.getKmS() * 1000 + ii.getmS(), ii.getKmE() * 1000 + ii.getmE()))
           .add(Restrictions.eq("deviation", devType))
           .list();
   session.close();
   return list;
 }
コード例 #29
0
 public List<RailsDefect> getRailsDefectList() {
   List<RailsDefect> list = null;
   session = HibernateUtil.getSessionFactory().openSession();
   list =
       session
           .createCriteria(RailsDefect.class)
           .add(Restrictions.eq("direction", ii.getDirection()))
           .add(Restrictions.eq("line", ii.getLine()))
           .add(Restrictions.eq("railThread", ii.getRailThread()))
           .add(
               Restrictions.between(
                   "coordinate", ii.getKmS() * 1000 + ii.getmS(), ii.getKmE() * 1000 + ii.getmE()))
           .list();
   session.close();
   return list;
 }
コード例 #30
0
 public List<TemporaryRecovery> getTemporaryRecovery() {
   List<TemporaryRecovery> list = new ArrayList<TemporaryRecovery>();
   session = HibernateUtil.getSessionFactory().openSession();
   list =
       session
           .createCriteria(TemporaryRecovery.class)
           .add(Restrictions.eq("direction", ii.getDirection()))
           .add(Restrictions.eq("line", ii.getLine()))
           .add(Restrictions.eq("railThread", ii.getRailThread()))
           .add(
               Restrictions.between(
                   "coordinate", ii.getKmS() * 1000 + ii.getmS(), ii.getKmE() * 1000 + ii.getmE()))
           .list();
   session.close();
   return list;
 }