Search in sources :

Example 1 with Ordering

use of org.killbill.billing.util.entity.dao.DefaultPaginationSqlDaoHelper.Ordering in project killbill by killbill.

the class DefaultPaymentDao method getByTransactionStatusAcrossTenants.

@Override
public Pagination<PaymentTransactionModelDao> getByTransactionStatusAcrossTenants(final Iterable<TransactionStatus> transactionStatuses, final DateTime createdBeforeDate, final DateTime createdAfterDate, final Long offset, final Long limit) {
    final Collection<String> allTransactionStatus = ImmutableList.copyOf(Iterables.transform(transactionStatuses, Functions.toStringFunction()));
    final Date createdBefore = createdBeforeDate.toDate();
    final Date createdAfter = createdAfterDate.toDate();
    return paginationHelper.getPagination(TransactionSqlDao.class, new PaginationIteratorBuilder<PaymentTransactionModelDao, PaymentTransaction, TransactionSqlDao>() {

        @Override
        public Long getCount(final TransactionSqlDao sqlDao, final InternalTenantContext context) {
            return sqlDao.getCountByTransactionStatusPriorDateAcrossTenants(allTransactionStatus, createdBefore, createdAfter);
        }

        @Override
        public Iterator<PaymentTransactionModelDao> build(final TransactionSqlDao sqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) {
            return sqlDao.getByTransactionStatusPriorDateAcrossTenants(allTransactionStatus, createdBefore, createdAfter, offset, limit, ordering.toString());
        }
    }, offset, limit, null);
}
Also used : PaymentTransaction(org.killbill.billing.payment.api.PaymentTransaction) InternalTenantContext(org.killbill.billing.callcontext.InternalTenantContext) Ordering(org.killbill.billing.util.entity.dao.DefaultPaginationSqlDaoHelper.Ordering) Iterator(java.util.Iterator) Date(java.util.Date)

Aggregations

Date (java.util.Date)1 Iterator (java.util.Iterator)1 InternalTenantContext (org.killbill.billing.callcontext.InternalTenantContext)1 PaymentTransaction (org.killbill.billing.payment.api.PaymentTransaction)1 Ordering (org.killbill.billing.util.entity.dao.DefaultPaginationSqlDaoHelper.Ordering)1