FluentHelperT
- The fluent helper type.EntityT
- The type of the result entity.SelectableT
- The type of the class that represents fields of the entity.public abstract class FluentHelperByKey<FluentHelperT,EntityT extends VdmEntity<?>,SelectableT> extends FluentHelperBasic<FluentHelperT,EntityT,EntityT>
executing
it.Constructor and Description |
---|
FluentHelperByKey(String servicePath)
Instantiates this fluent helper using the given service path to send the requests.
|
Modifier and Type | Method and Description |
---|---|
EntityT |
execute(HttpDestinationProperties destination)
Executes the underlying query using the stored key field values, plus any query modifiers that were previously
called.
|
protected abstract Map<String,Object> |
getKey()
Getter for a map containing the OData name of key properties, each mapped to the value to search by.
|
protected com.sap.cloud.sdk.odatav2.connectivity.ODataQueryBuilder |
getQueryBuilder()
Creates an instance of the
ODataQueryBuilder based on the Entity class. |
FluentHelperT |
select(SelectableT... fields)
Query modifier to limit which field values of the entity get fetched & populated.
|
com.sap.cloud.sdk.odatav2.connectivity.ODataQuery |
toQuery()
Provides access to the underlying Query object, to allow for custom integration scenarios not yet supported by
the virtual data model.
|
FluentHelperT |
withErrorHandler(com.sap.cloud.sdk.odatav2.connectivity.ErrorResultHandler<?> errorResultHandler)
An error handling class that implements the
ErrorResultHandler interface can be
attached to this fluent helper. |
FluentHelperT |
withQueryParameter(String key,
String value)
Gives the option to specify custom query parameters for the request.
|
cachingMetadata, getEntityClass, getHeadersForRequestAndImplicitRequests, getHeadersForRequestOnly, getParametersForRequestOnly, getServicePath, getThis, getVersionIdentifier, isCachingMetadata, withHeader, withHeaders, withoutCachingMetadata
@Nonnull protected abstract Map<String,Object> getKey()
@Nonnull protected com.sap.cloud.sdk.odatav2.connectivity.ODataQueryBuilder getQueryBuilder()
ODataQueryBuilder
based on the Entity class.
The following settings are necessary to build the ODataQueryBuilder
:
ODataQueryBuilder
.@Nonnull public FluentHelperT withQueryParameter(@Nonnull String key, @Nullable String value)
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")
withQueryParameter
in class FluentHelperBasic<FluentHelperT,EntityT extends VdmEntity<?>,EntityT extends VdmEntity<?>>
key
- Name of the query parameter.value
- Value of the query parameter.@Nonnull public FluentHelperT select(@Nonnull SelectableT... fields)
fields
- Array of fields to select.@Nonnull public com.sap.cloud.sdk.odatav2.connectivity.ODataQuery toQuery()
@Nonnull public FluentHelperT withErrorHandler(@Nonnull com.sap.cloud.sdk.odatav2.connectivity.ErrorResultHandler<?> errorResultHandler)
ErrorResultHandler
interface can be
attached to this fluent helper. This allows custom logic to be called when an error occurs in the execute
method. If this method is not called, then an instance of
ODataVdmErrorResultHandler
is used.
Only one handler can be attached at a time per fluent helper object, so calling this multiple times will replace
the handler.errorResultHandler
- Instance of an error handler class that implements the ErrorResultHandler
interface.@Nonnull public EntityT execute(@Nonnull HttpDestinationProperties destination) throws com.sap.cloud.sdk.odatav2.connectivity.ODataException
execute
in class FluentHelperBasic<FluentHelperT,EntityT extends VdmEntity<?>,EntityT extends VdmEntity<?>>
destination
- Supply the destinatio for executing the underlying OData query.com.sap.cloud.sdk.odatav2.connectivity.ODataException
Copyright © 2020 SAP SE. All rights reserved.