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.healthelink.dao.impl.transactionInDAOImpl.java

@Override
@Transactional/*from  w  w  w  .j a v  a 2 s .  com*/
public List<configurationFTPFields> getFTPInfoForJob(Integer method) {
    try {
        String sql = ("select rel_TransportFTPDetails.id, directory, ip, username, password, method, port, protocol, certification, transportId "
                + " from configurationTransportDetails, rel_TransportFTPDetails "
                + " where method = :method and configurationTransportDetails.id = rel_TransportFTPDetails.transportId "
                + " and configId in (select id from configurations where status = 1) and "
                + " directory not in (select folderPath from moveFilesLog where statusId = 1 and method = :method)"
                + " group by directory order by configId;");

        Query query = sessionFactory.getCurrentSession().createSQLQuery(sql)
                .setResultTransformer(Transformers.aliasToBean(configurationFTPFields.class))
                .setParameter("method", method);

        List<configurationFTPFields> ftpPaths = query.list();

        return ftpPaths;
    } catch (Exception ex) {
        System.err.println("getFTPInfoForJob " + ex.getCause());
        ex.printStackTrace();
        return null;
    }
}

From source file:com.ut.healthelink.dao.impl.transactionInDAOImpl.java

@Override
@Transactional/*from w w  w .j  a  v a 2 s  .  c o  m*/
@SuppressWarnings("unchecked")
public List<configurationRhapsodyFields> getRhapsodyInfoForJob(Integer method) {
    try {
        String sql = ("select rel_TransportRhapsodyDetails.id, directory, method, transportId "
                + " from configurationTransportDetails, rel_TransportRhapsodyDetails "
                + " where method = :method and configurationTransportDetails.id = rel_TransportRhapsodyDetails.transportId "
                + " and configId in (select id from configurations where status = 1) and  "
                + " directory not in (select folderPath from moveFilesLog where statusId = 1 and method = :method) "
                + " group by directory order by configId;");

        Query query = sessionFactory.getCurrentSession().createSQLQuery(sql)
                .setResultTransformer(Transformers.aliasToBean(configurationRhapsodyFields.class))
                .setParameter("method", method);

        List<configurationRhapsodyFields> directories = query.list();

        return directories;
    } catch (Exception ex) {
        System.err.println("getRhapsodyInfoForJob " + ex.getCause());
        ex.printStackTrace();
        return null;
    }
}

From source file:com.ut.healthelink.dao.impl.transactionInDAOImpl.java

@Override
@Transactional/*  ww  w .  ja va 2s .c o  m*/
@SuppressWarnings("unchecked")
public List<IdAndFieldValue> getIdAndValuesForConfigField(Integer configId, Integer batchId,
        configurationDataTranslations cdt, boolean foroutboundProcessing, Integer transactionId) {
    try {
        String sql = "";
        Integer id = batchId;
        if (!foroutboundProcessing) {
            sql = "select transactionInId as transactionId, F" + cdt.getFieldNo()
                    + " as fieldValue from transactionTranslatedIn "
                    + "where  configId = :configId and length(trim(F" + cdt.getFieldNo() + ")) != 0"
                    + " and length(REPLACE(REPLACE(F" + cdt.getFieldNo() + ", '\n', ''), '\r', '')) != 0"
                    + " and transactionInId ";
            if (transactionId == 0) {
                sql = sql + "in (select id from transactionIn where ";
                if (configId != 0) {
                    sql = sql + " configId = :configId and ";
                }
                sql = sql + " batchId = :id and statusId not in ( :transRELId ));";
            } else {
                sql = sql + " = :id";
                id = transactionId;
            }
        } else {

            sql = "select transactionTargetId as transactionId, F" + cdt.getFieldNo()
                    + " as fieldValue from transactionTranslatedOut "
                    + " where configId = :configId and length(trim(F" + cdt.getFieldNo() + ")) != 0"
                    + " and length(REPLACE(REPLACE(F" + cdt.getFieldNo() + ", '\n', ''), '\r', '')) != 0"
                    + " and transactionTargetId ";
            if (transactionId == 0) {
                sql = sql + "in (select id from transactionTarget where ";
                if (configId != 0) {
                    sql = sql + " configId = :configId and ";
                }
                sql = sql + " batchDLId = :id and statusId not in ( :transRELId ));";
            } else {
                sql = sql + " = :id";
                id = transactionId;
            }
        }
        Query query = sessionFactory.getCurrentSession().createSQLQuery(sql)
                .setResultTransformer(Transformers.aliasToBean(IdAndFieldValue.class))
                .setParameter("configId", configId).setParameter("id", id);
        if (transactionId == 0) {
            query.setParameter("transRELId", transRELId);
        }
        List<IdAndFieldValue> valueList = query.list();

        return valueList;
    } catch (Exception ex) {
        ex.printStackTrace();
        System.err.println("getIdAndValuesForConfigField " + ex.getCause());
        return null;
    }
}

