Class ODataDataUtils
java.lang.Object
com.sap.cds.services.impl.odata.utils.ODataDataUtils
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidCleans unknown elements from a list of entity data.static com.sap.cds.CdsDataentity(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.CdsDatanoContent(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 Objectoperation(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.
-
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 resultresultType- the structured type of the resultprotocol- 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 resultdata- 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 resultresultType- the structured type of the resultprotocol- 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 resulttargetType- the type of the resultprotocol- the OData protocol versionoperationName- 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 dataentryType- the structured type of the data
-