Example usage for org.hibernate.criterion Restrictions le

List of usage examples for org.hibernate.criterion Restrictions le

Introduction

In this page you can find the example usage for org.hibernate.criterion Restrictions le.

Prototype

public static SimpleExpression le(String propertyName, Object value) 

Source Link

Document

Apply a "less than or equal" constraint to the named property

Usage

From source file:com.ut.tekir.finance.ChequeToBankPayrollBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    crit.createAlias("this.bank", "bank");
    crit.createAlias("this.bankBranch", "bankBranch");
    crit.createAlias("this.bankAccount", "bankAccount");

    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.date"), "date")
            .add(Projections.property("this.info"), "info").add(Projections.property("bank.name"), "bankName")
            .add(Projections.property("bankBranch.name"), "bankBranchName")
            .add(Projections.property("bankAccount.name"), "bankAccountName"))
            .setResultTransformer(Transformers.aliasToBean(ChequeToBankPayrollFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }/* ww  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.getBank() != null) {
        crit.add(Restrictions.eq("this.bank", filterModel.getBank()));
    }
    if (filterModel.getBankBranch() != null) {
        crit.add(Restrictions.eq("this.bankBranch", filterModel.getBankBranch()));
    }
    if (filterModel.getBankAccount() != null) {
        crit.add(Restrictions.eq("this.bankAccount", filterModel.getBankAccount()));
    }

    crit.addOrder(Order.desc("this.date"));
    return crit;
}

From source file:com.ut.tekir.finance.ChequeToContactPayrollBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    crit.createAlias("contact", "contact");

    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.date"), "date")
            .add(Projections.property("this.info"), "info")
            .add(Projections.property("contact.code"), "contactCode")
            .add(Projections.property("contact.person"), "person")
            .add(Projections.property("contact.company"), "company")
            .add(Projections.property("contact.name"), "contactName"))
            .setResultTransformer(Transformers.aliasToBean(ChequeToContactPayrollFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }/*  ww w. ja  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 (isNotEmpty(filterModel.getContactName())) {
        crit.add(Restrictions.ilike("contact.name", "%" + filterModel.getContactName(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getContactCode())) {
        crit.add(Restrictions.ilike("contact.code", "%" + filterModel.getContactCode(), 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()));
    }

    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

From source file:com.ut.tekir.finance.CollectionBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    crit.createAlias("this.contact", "contact");
    crit.createAlias("this.account", "account");

    ProjectionList pl = Projections.projectionList();
    pl.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.date"), "date")
            .add(Projections.property("this.info"), "info")
            .add(Projections.property("contact.code"), "contactCode")
            .add(Projections.property("contact.fullname"), "contactName")
            .add(Projections.property("contact.company"), "company")
            .add(Projections.property("contact.person"), "person")
            .add(Projections.property("account.code"), "accountCode")
            .add(Projections.property("this.totalAmount.currency"), "totalAmountCurrency")
            .add(Projections.property("this.totalAmount.value"), "totalAmountValue");

    if (filterModel.getWorkBunch() != null) {
        crit.createAlias("this.items", "it", CriteriaSpecification.LEFT_JOIN);
        pl.add(Projections.property("it.workBunch"), "workBunch");
        pl.add(Projections.property("it.amount.value"), "itemAmountValue");
        crit.add(Restrictions.eq("it.workBunch", filterModel.getWorkBunch()));
    }//w w w  .ja  v  a 2s. c  om

    crit.setProjection(pl).setResultTransformer(Transformers.aliasToBean(PaymentFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }

    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 (filterModel.getProcessType() != null) {
        crit.add(Restrictions.eq("this.processType", filterModel.getProcessType()));
    }

    crit.add(Restrictions.eq("this.action", FinanceAction.Credit));
    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

From source file:com.ut.tekir.finance.ContactToBankTransferBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(BankToContactTransfer.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("bankAccount"), "bankAccount")
            .add(Projections.property("bankBranch"), "bankBranch").add(Projections.property("bank"), "bank")
            .add(Projections.property("contact.fullname"), "contactName")
            .add(Projections.property("contact.code"), "contactCode")
            .add(Projections.property("contact.company"), "company")
            .add(Projections.property("contact.person"), "person").add(Projections.property("date"), "date")
            .add(Projections.property("info"), "info")
            .add(Projections.property("this.amount.value"), "amountValue")
            .add(Projections.property("this.amount.currency"), "amountCurrency")
            .add(Projections.property("this.cost.value"), "costValue")
            .add(Projections.property("this.cost.currency"), "costCurrency"))
            .setResultTransformer(Transformers.aliasToBean(ContactToBankTransferFilterModel.class));

    if (filterModel.getWorkBunch() != null) {
        crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch()));
    }/*from  ww  w.  jav a  2 s.  c  om*/

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }

    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.getContactName())) {
        crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getContactCode())) {
        crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START));
    }

    if (filterModel.getBank() != null) {
        crit.add(Restrictions.eq("this.bank", filterModel.getBank()));
    }

    if (filterModel.getBankBranch() != null) {
        crit.add(Restrictions.eq("this.bankBranch", filterModel.getBankBranch()));
    }

    if (filterModel.getBankAccount() != null) {
        crit.add(Restrictions.eq("this.bankAccount", filterModel.getBankAccount()));
    }
    if (filterModel.getTransferType() != BankTransferType.Unknown) {
        crit.add(Restrictions.eq("this.transferType", filterModel.getTransferType()));
    }

    if (filterModel.getProcessType() != null) {
        crit.add(Restrictions.eq("this.processType", filterModel.getProcessType()));
    }

    crit.add(Restrictions.eq("action", FinanceAction.Credit));

    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