From source file:com.ut.healthelink.dao.impl.transactionInDAOImpl.java

/**
 * The 'getuploadBatchesByConfigAndTarget' method will return the list of uploaded messages for the passed in configId and passed in target orgId
 *
 * @param configId The configuration Id to find uploaded messages
 *
 * @param orgId The organization Id that the message was sent to
 *
 * @return This method will return a list of uploaded batches
 *//* w  w  w .  ja v  a  2  s.  c  o  m*/
@Override
@Transactional
public List<batchUploadSummary> getuploadBatchesByConfigAndTarget(Integer configId, Integer orgId,
        Integer tgtConfigId) {

    String sql = "select * from batchuploadsummary where sourceConfigId = :sourceConfigId"
            + " and targetOrgId = :targetOrgId and batchId in (select batchUploadId from transactionTarget"
            + " where batchUploadId = batchuploadsummary.batchId and configId = :targetConfigId)";

    Query query = sessionFactory.getCurrentSession().createSQLQuery(sql)
            .setResultTransformer(Transformers.aliasToBean(batchUploadSummary.class))
            .setParameter("sourceConfigId", configId).setParameter("targetOrgId", orgId)
            .setParameter("targetConfigId", tgtConfigId);

    /*Criteria batchSummaries = sessionFactory.getCurrentSession().createCriteria(batchUploadSummary.class);
    batchSummaries.add(Restrictions.eq("sourceConfigId", configId));
    batchSummaries.add(Restrictions.eq("targetOrgId", orgId));*/

    return query.list();

}

From source file:com.ut.tekir.contact.ContactBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {
    DetachedCriteria crit = DetachedCriteria.forClass(Contact.class);

    crit.setProjection(Projections.distinct(Projections.projectionList().add(Projections.property("id"), "id")
            .add(Projections.property("code"), "code").add(Projections.property("name"), "name")
            .add(Projections.property("fullname"), "fullname").add(Projections.property("ssn"), "ssn")
            .add(Projections.property("company"), "company").add(Projections.property("taxNumber"), "taxNumber")
            .add(Projections.property("taxOffice"), "taxOffice").add(Projections.property("title"), "title")
            .add(Projections.property("representative"), "representative")
            .add(Projections.property("info"), "info").add(Projections.property("exCode1"), "exCode1")
            .add(Projections.property("exCode2"), "exCode2").add(Projections.property("allType"), "allType")
            .add(Projections.property("customerType"), "customerType")
            .add(Projections.property("providerType"), "providerType")
            .add(Projections.property("agentType"), "agentType")
            .add(Projections.property("personnelType"), "personnelType")
            .add(Projections.property("branchType"), "branchType")
            .add(Projections.property("contactType"), "contactType")
            .add(Projections.property("bankType"), "bankType")
            .add(Projections.property("relatedType"), "relatedType")
            .add(Projections.property("foundationType"), "foundationType")));

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

    if (filterModel.getCode() != null && filterModel.getCode().length() > 0) {
        crit.add(Restrictions.ilike("this.code", filterModel.getCode(), MatchMode.START));
    }// w ww.  ja v a 2s  .c o m

    if (filterModel.getFullname() != null && filterModel.getFullname().length() > 0) {
        crit.add(Restrictions.ilike("this.fullname", filterModel.getFullname(), MatchMode.ANYWHERE));
    }

    if (filterModel.getCompany() != null && filterModel.getCompany().length() > 0) {
        crit.add(Restrictions.ilike("this.company", filterModel.getCompany(), MatchMode.START));
    }

    if (filterModel.getSsn() != null && filterModel.getSsn().length() > 0) {
        crit.add(Restrictions.ilike("this.ssn", filterModel.getSsn(), MatchMode.START));
    }

    if (filterModel.getTaxNumber() != null && filterModel.getTaxNumber().length() > 0) {
        crit.add(Restrictions.ilike("this.taxNumber", filterModel.getTaxNumber(), MatchMode.START));
    }

    if (filterModel.getRepresentative() != null && filterModel.getRepresentative().length() > 0) {
        crit.add(Restrictions.ilike("this.representative", filterModel.getRepresentative(), MatchMode.START));
    }

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

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

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

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

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

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

    if (filterModel.getCountry() != null) {
        crit.createAlias("this.addressList", "addressList", CriteriaSpecification.INNER_JOIN);
        crit.add(Restrictions.eq("addressList.address.country", filterModel.getCountry()));

        if (filterModel.getCity1() != null) {
            crit.add(Restrictions.eq("addressList.city", filterModel.getCity1()));
        }
    }

    //FIXME: bu kontrol nasl olmal?
    if (hasRegionRestriction()) {
        if (activeUser.getContact() != null && activeUser.getContact().getOrganization() != null
                && activeUser.getContact().getOrganization() != null) {

            crit.add(Restrictions.or(
                    Restrictions.eq("this.organization.id", activeUser.getContact().getOrganization().getId()),
                    Restrictions.eq("this.isPublic", Boolean.TRUE)));
        }
    }
    crit.addOrder(Order.desc("this.code"));

    return crit;
}

