Java Code Examples for org.apache.deltaspike.data.api.criteria.Criteria#getResultList()

The following examples show how to use org.apache.deltaspike.data.api.criteria.Criteria#getResultList() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DeltaSpikeRepository.java    From library with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @return
 */
@Override
default List<T> findAllInactive() {

    final Criteria<T, T> criteria = criteria()
            .eq(this.getEntityStateProperty(), false);

    this.applyOrder(criteria);

    return criteria.getResultList();
}
 
Example 2
Source File: DeltaSpikeRepository.java    From library with Apache License 2.0 5 votes vote down vote up
/**
 * {@inheritDoc}
 *
 * @return
 */
@Override
default List<T> findAllActive() {

    final Criteria<T, T> criteria = criteria()
            .eq(this.getEntityStateProperty(), true);

    this.applyOrder(criteria);

    return criteria.getResultList();
}
 
Example 3
Source File: WalletBalanceRepository.java    From web-budget with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find the {@link WalletBalance} by a given filter
 *
 * @param filter to be used on the search process
 * @return a {@link List} of the {@link WalletBalance} found
 */
default List<WalletBalance> findByFilter(WalletBalanceFilter filter) {

    final Criteria<WalletBalance, WalletBalance> criteria = this.criteria();

    final List<Criteria<WalletBalance, WalletBalance>> restrictions = new ArrayList<>();

    if (filter.getReasonType() != null) {
        restrictions.add(this.criteria().eq(WalletBalance_.reasonType, filter.getReasonType()));
    }

    if (filter.getBalanceType() != null) {
        restrictions.add(this.criteria().eq(WalletBalance_.balanceType, filter.getBalanceType()));
    }

    if (filter.getOperationDate() != null) {

        final var start = filter.getOperationDate().atTime(0, 0);
        final var end = filter.getOperationDate().atTime(23, 59);

        restrictions.add(this.criteria().between(WalletBalance_.movementDateTime, start, end));
    }

    if (!restrictions.isEmpty()) {
        criteria.or(restrictions);
    }

    criteria.join(WalletBalance_.wallet,
            where(Wallet.class).eq(Wallet_.id, filter.getWallet().getId()));

    return criteria.getResultList();
}
 
Example 4
Source File: TransferenceRepository.java    From web-budget with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find all transference using a given filter
 *
 * @param filter used to search for {@link Transference}
 * @return a list of {@link Transference} found
 */
default List<Transference> findByFilter(TransferenceFilter filter) {

    final Criteria<Transference, Transference> criteria = this.criteria();

    final List<Criteria<Transference, Transference>> restrictions = new ArrayList<>();

    if (filter.getOriginWallet() != null) {
        restrictions.add(this.criteria().join(Transference_.origin,
                where(Wallet.class).eq(Wallet_.id, filter.getOriginWallet().getId())));
    }

    if (filter.getDestinationWallet() != null) {
        restrictions.add(this.criteria().join(Transference_.destination,
                where(Wallet.class).eq(Wallet_.id, filter.getDestinationWallet().getId())));
    }

    if (filter.getOperationDate() != null) {
        restrictions.add(this.criteria().eq(Transference_.transferDate, filter.getOperationDate()));
    }

    if (!restrictions.isEmpty()) {
        criteria.or(restrictions);
    }

    return criteria.getResultList();
}
 
Example 5
Source File: WalletBalanceRepository.java    From web-budget with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find the {@link WalletBalance} by a given filter
 *
 * @param filter to be used on the search process
 * @return a {@link List} of the {@link WalletBalance} found
 */
default List<WalletBalance> findByFilter(WalletBalanceFilter filter) {

    final Criteria<WalletBalance, WalletBalance> criteria = this.criteria();

    final List<Criteria<WalletBalance, WalletBalance>> restrictions = new ArrayList<>();

    if (filter.getReasonType() != null) {
        restrictions.add(this.criteria().eq(WalletBalance_.reasonType, filter.getReasonType()));
    }

    if (filter.getBalanceType() != null) {
        restrictions.add(this.criteria().eq(WalletBalance_.balanceType, filter.getBalanceType()));
    }

    if (filter.getOperationDate() != null) {

        final var start = filter.getOperationDate().atTime(0, 0);
        final var end = filter.getOperationDate().atTime(23, 59);

        restrictions.add(this.criteria().between(WalletBalance_.movementDateTime, start, end));
    }

    if (!restrictions.isEmpty()) {
        criteria.or(restrictions);
    }

    criteria.join(WalletBalance_.wallet,
            where(Wallet.class).eq(Wallet_.id, filter.getWallet().getId()));

    return criteria.getResultList();
}
 
Example 6
Source File: TransferenceRepository.java    From web-budget with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Find all transference using a given filter
 *
 * @param filter used to search for {@link Transference}
 * @return a list of {@link Transference} found
 */
default List<Transference> findByFilter(TransferenceFilter filter) {

    final Criteria<Transference, Transference> criteria = this.criteria();

    final List<Criteria<Transference, Transference>> restrictions = new ArrayList<>();

    if (filter.getOriginWallet() != null) {
        restrictions.add(this.criteria().join(Transference_.origin,
                where(Wallet.class).eq(Wallet_.id, filter.getOriginWallet().getId())));
    }

    if (filter.getDestinationWallet() != null) {
        restrictions.add(this.criteria().join(Transference_.destination,
                where(Wallet.class).eq(Wallet_.id, filter.getDestinationWallet().getId())));
    }

    if (filter.getOperationDate() != null) {
        restrictions.add(this.criteria().eq(Transference_.transferDate, filter.getOperationDate()));
    }

    if (!restrictions.isEmpty()) {
        criteria.or(restrictions);
    }

    return criteria.getResultList();
}
 
Example 7
Source File: DefaultRepository.java    From web-budget with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Generic method to find all inactive entities
 *
 * @return a {@link List} of all inactive entities
 */
default List<T> findAllInactive() {

    final Criteria<T, T> criteria = criteria()
            .eq(this.getEntityStateProperty(), false);

    this.setOrder(criteria);

    return criteria.getResultList();
}
 
Example 8
Source File: DefaultRepository.java    From web-budget with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Generic method to find all active entities
 *
 * @return the {@link List} of all active entities
 */
default List<T> findAllActive() {

    final Criteria<T, T> criteria = criteria()
            .eq(this.getEntityStateProperty(), true);

    this.setOrder(criteria);

    return criteria.getResultList();
}
 
Example 9
Source File: DefaultRepository.java    From web-budget with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Generic method to find all inactive entities
 *
 * @return a {@link List} of all inactive entities
 */
default List<T> findAllInactive() {

    final Criteria<T, T> criteria = criteria()
            .eq(this.getEntityStateProperty(), false);

    this.setOrder(criteria);

    return criteria.getResultList();
}
 
Example 10
Source File: DefaultRepository.java    From web-budget with GNU General Public License v3.0 3 votes vote down vote up
/**
 * Generic method to find all active entities
 *
 * @return the {@link List} of all active entities
 */
default List<T> findAllActive() {

    final Criteria<T, T> criteria = criteria()
            .eq(this.getEntityStateProperty(), true);

    this.setOrder(criteria);

    return criteria.getResultList();
}