From source file:com.ut.tekir.finance.DebitCreditNoteCollectionBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    if (filterModel.getWorkBunch() != null) {
        crit.createAlias("this.items", "it", CriteriaSpecification.LEFT_JOIN);
        crit.add(Restrictions.eq("it.workBunch", filterModel.getWorkBunch()));
    }//from   www .ja  v a  2  s.c  om

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }

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

    crit.add(Restrictions.eq("this.action", FinanceAction.Credit));

    crit.addOrder(Order.desc("this.serial"));
    crit.addOrder(Order.desc("this.date"));
    return crit;
}

From source file:com.ut.tekir.finance.DebitCreditNotePaymentBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    if (filterModel.getWorkBunch() != null) {
        crit.createAlias("this.items", "it", CriteriaSpecification.LEFT_JOIN);
        crit.add(Restrictions.eq("it.workBunch", filterModel.getWorkBunch()));
    }/*from ww  w . ja  v  a2 s.  co  m*/

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }

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

    crit.add(Restrictions.eq("this.action", FinanceAction.Debit));
    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

From source file:com.ut.tekir.finance.DebitCreditVirementBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("serial", filterModel.getSerial(), MatchMode.START));
    }//  w w w .j a v a 2  s.co m

    if (isNotEmpty(filterModel.getReference())) {
        crit.add(Restrictions.ilike("reference", filterModel.getReference(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.ilike("code", filterModel.getCode(), MatchMode.START));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("date", filterModel.getEndDate()));
    }

    crit.addOrder(Order.desc("date"));

    return crit;
}

From source file:com.ut.tekir.finance.DepositAccountBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.like("serial", filterModel.getSerial() + "%"));
    }/*from   w w w.j a  v a2s . c o  m*/

    if (isNotEmpty(filterModel.getReference())) {
        crit.add(Restrictions.like("reference", filterModel.getReference() + "%"));
    }

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.like("code", filterModel.getCode() + "%"));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("date", filterModel.getEndDate()));
    }

    return crit;
}

