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.CountNoteBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {
    DetachedCriteria crit = DetachedCriteria.forClass(CountNote.class);

    crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id")
            .add(Projections.property("this.serial"), "serial")
            .add(Projections.property("this.reference"), "reference")
            .add(Projections.property("this.code"), "code").add(Projections.property("this.info"), "info")
            .add(Projections.property("this.date"), "date")
            .add(Projections.property("this.hasQuantity"), "hasQuantity")
            .add(Projections.property("this.approved"), "approved"))
            .setResultTransformer(Transformers.aliasToBean(CountNote.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.like("this.serial", filterModel.getSerial(), MatchMode.START));
    }//from   ww w  .  ja  va  2 s.c o m

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

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.like("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.getStatusList() != null) {
        crit.add(Restrictions.in("this.status", filterModel.getStatusList()));
    }

    crit.addOrder(Order.desc("date"));
    crit.addOrder(Order.desc("serial"));
    return crit;
}

From source file:com.ut.tekir.stock.PriceItemBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }//w  ww .j  av  a  2s . co  m

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

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

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

    crit.addOrder(Order.desc("this.beginDate"));
    crit.addOrder(Order.desc("this.code"));

    return crit;
}

From source file:com.ut.tekir.stock.ProductTransferBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("serial", filterModel.getSerial(), MatchMode.START));
    }//from   w ww  . j  a v  a  2s. c  o  m

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

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

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

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

    if (filterModel.getFromWarehouse() != null) {
        crit.add(Restrictions.eq("fromWarehouse", filterModel.getFromWarehouse()));
    }

    if (filterModel.getToWarehouse() != null) {
        crit.add(Restrictions.eq("toWarehouse", filterModel.getToWarehouse()));
    }

    crit.addOrder(Order.desc("serial"));
    return crit;
}

From source file:com.ut.tekir.stock.ProductTxnReportBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    crit.createAlias("product", "product");
    crit.createAlias("warehouse", "warehouse");
    crit.createAlias("workBunch", "workBunch", Criteria.LEFT_JOIN);

    crit.setProjection(Projections.projectionList().add(Projections.property("documentType"), "documentType")
            .add(Projections.property("documentId"), "documentId")
            .add(Projections.property("product.id"), "productId").add(Projections.property("serial"), "serial")
            .add(Projections.property("reference"), "reference").add(Projections.property("code"), "code")
            .add(Projections.property("date"), "date").add(Projections.property("warehouse.name"), "wareName")
            .add(Projections.property("product.name"), "prodName")
            .add(Projections.property("product.code"), "prodCode")
            .add(Projections.property("product.group"), "group")
            .add(Projections.property("product.barcode1"), "barcode")
            .add(Projections.property("adverseCode"), "adverseCode")
            .add(Projections.property("adverseName"), "adverseName").add(Projections.property("info"), "info")
            .add(Projections.property("action"), "action")
            .add(Projections.property("quantity.value"), "quantityValue")
            .add(Projections.property("quantity.unit"), "quantityUnit")
            .add(Projections.property("unitPrice.currency"), "unitPriceCurrency")
            .add(Projections.property("unitPrice.value"), "unitPriceValue")
            .add(Projections.property("financeAction"), "financeAction")
            .add(Projections.property("workBunch.code"), "workBunchCode"));

    crit.setResultTransformer(Transformers.aliasToBean(ProductTxnModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }//from w w w  .ja va 2 s .  c  om

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

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

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

    if (filterModel.getGroup() != null) {
        crit.add(Restrictions.eq("product.group", filterModel.getGroup()));
    }

    if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) {
        Criterion criteria1 = Restrictions.like("product.barcode1", filterModel.getBarcode(), MatchMode.START);
        Criterion criteria2 = Restrictions.like("product.barcode2", filterModel.getBarcode(), MatchMode.START);
        Criterion criteria3 = Restrictions.like("product.barcode3", filterModel.getBarcode(), MatchMode.START);

        crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3)));
    }

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

    if (filterModel.getProductType() != null) {

        if (filterModel.getProductType() == 1) {
            crit.add(Restrictions.like("this.productType", ProductType.Product));
        } else if (filterModel.getProductType() == 2) {
            crit.add(Restrictions.like("this.productType", ProductType.Service));

        }
    }

    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.getContact() != null) {
        crit.add(Restrictions.eq("contact", filterModel.getContact()));
    }

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

    if (filterModel.getCategory() != null) {
        crit.add(Restrictions.eq("product.category", filterModel.getCategory()));
    }

    if (filterModel.getProduct() != null) {
        crit.add(Restrictions.eq("product", filterModel.getProduct()));
    }

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

    if (filterModel.getDocumentType() != null && filterModel.getDocumentType() != DocumentType.Unknown) {
        crit.add(Restrictions.eq("this.documentType", filterModel.getDocumentType()));
    }

    /*
    if( filterModel.getLocalCurrencyOnly()){
    crit.setProjection( Projections.projectionList()
    .add( Projections.groupProperty("documentType"), "documentType" )
    .add( Projections.groupProperty("documentId"), "documentId" )
    .add( Projections.groupProperty("serial"), "serial" )
    .add( Projections.groupProperty("reference"), "reference" )
    .add( Projections.groupProperty("date"), "date" )
    .add( Projections.groupProperty("contact"), "contact" )
    .add( Projections.groupProperty("code"), "code" )
    .add( Projections.groupProperty("info"), "info" )
    .add( Projections.groupProperty("action"), "action" )
    .add( Projections.sum("localAmount.value"), "localAmount" )
    );
    }
     */

    crit.add(Restrictions.eq("this.active", true));
    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.id"));
    //crit.addOrder(Order.asc("warehouse"));
    //crit.addOrder(Order.desc("this.serial"));
    //crit.addOrder(Order.asc("product"));

    log.debug("Sonu : #0", crit);

    return crit;
}

