argos/dmp-backend/web/src/main/java/eu/eudat/controllers/publicapi/QueryableList.java

77 lines
2.7 KiB
Java
Raw Normal View History

package eu.eudat.controllers.publicapi;
import eu.eudat.controllers.publicapi.jpa.predicates.*;
import eu.eudat.controllers.publicapi.types.SelectionField;
import jakarta.persistence.criteria.Join;
import jakarta.persistence.criteria.JoinType;
import jakarta.persistence.criteria.Subquery;
import javax.management.InvalidApplicationException;
import java.util.List;
import java.util.Map;
2018-02-07 10:56:30 +01:00
import java.util.concurrent.CompletableFuture;
2024-02-01 16:29:04 +01:00
public interface QueryableList<T> {
QueryableList<T> where(SinglePredicate<T> predicate);
<R> List<R> select(SelectPredicate<T, R> predicate) throws InvalidApplicationException;
<R> CompletableFuture<List<R>> selectAsync(SelectPredicate<T, R> predicate) throws InvalidApplicationException;
2018-02-21 11:07:31 +01:00
List<T> toList() throws InvalidApplicationException;
<V> void update(EntitySelectPredicate<T> selectPredicate, V value) throws InvalidApplicationException;
2018-02-23 11:36:51 +01:00
QueryableList<T> withFields(List<String> fields);
List<Map> toListWithFields();
CompletableFuture<List<T>> toListAsync() throws InvalidApplicationException;
2018-02-07 10:56:30 +01:00
T getSingle() throws InvalidApplicationException;
2018-01-19 10:31:05 +01:00
CompletableFuture<T> getSingleAsync() throws InvalidApplicationException;
2018-02-07 10:56:30 +01:00
T getSingleOrDefault() throws InvalidApplicationException;
2018-01-30 13:23:47 +01:00
CompletableFuture<T> getSingleOrDefaultAsync() throws InvalidApplicationException;
2018-02-07 10:56:30 +01:00
QueryableList<T> skip(Integer offset);
QueryableList<T> take(Integer length);
QueryableList<T> distinct();
2018-02-02 16:24:06 +01:00
QueryableList<T> orderBy(OrderByPredicate<T> predicate);
2018-01-25 16:24:21 +01:00
2021-09-30 17:02:53 +02:00
QueryableList<T> groupBy(GroupByPredicate<T> predicate);
2018-01-19 10:31:05 +01:00
QueryableList<T> withHint(String hint);
2018-01-25 16:24:21 +01:00
Long count() throws InvalidApplicationException;
2018-02-02 11:33:37 +01:00
2018-02-08 09:42:02 +01:00
QueryableList<T> where(NestedQuerySinglePredicate<T> predicate);
CompletableFuture<Long> countAsync() throws InvalidApplicationException;
2018-02-07 10:56:30 +01:00
Subquery<T> query(List<SelectionField> fields) throws InvalidApplicationException;
Subquery<T> subQuery(SinglePredicate<T> predicate, List<SelectionField> fields) throws InvalidApplicationException;
2018-02-08 09:42:02 +01:00
Subquery<T> subQuery(NestedQuerySinglePredicate<T> predicate, List<SelectionField> fields);
Subquery<Long> subQueryCount(NestedQuerySinglePredicate<T> predicate, List<SelectionField> fields);
Subquery<Long> subQueryCount(SinglePredicate<T> predicate, List<SelectionField> fields) throws InvalidApplicationException;
2018-02-08 09:42:02 +01:00
2019-05-20 13:24:15 +02:00
<U> QueryableList<T> initSubQuery(Class<U> uClass);
2018-03-19 13:40:04 +01:00
<U extends Comparable> Subquery<U> subQueryMax(SinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass) throws InvalidApplicationException;
2018-02-07 10:56:30 +01:00
2018-02-16 11:34:02 +01:00
<U extends Comparable> Subquery<U> subQueryMax(NestedQuerySinglePredicate<T> predicate, List<SelectionField> fields, Class<U> uClass);
Join getJoin(String field, JoinType type);
}