From source file:com.ut.tekir.finance.ExpenseNoteBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(ExpenseNote.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.documentType"), "documentType")
            .add(Projections.property("this.contact"), "contact")
            .add(Projections.property("this.workBunch"), "workBunch"))
            .setResultTransformer(Transformers.aliasToBean(ExpenseNote.class));

    if (filterModel.getWorkBunch() != null) {
        crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch()));
    }/*from  www. ja v  a  2s.  co m*/

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.like("this.serial", filterModel.getSerial() + "%"));
    }

    if (isNotEmpty(filterModel.getReference())) {
        crit.add(Restrictions.like("this.reference", filterModel.getReference() + "%"));
    }

    if (isNotEmpty(filterModel.getCode())) {
        crit.add(Restrictions.like("this.code", filterModel.getCode() + "%"));
    }

    if (filterModel.getBeginDate() != null) {
        crit.add(Restrictions.ge("this.date", filterModel.getBeginDate()));
    }

    if (filterModel.getEndDate() != null) {
        crit.add(Restrictions.le("this.date", filterModel.getEndDate()));
    }

    if (filterModel.getContact() != null) {
        crit.add(Restrictions.le("this.contact", filterModel.getContact()));
    }

    if (isNotEmpty(filterModel.getInfo())) {
        crit.add(Restrictions.ilike("this.info", filterModel.getInfo(), MatchMode.ANYWHERE));
    }

    crit.addOrder(Order.desc("date"));
    crit.addOrder(Order.desc("serial"));
    return crit;
}

From source file:com.ut.tekir.finance.FinanceTxnReportBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

    crit.createAlias("contact", "contact");

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }/*  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 (isNotEmpty(filterModel.getContactName())) {
        crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.START));
    }

    if (isNotEmpty(filterModel.getContactCode())) {
        crit.add(Restrictions.ilike("contact.code", filterModel.getContactCode(), MatchMode.START));
    }

    if (filterModel.getCompanyType() != null && !filterModel.getCompanyType().equals("All")) {
        if (filterModel.getCompanyType().equals("Person")) {
            crit.add(Restrictions.eq("contact.person", Boolean.TRUE));
        } else
            crit.add(Restrictions.eq("contact.person", Boolean.FALSE));
    }

    if (filterModel.getType() != null && filterModel.getType() != ContactType.All) {
        crit.add(Restrictions.eq("contact." + filterModel.getType().toString().toLowerCase() + "Type",
                Boolean.TRUE));
    }

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

    if (filterModel.getExCode1() != null && filterModel.getExCode1().length() > 0) {
        crit.add(Restrictions.ilike("contact.exCode1", filterModel.getExCode1(), MatchMode.START));
    }

    if (filterModel.getExCode2() != null && filterModel.getExCode2().length() > 0) {
        crit.add(Restrictions.ilike("contact.exCode2", filterModel.getExCode2(), MatchMode.START));
    }

    if (filterModel.getOrganization() != null) {
        crit.add(Restrictions.eq("contact.organization", filterModel.getOrganization()));
    }

    if (filterModel.getActive() != null) {
        crit.add(Restrictions.eq("this.active", filterModel.getActive()));
    }

    if (filterModel.getDocumentType() != null && filterModel.getDocumentType() != DocumentType.Unknown) {
        crit.add(Restrictions.eq("this.documentType", filterModel.getDocumentType()));
    }
    if (filterModel.getContact() != null) {
        crit.add(Restrictions.eq("contact.id", filterModel.getContact().getId()));
    }

    if (filterModel.getWorkBunch() != null) {
        crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch()));
    }

    if (filterModel.getCurrency() != null) {
        crit.add(Restrictions.eq("this.amount.currency", filterModel.getCurrency()));
    }

    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.fullname"), "contactName")
                .add(Projections.groupProperty("contact.code"), "contactCode")
                .add(Projections.groupProperty("code"), "code").add(Projections.groupProperty("info"), "info")
                .add(Projections.groupProperty("action"), "action")
                .add(Projections.sum("amount.localAmount"), "localAmount")
                .add(Projections.sum("processType"), "processType")
                .add(Projections.sum("amount.currency"), "currency")
                .add(Projections.groupProperty("workBunch"), "workBunch"));
        log.info("yerel secili : #0", crit);
    }

    if (filterModel.getProcessType() != null) {
        crit.add(Restrictions.eq("this.processType", filterModel.getProcessType()));
    }

    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.id"));
    //crit.addOrder(Order.desc("serial"));
    //crit.addOrder(Order.asc("contact.name"));

    log.debug("Sonu : #0", crit);

    return crit;
}