当前位置: 首页>>代码示例>>Java>>正文


Java ScheduledPaymentQuery.getSearchType方法代码示例

本文整理汇总了Java中nl.strohalm.cyclos.entities.accounts.transactions.ScheduledPaymentQuery.getSearchType方法的典型用法代码示例。如果您正苦于以下问题:Java ScheduledPaymentQuery.getSearchType方法的具体用法?Java ScheduledPaymentQuery.getSearchType怎么用?Java ScheduledPaymentQuery.getSearchType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在nl.strohalm.cyclos.entities.accounts.transactions.ScheduledPaymentQuery的用法示例。


在下文中一共展示了ScheduledPaymentQuery.getSearchType方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: search

import nl.strohalm.cyclos.entities.accounts.transactions.ScheduledPaymentQuery; //导入方法依赖的package包/类
@Override
public List<ScheduledPayment> search(final ScheduledPaymentQuery query) {
    final Map<String, Object> namedParameters = new HashMap<String, Object>();
    final StringBuilder hql = JpaQueryHelper.getInitialQuery(ScheduledPayment.class, "sp", query.getFetch());
    JpaQueryHelper.addInParameterToQuery(hql, namedParameters, "sp.status", query.getStatusList());
    JpaQueryHelper.addPeriodParameterToQuery(hql, namedParameters, "sp.date", query.getPeriod());

    // Account owner
    List<? extends Account> ownerAccounts = new ArrayList<Account>();
    final AccountQuery accountQuery = new AccountQuery();
    accountQuery.setOwner(query.getOwner());
    if (query.getAccountType() != null) {
        accountQuery.setType(query.getAccountType());
    }
    ownerAccounts = accountDao.search(accountQuery);
    if (CollectionUtils.isEmpty(ownerAccounts)) {
        // No accounts - nothing will be returned
        return Collections.emptyList();
    }
    namedParameters.put("ownerAccounts", ownerAccounts);

    // Member
    List<? extends Account> otherAccounts = new ArrayList<MemberAccount>();
    if (query.getMember() != null) {
        final AccountQuery otherAccountsQuery = new AccountQuery();
        otherAccountsQuery.setOwner(query.getMember());
        otherAccounts = accountDao.search(otherAccountsQuery);
        if (CollectionUtils.isEmpty(otherAccounts)) {
            // No accounts - nothing will be returned
            return Collections.emptyList();
        }
        namedParameters.put("otherAccounts", otherAccounts);
    }

    // Search type
    if (query.getSearchType() == ScheduledPaymentQuery.SearchType.OUTGOING) {
        hql.append(" and sp.from in :ownerAccounts ");
        if (CollectionUtils.isNotEmpty(otherAccounts)) {
            hql.append(" and sp.to in :otherAccounts ");
        }
    } else {
        hql.append(" and sp.to in :ownerAccounts ");
        if (CollectionUtils.isNotEmpty(otherAccounts)) {
            hql.append(" and sp.from in :otherAccounts ");
        }
        hql.append(" and sp.showToReceiver = true");
    }

    JpaQueryHelper.appendOrder(hql, "sp.date desc");

    return list(query, hql.toString(), namedParameters);
}
 
开发者ID:mateli,项目名称:OpenCyclos,代码行数:53,代码来源:ScheduledPaymentDAOImpl.java

示例2: search

import nl.strohalm.cyclos.entities.accounts.transactions.ScheduledPaymentQuery; //导入方法依赖的package包/类
@Override
public List<ScheduledPayment> search(final ScheduledPaymentQuery query) {
    final Map<String, Object> namedParameters = new HashMap<String, Object>();
    final StringBuilder hql = HibernateHelper.getInitialQuery(ScheduledPayment.class, "sp", query.getFetch());
    HibernateHelper.addInParameterToQuery(hql, namedParameters, "sp.status", query.getStatusList());
    HibernateHelper.addPeriodParameterToQuery(hql, namedParameters, "sp.date", query.getPeriod());

    // Account owner
    List<? extends Account> ownerAccounts = new ArrayList<Account>();
    final AccountQuery accountQuery = new AccountQuery();
    accountQuery.setOwner(query.getOwner());
    if (query.getAccountType() != null) {
        accountQuery.setType(query.getAccountType());
    }
    ownerAccounts = accountDao.search(accountQuery);
    if (CollectionUtils.isEmpty(ownerAccounts)) {
        // No accounts - nothing will be returned
        return Collections.emptyList();
    }
    namedParameters.put("ownerAccounts", ownerAccounts);

    // Member
    List<? extends Account> otherAccounts = new ArrayList<MemberAccount>();
    if (query.getMember() != null) {
        final AccountQuery otherAccountsQuery = new AccountQuery();
        otherAccountsQuery.setOwner(query.getMember());
        otherAccounts = accountDao.search(otherAccountsQuery);
        if (CollectionUtils.isEmpty(otherAccounts)) {
            // No accounts - nothing will be returned
            return Collections.emptyList();
        }
        namedParameters.put("otherAccounts", otherAccounts);
    }

    // Search type
    if (query.getSearchType() == ScheduledPaymentQuery.SearchType.OUTGOING) {
        hql.append(" and sp.from in (:ownerAccounts) ");
        if (CollectionUtils.isNotEmpty(otherAccounts)) {
            hql.append(" and sp.to in (:otherAccounts) ");
        }
    } else {
        hql.append(" and sp.to in (:ownerAccounts) ");
        if (CollectionUtils.isNotEmpty(otherAccounts)) {
            hql.append(" and sp.from in (:otherAccounts) ");
        }
        hql.append(" and sp.showToReceiver = true");
    }

    HibernateHelper.appendOrder(hql, "sp.date desc");

    return list(query, hql.toString(), namedParameters);
}
 
开发者ID:crypto-coder,项目名称:open-cyclos,代码行数:53,代码来源:ScheduledPaymentDAOImpl.java


注:本文中的nl.strohalm.cyclos.entities.accounts.transactions.ScheduledPaymentQuery.getSearchType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。