Example usage for org.hibernate.criterion Restrictions ge

List of usage examples for org.hibernate.criterion Restrictions ge

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions ge.

Prototype

public static SimpleExpression ge(String propertyName, Object value) 

Source Link

Document

Apply a "greater than or equal" constraint to the named property

Usage

From source file:com.ut.tekir.stock.yeni.PurchaseShipmentBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(TekirShipmentNote.class);

    crit.createAlias("contact", "contact");

    crit.setProjection(Projections.projectionList().add(Projections.property("id"), "id")
            .add(Projections.property("serial"), "serial").add(Projections.property("reference"), "reference")
            .add(Projections.property("code"), "code").add(Projections.property("date"), "date")
            .add(Projections.property("info"), "info").add(Projections.property("info1"), "info1")
            .add(Projections.property("info2"), "info2").add(Projections.property("warehouse"), "warehouse")
            .add(Projections.property("contact.fullname"), "contactName")
            .add(Projections.property("contact.company"), "company")
            .add(Projections.property("contact.person"), "person")
            .add(Projections.property("contact.code"), "contactCode")
            .add(Projections.property("workBunch"), "workBunch"))
            .setResultTransformer(Transformers.aliasToBean(ShipmentFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }/*from  w  ww.  j  a v a2  s.  com*/

    if (isNotEmpty(filterModel.getReference())) {
        crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("this.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("this.date", filterModel.getEndDate()));
    }

    if (filterModel.getWarehouse() != null) {
        crit.add(Restrictions.eq("this.warehouse", filterModel.getWarehouse()));
    }

    if (isNotEmpty(filterModel.getContactName())) {
        crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.ANYWHERE));
    }

    if (isNotEmpty(filterModel.getContactCode())) {
        crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START));
    }

    if (filterModel.getInvoiced() != null) {
        if (filterModel.getInvoiced().equals(Boolean.TRUE)) {
            crit.add(Restrictions.isNotNull("this.invoice"));
        } else {
            crit.add(Restrictions.isNull("this.invoice"));
        }
    }

    if (filterModel.getWorkBunch() != null) {
        crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch()));
    }

    crit.add(Restrictions.eq("this.tradeAction", TradeAction.Purchase));
    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

From source file:com.ut.tekir.stock.yeni.SaleOrderBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(TekirOrderNote.class);

    crit.createAlias("contact", "contact");

    crit.setProjection(Projections.projectionList().add(Projections.property("id"), "id")
            .add(Projections.property("serial"), "serial").add(Projections.property("reference"), "reference")
            .add(Projections.property("code"), "code").add(Projections.property("status"), "status")
            .add(Projections.property("date"), "date").add(Projections.property("deliveryDate"), "deliveryDate")
            .add(Projections.property("info"), "info").add(Projections.property("warehouse"), "warehouse")
            .add(Projections.property("contact.fullname"), "contactName")
            .add(Projections.property("contact.code"), "contactCode")
            .add(Projections.property("contact.person"), "person")
            .add(Projections.property("contact.company"), "company")
            .add(Projections.property("workBunch"), "workBunch"))
            .setResultTransformer(Transformers.aliasToBean(OrderFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }/*from www  .  ja v  a2s. c  om*/

    if (isNotEmpty(filterModel.getReference())) {
        crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("this.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("this.date", filterModel.getEndDate()));
    }

    if (filterModel.getDeliveryBeginDate() != null) {
        crit.add(Restrictions.ge("this.deliveryDate", filterModel.getDeliveryBeginDate()));
    }

    if (filterModel.getDeliveryEndDate() != null) {
        crit.add(Restrictions.le("this.deliveryDate", filterModel.getDeliveryEndDate()));
    }

    if (filterModel.getWarehouse() != null) {
        crit.add(Restrictions.eq("this.warehouse", filterModel.getWarehouse()));
    }

    if (isNotEmpty(filterModel.getContactCode())) {
        crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getContactName())) {
        crit.add(Restrictions.ilike("contact.name", filterModel.getContactName(), MatchMode.START));
    }

    if (filterModel.getStatus() != null) {
        crit.add(Restrictions.eq("this.status", filterModel.getStatus()));
    }

    if (filterModel.getWorkBunch() != null) {
        crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch()));
    }

    crit.add(Restrictions.eq("this.tradeAction", TradeAction.Sale));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