From source file:com.ut.tekir.stock.ProductVirementBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("serial", filterModel.getSerial(), MatchMode.START));
    }//from ww  w .j  ava 2s.co  m

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

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

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

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

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

    crit.addOrder(Order.desc("date"));
    crit.addOrder(Order.desc("serial"));
    return crit;
}

From source file:com.ut.tekir.stock.PurchaseOrderBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(OrderNote.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("info"), "info")
            .add(Projections.property("warehouse"), "warehouse")
            .add(Projections.property("contact.name"), "contactName")
            .add(Projections.property("contact.company"), "company")
            .add(Projections.property("contact.code"), "contactCode"))
            .setResultTransformer(Transformers.aliasToBean(OrderFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }//from  w  w  w.  j ava2s .c o  m

    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.name", filterModel.getContactName(), MatchMode.START));
    }

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

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

    return crit;
}

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

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(ShipmentNote.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("warehouse"), "warehouse")
            .add(Projections.property("contact.fullname"), "contactName")
            .add(Projections.property("contact.code"), "contactCode"))
            .setResultTransformer(Transformers.aliasToBean(ShipmentFilterModel.class));

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

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

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

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

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

    if (filterModel.getWarehouse() != null) {
        crit.add(Restrictions.eq("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));
    }

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

    return crit;
}

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

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(OrderNote.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("info"), "info")
            .add(Projections.property("warehouse"), "warehouse")
            .add(Projections.property("contact.name"), "contactName")
            .add(Projections.property("contact.code"), "contactCode"))
            .setResultTransformer(Transformers.aliasToBean(OrderFilterModel.class));

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

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

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

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

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

    if (filterModel.getWarehouse() != null) {
        crit.add(Restrictions.eq("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("status", filterModel.getStatus()));
    }

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

    return crit;
}

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

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(ShipmentNote.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("warehouse"), "warehouse")
            .add(Projections.property("contact.fullname"), "contactName")
            .add(Projections.property("contact.code"), "contactCode"))
            .setResultTransformer(Transformers.aliasToBean(ShipmentFilterModel.class));

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

    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));
    }

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

    return crit;
}

From source file:com.ut.tekir.stock.SpendingNoteBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    crit.setProjection(Projections.projectionList().add(Projections.property("this.id"), "id")
            .add(Projections.property("this.serial"), "serial")
            .add(Projections.property("this.reference"), "reference")
            .add(Projections.property("this.code"), "code").add(Projections.property("this.info"), "info")
            .add(Projections.property("this.date"), "date")
            .add(Projections.property("this.warehouse"), "warehouse")
            .add(Projections.property("this.employee"), "employee"))
            .setResultTransformer(Transformers.aliasToBean(SpendingNote.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.like("this.serial", filterModel.getSerial() + "%"));
    }/*ww w  .  j  ava2  s . co  m*/

    if (isNotEmpty(filterModel.getReference())) {
        crit.add(Restrictions.like("this.reference", filterModel.getReference() + "%"));
    }

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.like("this.code", filterModel.getCode() + "%"));
    }

    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 (filterModel.getEmployee() != null) {
        crit.add(Restrictions.eq("this.employee", filterModel.getEmployee()));
    }

    return crit;
}