Example usage for org.hibernate.criterion Projections projectionList

List of usage examples for org.hibernate.criterion Projections projectionList

Introduction

In this page you can find the example usage for org.hibernate.criterion Projections projectionList.

Prototype

public static ProjectionList projectionList() 

Source Link

Document

Create a new projection list.

Usage

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));
    }//  w w w. j a v a2s  .co 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));
    }/* w  ww .  j  ava  2  s  .  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.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));
    }/* ww  w . j a v  a  2  s.  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.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));
    }// w  w  w.j a  va 2  s  .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.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() + "%"));
    }//from  w  w  w . j  ava2 s .  c  om

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

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

License:LGPL

public void selectProductList() {

    HibernateSessionProxy session = (HibernateSessionProxy) entityManager.getDelegate();

    Criteria crit = session.createCriteria(Product.class);

    if (getCode() != null && getCode().length() > 0) {
        crit.add(Restrictions.like("this.code", getCode() + "%"));
    }//from  w  ww  . ja va2s . com

    if (getName() != null && getName().length() > 0) {
        crit.add(Restrictions.like("this.name", getName() + "%"));
    }

    if (getBarcode() != null && getBarcode().length() > 0) {
        SimpleExpression barcodeCrit1 = Restrictions.like("this.barcode1", getBarcode() + "%");
        SimpleExpression barcodeCrit2 = Restrictions.like("this.barcode2", getBarcode() + "%");
        SimpleExpression barcodeCrit3 = Restrictions.like("this.barcode3", getBarcode() + "%");

        crit.add(Restrictions.or(Restrictions.or(barcodeCrit1, barcodeCrit2), barcodeCrit3));
    }

    if (getProductType() != ProductType.Unknown) {
        crit.add(Restrictions.eq("this.productType", getProductType()));
    }

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

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

    crit.setProjection(Projections.projectionList().add(Projections.property("code"), "code")
            .add(Projections.property("name"), "name").add(Projections.property("productType"), "productType")
            .add(Projections.property("barcode1"), "barcode1").add(Projections.property("category"), "category")
            .add(Projections.property("group"), "group"));

    crit.add(Restrictions.eq("this.active", true));

    crit.setMaxResults(30);
    //        crit.setCacheable(true);
    //TODO: Map niye almyor kine?
    //crit.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    productList = crit.list();

}

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

License:LGPL

public void selectExpenseAndDiscountList() {

    HibernateSessionProxy session = (HibernateSessionProxy) entityManager.getDelegate();
    Criteria crit = session.createCriteria(Product.class);

    if (getCode() != null && getCode().length() > 0) {
        crit.add(Restrictions.like("this.code", getCode() + "%"));
    }// w ww . j a va2 s .  co  m

    if (getName() != null && getName().length() > 0) {
        crit.add(Restrictions.like("this.name", getName() + "%"));
    }

    if (getProductType() != null && getProductType() == ProductType.Unknown) {
        crit.add(Restrictions.or(Restrictions.eq("this.productType", ProductType.Expense),
                Restrictions.eq("this.productType", ProductType.Discount)));
    } else {
        crit.add(Restrictions.eq("this.productType", getProductType()));
    }

    crit.setProjection(Projections.projectionList().add(Projections.property("code"), "code")
            .add(Projections.property("name"), "name").add(Projections.property("productType"), "productType"));

    crit.add(Restrictions.eq("active", true));

    crit.setMaxResults(30);
    crit.setCacheable(true);
    //TODO: Map niye almyor kine?
    //crit.setResultTransformer(Criteria.ALIAS_TO_ENTITY_MAP);
    expenseAndDiscountList = crit.list();

}

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));
    }/*  w  w w.j av  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.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));
    }// w  ww.  j ava  2 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.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));
    }/* w  w w  .  jav  a 2 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));
    }

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