本文整理汇总了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);
}
示例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);
}