Example usage for org.hibernate.transform Transformers aliasToBean

List of usage examples for org.hibernate.transform Transformers aliasToBean

Introduction

In this page you can find the example usage for org.hibernate.transform Transformers aliasToBean.

Prototype

public static ResultTransformer aliasToBean(Class target) 

Source Link

Document

Creates a resulttransformer that will inject aliased values into instances of Class via property methods or fields.

Usage

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 www . 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 (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));
    }/* ww  w .  j  a  v  a  2  s .  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 (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.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 .  java2  s . co 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));
    }/*  w w w.  jav a  2s . 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);//from  w w  w  .j a v  a2 s  .co  m

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

}

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 w  ww.j ava 2  s.  com

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

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  ww . j a  v a 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.ProductTxnReportBean.java

License:LGPL

public DetachedCriteria buildCriteriaForPrice(TradeAction tradeAction) {

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

    crit.createAlias("product", "product");
    crit.createAlias("warehouse", "warehouse");

    crit.setProjection(Projections.projectionList().add(Projections.property("documentType"), "documentType")
            .add(Projections.property("documentId"), "documentId").add(Projections.property("code"), "code")
            .add(Projections.property("action"), "action")
            .add(Projections.property("warehouse.name"), "wareName")
            .add(Projections.property("product.id"), "prodId")
            .add(Projections.property("product.name"), "prodName")
            .add(Projections.property("product.code"), "prodCode")
            .add(Projections.property("product.barcode1"), "barcode")
            .add(Projections.property("product.barcode2"), "barcode2")
            .add(Projections.property("product.barcode3"), "barcode3")
            .add(Projections.property("product.buyTax"), "buyTax1")
            .add(Projections.property("product.buyTax2"), "buyTax2")
            .add(Projections.property("product.buyTax3"), "buyTax3")
            .add(Projections.property("product.buyTax4"), "buyTax4")
            .add(Projections.property("product.buyTax5"), "buyTax5")
            .add(Projections.property("product.sellTax"), "sellTax1")
            .add(Projections.property("product.sellTax2"), "sellTax2")
            .add(Projections.property("product.sellTax3"), "sellTax3")
            .add(Projections.property("product.sellTax4"), "sellTax4")
            .add(Projections.property("product.sellTax5"), "sellTax5")
            .add(Projections.property("product.labelName"), "labelName")
            .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"), "workBunch"));

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

    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)));
    }//from   w ww .  ja  v  a 2 s . co m

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

    crit.add(Restrictions.eq("this.action", tradeAction));
    crit.add(Restrictions.eq("this.active", true));
    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.id"));
    return crit;
}

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

License:LGPL

public DetachedCriteria buildCriteriaForProduct() {

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

    crit.setProjection(Projections.projectionList().add(Projections.property("id"), "prodId")
            .add(Projections.property("name"), "prodName").add(Projections.property("code"), "prodCode")
            .add(Projections.property("barcode1"), "barcode").add(Projections.property("barcode2"), "barcode2")
            .add(Projections.property("barcode3"), "barcode3").add(Projections.property("buyTax"), "buyTax1")
            .add(Projections.property("buyTax2"), "buyTax2").add(Projections.property("buyTax3"), "buyTax3")
            .add(Projections.property("buyTax4"), "buyTax4").add(Projections.property("buyTax5"), "buyTax5")
            .add(Projections.property("sellTax"), "sellTax1").add(Projections.property("sellTax2"), "sellTax2")
            .add(Projections.property("sellTax3"), "sellTax3").add(Projections.property("sellTax4"), "sellTax4")
            .add(Projections.property("sellTax5"), "sellTax5").add(Projections.property("unit"), "quantityUnit")
            .add(Projections.property("labelName"), "labelName"));

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

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

        crit.add(Restrictions.or(criteria1, Restrictions.or(criteria2, criteria3)));
    }/*from   ww w. ja v a2 s.com*/

    if (filterModel.getProduct() != null) {
        crit.add(Restrictions.eq("this.id", filterModel.getProduct().getId()));
    }
    crit.add(Restrictions.eq("this.active", true));
    crit.addOrder(Order.desc("this.id"));
    return crit;
}

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")
    );//from   ww w  .j  a  v a 2 s  .co 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;
}