List of usage examples for org.hibernate.criterion DetachedCriteria forClass
public static DetachedCriteria forClass(Class clazz)
From source file:com.ut.tekir.report.BankTxnReportBean.java
License:LGPL
public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(BankTxn.class); crit.createAlias("bankAccount", "bankAccount"); if (getBankAccount() != null) { crit.add(Restrictions.eq("bankAccount", getBankAccount())); } else {/*ww w. ja va2s.co m*/ if (getBankBranch() != null) { crit.createAlias("bankAccount.bankBranch", "bankBranch"); crit.add(Restrictions.eq("bankAccount.bankBranch", getBankBranch())); } else { if (getBank() != null) { crit.createAlias("bankAccount.bankBranch", "bankBranch"); crit.createAlias("bankAccount.bankBranch.bank", "bank"); crit.add(Restrictions.eq("bankBranch.bank", getBank())); } } } if (getSerial() != null && getSerial().length() > 0) { crit.add(Restrictions.ilike("serial", getSerial(), MatchMode.START)); } if (getReference() != null && getReference().length() > 0) { crit.add(Restrictions.ilike("reference", getReference(), MatchMode.START)); } if (getCode() != null && getCode().length() > 0) { crit.add(Restrictions.ilike("code", getCode(), MatchMode.START)); } if (getDocumentType() != null && getDocumentType() != DocumentType.Unknown) { crit.add(Restrictions.eq("documentType", getDocumentType())); } if (getBeginDate() != null) { crit.add(Restrictions.ge("date", getBeginDate())); } if (getEndDate() != null) { crit.add(Restrictions.le("date", getEndDate())); } if (getAdverseCode() != null) { crit.add(Restrictions.ilike("adverseCode", getAdverseCode(), MatchMode.START)); } if (getAdverseName() != null) { crit.add(Restrictions.ilike("adverseName", getAdverseName(), MatchMode.START)); } if (getWorkBunch() != null) { crit.add(Restrictions.eq("workBunch", getWorkBunch())); } if (getProcessType() != null) { crit.add(Restrictions.eq("this.processType", getProcessType())); } crit.add(Restrictions.eq("this.active", true)); crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); crit.addOrder(Order.desc("this.id")); //crit.addOrder(Order.asc("documentType")); //crit.addOrder(Order.asc("bankAccount")); return crit; }
From source file:com.ut.tekir.report.ContactStatusReportBean.java
License:LGPL
public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(FinanceTxn.class); crit.createAlias("contact", "contact"); crit.setProjection(Projections.projectionList().add(Projections.groupProperty("contact.code"), "concode") .add(Projections.groupProperty("contact.fullname"), "conname") .add(Projections.groupProperty("contact.company"), "company") .add(Projections.groupProperty("contact.person"), "person") //.add( Projections.groupProperty("action"), "action" ) //.add( Projections.groupProperty("amount.currency"), "currency" ) .add(Projections.sum("amount.value"), "amount") .add(Projections.sum("amount.localAmount"), "localAmount") .add(Projections.sqlGroupProjection( "{alias}.CCY as currency, sum( case {alias}.finance_action when 0 then {alias}.CCYVAL else 0 end ) as DEBIT, sum( case {alias}.finance_action when 0 then 0 else {alias}.CCYVAL end ) as CREDIT", "{alias}.CCY", new String[] { "currency", "debit", "credit" }, new Type[] { Hibernate.STRING, Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL }))); if (fm.getActive() != null) { crit.add(Restrictions.eq("active", fm.getActive())); }//from w ww . j ava2 s .co m if (StringUtils.isNotEmpty(fm.getCode())) { crit.add(Restrictions.ilike("contact.code", fm.getCode(), MatchMode.START)); } if (StringUtils.isNotEmpty(fm.getName())) { crit.add(Restrictions.ilike("contact.name", fm.getName(), MatchMode.START)); } if (fm.getCategory() != null) { crit.add(Restrictions.eq("contact.category", fm.getCategory())); } if (fm.getBeginDate() != null) { crit.add(Restrictions.ge("date", fm.getBeginDate())); } if (fm.getEndDate() != null) { crit.add(Restrictions.le("date", fm.getEndDate())); } if (fm.getCompanyType() != null && !fm.getCompanyType().equals("All")) { if (fm.getCompanyType().equals("Person")) { crit.add(Restrictions.eq("contact.person", Boolean.TRUE)); } else crit.add(Restrictions.eq("contact.person", Boolean.FALSE)); } if (fm.getType() != null && fm.getType() != ContactType.All) { crit.add(Restrictions.eq("contact." + fm.getType().toString().toLowerCase() + "Type", Boolean.TRUE)); } if (StringUtils.isNotEmpty(fm.getExCode1())) { crit.add(Restrictions.ilike("contact.exCode1", fm.getExCode1(), MatchMode.START)); } if (StringUtils.isNotEmpty(fm.getExCode2())) { crit.add(Restrictions.ilike("contact.exCode2", fm.getExCode2(), MatchMode.START)); } if (fm.getOrganization() != null) { crit.add(Restrictions.eq("contact.organization", fm.getOrganization())); } if (StringUtils.isNotEmpty(fm.getDocCode())) { crit.add(Restrictions.ilike("code", fm.getDocCode(), MatchMode.START)); } if (fm.getDocumentType() != null && fm.getDocumentType() != DocumentType.Unknown) { crit.add(Restrictions.eq("this.documentType", fm.getDocumentType())); } if (fm.getProcessType() != null) { crit.add(Restrictions.eq("this.processType", fm.getProcessType())); } if (fm.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", fm.getWorkBunch())); } if (fm.getContact() != null) { crit.add(Restrictions.eq("contact.id", fm.getContact().getId())); } /* crit.addOrder( Order.asc("date")); crit.addOrder( Order.asc("serial")); * */ crit.addOrder(Order.asc("contact.code")); crit.addOrder(Order.asc("amount.currency")); log.debug("Sonu : #0", crit); return crit; }
From source file:com.ut.tekir.report.ProductStatusReportBean.java
License:LGPL
public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(ProductTxn.class); crit.createAlias("product", "product"); crit.createAlias("warehouse", "warehouse"); //TODO: Unit Price'n farkl dvizlerde olma sorunu zle... ProjectionList pl = Projections.projectionList(); pl.add(Projections.groupProperty("product.code"), "prodcode") .add(Projections.groupProperty("product.name"), "prodname") //.add( Projections.groupProperty("action"), "action" ) //.add( Projections.groupProperty("amount.currency"), "currency" ) .add(Projections.groupProperty("product.group"), "group") .add(Projections.groupProperty("product.barcode1"), "barcode") .add(Projections.sum("quantity.value"), "quantity") .add(Projections.avg("unitPrice.value"), "unitPrice") .add(Projections.sqlGroupProjection("{alias}.UNIT as unit, " + //"sum( case {alias}.finance_action when 0 then {alias}.QUANTITY else 0 end ) as INQTY, " + //"sum( case {alias}.finance_action when 0 then 0 else {alias}.QUANTITY end ) as OUTQTY", "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 })); if (warehouseBase) { //Depo krlml pl.add(Projections.groupProperty("warehouse.code"), "warecode") .add(Projections.groupProperty("warehouse.name"), "warename"); crit.addOrder(Order.asc("warehouse.code")); }//from w w w . j a v a 2s .c o m crit.setProjection(pl); crit.add(Restrictions.eq("active", true)); if (code != null && code.length() > 0) { crit.add(Restrictions.ilike("product.code", code, MatchMode.START)); } if (name != null && name.length() > 0) { crit.add(Restrictions.ilike("product.name", name, MatchMode.START)); } if (productType != null) { if (getProductType() == 1) { crit.add(Restrictions.like("this.productType", ProductType.Product)); } else if (getProductType() == 2) { crit.add(Restrictions.like("this.productType", ProductType.Service)); } } if (barcode != null && barcode.length() > 0) { Criterion criteria1 = Restrictions.like("product.barcode1", barcode, MatchMode.START); Criterion criteria2 = Restrictions.like("product.barcode2", barcode, MatchMode.START); Criterion criteria3 = Restrictions.like("product.barcode3", barcode, MatchMode.START); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (group != null) { crit.add(Restrictions.eq("product.group", group)); } if (warehouse != null) { crit.add(Restrictions.eq("warehouse", warehouse)); } if (beginDate != null) { crit.add(Restrictions.ge("date", beginDate)); } if (endDate != null) { crit.add(Restrictions.le("date", endDate)); } if (category != null) { crit.add(Restrictions.eq("product.category", category)); } if (docCode != null && docCode.length() > 0) { crit.add(Restrictions.ilike("code", docCode, MatchMode.START)); } if (getDocumentType() != null && getDocumentType() != DocumentType.Unknown) { crit.add(Restrictions.eq("this.documentType", getDocumentType())); } if (getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", getWorkBunch())); } /* crit.addOrder( Order.asc("date")); crit.addOrder( Order.asc("serial")); * */ crit.addOrder(Order.asc("product.name")); log.debug("Sonu : #0", crit); return crit; }
From source file:com.ut.tekir.report.SaleInvoiceReportBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirInvoice.class); crit.createAlias("this.contact", "contact"); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//from www . ja 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 (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.START)); } crit.add(Restrictions.or(Restrictions.eq("this.tradeAction", TradeAction.Sale), Restrictions.eq("this.tradeAction", TradeAction.SaleReturn))); crit.add(Restrictions.or(Restrictions.eq("this.documentType", DocumentType.RetailSaleShipmentInvoice), Restrictions.or(Restrictions.eq("this.documentType", DocumentType.SaleInvoice), Restrictions.eq("this.documentType", DocumentType.SaleShipmentInvoice)))); crit.addOrder(Order.desc("this.serial")); crit.addOrder(Order.desc("this.date")); return crit; }
From source file:com.ut.tekir.report.TaxTxnReportBean.java
License:LGPL
public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TaxTxn.class); if (getFilterModel().getSerial() != null && getFilterModel().getSerial().length() > 0) { crit.add(Restrictions.ilike("serial", getFilterModel().getSerial(), MatchMode.START)); }/*from w ww . j a va2s.c o m*/ if (getFilterModel().getReference() != null && getFilterModel().getReference().length() > 0) { crit.add(Restrictions.ilike("reference", getFilterModel().getReference(), MatchMode.START)); } if (getFilterModel().getCode() != null && getFilterModel().getCode().length() > 0) { crit.add(Restrictions.ilike("code", getFilterModel().getCode(), MatchMode.START)); } if (getFilterModel().getBeginDate() != null) { crit.add(Restrictions.ge("date", getFilterModel().getBeginDate())); } if (getFilterModel().getEndDate() != null) { crit.add(Restrictions.le("date", getFilterModel().getEndDate())); } /* if (getFilterModel().getDocumentType() != null && getFilterModel().getDocumentType() != DocumentType.Unknown) { crit.add(Restrictions.eq("documentType", getFilterModel().getDocumentType())); } */ if ((getFilterModel().getTaxReturnType() != null && getFilterModel().getTaxReturnType().getDocumentTypesAsArray().length != 0) || getFilterModel().getDocumentType() != null) { List<DocumentType> documentTypes = new ArrayList<DocumentType>(); if (getFilterModel().getTaxReturnType() != null && getFilterModel().getTaxReturnType().getDocumentTypesAsArray().length != 0) { documentTypes.addAll(getFilterModel().getTaxReturnType().getDocumentTypesAsList()); } if (getFilterModel().getDocumentType() != null) { documentTypes.add(getFilterModel().getDocumentType()); } crit.add(Restrictions.in("documentType", documentTypes)); } if (getFilterModel().getTaxType() != null) { crit.add(Restrictions.eq("taxType", getFilterModel().getTaxType())); } if (getFilterModel().getAction() != null) { crit.add(Restrictions.eq("action", getFilterModel().getAction())); } if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("workBunch", filterModel.getWorkBunch())); } crit.add(Restrictions.eq("this.active", true)); crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.id")); //crit.addOrder(Order.desc("serial")); log.debug("Sonu : #0", crit); return crit; }
From source file:com.ut.tekir.stock.BarcodePrintBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(BarcodeTxn.class); if (filterModel.getActive() != null) { crit.add(Restrictions.eq("active", filterModel.getActive())); }/*from w w w . j a v a 2s . co m*/ if (filterModel.getProduct() != null) { crit.add(Restrictions.eq("product", filterModel.getProduct())); } return crit; }
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 w ww . j a 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.ExpenseDiscBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(Product.class); crit.setProjection(Projections.projectionList().add(Projections.property("id"), "id") .add(Projections.property("code"), "code").add(Projections.property("name"), "name") .add(Projections.property("category"), "category").add(Projections.property("info"), "info") .add(Projections.property("productType"), "productType") .add(Projections.property("barcode1"), "barcode1").add(Projections.property("barcode2"), "barcode2") .add(Projections.property("barcode3"), "barcode3").add(Projections.property("unit"), "unit")); crit.setResultTransformer(Transformers.aliasToBean(Product.class)); if (filterModel.getCode() != null && filterModel.getCode().length() > 0) { crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START)); }//from ww w. j a v a 2s . c om if (filterModel.getName() != null && filterModel.getName().length() > 0) { crit.add(Restrictions.ilike("this.name", filterModel.getName(), MatchMode.START)); } if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) { Criterion criteria1 = Restrictions.like("this.barcode1", filterModel.getBarcode(), MatchMode.START); Criterion criteria2 = Restrictions.like("this.barcode2", filterModel.getBarcode(), MatchMode.START); Criterion criteria3 = Restrictions.like("this.barcode3", filterModel.getBarcode(), MatchMode.START); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (filterModel.getProductType() != ProductType.Unknown) { crit.add(Restrictions.eq("this.productType", filterModel.getProductType())); } else { // Criterion exps = Restrictions.eq("this.productType", ProductType.Expense ); // Criterion disc = Restrictions.eq("this.productType", ProductType.Discount ); // LogicalExpression orExp = Restrictions.or(exps,disc); // crit.add(orExp); crit.add(Restrictions.in("this.productType", new ProductType[] { ProductType.Expense, ProductType.Discount, ProductType.DiscountAddition, ProductType.ExpenseAddition })); } if (filterModel.getCategory() != null) { crit.add(Restrictions.eq("this.category", filterModel.getCategory())); } crit.addOrder(Order.asc("this.code")); 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)); }/*from www . ja va 2s . c o 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.ProductBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(Product.class); crit.setProjection(Projections.projectionList().add(Projections.property("id"), "id") .add(Projections.property("code"), "code").add(Projections.property("name"), "name") .add(Projections.property("category"), "category").add(Projections.property("info"), "info") .add(Projections.property("productType"), "productType") .add(Projections.property("barcode1"), "barcode1").add(Projections.property("barcode2"), "barcode2") .add(Projections.property("barcode3"), "barcode3").add(Projections.property("unit"), "unit") .add(Projections.property("group"), "group").add(Projections.property("openDate"), "openDate") .add(Projections.property("category"), "category").add(Projections.property("system"), "system") .add(Projections.property("active"), "active").add(Projections.property("buyTax"), "buyTax") .add(Projections.property("sellTax"), "sellTax").add(Projections.property("buyTax2"), "buyTax2") .add(Projections.property("sellTax2"), "sellTax2").add(Projections.property("buyTax3"), "buyTax3") .add(Projections.property("sellTax3"), "sellTax3").add(Projections.property("buyTax4"), "buyTax4") .add(Projections.property("sellTax4"), "sellTax4").add(Projections.property("buyTax5"), "buyTax5") .add(Projections.property("sellTax5"), "sellTax5") .add(Projections.property("expenseType"), "expenseType") .add(Projections.property("taxIncluded"), "taxIncluded") .add(Projections.property("tax2Included"), "tax2Included") .add(Projections.property("tax3Included"), "tax3Included") .add(Projections.property("tax4Included"), "tax4Included") .add(Projections.property("tax5Included"), "tax5Included") .add(Projections.property("shelfPlace"), "shelfPlace") .add(Projections.property("labelName"), "labelName") .add(Projections.property("lastPurchasePrice.value"), "lastPurchasePriceValue") .add(Projections.property("lastSalePrice.value"), "lastSalePriceValue") .add(Projections.property("createUser"), "createUser") .add(Projections.property("createDate"), "createDate") .add(Projections.property("updateUser"), "updateUser") .add(Projections.property("updateDate"), "updateDate") );//from ww w.ja v a2 s . c o m crit.setResultTransformer(Transformers.aliasToBean(Product.class)); if (filterModel.getCode() != null && filterModel.getCode().length() > 0) { crit.add(Restrictions.or(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START), Restrictions.like("this.code", filterModel.getCode(), MatchMode.START))); } if (filterModel.getName() != null && filterModel.getName().length() > 0) { crit.add(Restrictions.ilike("this.name", filterModel.getName(), MatchMode.START)); } if (filterModel.getBarcode() != null && filterModel.getBarcode().length() > 0) { Criterion criteria1 = Restrictions.like("this.barcode1", filterModel.getBarcode(), MatchMode.START); Criterion criteria2 = Restrictions.like("this.barcode2", filterModel.getBarcode(), MatchMode.START); Criterion criteria3 = Restrictions.like("this.barcode3", filterModel.getBarcode(), MatchMode.START); crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3))); } if (filterModel.getProductType() != ProductType.Unknown) { crit.add(Restrictions.eq("this.productType", filterModel.getProductType())); } else { Criterion prod = Restrictions.eq("this.productType", ProductType.Product); Criterion serv = Restrictions.eq("this.productType", ProductType.Service); LogicalExpression orExp = Restrictions.or(prod, serv); crit.add(orExp); } if (filterModel.getGroup() != null) { crit.add(Restrictions.eq("this.group", filterModel.getGroup())); } if (filterModel.getCategory() != null) { crit.add(Restrictions.eq("this.category", filterModel.getCategory())); } crit.addOrder(Order.asc("this.code")); return crit; }