From source file:com.ut.tekir.finance.BankToContactTransferBrowseBean.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.name"), "contactName")
            .add(Projections.property("contact.company"), "company")
            .add(Projections.property("contact.person"), "person")
            .add(Projections.property("contact.code"), "contactCode").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(BankToContactTransferFilterModel.class));

    if (filterModel.getWorkBunch() != null) {
        crit.add(Restrictions.eq("this.workBunch", filterModel.getWorkBunch()));
    }/* w  ww .j  av  a  2s.  c o  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()));
    }

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

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

    if (filterModel.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.Debit));
    crit.addOrder(Order.desc("this.date"));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

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

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

    DetachedCriteria crit = DetachedCriteria.forClass(ChequeCollectedAtBankPayroll.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(ChequeCollectionAtBankPayrollFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }/*  ww  w.  ja va 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 (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"));
    crit.addOrder(Order.desc("this.serial"));

    return crit;
}

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

License:LGPL

@Override
public DetachedCriteria buildCriteria() {
    DetachedCriteria crit = DetachedCriteria.forClass(ChequeFromContactPayroll.class);

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

    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.fullname"), "contactName")
            .add(Projections.property("account.code"), "accountCode")
            .add(Projections.property("account.name"), "accountName"))
            .setResultTransformer(Transformers.aliasToBean(ChequeFromContactPayrollFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.like("this.serial", filterModel.getSerial() + "%"));
    }//  w ww.  ja  v a  2  s  .  co m

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

    if (isNotEmpty(filterModel.getContactName())) {
        crit.add(Restrictions.ilike("contact.fullname", filterModel.getContactName(), MatchMode.ANYWHERE));
    }

    if (filterModel.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.ChequeToAccountCollectionPayrollBrowseBean.java

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

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

    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("account.name"), "accountName"))
            .setResultTransformer(Transformers.aliasToBean(ChequeToAccountCollectionPayrollFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }//  w  ww .j  a  v a2s.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.getAccount() != null) {
        crit.add(Restrictions.eq("this.account", filterModel.getAccount()));
    }

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

    return crit;
}

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

License:LGPL

@Override
public DetachedCriteria buildCriteria() {

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

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

    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("account.name"), "accountName"))
            .setResultTransformer(Transformers.aliasToBean(ChequeToAccountPaymentPayrollFilterModel.class));

    if (isNotEmpty(filterModel.getSerial())) {
        crit.add(Restrictions.ilike("this.serial", filterModel.getSerial(), MatchMode.START));
    }//  w  w  w.j  ava  2 s .  com

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

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

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

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

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

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

    return crit;
}