From source file:com.ut.tekir.stock.yeni.SaleShipmentBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(TekirShipmentNote.class);

    crit.createAlias("contact", "contact");

    crit.setProjection(Projections.projectionList().add(Projections.property("id"), "id")
            .add(Projections.property("serial"), "serial").add(Projections.property("reference"), "reference")
            .add(Projections.property("code"), "code").add(Projections.property("date"), "date")
            .add(Projections.property("info1"), "info1").add(Projections.property("info2"), "info2")
            .add(Projections.property("warehouse"), "warehouse")
            .add(Projections.property("contact.fullname"), "contactName")
            .add(Projections.property("contact.company"), "company")
            .add(Projections.property("contact.person"), "person")
            .add(Projections.property("contact.code"), "contactCode")
            .add(Projections.property("workBunch"), "workBunch"))
            .setResultTransformer(Transformers.aliasToBean(ShipmentFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }//from w  ww .  ja  v  a2 s .com

    if (isNotEmpty(filterModel.getReference())) {
        crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("this.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("this.date", filterModel.getEndDate()));
    }

    if (filterModel.getWarehouse() != null) {
        crit.add(Restrictions.eq("this.warehouse", filterModel.getWarehouse()));
    }

    if (isNotEmpty(filterModel.getContactCode())) {
        crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getContactName())) {
        crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.ANYWHERE));
    }

    if (filterModel.getInvoiced() != null) {
        if (filterModel.getInvoiced().equals(Boolean.TRUE)) {
            crit.add(Restrictions.isNotNull("this.invoice"));
        } else {
            crit.add(Restrictions.isNull("this.invoice"));
        }
    }

    if (filterModel.getWorkBunch() != null) {
        crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch()));
    }

    crit.add(Restrictions.eq("this.tradeAction", TradeAction.Sale));
    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

From source file:com.ut.tekir.tender.TenderBrowseBean.java

License:LGPL

