Class FluentHelperRead<FluentHelperT,EntityT extends VdmEntity<?>,SelectableT>

java.lang.Object
com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperBasic<FluentHelperT,EntityT,List<EntityT>>
com.sap.cloud.sdk.datamodel.odata.helper.FluentHelperRead<FluentHelperT,EntityT,SelectableT>
Type Parameters:
FluentHelperT - The fluent helper type.
EntityT - The type of the result entity.
SelectableT - The type of the class that represents fields of the entity.
All Implemented Interfaces:
FluentHelperExecutable<Object>

public abstract class FluentHelperRead<FluentHelperT,EntityT extends VdmEntity<?>,SelectableT> extends FluentHelperBasic<FluentHelperT,EntityT,List<EntityT>>
Representation of an OData query as a fluent interface for further configuring the request and executing it.
  • Constructor Details

    • FluentHelperRead

      public FluentHelperRead(@Nonnull String servicePath, @Nonnull String entityCollection)
      Instantiates this fluent helper using the given service path and entity collection to send the requests.
      Parameters:
      servicePath - The service path to direct the requests to.
      entityCollection - The entity collection to direct the requests to.
  • Method Details

    • toRequest

      @Nonnull public ODataRequestRead toRequest()
      Description copied from class: FluentHelperBasic
      Translate this OData v2 request into a OData request object extending ODataRequestGeneric.
      Specified by:
      toRequest in class FluentHelperBasic<FluentHelperT,EntityT extends VdmEntity<?>,List<EntityT extends VdmEntity<?>>>
      Returns:
      A protocol agnostic OData request instance.
    • withQueryParameter

      @Nonnull public FluentHelperT withQueryParameter(@Nonnull String key, @Nullable String value)
      Description copied from class: FluentHelperBasic
      Gives the option to specify custom query parameters for the request. The passed parameter value will be encoded with percentage encoding.

      Note: It is recommended to only use this function for query parameters which are not supported by the VDM by default. Using this function to bypass fluent helper method calls can lead to unsupported response handling. There is no contract on the order or priority of parameters added to the query.

      Example: Use the query option $search to reduce the result set, leaving only entities which match the specified search expression. This feature is supported in protocol OData v4.

       new DefaultBusinessPartnerService().getAllBusinessPartner().withQueryParameter("$search", "Köln OR Cologne")
       

      Overrides:
      withQueryParameter in class FluentHelperBasic<FluentHelperT,EntityT extends VdmEntity<?>,List<EntityT extends VdmEntity<?>>>
      Parameters:
      key - Name of the query parameter.
      value - Unencoded value of the query parameter.
      Returns:
      The same fluent helper.
    • select

      @Nonnull public FluentHelperT select(@Nonnull SelectableT... fields)
      Query modifier to limit which field values of the entity get fetched and populated, and to specify which navigation properties to expand. If this method is never called, then all fields will be fetched and populated, and no navigation properties expanded. But if this method is called at least once, then only the specified fields will be fetched and populated. Calling this multiple times will combine the set(s) of fields and expansions of each call.
      Parameters:
      fields - Fields to select and/or navigation properties to expand.
      Returns:
      The same fluent helper with this query modifier applied.
    • orderBy

      @Nonnull public FluentHelperT orderBy(@Nonnull EntityField<EntityT,?> field, @Nonnull Order order)
      Query modifier to sort the set of returned entities by one or more fields. If this method is called more than once, then the result entity set will be sorted by each field in the order that the methods were called.
      Parameters:
      field - Field to sort by.
      order - Sorting direction to use (ascending or descending).
      Returns:
      The same fluent helper with this query modifier applied.
    • top

      @Nonnull public FluentHelperT top(@Nonnull Number top)
      Query modifier to limit the number of entities returned. If this method is never called, then the result entity list will not be limited in size. If this method is called multiple times, then only the value of the last call will be used.
      Parameters:
      top - Number of entities to limit the result set to.
      Returns:
      The same fluent helper with this query modifier applied.
    • skip

      @Nonnull public FluentHelperT skip(@Nonnull Number skip)
      Query modifier to not return the first N entities of the result set. If this method is never called, then the full list will be returned from the first entity. If this method is called multiple times, then only the value of the last call will be used.
      Parameters:
      skip - Number of entities to skip by.
      Returns:
      The same fluent helper with this query modifier applied.
    • executeRequest

      @Nonnull public List<EntityT> executeRequest(@Nonnull Destination destination) throws ODataException
      Description copied from interface: FluentHelperExecutable
      Executes this request.
      Specified by:
      executeRequest in interface FluentHelperExecutable<FluentHelperT>
      Specified by:
      executeRequest in class FluentHelperBasic<FluentHelperT,EntityT extends VdmEntity<?>,List<EntityT extends VdmEntity<?>>>
      Parameters:
      destination - The target system this request should be issued against.
      Returns:
      A response according to the query criteria.
      Throws:
      ODataException - If the OData request execution failed.
    • iteratingPages

      @Nonnull public FluentHelperExecutable<Iterable<List<EntityT>>> iteratingPages()
      Manually explore the individual pages from the lazy-loading entity result-set. The returning object allows for performant consumption of all data through server-driven pagination.
      Returns:
      An instance of FluentHelperExecutable that allows for lazy iteration through the result-set pages.
    • iteratingEntities

      @Nonnull public FluentHelperExecutable<Iterable<EntityT>> iteratingEntities()
      Manually explore the individual entities from the lazy-loading entity result-set. The returning iterable allows for performant consumption of all data through server-driven pagination.
      Returns:
      An instance of FluentHelperExecutable that allows for lazy iteration through the result-set pages.
    • streamingEntities

      @Nonnull public FluentHelperExecutable<Stream<EntityT>> streamingEntities()
      Manually explore the individual entities from the lazy-loading entity result-set. The returning Stream allows for performant consumption of all data through server-driven pagination.
      Returns:
      An instance of FluentHelperExecutable that allows for lazy iteration through the result-set pages.
    • filter

      @Nonnull public FluentHelperT filter(@Nonnull ExpressionFluentHelper<EntityT> expression)
      Query modifier to restrict the set of returned entities based on the values of one or more fields. If this method is never called, then all accessible entities will be fetched. Calling this multiple times will combine the filters into one that is the intersection of all filters (filter1 AND filter2 AND ... filterN).
      Parameters:
      expression - Fluent helper that represents a field value expression. To create this, start with an EntityField constant in your respective entity type for the desired entity field. Then call one of the comparison operators and provide a comparison value. Optionally the resulting fluent helper can be chained with other expression fluent helpers.
      Returns:
      The same fluent helper with this query modifier applied.
    • count

      @Nonnull public FluentHelperCount count()
      Query modifier to return only the number of tuples that match the criteria specified in the query. The actual tuples are not returned. May be used with all other query modifiers. Any call to top is overloaded with top(0). Any call to skip is ignored.
      Returns:
      The number of tuples that match the criteria specified in the query.
    • withPreferredPageSize

      @Nonnull public FluentHelperT withPreferredPageSize(int size)
      Set the preferred page size of the OData response. A result-set may be split into multiple pages, each including a subset of the entities matching the query.

      Note: The OData service might ignore the preferred page size setting and may not use pagination at all.

      Parameters:
      size - The preferred page size
      Returns:
      This request object with the added parameter.
    • withCsrfToken

      @Nonnull public FluentHelperT withCsrfToken()
      Activates the CSRF token retrieval for this OData request. This is useful if the server does require CSRF tokens as part of the request.
      Returns:
      The same builder