List of usage examples for com.google.common.collect Ordering toString
public String toString()
From source file:org.killbill.billing.util.entity.dao.EntityDaoBase.java
@Override public Pagination<M> get(final Long offset, final Long limit, final InternalTenantContext context) { return paginationHelper.getPagination(realSqlDao, new PaginationIteratorBuilder<M, E, EntitySqlDao<M, E>>() { @Override/*from w ww .j a va 2 s. c om*/ public Long getCount(final EntitySqlDao<M, E> sqlDao, final InternalTenantContext context) { // Only need to compute it once, because no search filter has been applied (see DefaultPaginationSqlDaoHelper) return null; } @Override public Iterator<M> build(final EntitySqlDao<M, E> sqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { return sqlDao.get(offset, limit, getNaturalOrderingColumns(), ordering.toString(), context); } }, offset, limit, context); }
From source file:org.killbill.billing.util.customfield.dao.DefaultCustomFieldDao.java
@Override public Pagination<CustomFieldModelDao> searchCustomFields(final String searchKey, final Long offset, final Long limit, final InternalTenantContext context) { return paginationHelper.getPagination(CustomFieldSqlDao.class, new PaginationIteratorBuilder<CustomFieldModelDao, CustomField, CustomFieldSqlDao>() { @Override//from ww w . j a va 2 s. c o m public Long getCount(final CustomFieldSqlDao customFieldSqlDao, final InternalTenantContext context) { return customFieldSqlDao.getSearchCount(searchKey, String.format("%%%s%%", searchKey), context); } @Override public Iterator<CustomFieldModelDao> build(final CustomFieldSqlDao customFieldSqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { return customFieldSqlDao.search(searchKey, String.format("%%%s%%", searchKey), offset, limit, ordering.toString(), context); } }, offset, limit, context); }
From source file:org.killbill.billing.util.tag.dao.DefaultTagDao.java
@Override public Pagination<TagModelDao> searchTags(final String searchKey, final Long offset, final Long limit, final InternalTenantContext context) { return paginationHelper.getPagination(TagSqlDao.class, new PaginationIteratorBuilder<TagModelDao, Tag, TagSqlDao>() { @Override/* w w w.j a v a2 s . c o m*/ public Long getCount(final TagSqlDao tagSqlDao, final InternalTenantContext context) { return tagSqlDao.getSearchCount(searchKey, String.format("%%%s%%", searchKey), context); } @Override public Iterator<TagModelDao> build(final TagSqlDao tagSqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { return tagSqlDao.search(searchKey, String.format("%%%s%%", searchKey), offset, limit, ordering.toString(), context); } }, offset, limit, context); }
From source file:org.killbill.billing.account.dao.DefaultAccountDao.java
@Override public Pagination<AccountModelDao> searchAccounts(final String searchKey, final Long offset, final Long limit, final InternalTenantContext context) { final boolean userIsFeelingLucky = limit == 1 && offset == -1; if (userIsFeelingLucky) { // The use-case we can optimize is when the user is looking for an exact match (e.g. he knows the full email). In that case, we can speed up the queries // by doing exact searches only. final AccountModelDao accountModelDao = transactionalSqlDao .execute(new EntitySqlDaoTransactionWrapper<AccountModelDao>() { @Override// www .j a va2 s . com public AccountModelDao inTransaction( final EntitySqlDaoWrapperFactory entitySqlDaoWrapperFactory) throws Exception { return entitySqlDaoWrapperFactory.become(AccountSqlDao.class).luckySearch(searchKey, context); } }); return new DefaultPagination<AccountModelDao>(0L, 1L, accountModelDao == null ? 0L : 1L, null, // We don't compute stats for speed in that case accountModelDao == null ? ImmutableList.<AccountModelDao>of().iterator() : ImmutableList.<AccountModelDao>of(accountModelDao).iterator()); } // Otherwise, we pretty much need to do a full table scan (leading % in the like clause). // Note: forcing MySQL to search indexes (like luckySearch above) doesn't always seem to help on large tables, especially with large offsets return paginationHelper.getPagination(AccountSqlDao.class, new PaginationIteratorBuilder<AccountModelDao, Account, AccountSqlDao>() { @Override public Long getCount(final AccountSqlDao accountSqlDao, final InternalTenantContext context) { return accountSqlDao.getSearchCount(searchKey, String.format("%%%s%%", searchKey), context); } @Override public Iterator<AccountModelDao> build(final AccountSqlDao accountSqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { return accountSqlDao.search(searchKey, String.format("%%%s%%", searchKey), offset, limit, ordering.toString(), context); } }, offset, limit, context); }
From source file:org.killbill.billing.payment.dao.DefaultPaymentDao.java
@Override public Pagination<PaymentMethodModelDao> getPaymentMethods(final String pluginName, final Long offset, final Long limit, final InternalTenantContext context) { return paginationHelper.getPagination(PaymentMethodSqlDao.class, new PaginationIteratorBuilder<PaymentMethodModelDao, PaymentMethod, PaymentMethodSqlDao>() { @Override// w ww .ja va 2 s . co m public Long getCount(final PaymentMethodSqlDao paymentMethodSqlDao, final InternalTenantContext context) { return paymentMethodSqlDao.getCountByPluginName(pluginName, context); } @Override public Iterator<PaymentMethodModelDao> build(final PaymentMethodSqlDao paymentMethodSqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { return paymentMethodSqlDao.getByPluginName(pluginName, offset, limit, ordering.toString(), context); } }, offset, limit, context); }
From source file:org.killbill.billing.payment.dao.DefaultPaymentDao.java
@Override public Pagination<PaymentModelDao> getPayments(final String pluginName, final Long offset, final Long limit, final InternalTenantContext context) { return paginationHelper.getPagination(PaymentSqlDao.class, new PaginationIteratorBuilder<PaymentModelDao, Payment, PaymentSqlDao>() { @Override//from www. j a va2 s .c om public Long getCount(final PaymentSqlDao paymentSqlDao, final InternalTenantContext context) { return paymentSqlDao.getCountByPluginName(pluginName, context); } @Override public Iterator<PaymentModelDao> build(final PaymentSqlDao paymentSqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { final Iterator<PaymentModelDao> result = paymentSqlDao.getByPluginName(pluginName, offset, limit, ordering.toString(), context); return result; } }, offset, limit, context); }
From source file:org.killbill.billing.payment.dao.DefaultPaymentDao.java
@Override public Pagination<PaymentModelDao> searchPayments(final String searchKey, final Long offset, final Long limit, final InternalTenantContext context) { // Optimization: if the search key looks like a state name (e.g. _ERRORED), assume the user is searching by state only final List<String> paymentStates = expandSearchFilterToStateNames(searchKey); final String likeSearchKey = String.format("%%%s%%", searchKey); return paginationHelper.getPagination(PaymentSqlDao.class, new PaginationIteratorBuilder<PaymentModelDao, Payment, PaymentSqlDao>() { @Override//from www. ja v a 2 s. co m public Long getCount(final PaymentSqlDao paymentSqlDao, final InternalTenantContext context) { return !paymentStates.isEmpty() ? paymentSqlDao.getSearchByStateCount(paymentStates, context) : paymentSqlDao.getSearchCount(searchKey, likeSearchKey, context); } @Override public Iterator<PaymentModelDao> build(final PaymentSqlDao paymentSqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { return !paymentStates.isEmpty() ? paymentSqlDao.searchByState(paymentStates, offset, limit, ordering.toString(), context) : paymentSqlDao.search(searchKey, likeSearchKey, offset, limit, ordering.toString(), context); } }, offset, limit, context); }
From source file:org.killbill.billing.payment.dao.DefaultPaymentDao.java
@Override public Pagination<PaymentAttemptModelDao> getPaymentAttemptsByStateAcrossTenants(final String stateName, final DateTime createdBeforeDate, final Long offset, final Long limit) { final Date createdBefore = createdBeforeDate.toDate(); return paginationHelper.getPagination(PaymentAttemptSqlDao.class, new PaginationIteratorBuilder<PaymentAttemptModelDao, Entity, PaymentAttemptSqlDao>() { @Override/*from www .j av a 2 s . co m*/ public Long getCount(final PaymentAttemptSqlDao sqlDao, final InternalTenantContext context) { return sqlDao.getCountByStateNameAcrossTenants(stateName, createdBefore); } @Override public Iterator<PaymentAttemptModelDao> build(final PaymentAttemptSqlDao sqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { return sqlDao.getByStateNameAcrossTenants(stateName, createdBefore, offset, limit, ordering.toString()); } }, offset, limit, null); }
From source file:org.killbill.billing.payment.dao.DefaultPaymentDao.java
@Override public Pagination<PaymentMethodModelDao> searchPaymentMethods(final String searchKey, final Long offset, final Long limit, final InternalTenantContext context) { return paginationHelper.getPagination(PaymentMethodSqlDao.class, new PaginationIteratorBuilder<PaymentMethodModelDao, PaymentMethod, PaymentMethodSqlDao>() { @Override/*from www . j av a 2s. c o m*/ public Long getCount(final PaymentMethodSqlDao paymentMethodSqlDao, final InternalTenantContext context) { return paymentMethodSqlDao.getSearchCount(searchKey, String.format("%%%s%%", searchKey), context); } @Override public Iterator<PaymentMethodModelDao> build(final PaymentMethodSqlDao paymentMethodSqlDao, final Long offset, final Long limit, final Ordering ordering, final InternalTenantContext context) { return paymentMethodSqlDao.search(searchKey, String.format("%%%s%%", searchKey), offset, limit, ordering.toString(), context); } }, offset, limit, context); }
From source file:org.killbill.billing.payment.dao.DefaultPaymentDao.java
@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/* w ww. j av a 2 s .c o m*/ 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); }