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 Details

  • Constructor Details

    • 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, List<T> results, int total)
      Initialize from a query and results
      Parameters:
      query -
    • RequestResponseOK

      public RequestResponseOK(com.fasterxml.jackson.databind.JsonNode query, List<T> results, int total, String scrollId)
      Initialize from a query and results
      Parameters:
      query -
  • Method Details

    • addResult

      public RequestResponseOK<T> addResult(T result)
      Add one result
      Parameters:
      result - to add to request response
      Returns:
      this
    • addAllResults

      public RequestResponseOK<T> addAllResults(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(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 integer
      offset - of unit in database as integer
      limit - 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, String scrollId)
      Parameters:
      total - of units inserted/modified as integer
      offset - of unit in database as integer
      limit - of unit per response as integer
      size - of unit per response
      scrollId - 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 integer
      offset - of unit in database as integer
      limit - of unit per response as integer
      size - 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(String scrollId)
      When activate scroll
      Parameters:
      scrollId -
      Returns:
    • getFacetResults

      public List<FacetResult> getFacetResults()
      Returns:
      the facetResults
    • getResults

      public 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
    • getHistory

      public com.fasterxml.jackson.databind.JsonNode getHistory()
      Returns:
      the history 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, Class<T> clazz) throws InvalidParseOperationException
      Parameters:
      node - to transform
      Returns:
      the corresponding VitamError
      Throws:
      InvalidParseOperationException - if parse json object exception occurred
    • getResultsAsJsonNodes

      public 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 class RequestResponse<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 class RequestResponse<T>
      Returns:
      Response