Package ubic.gemma.rest.util
Class Responder
- java.lang.Object
-
- ubic.gemma.rest.util.Responder
-
public class Responder extends Object
Handles setting of the response status code and composing a proper payload structure.- Author:
- tesarst
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Responder.FilterMethod<T>
A functional interface matching the signature of a paginating service method.
-
Constructor Summary
Constructors Constructor Description Responder()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> FilteredResponseDataObject<T>
filter(List<T> payload, ubic.gemma.persistence.util.Filters filters)
Produce aFilteredResponseDataObject
for a given filteredList
.static <T> LimitedResponseDataObject<T>
limit(List<T> payload, String query, ubic.gemma.persistence.util.Filters filters, String[] groupBy, ubic.gemma.persistence.util.Sort sort, Integer limit)
static <T extends ubic.gemma.model.IdentifiableValueObject<?>>
PaginatedResponseDataObject<T>paginate(ubic.gemma.persistence.util.Slice<T> payload, String[] groupBy)
Produce aPaginatedResponseDataObject
for a given unfilteredSlice
.static <T extends ubic.gemma.model.IdentifiableValueObject<?>>
FilteredAndPaginatedResponseDataObject<T>paginate(ubic.gemma.persistence.util.Slice<T> payload, ubic.gemma.persistence.util.Filters filters, String[] groupBy)
Produce aFilteredAndPaginatedResponseDataObject
for a givenSlice
static <T extends ubic.gemma.model.IdentifiableValueObject<?>>
FilteredAndPaginatedResponseDataObject<T>paginate(Responder.FilterMethod<T> filterMethod, ubic.gemma.persistence.util.Filters filters, String[] groupBy, ubic.gemma.persistence.util.Sort sort, int offset, int limit)
Paginate using an arbitrary filtering method.static <T> QueriedAndFilteredResponseDataObject<T>
queryAndFilter(List<T> payload, String query, ubic.gemma.persistence.util.Filters filters, String[] groupBy, ubic.gemma.persistence.util.Sort sort)
static <T extends ubic.gemma.model.IdentifiableValueObject<?>>
QueriedAndFilteredAndPaginatedResponseDataObject<T>queryAndPaginate(ubic.gemma.persistence.util.Slice<T> payload, String query, ubic.gemma.persistence.util.Filters filters, String[] groupBy)
static <T> ResponseDataObject<T>
respond(T payload)
Produce aResponseDataObject
that wraps the given argument.
-
-
-
Method Detail
-
respond
public static <T> ResponseDataObject<T> respond(@Nullable T payload) throws javax.ws.rs.NotFoundException
Produce aResponseDataObject
that wraps the given argument.- Parameters:
payload
- an object to be wrapped and published to the API- Returns:
- a
ResponseDataObject
containing the argument - Throws:
javax.ws.rs.NotFoundException
- if the argument is null, a suitableResponseErrorObject
will be subsequently produced byNotFoundExceptionMapper
-
limit
public static <T> LimitedResponseDataObject<T> limit(List<T> payload, @Nullable String query, @Nullable ubic.gemma.persistence.util.Filters filters, String[] groupBy, @Nullable ubic.gemma.persistence.util.Sort sort, @Nullable Integer limit)
-
paginate
public static <T extends ubic.gemma.model.IdentifiableValueObject<?>> PaginatedResponseDataObject<T> paginate(ubic.gemma.persistence.util.Slice<T> payload, String[] groupBy) throws javax.ws.rs.NotFoundException
Produce aPaginatedResponseDataObject
for a given unfilteredSlice
.- Throws:
javax.ws.rs.NotFoundException
-
filter
public static <T> FilteredResponseDataObject<T> filter(List<T> payload, @Nullable ubic.gemma.persistence.util.Filters filters)
Produce aFilteredResponseDataObject
for a given filteredList
.
-
queryAndFilter
public static <T> QueriedAndFilteredResponseDataObject<T> queryAndFilter(List<T> payload, String query, @Nullable ubic.gemma.persistence.util.Filters filters, String[] groupBy, @Nullable ubic.gemma.persistence.util.Sort sort)
-
paginate
public static <T extends ubic.gemma.model.IdentifiableValueObject<?>> FilteredAndPaginatedResponseDataObject<T> paginate(ubic.gemma.persistence.util.Slice<T> payload, @Nullable ubic.gemma.persistence.util.Filters filters, String[] groupBy) throws javax.ws.rs.NotFoundException
Produce aFilteredAndPaginatedResponseDataObject
for a givenSlice
- Throws:
javax.ws.rs.NotFoundException
-
paginate
public static <T extends ubic.gemma.model.IdentifiableValueObject<?>> FilteredAndPaginatedResponseDataObject<T> paginate(Responder.FilterMethod<T> filterMethod, @Nullable ubic.gemma.persistence.util.Filters filters, String[] groupBy, @Nullable ubic.gemma.persistence.util.Sort sort, int offset, int limit) throws javax.ws.rs.NotFoundException
Paginate using an arbitrary filtering method.- Throws:
javax.ws.rs.NotFoundException
-
queryAndPaginate
public static <T extends ubic.gemma.model.IdentifiableValueObject<?>> QueriedAndFilteredAndPaginatedResponseDataObject<T> queryAndPaginate(ubic.gemma.persistence.util.Slice<T> payload, String query, @Nullable ubic.gemma.persistence.util.Filters filters, String[] groupBy)
-
-