private void addRestrictions(DetachedCriteria crit) {
    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }//from w  w w.  j  a v a 2 s . c om

    if (isNotEmpty(filterModel.getReference())) {
        crit.add(Restrictions.ilike("this.reference", filterModel.getReference(), MatchMode.START));
    }

    if (filterModel.getStatus() != null) {
        crit.add(Restrictions.eq("this.status", filterModel.getStatus()));
    }

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getContactName())) {
        crit.add(Restrictions.ilike("contact.name", filterModel.getContactName(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getContactCode())) {
        crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("this.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("this.date", filterModel.getEndDate()));
    }
}

From source file:com.valco.dao.NotasVentaDAO.java

public List<NotasDeVenta> getNotasXRangoFolio(Integer folioInicial, Integer folioFinal) throws Exception {
    Session session = HibernateUtil.getSessionFactory().openSession();
    Transaction tx = null;/*from ww w .  j a v  a  2  s  .c o  m*/
    List<NotasDeVenta> notas = new ArrayList<NotasDeVenta>();
    try {
        tx = session.beginTransaction();
        Criteria q = session.createCriteria(NotasDeVenta.class).add(Restrictions.ge("folio", folioInicial))
                .add(Restrictions.le("folio", folioFinal));
        notas = (List<NotasDeVenta>) q.list();
        return notas;

    } catch (HibernateException he) {
        throw new Exception("Ocurri un error al consultar los clientes.");

    } finally {
        try {
            if (session.isOpen()) {
                session.close();
            }
        } catch (HibernateException he) {
            throw new Exception("Ocurri un error al consultar los clientes.");
        }
    }
}

From source file:com.viettel.ttbankplus.servicegw.hibernate.dao.transaction.TransferMerchantDAO.java

License:Open Source License

public List<TransferMerchant> getListTransfer(Date fromDate, Date toDate, ArrayList<String> lstCpCode) {
    try {//from   w w w .j  a  va 2 s .  c o m
        List<TransferMerchant> lst = null;

        Criteria crt = getSession().createCriteria(TransferMerchant.class);
        crt.add(Restrictions.in("cpCode", lstCpCode)).add(Restrictions.ge("requestDate", fromDate))
                .add(Restrictions.le("requestDate", toDate));
        lst = crt.list();
        return lst;
    } catch (Exception e) {
        return null;
    } finally {
        //        PHUCPT edit Jan, 05th 2017
        DAOFactory.commitCurrentSessions();
        //        end edit
    }
}

From source file:com.wdeanmedical.portal.persistence.AppDAO.java

License:LGPL

public List<Appointment> getAppointments(Patient patient, boolean isPast) throws Exception {
    Session session = this.getSession();
    Criteria crit = session.createCriteria(Appointment.class);
    crit.add(Restrictions.eq("patient", patient));
    if (isPast) {
        crit.add(Restrictions.lt("startTime", new Date()));
    } else {/*from   w ww. ja v  a 2s . c o  m*/
        crit.add(Restrictions.ge("startTime", new Date()));
    }
    List<Appointment> list = crit.list();
    return list;
}

From source file:com.webbfontaine.valuewebb.action.pricedb.mp.PRDConsult.java

License:Open Source License

private void fillPDs(Pd pd) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(new Date());
    calendar.add(Calendar.MONTH, -3);
    Date dateOfTodayMinus3Months = calendar.getTime();

    Criteria criteria = PersistenceUtil.getSession(entityManager).createCriteria(Pd.class)
            .setMaxResults(Constants.MAX_RECORDS_IN_FINDER_RESULT).addOrder(Order.desc("id"));
    if (pd.getHsCodeF() != null) {
        criteria.add(Restrictions.like("hsCodeF", pd.getHsCodeF(), MatchMode.START));
    }/* w w w  .ja  v a2s. c  om*/
    if (pd.getProductDscF() != null) {
        criteria.add(Restrictions.ilike("productDscF", pd.getProductDscF(), MatchMode.ANYWHERE));
    }
    if (!StringUtils.isEmpty(pd.getValMethod())) {
        criteria.add(Restrictions.ilike("valMethod", pd.getValMethod(), MatchMode.ANYWHERE));
    }

    if (ApplicationProperties.getAppCountry().equals(Constants.CI)) {
        // according to ELL-1186, hardcoded restriction added to qlClassLine, qlValLine
        criteria.add(Restrictions.and(
                Restrictions.or(Restrictions.eq("qlValLine", "1"), Restrictions.isNull("qlValLine")),
                Restrictions.or(Restrictions.eq("qlClassLine", "1"), Restrictions.isNull("qlClassLine"))));
    }

    Criteria ttCrit = criteria.createCriteria("ttGen");
    ttCrit.add(Restrictions.ge("date", dateOfTodayMinus3Months));

    pdDB.addAll(criteria.list());
}

From source file:com.webbfontaine.valuewebb.search.custom.UserCriterion.java

License:Open Source License

public Criterion getCriterion() throws Exception {
    if (condition.equals(EQ)) {
        if (value == null || value.toString().trim().length() == 0) {
            return Restrictions.isNull(fullKey);
        } else {//w  ww. j  a  v  a2  s.co m
            return Restrictions.eq(fullKey, value);
        }
    }

    if (condition.equals(NE)) {
        if (value == null || value.toString().trim().length() == 0) {
            return Restrictions.isNotNull(fullKey);
        } else {
            return Restrictions.ne(fullKey, value);
        }
    }

    if (condition.equals(GT)) {
        assertNonNullity(value);
        return Restrictions.gt(fullKey, value);
    }

    if (condition.equals(GE)) {
        assertNonNullity(value);
        return Restrictions.ge(fullKey, value);
    }

    if (condition.equals(LT)) {
        assertNonNullity(value);
        return Restrictions.lt(fullKey, value);
    }

    if (condition.equals(LE)) {
        assertNonNullity(value);
        return Restrictions.le(fullKey, value);
    }

    if (condition.equals(IN_A_RANGE)) {
        assertNonNullity(value);
        assertNonNullity(diff);
        return getPercentRange();
    }

    if (condition.equals(ENDS_WITH)) {
        return Restrictions.like(fullKey, "%" + StringUtils.trim(value.toString()));
    }

    if (condition.equals(STARTS_WITH)) {
        return Restrictions.like(fullKey, StringUtils.trim(value.toString()) + "%");
    }

    if (condition.equals(CONTAINS)) {
        return Restrictions.like(fullKey, "%" + StringUtils.trim(value.toString()) + '%');
    }

    if (condition.equals(NOT_CONTAIN)) {
        return Restrictions.not(Restrictions.like(fullKey, "%" + StringUtils.trim(value.toString()) + '%'));
    }

    LOGGER.error(
            "Undefined User Criteria [key:{0}, value:{1}, condition:{3}] couldn't be transformed to search criterion",
            fullKey, value, condition);

    throw new RuntimeException("Undefined User Criteria: " + name);
}

From source file:com.webbfontaine.valuewebb.search.custom.UserCriterion.java

License:Open Source License

private Criterion getPercentRange() {
    BigDecimal bdValue = new BigDecimal(value.toString());

    BigDecimal range = bdValue.multiply(new BigDecimal(diff).divide(new BigDecimal(100)));

    BigDecimal bdValueFrom = bdValue.subtract(range);
    BigDecimal bdValueTo = bdValue.add(range);
    return Restrictions.and(Restrictions.ge(fullKey, bdValueFrom), Restrictions.le(fullKey, bdValueTo));
}