List of usage examples for org.hibernate.criterion Projections property
public static PropertyProjection property(String propertyName)
From source file:com.ut.tekir.general.OrganizationBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(Organization.class); crit.setProjection(Projections.projectionList().add(Projections.property("id"), "id") .add(Projections.property("code"), "code").add(Projections.property("name"), "name") .add(Projections.property("info"), "info")); crit.setResultTransformer(Transformers.aliasToBean(Organization.class)); if (filterModel.getCode() != null && filterModel.getCode().length() > 0) { crit.add(Restrictions.ilike("code", filterModel.getCode(), MatchMode.START)); }/*from www. j a va 2s.c om*/ if (filterModel.getName() != null && filterModel.getName().length() > 0) { crit.add(Restrictions.ilike("name", filterModel.getName(), MatchMode.START)); } if (filterModel.getLevel() != null) { crit.add(Restrictions.eq("level", filterModel.getLevel())); } return crit; }
From source file:com.ut.tekir.general.PosCommisionBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(PosCommision.class); //crit.createAlias("detailList", "detailList"); crit.createAlias("pos", "pos"); crit.createAlias("pos.bank", "bank"); crit.createAlias("pos.bankBranch", "bankBranch"); crit.createAlias("pos.bankAccount", "bankAccount"); crit.setProjection(Projections.projectionList() // .add(Projections.property("detailList.month"), "month") // .add(Projections.property("detailList.rate"), "rate") // .add(Projections.property("detailList.valor"), "valor") // .add(Projections.property("detailList"), "detailList") .add(Projections.property("pos"), "pos").add(Projections.property("id"), "id") .add(Projections.property("pos.bank"), "bank") .add(Projections.property("pos.bankBranch"), "bankBranch") .add(Projections.property("pos.bankAccount"), "bankAccount") .add(Projections.property("startDate"), "startDate").add(Projections.property("endDate"), "endDate") ).setResultTransformer(Transformers.aliasToBean(PosCommisionFilterModel.class)); if (filterModel.getBank() != null) { crit.add(Restrictions.eq("pos.bank", filterModel.getBank())); }/*from ww w . j a v a 2s. com*/ if (filterModel.getBankBranch() != null) { crit.add(Restrictions.eq("pos.bankBranch", filterModel.getBankBranch())); } if (filterModel.getBankAccount() != null) { crit.add(Restrictions.eq("pos.bankAccount", filterModel.getBankAccount())); } if (filterModel.getPos() != null) { crit.add(Restrictions.eq("this.pos", filterModel.getPos())); } // if (filterModel.getMonth() != null) { // crit.add(Restrictions.eq("detailList.month", filterModel.getMonth())); // } if (filterModel.getStartDate() != null) { crit.add(Restrictions.ge("this.startDate", filterModel.getStartDate())); } if (filterModel.getEndDate() != null) { crit.add(Restrictions.le("this.endDate", filterModel.getEndDate())); } crit.addOrder(Order.desc("this.id")); return crit; }
From source file:com.ut.tekir.general.WorkBunchSuggestionBean.java
License:LGPL
@SuppressWarnings("unchecked") public void selectWorkBunchList() { HibernateSessionProxy session = (HibernateSessionProxy) entityManager.getDelegate(); Criteria crit = session.createCriteria(WorkBunch.class); if (getCode() != null && getCode().length() > 0) { crit.add(Restrictions.like("this.code", getCode() + "%")); }/* ww w . ja v a 2s . c o m*/ if (getName() != null && getName().length() > 0) { crit.add(Restrictions.like("this.name", getName() + "%")); } if (getContact() != null) { crit.add(Restrictions.eq("this.contact", getContact())); } if (getWorkBunchStatus() != null && getWorkBunchStatus() != WorkBunchStatus.All) { crit.add(Restrictions.eq("this.WorkBunchStatus", getWorkBunchStatus())); } if (getEndDate() != null) { crit.add(Restrictions.le("this.endDate", getEndDate())); } if (getBeginDate() != null) { crit.add(Restrictions.ge("this.beginDate", getBeginDate())); } crit.add(Restrictions.eq("this.active", true)); crit.setProjection(Projections.projectionList().add(Projections.property("code"), "code") .add(Projections.property("name"), "name").add(Projections.property("contact"), "contact") .add(Projections.property("workBunchStatus"), "workBunchStatus") .add(Projections.property("beginDate"), "beginDate") .add(Projections.property("endDate"), "endDate")); crit.setMaxResults(30); setWorkBunchList(crit.list()); }
From source file:com.ut.tekir.invoice.yeni.PurchaseInvoiceBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirInvoice.class); crit.createAlias("this.contact", "contact"); crit.createAlias("this.warehouse", "warehouse"); crit.setProjection(Projections.projectionList().add(Projections.property("contact"), "contact") .add(Projections.property("warehouse"), "warehouse").add(Projections.property("serial"), "serial") .add(Projections.property("reference"), "reference").add(Projections.property("code"), "code") .add(Projections.property("date"), "date").add(Projections.property("contact.code"), "contactCode") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("tradeAction"), "tradeAction") .add(Projections.property("documentType"), "documentType").add(Projections.property("id"), "id") .add(Projections.property("info"), "info") .add(Projections.property("totalBeforeTax.localAmount"), "totalBeforeTaxLocalAmount") .add(Projections.property("totalBeforeTax.value"), "totalBeforeTaxValue") .add(Projections.property("totalBeforeTax.currency"), "totalBeforeTaxCurrency") .add(Projections.property("totalTax.localAmount"), "totalTaxLocalAmount") .add(Projections.property("totalTax.value"), "totalTaxValue") .add(Projections.property("totalTax.currency"), "totalTaxCurrency") .add(Projections.property("grandTotal.localAmount"), "grandTotalLocalAmount") .add(Projections.property("grandTotal.value"), "grandTotalValue") .add(Projections.property("grandTotal.currency"), "grandTotalCurrency") .add(Projections.property("workBunch"), "workBunch")); crit.setResultTransformer(Transformers.aliasToBean(InvoiceFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }//from w ww . j av 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 (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 (isNotEmpty(filterModel.getInfo())) { crit.add(Restrictions.ilike("this.info", filterModel.getInfo(), MatchMode.ANYWHERE)); } if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch())); } if (filterModel.getReturned() != null) { if (filterModel.getReturned()) { crit.add(Restrictions.eq("this.tradeAction", TradeAction.SaleReturn)); } else { crit.add(Restrictions.eq("this.tradeAction", TradeAction.Purchase)); } } else { crit.add(Restrictions.or(Restrictions.eq("this.tradeAction", TradeAction.SaleReturn), Restrictions.eq("this.tradeAction", TradeAction.Purchase))); } crit.add(Restrictions.or(Restrictions.eq("this.documentType", DocumentType.PurchaseInvoice), Restrictions.eq("this.documentType", DocumentType.PurchaseShipmentInvoice))); crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.invoice.yeni.SaleInvoiceBrowseBean.java
License:LGPL
@Override public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(TekirInvoice.class); crit.createAlias("this.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("contact.code"), "contactCode") .add(Projections.property("contact.fullname"), "contactName") .add(Projections.property("contact.company"), "contactCompany") .add(Projections.property("contact.person"), "contactPerson") .add(Projections.property("documentType"), "documentType") .add(Projections.property("tradeAction"), "tradeAction") .add(Projections.property("totalBeforeTax.value"), "totalBeforeTaxValue") .add(Projections.property("totalBeforeTax.currency"), "totalBeforeTaxCurrency") .add(Projections.property("totalTax.value"), "totalTaxValue") .add(Projections.property("totalTax.currency"), "totalTaxCurrency") .add(Projections.property("grandTotal.value"), "grandTotalValue") .add(Projections.property("grandTotal.currency"), "grandTotalCurrency") .add(Projections.property("workBunch"), "workBunch")); crit.setResultTransformer(Transformers.aliasToBean(InvoiceFilterModel.class)); if (isNotEmpty(filterModel.getSerial())) { crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START)); }/*from w w w. j a 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 (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)); } if (isNotEmpty(filterModel.getInfo())) { crit.add(Restrictions.ilike("this.info", filterModel.getInfo(), MatchMode.ANYWHERE)); } if (filterModel.getActive() != null) { crit.add(Restrictions.eq("this.active", filterModel.getActive())); } if (filterModel.getWorkBunch() != null) { crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch())); } if (filterModel.getReturned() != null) { if (filterModel.getReturned()) { crit.add(Restrictions.eq("this.tradeAction", TradeAction.PurchseReturn)); } else { crit.add(Restrictions.eq("this.tradeAction", TradeAction.Sale)); } } else { crit.add(Restrictions.or(Restrictions.eq("this.tradeAction", TradeAction.PurchseReturn), Restrictions.eq("this.tradeAction", TradeAction.Sale))); } if (filterModel.getProformaInvoice() != null) { if (filterModel.getProformaInvoice()) { crit.add(Restrictions.eq("this.documentType", DocumentType.SaleProformaInvoice)); } else { crit.add(Restrictions.in("this.documentType", new DocumentType[] { DocumentType.SaleInvoice, DocumentType.SaleShipmentInvoice, DocumentType.RetailSaleShipmentInvoice })); } } else { crit.add(Restrictions.in("this.documentType", new DocumentType[] { DocumentType.SaleInvoice, DocumentType.SaleShipmentInvoice, DocumentType.RetailSaleShipmentInvoice, DocumentType.SaleProformaInvoice })); } crit.addOrder(Order.desc("this.date")); crit.addOrder(Order.desc("this.serial")); return crit; }
From source file:com.ut.tekir.report.AccountStatusReportBean.java
License:LGPL
public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(AccountTxn.class); crit.createAlias("account", "account"); crit.setProjection(Projections.projectionList() .add(Projections.groupProperty("account.code"), "accountCode") .add(Projections.groupProperty("account.name"), "accountName") .add(Projections.groupProperty("amount.currency"), "currency") .add(Projections.sum("amount.value"), "amount") .add(Projections.sum("amount.localAmount"), "localAmount") .add(Projections.property("this.processType"), "processType") .add(Projections.sqlGroupProjection( "{alias}.CCY as currency, sum( ( case {alias}.finance_action when 0 then 1 else -1 end ) * {alias}.CCYVAL ) as AMOUNT, 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", "CCY", new String[] { "currency", "amount", "debit", "credit" }, new Type[] { Hibernate.STRING, Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL }))); crit.add(Restrictions.eq("active", true)); if (code != null && code.length() > 0) { crit.add(Restrictions.ilike("code", code, MatchMode.START)); }/*from w ww. j a v a 2s . c o m*/ if (account != null) { crit.add(Restrictions.eq("account", account)); } if (beginDate != null) { crit.add(Restrictions.ge("date", beginDate)); } if (endDate != null) { crit.add(Restrictions.le("date", endDate)); } if (getDocumentType() != null && getDocumentType() != DocumentType.Unknown) { crit.add(Restrictions.eq("documentType", getDocumentType())); } if (getProcessType() != null) { crit.add(Restrictions.eq("this.processType", getProcessType())); } if (getWorkBunch() != null) { crit.add(Restrictions.eq("workBunch", getWorkBunch())); } crit.addOrder(Order.asc("account.code")); return crit; }
From source file:com.ut.tekir.report.BankStatusReportBean.java
License:LGPL
public DetachedCriteria buildCriteria() { DetachedCriteria crit = DetachedCriteria.forClass(BankTxn.class); crit.createAlias("bankAccount", "bankAccount"); crit.createAlias("bankAccount.bankBranch", "bankBranch"); crit.createAlias("bankAccount.bankBranch.bank", "bank"); crit.setProjection(Projections.projectionList() .add(Projections.groupProperty("bankAccount.accountNo"), "bankAccount") .add(Projections.groupProperty("bankBranch.name"), "bankBranchName") .add(Projections.groupProperty("bank.name"), "bankName") .add(Projections.groupProperty("amount.currency"), "currency") .add(Projections.sum("amount.value"), "amount") .add(Projections.property("processType"), "processType") .add(Projections.sum("amount.localAmount"), "localAmount") .add(Projections.sqlGroupProjection( "{alias}.CCY as currency, sum( ( case {alias}.action when 0 then 1 else -1 end ) * {alias}.CCYVAL ) as AMOUNT, sum( case {alias}.action when 0 then {alias}.CCYVAL else 0 end ) as DEBIT, sum( case {alias}.action when 0 then 0 else {alias}.CCYVAL end ) as CREDIT", "{alias}.CCY", new String[] { "currency", "amount", "debit", "credit" }, new Type[] { Hibernate.STRING, Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL, Hibernate.BIG_DECIMAL }))); crit.add(Restrictions.eq("active", true)); if (bankAccount != null) { crit.add(Restrictions.eq("this.bankAccount", bankAccount)); } else {//from w w w. j a v a2 s . c o m if (bankBranch != null) { crit.add(Restrictions.eq("bankAccount.bankBranch", bankBranch)); } else { if (bank != null) { crit.add(Restrictions.eq("bankBranch.bank", bank)); } } } if (code != null && code.length() > 0) { crit.add(Restrictions.ilike("code", code, MatchMode.START)); } if (beginDate != null) { crit.add(Restrictions.ge("date", beginDate)); } if (endDate != null) { crit.add(Restrictions.le("date", endDate)); } if (getWorkBunch() != null) { crit.add(Restrictions.eq("workBunch", getWorkBunch())); } if (getDocumentType() != null && getDocumentType() != DocumentType.Unknown) { crit.add(Restrictions.eq("documentType", getDocumentType())); } if (getProcessType() != null) { crit.add(Restrictions.eq("this.processType", getProcessType())); } crit.addOrder(Order.asc("bankAccount.name")); 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 w w. ja v a 2 s . c om*/ 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 w ww . j a v a 2 s .co m*/ 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 @SuppressWarnings("unchecked") public void search() { log.debug("Search Execute"); HibernateSessionProxy session = (HibernateSessionProxy) getEntityManager().getDelegate(); Criteria ecrit = buildCriteria().getExecutableCriteria(session); //ecrit.setCacheable(true); ecrit.setMaxResults(100);/* w w w. j a v a 2s . c om*/ ProjectionList pl = Projections.projectionList().add(Projections.property("this.id"), "id") .add(Projections.property("this.active"), "active") .add(Projections.property("this.defaultItem"), "defaultItem") .add(Projections.property("this.info"), "info").add(Projections.property("this.code"), "code") .add(Projections.property("this.endDate"), "endDate") .add(Projections.property("this.beginDate"), "beginDate") .add(Projections.property("this.action"), "action"); ecrit.createAlias("this.owner", "owner", DetachedCriteria.LEFT_JOIN); pl.add(Projections.property("owner.code"), "ownerCode").add(Projections.property("owner.listName"), "ownerListName"); if (filterModel.getPriceList() != null) { ecrit.add(Restrictions.eq("owner", filterModel.getPriceList())); } ecrit.createAlias("this.group", "group", DetachedCriteria.LEFT_JOIN); pl.add(Projections.property("group"), "group"); if (filterModel.getGroup() != null) { ecrit.add(Restrictions.eq("this.group", filterModel.getGroup())); } ecrit.setProjection(pl).setResultTransformer(Transformers.aliasToBean(PriceItemFilterModel.class)); setEntityList(ecrit.list()); }