List of usage examples for org.hibernate.criterion DetachedCriteria addOrder
public DetachedCriteria addOrder(Order order)
From source file:com.ut.tekir.stock.ProductTxnReportBean.java
License:LGPL
public DetachedCriteria buildCriteriaForPriceList(TradeAction tradeAction) { DetachedCriteria crit = DetachedCriteria.forClass(PriceItemDetail.class); crit.createAlias("this.owner", "owner"); crit.createAlias("product", "product"); // crit.createAlias("owner.owner", "ownerPriceList",DetachedCriteria.LEFT_JOIN); crit.setProjection(Projections.projectionList().add(Projections.property("product"), "product") .add(Projections.property("netPrice.value"), "netPriceValue") .add(Projections.property("netPrice.currency"), "netPriceCurrency") .add(Projections.property("grossPrice.value"), "grossPriceValue") .add(Projections.property("grossPrice.currency"), "grossPriceCurrency") .add(Projections.property("owner.code"), "ownerCode") .add(Projections.property("owner.beginDate"), "ownerBeginDate") .add(Projections.property("owner.endDate"), "ownerEndDate") .add(Projections.property("owner.active"), "ownerIsActive") .add(Projections.property("owner.info"), "priceListName") // FIXME: listeden ad m gelmeli yoksa info mu? // .add(Projections.property("ownerPriceList.listName"), "priceListName") );/*ww w . j a va 2 s . c o m*/ crit.setResultTransformer(Transformers.aliasToBean(ProductTxnModel.class)); crit.add(Restrictions.eq("owner.action", tradeAction)); if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) { Criterion criteria1 = Restrictions.eq("product.barcode1", filterModel.getBarcode()); Criterion criteria2 = Restrictions.eq("product.barcode2", filterModel.getBarcode()); Criterion criteria3 = Restrictions.eq("product.barcode3", filterModel.getBarcode()); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (filterModel.getProduct() != null) { crit.add(Restrictions.eq("this.product", filterModel.getProduct())); } crit.addOrder(Order.desc("this.id")); return crit; }
From source file:com.ut.tekir.stock.ProductTxnReportBean.java
License:LGPL
public DetachedCriteria buildCriteriaForWarehouse() { DetachedCriteria crit = DetachedCriteria.forClass(ProductTxn.class); crit.createAlias("product", "product"); crit.createAlias("warehouse", "warehouse"); ProjectionList pl = Projections.projectionList(); pl.add(Projections.groupProperty("product.code"), "prodcode") .add(Projections.groupProperty("product.name"), "prodname") .add(Projections.groupProperty("product.group"), "group") .add(Projections.groupProperty("product.barcode1"), "barcode") .add(Projections.groupProperty("warehouse.code"), "warecode") .add(Projections.groupProperty("warehouse.name"), "warename") .add(Projections.sum("quantity.value"), "quantity") .add(Projections.avg("unitPrice.value"), "unitPrice") .add(Projections.sqlGroupProjection("{alias}.UNIT as unit, " + "sum( case {alias}.trade_action when 0 then {alias}.QUANTITY else 0 end ) as INQTY, " + "sum( case {alias}.trade_action when 1 then {alias}.QUANTITY else 0 end ) as OUTQTY , " + "sum( case {alias}.trade_action when 2 then {alias}.QUANTITY else 0 end ) as BUYRETQTY, " + "sum( case {alias}.trade_action when 3 then {alias}.QUANTITY else 0 end ) as SELLRETQTY, " + "sum( case {alias}.trade_action when 6 then {alias}.QUANTITY else 0 end ) as RESQTY , " + "sum( case {alias}.trade_action when 7 then {alias}.QUANTITY else 0 end ) as DELQTY ", "UNIT", new String[] { "unit", "inqty", "outqty", "buyretqty", "sellretqty", "resqty", "delqty" }, new Type[] { Hibernate.STRING, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE, Hibernate.DOUBLE })); crit.setProjection(pl);// ww w . j a va 2s. co m crit.add(Restrictions.eq("active", true)); if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) { Criterion criteria1 = Restrictions.eq("product.barcode1", filterModel.getBarcode()); Criterion criteria2 = Restrictions.eq("product.barcode2", filterModel.getBarcode()); Criterion criteria3 = Restrictions.eq("product.barcode3", filterModel.getBarcode()); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (filterModel.getProduct() != null) { crit.add(Restrictions.eq("product", filterModel.getProduct())); } crit.addOrder(Order.asc("product.name")); 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)); }/* ww w . j av 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.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 ww w .j a va 2s. 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 . ja va 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 w w. j av 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.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)); }/*from w ww . j a v 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)); } crit.add(Restrictions.eq("this.action", TradeAction.Sale)); crit.addOrder(Order.desc("this.serial")); return crit; }
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 w w.j a v 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.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 w w w .jav 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.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)); }//ww w. ja v a 2 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; }