Package fr.gouv.vitam.common.model
Class RequestResponseOK<T>
- java.lang.Object
-
- fr.gouv.vitam.common.model.RequestResponse<T>
-
- fr.gouv.vitam.common.model.RequestResponseOK<T>
-
- Type Parameters:
T
- Type of results
public final class RequestResponseOK<T> extends RequestResponse<T>
Access RequestResponseOK class contains list of results
default results : is an empty list (immutable)
-
-
Field Summary
Fields Modifier and Type Field Description static java.lang.String
TAG_CONTEXT
context in responsestatic java.lang.String
TAG_FACET_RESULTS
facet results in responsestatic java.lang.String
TAG_RESULTS
result in response
-
Constructor Summary
Constructors Constructor Description RequestResponseOK()
Empty RequestResponseOK constructorRequestResponseOK(com.fasterxml.jackson.databind.JsonNode query)
Initialize from a queryRequestResponseOK(com.fasterxml.jackson.databind.JsonNode query, java.util.List<T> results, int total)
Initialize from a query and resultsRequestResponseOK(com.fasterxml.jackson.databind.JsonNode query, java.util.List<T> results, int total, java.lang.String scrollId)
Initialize from a query and results
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description RequestResponseOK<T>
addAllFacetResults(java.util.List<FacetResult> facetResultList)
Add list of facetResultRequestResponseOK<T>
addAllResults(java.util.List<T> resultList)
Add list of resultsRequestResponseOK<T>
addFacetResult(FacetResult facetResult)
Add one facetResultRequestResponseOK<T>
addResult(T result)
Add one resultjava.util.List<FacetResult>
getFacetResults()
T
getFirstResult()
static RequestResponseOK<com.fasterxml.jackson.databind.JsonNode>
getFromJsonNode(com.fasterxml.jackson.databind.JsonNode node)
static <T> RequestResponseOK<T>
getFromJsonNode(com.fasterxml.jackson.databind.JsonNode node, java.lang.Class<T> clazz)
DatabaseCursor
getHits()
com.fasterxml.jackson.databind.JsonNode
getQuery()
java.util.List<T>
getResults()
java.util.List<com.fasterxml.jackson.databind.JsonNode>
getResultsAsJsonNodes()
boolean
isEmpty()
RequestResponseOK<T>
setHits(long total, int offset, int limit)
RequestResponseOK<T>
setHits(long total, int offset, int limit, int size)
RequestResponseOK<T>
setHits(long total, int offset, int limit, int size, java.lang.String scrollId)
RequestResponseOK<T>
setHits(DatabaseCursor hits)
RequestResponseOK<T>
setHttpCode(int httpCode)
RequestResponseOK<T>
setQuery(com.fasterxml.jackson.databind.JsonNode query)
RequestResponseOK<T>
setScrollId(java.lang.String scrollId)
When activate scrollRequestResponseOK<T>
setTotal(long total)
Should be used only with hints of elasticsearchjavax.ws.rs.core.Response
toResponse()
transform a RequestResponse to a standard response-
Methods inherited from class fr.gouv.vitam.common.model.RequestResponse
addHeader, getHeaderString, getHttpCode, getStatus, getVitamHeaders, isOk, isRequestResponseOk, parseFromResponse, parseFromResponse, parseHeadersFromResponse, parseRequestResponseOk, parseRequestResponseOk, parseVitamError, parseVitamError, toJsonNode, toString, unSetVitamHeaders
-
-
-
-
Field Detail
-
TAG_RESULTS
public static final java.lang.String TAG_RESULTS
result in response- See Also:
- Constant Field Values
-
TAG_FACET_RESULTS
public static final java.lang.String TAG_FACET_RESULTS
facet results in response- See Also:
- Constant Field Values
-
TAG_CONTEXT
public static final java.lang.String TAG_CONTEXT
context in response- See Also:
- Constant Field Values
-
-
Constructor Detail
-
RequestResponseOK
public RequestResponseOK()
Empty RequestResponseOK constructor
-
RequestResponseOK
public RequestResponseOK(com.fasterxml.jackson.databind.JsonNode query)
Initialize from a query- Parameters:
query
-
-
RequestResponseOK
public RequestResponseOK(com.fasterxml.jackson.databind.JsonNode query, java.util.List<T> results, int total)
Initialize from a query and results- Parameters:
query
-
-
RequestResponseOK
public RequestResponseOK(com.fasterxml.jackson.databind.JsonNode query, java.util.List<T> results, int total, java.lang.String scrollId)
Initialize from a query and results- Parameters:
query
-
-
-
Method Detail
-
addResult
public RequestResponseOK<T> addResult(T result)
Add one result- Parameters:
result
- to add to request response- Returns:
- this
-
addAllResults
public RequestResponseOK<T> addAllResults(java.util.List<T> resultList)
Add list of results- Parameters:
resultList
- the list of results- Returns:
- RequestResponseOK with mutable results list of String
-
addFacetResult
public RequestResponseOK<T> addFacetResult(FacetResult facetResult)
Add one facetResult- Parameters:
facetResult
- to add to request response- Returns:
- this
-
addAllFacetResults
public RequestResponseOK<T> addAllFacetResults(java.util.List<FacetResult> facetResultList)
Add list of facetResult- Parameters:
facetResultList
- the list of facetResults- Returns:
- RequestResponseOK with mutable results list of String
-
getHits
public DatabaseCursor getHits()
- Returns:
- the hits of RequestResponseOK object
-
setHits
public RequestResponseOK<T> setHits(DatabaseCursor hits)
- Parameters:
hits
- as DatabaseCursor object- Returns:
- RequestReponseOK with the hits are setted
-
setHits
public RequestResponseOK<T> setHits(long total, int offset, int limit)
- Parameters:
total
- of units inserted/modified as integeroffset
- of unit in database as integerlimit
- of unit per response as integer- Returns:
- the RequestReponseOK with the hits are setted
-
setHits
public RequestResponseOK<T> setHits(long total, int offset, int limit, int size, java.lang.String scrollId)
- Parameters:
total
- of units inserted/modified as integeroffset
- of unit in database as integerlimit
- of unit per response as integersize
- of unit per responsescrollId
- of response- Returns:
- the RequestReponseOK with the hits are setted
-
setHits
public RequestResponseOK<T> setHits(long total, int offset, int limit, int size)
- Parameters:
total
- of units inserted/modified as integeroffset
- of unit in database as integerlimit
- of unit per response as integersize
- of unit per response- Returns:
- the RequestReponseOK with the hits are setted
-
setTotal
public RequestResponseOK<T> setTotal(long total)
Should be used only with hints of elasticsearch- Parameters:
total
-- Returns:
-
setScrollId
public RequestResponseOK<T> setScrollId(java.lang.String scrollId)
When activate scroll- Parameters:
scrollId
-- Returns:
-
getFacetResults
public java.util.List<FacetResult> getFacetResults()
- Returns:
- the facetResults
-
getResults
public java.util.List<T> getResults()
- Returns:
- the result of RequestResponse as a list of
-
getQuery
public com.fasterxml.jackson.databind.JsonNode getQuery()
- Returns:
- the query as JsonNode of Response
-
getFirstResult
public T getFirstResult()
- Returns:
- the first result of RequestResponse as a
-
setQuery
public RequestResponseOK<T> setQuery(com.fasterxml.jackson.databind.JsonNode query)
- Parameters:
query
- the set to request response- Returns:
- this
-
isEmpty
public boolean isEmpty()
- Returns:
- True if the result is empty
-
getFromJsonNode
public static RequestResponseOK<com.fasterxml.jackson.databind.JsonNode> getFromJsonNode(com.fasterxml.jackson.databind.JsonNode node) throws InvalidParseOperationException
- Parameters:
node
- to transform- Returns:
- the corresponding VitamError
- Throws:
InvalidParseOperationException
- if parse json object exception occurred
-
getFromJsonNode
public static <T> RequestResponseOK<T> getFromJsonNode(com.fasterxml.jackson.databind.JsonNode node, java.lang.Class<T> clazz) throws InvalidParseOperationException
- Parameters:
node
- to transform- Returns:
- the corresponding VitamError
- Throws:
InvalidParseOperationException
- if parse json object exception occurred
-
getResultsAsJsonNodes
public java.util.List<com.fasterxml.jackson.databind.JsonNode> getResultsAsJsonNodes() throws InvalidParseOperationException
- Returns:
- the result of RequestResponse as a list of jsonNode
- Throws:
InvalidParseOperationException
-
setHttpCode
public RequestResponseOK<T> setHttpCode(int httpCode)
- Overrides:
setHttpCode
in classRequestResponse<T>
- Parameters:
httpCode
- the httpCode to set- Returns:
- this
-
toResponse
public javax.ws.rs.core.Response toResponse()
transform a RequestResponse to a standard response- Specified by:
toResponse
in classRequestResponse<T>
- Returns:
- Response
-
-