Class ODataDataUtils

java.lang.Object
com.sap.cds.services.impl.odata.utils.ODataDataUtils

public class ODataDataUtils extends Object
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static void
    clean(List<Map<String,Object>> entryData, com.sap.cds.reflect.CdsStructuredType entryType)
    Cleans unknown elements from a list of entity data.
    static com.sap.cds.CdsData
    entity(com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric result, com.sap.cds.reflect.CdsStructuredType resultType, com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol protocol)
    Extracts an entity map from the OData result.
    static List<com.sap.cds.CdsData>
    entityCollection(com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric result, com.sap.cds.reflect.CdsStructuredType resultType, com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol protocol)
    Extracts a list of entity maps from the OData result.
    static com.sap.cds.CdsData
    noContent(com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric result, Map<String,Object> data)
    Copies the original updated data to provide as a result for a "204 No Content" response.
    static Object
    operation(com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric result, com.sap.cds.reflect.CdsType targetType, com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol protocol, String operationName)
    Extracts the return value of an operation from the OData result.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • ODataDataUtils

      public ODataDataUtils()
  • Method Details

    • entity

      public static com.sap.cds.CdsData entity(com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric result, com.sap.cds.reflect.CdsStructuredType resultType, com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol protocol)
      Extracts an entity map from the OData result. OData V2 and V4 responses are normalized by mapping the response to the entity structure (e.g. removing results substructures). Also non entity keys and values are removed (e.g. _metadata or @odata.etag)
      Parameters:
      result - the OData result
      resultType - the structured type of the result
      protocol - the OData protocol version
      Returns:
      the entity data
    • noContent

      public static com.sap.cds.CdsData noContent(com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric result, Map<String,Object> data)
      Copies the original updated data to provide as a result for a "204 No Content" response. Takes care of updating the returned ETag on the data map.
      Parameters:
      result - the OData result
      data - the original data
      Returns:
      the copied data, with updated ETag
    • entityCollection

      public static List<com.sap.cds.CdsData> entityCollection(com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric result, com.sap.cds.reflect.CdsStructuredType resultType, com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol protocol)
      Extracts a list of entity maps from the OData result. OData V2 and V4 responses are normalized by mapping the response to the entity structure (e.g. removing results substructures). Also non entity keys and values are removed (e.g. _metadata or @odata.etag)
      Parameters:
      result - the OData result
      resultType - the structured type of the result
      protocol - the OData protocol version
      Returns:
      the list of entity data
    • operation

      public static Object operation(com.sap.cloud.sdk.datamodel.odata.client.request.ODataRequestResultGeneric result, com.sap.cds.reflect.CdsType targetType, com.sap.cloud.sdk.datamodel.odata.client.ODataProtocol protocol, String operationName)
      Extracts the return value of an operation from the OData result. OData V2 and V4 responses are normalized by mapping the response to the entity structure (e.g. removing results substructures). Also non entity keys and values are removed (e.g. _metadata or @odata.etag)
      Parameters:
      result - the OData result
      targetType - the type of the result
      protocol - the OData protocol version
      operationName - the name of the operation
      Returns:
      the operation return value
    • clean

      public static void clean(List<Map<String,Object>> entryData, com.sap.cds.reflect.CdsStructuredType entryType)
      Cleans unknown elements from a list of entity data. All keys in the map that can't be associated with an entity element are removed.
      Parameters:
      entryData - the incoming data
      entryType - the structured type of the data