public class DataService
extends java.lang.Object
Encapsulates an OData data service.
DataServlet
, for server-side implementation of data services.
public void dataServiceExample() { OnlineODataProvider provider = new OnlineODataProvider("NorthwindService", "http://services.odata.org/V4/Northwind/Northwind.svc/"); NorthwindService service = new NorthwindService(provider); DataQuery query = new DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .orderBy(Customer.companyName); Customer__List customers = service.getCustomers(query); this.showCustomers(customers); Customer customer = customers.first().copy(); customer.setCompanyName("Created Inc."); service.createEntity(customer); customer.setCompanyName("Updated Inc."); service.updateEntity(customer); service.deleteEntity(customer); }
public void dataServiceExample() { OnlineODataProvider provider = new OnlineODataProvider("NorthwindService", "http://services.odata.org/V4/Northwind/Northwind.svc/"); DataService service = new DataService(provider); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property customerIDProperty = customerEntityType.getProperty("CustomerID"); Property companyNameProperty = customerEntityType.getProperty("CompanyName"); Property contactNameProperty = customerEntityType.getProperty("ContactName"); DataQuery query = new DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet).orderBy(companyNameProperty); EntityValueList customers = service.executeQuery(query).getEntityList(); this.showCustomers(customers); EntityValue customer = customers.first().copyEntity(); companyNameProperty.setString(customer, "Created Inc."); service.createEntity(customer); companyNameProperty.setString(customer, "Updated Inc."); service.updateEntity(customer); service.deleteEntity(customer); }
Constructor and Description |
---|
DataService(DataServiceProvider provider)
Construct a new data service using a specified provider.
|
Modifier and Type | Method and Description |
---|---|
void |
applyChanges(ChangeSet changes)
|
void |
applyChanges(ChangeSet changes,
HttpHeaders headers)
|
void |
applyChanges(ChangeSet changes,
HttpHeaders headers,
RequestOptions options)
Apply the changes from a change set to the target system.
|
void |
applyChangesAsync(ChangeSet changes,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
applyChangesAsync(ChangeSet changes,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
applyChangesAsync(ChangeSet changes,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.applyChanges . |
void |
asyncAction(com.sap.cloud.server.odata.core.Action0 action,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
Invoke an action asynchronously.
|
void |
asyncAction(com.sap.cloud.server.odata.core.Action0 action,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
RequestOptions requestOptions)
Invoke an action asynchronously.
|
void |
asyncAction(com.sap.cloud.server.odata.core.Action0 action,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
RequestOptions requestOptions,
boolean functionExecutor)
Invoke an action asynchronously.
|
<T> void |
asyncFunction(com.sap.cloud.server.odata.core.Function0<T> function,
com.sap.cloud.server.odata.core.Action1<T> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
Invoke a function asynchronously.
|
<T> void |
asyncFunction(com.sap.cloud.server.odata.core.Function0<T> function,
com.sap.cloud.server.odata.core.Action1<T> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
RequestOptions requestOptions)
Invoke a function asynchronously.
|
<T> void |
asyncFunction(com.sap.cloud.server.odata.core.Function0<T> function,
com.sap.cloud.server.odata.core.Action1<T> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
RequestOptions requestOptions,
boolean actionExecutor)
Invoke a function asynchronously.
|
void |
createEntity(EntityValue entity)
|
void |
createEntity(EntityValue entity,
HttpHeaders headers)
|
void |
createEntity(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Create an entity in the target system.
|
void |
createEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
createEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
createEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.createEntity . |
void |
createLink(EntityValue from,
Property property,
EntityValue to)
|
void |
createLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers)
|
void |
createLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers,
RequestOptions options)
Create a link from a source entity to a target entity in the target system.
|
void |
createLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
createLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
createLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.createLink . |
void |
createMedia(EntityValue entity,
StreamBase content)
|
void |
createMedia(EntityValue entity,
StreamBase content,
HttpHeaders headers)
|
void |
createMedia(EntityValue entity,
StreamBase content,
HttpHeaders headers,
RequestOptions options)
Create a media entity with the specified content.
|
void |
createMediaAsync(EntityValue entity,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
createMediaAsync(EntityValue entity,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
createMediaAsync(EntityValue entity,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.createMedia . |
void |
createRelatedEntity(EntityValue entity,
EntityValue parent,
Property property)
|
void |
createRelatedEntity(EntityValue entity,
EntityValue parent,
Property property,
HttpHeaders headers)
|
void |
createRelatedEntity(EntityValue entity,
EntityValue parent,
Property property,
HttpHeaders headers,
RequestOptions options)
Create an entity in the target system, related to a parent entity via a parent navigation property.
|
void |
createRelatedEntityAsync(EntityValue entity,
EntityValue parent,
Property property,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
createRelatedEntityAsync(EntityValue entity,
EntityValue parent,
Property property,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
createRelatedEntityAsync(EntityValue entity,
EntityValue parent,
Property property,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.createRelatedEntity . |
void |
createRelatedMedia(EntityValue entity,
StreamBase content,
EntityValue parent,
Property property)
|
void |
createRelatedMedia(EntityValue entity,
StreamBase content,
EntityValue parent,
Property property,
HttpHeaders headers)
|
void |
createRelatedMedia(EntityValue entity,
StreamBase content,
EntityValue parent,
Property property,
HttpHeaders headers,
RequestOptions options)
Create an media entity in the target system, related to a parent entity via a parent navigation property.
|
void |
deleteByQuery(DataQuery query)
|
void |
deleteByQuery(DataQuery query,
HttpHeaders headers)
|
void |
deleteByQuery(DataQuery query,
HttpHeaders headers,
RequestOptions options)
Execute query to delete data from the target system.
|
void |
deleteByQueryAsync(DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
deleteByQueryAsync(DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
deleteByQueryAsync(DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.deleteByQuery . |
void |
deleteEntity(EntityValue entity)
|
void |
deleteEntity(EntityValue entity,
HttpHeaders headers)
|
void |
deleteEntity(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Delete an entity from the target system.
|
void |
deleteEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
deleteEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
deleteEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.deleteEntity . |
void |
deleteLink(EntityValue from,
Property property)
|
void |
deleteLink(EntityValue from,
Property property,
EntityValue to)
|
void |
deleteLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers)
|
void |
deleteLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers,
RequestOptions options)
Delete a link from a source entity to a target entity.
|
void |
deleteLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
deleteLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
deleteLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.deleteLink . |
void |
deleteStream(EntityValue entity,
StreamLink link)
|
void |
deleteStream(EntityValue entity,
StreamLink link,
HttpHeaders headers)
|
void |
deleteStream(EntityValue entity,
StreamLink link,
HttpHeaders headers,
RequestOptions options)
Delete the content of a stream property from the target system.
|
void |
deleteStreamAsync(EntityValue entity,
StreamLink link,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
deleteStreamAsync(EntityValue entity,
StreamLink link,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
deleteStreamAsync(EntityValue entity,
StreamLink link,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.deleteStream . |
ByteStream |
downloadMedia(EntityValue entity)
|
ByteStream |
downloadMedia(EntityValue entity,
HttpHeaders headers)
|
ByteStream |
downloadMedia(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Obtain a stream for downloading the content of a media entity from the target system.
|
void |
downloadMediaAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action1<byte[]> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
downloadMediaAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action1<byte[]> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
downloadMediaAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action1<byte[]> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.downloadMedia . |
ByteStream |
downloadStream(EntityValue entity,
StreamLink link)
|
ByteStream |
downloadStream(EntityValue entity,
StreamLink link,
HttpHeaders headers)
|
ByteStream |
downloadStream(EntityValue entity,
StreamLink link,
HttpHeaders headers,
RequestOptions options)
Obtain a stream for downloading the content of a stream property from the target system.
|
void |
downloadStreamAsync(EntityValue entity,
StreamLink link,
com.sap.cloud.server.odata.core.Action1<byte[]> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
downloadStreamAsync(EntityValue entity,
StreamLink link,
com.sap.cloud.server.odata.core.Action1<byte[]> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
downloadStreamAsync(EntityValue entity,
StreamLink link,
com.sap.cloud.server.odata.core.Action1<byte[]> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.downloadStream . |
DataContext |
entityContext(EntitySet entitySet)
|
DataContext |
entityContext(EntitySet entitySet,
StructureType derivedType)
|
DataContext |
entityContext(EntitySet entitySet,
StructureType derivedType,
int format)
|
DataContext |
entityContext(EntitySet entitySet,
StructureType derivedType,
int format,
int version)
Return a data context for a specified entity set, data format and data version.
|
DataValue |
executeMethod(DataMethod method)
|
DataValue |
executeMethod(DataMethod method,
ParameterList parameters)
|
DataValue |
executeMethod(DataMethod method,
ParameterList parameters,
HttpHeaders headers)
|
DataValue |
executeMethod(DataMethod method,
ParameterList parameters,
HttpHeaders headers,
RequestOptions options)
Execute a data method (action or function) in the target system.
|
void |
executeMethodAsync(DataMethod method,
ParameterList parameters,
com.sap.cloud.server.odata.core.Action1<DataValue> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
executeMethodAsync(DataMethod method,
ParameterList parameters,
com.sap.cloud.server.odata.core.Action1<DataValue> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
executeMethodAsync(DataMethod method,
ParameterList parameters,
com.sap.cloud.server.odata.core.Action1<DataValue> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.executeMethod . |
QueryResult |
executeQuery(DataQuery query)
|
QueryResult |
executeQuery(DataQuery query,
HttpHeaders headers)
|
QueryResult |
executeQuery(DataQuery query,
HttpHeaders headers,
RequestOptions options)
Execute a data query to get data from the target system.
|
void |
executeQueryAsync(DataQuery query,
com.sap.cloud.server.odata.core.Action1<QueryResult> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
executeQueryAsync(DataQuery query,
com.sap.cloud.server.odata.core.Action1<QueryResult> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
executeQueryAsync(DataQuery query,
com.sap.cloud.server.odata.core.Action1<QueryResult> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.executeQuery . |
CsdlDocument |
fetchMetadata()
|
CsdlDocument |
fetchMetadata(HttpHeaders headers)
|
CsdlDocument |
fetchMetadata(HttpHeaders headers,
RequestOptions options)
Fetch latest service metadata and return it, but don't change the
DataService.metadata property. |
void |
fetchMetadataAsync(com.sap.cloud.server.odata.core.Action1<CsdlDocument> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
fetchMetadataAsync(com.sap.cloud.server.odata.core.Action1<CsdlDocument> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
fetchMetadataAsync(com.sap.cloud.server.odata.core.Action1<CsdlDocument> successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.fetchMetadata . |
java.util.concurrent.Executor |
getActionExecutor() |
DataMethod |
getDataMethod(java.lang.String name)
Lookup a data method by qualified name (for function/action definitions) or by unqualified name (for function/action imports).
|
DataTransaction |
getDataTransaction()
Return current transaction for this data service.
|
EntitySet |
getEntitySet(java.lang.String name)
Lookup an entity set (or singleton entity) by name.
|
java.util.concurrent.Executor |
getFunctionExecutor() |
CsdlDocument |
getMetadata()
Return service metadata.
|
MetadataLock |
getMetadataLock()
Return a readers/writer lock that can be used to prevent readers from using the data service while the
DataService.metadata is being refreshed. |
java.lang.String |
getName()
Return service name.
|
DataServiceProvider |
getProvider()
Return the data service provider.
|
boolean |
hasMetadata()
Return has service metadata been loaded.
|
void |
loadEntity(EntityValue entity)
|
void |
loadEntity(EntityValue entity,
DataQuery query)
|
void |
loadEntity(EntityValue entity,
DataQuery query,
HttpHeaders headers)
|
void |
loadEntity(EntityValue entity,
DataQuery query,
HttpHeaders headers,
RequestOptions options)
Reload an existing entity from the target system.
|
void |
loadEntityAsync(EntityValue entity,
DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
loadEntityAsync(EntityValue entity,
DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
loadEntityAsync(EntityValue entity,
DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.loadEntity . |
void |
loadMetadata()
|
void |
loadMetadata(HttpHeaders headers)
|
void |
loadMetadata(HttpHeaders headers,
RequestOptions options)
Load service metadata into
DataService.provider (if not already loaded). |
void |
loadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
loadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
loadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.loadMetadata . |
void |
loadProperty(Property property,
EntityValue into)
|
void |
loadProperty(Property property,
EntityValue into,
DataQuery query)
|
void |
loadProperty(Property property,
EntityValue into,
DataQuery query,
HttpHeaders headers)
|
void |
loadProperty(Property property,
EntityValue into,
DataQuery query,
HttpHeaders headers,
RequestOptions options)
Load the value of a property into an existing entity.
|
void |
loadPropertyAsync(Property property,
EntityValue into,
DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
loadPropertyAsync(Property property,
EntityValue into,
DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
loadPropertyAsync(Property property,
EntityValue into,
DataQuery query,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.loadProperty . |
java.lang.String |
metadataText(int format)
Return metadata document text of the service.
|
void |
pingServer()
|
void |
pingServer(HttpHeaders headers)
|
void |
pingServer(HttpHeaders headers,
RequestOptions options)
Ping the server.
|
void |
pingServerAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
pingServerAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
pingServerAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.pingServer . |
void |
processBatch(RequestBatch batch)
|
void |
processBatch(RequestBatch batch,
HttpHeaders headers)
|
void |
processBatch(RequestBatch batch,
HttpHeaders headers,
RequestOptions options)
Execute a request batch in the target system.
|
void |
processBatchAsync(RequestBatch batch,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
processBatchAsync(RequestBatch batch,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
processBatchAsync(RequestBatch batch,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.processBatch . |
DataContext |
queryContext(int version)
Return a data context for parsing a data query.
|
void |
refreshMetadata()
Reload latest metadata from the backend server.
|
void |
saveEntity(EntityValue entity)
|
void |
saveEntity(EntityValue entity,
HttpHeaders headers)
|
void |
saveEntity(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Create (if
EntityValue.isNew ) or update (if existing) an entity in the target system. |
void |
saveEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
saveEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
saveEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.saveEntity . |
java.lang.String |
serviceDocument(int format)
Return the service document, in XML or JSON format.
|
void |
setActionExecutor(java.util.concurrent.Executor executor)
Set the executor for async actions (e.g.
|
void |
setFunctionExecutor(java.util.concurrent.Executor executor)
Set the executor for async functions (e.g.
|
void |
unloadMetadata()
Unload service metadata
DataService.provider (if previously loaded). |
void |
unloadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
unloadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
unloadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.unloadMetadata . |
void |
updateEntity(EntityValue entity)
|
void |
updateEntity(EntityValue entity,
HttpHeaders headers)
|
void |
updateEntity(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Update an entity in the target system.
|
void |
updateEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
updateEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
updateEntityAsync(EntityValue entity,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.updateEntity . |
void |
updateLink(EntityValue from,
Property property,
EntityValue to)
|
void |
updateLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers)
|
void |
updateLink(EntityValue from,
Property property,
EntityValue to,
HttpHeaders headers,
RequestOptions options)
Update a link from a source entity to a target entity.
|
void |
updateLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
updateLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
updateLinkAsync(EntityValue from,
Property property,
EntityValue to,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.updateLink . |
void |
uploadMedia(EntityValue entity,
StreamBase content)
|
void |
uploadMedia(EntityValue entity,
StreamBase content,
HttpHeaders headers)
|
void |
uploadMedia(EntityValue entity,
StreamBase content,
HttpHeaders headers,
RequestOptions options)
Upload content for a media entity to the target system.
|
void |
uploadMediaAsync(EntityValue entity,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
uploadMediaAsync(EntityValue entity,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
uploadMediaAsync(EntityValue entity,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.uploadMedia . |
void |
uploadStream(EntityValue entity,
StreamLink link,
StreamBase content)
|
void |
uploadStream(EntityValue entity,
StreamLink link,
StreamBase content,
HttpHeaders headers)
|
void |
uploadStream(EntityValue entity,
StreamLink link,
StreamBase content,
HttpHeaders headers,
RequestOptions options)
Upload content for a stream property to the target system.
|
void |
uploadStreamAsync(EntityValue entity,
StreamLink link,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
|
void |
uploadStreamAsync(EntityValue entity,
StreamLink link,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers)
|
void |
uploadStreamAsync(EntityValue entity,
StreamLink link,
StreamBase content,
com.sap.cloud.server.odata.core.Action0 successHandler,
com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler,
HttpHeaders headers,
RequestOptions options)
Asynchronous equivalent of
DataService.uploadStream . |
void |
upsertEntity(EntityValue entity)
|
void |
upsertEntity(EntityValue entity,
HttpHeaders headers)
|
void |
upsertEntity(EntityValue entity,
HttpHeaders headers,
RequestOptions options)
Upsert an entity in the target system (update if it exists already, otherwise insert).
|
public DataService(DataServiceProvider provider)
Construct a new data service using a specified provider.
provider
- Data service provider.public java.util.concurrent.Executor getActionExecutor()
public java.util.concurrent.Executor getFunctionExecutor()
public void setActionExecutor(java.util.concurrent.Executor executor)
executor
- Action executor.public void setFunctionExecutor(java.util.concurrent.Executor executor)
executor
- Function executor.public void asyncAction(com.sap.cloud.server.odata.core.Action0 action, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
action
- Action to be invoked.successHandler
- Success handler.failureHandler
- Failure handler.public void asyncAction(com.sap.cloud.server.odata.core.Action0 action, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, RequestOptions requestOptions)
action
- Action to be invoked.successHandler
- Success handler.failureHandler
- Failure handler.requestOptions
- Request options.public <T> void asyncFunction(com.sap.cloud.server.odata.core.Function0<T> function, com.sap.cloud.server.odata.core.Action1<T> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
T
- Function return type.function
- Function to be invoked.successHandler
- Success handler.failureHandler
- Failure handler.public <T> void asyncFunction(com.sap.cloud.server.odata.core.Function0<T> function, com.sap.cloud.server.odata.core.Action1<T> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, RequestOptions requestOptions)
T
- Function return type.function
- Function to be invoked.successHandler
- Success handler.failureHandler
- Failure handler.requestOptions
- (nullable) Request options.public void asyncAction(com.sap.cloud.server.odata.core.Action0 action, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, RequestOptions requestOptions, boolean functionExecutor)
action
- Action to be invoked.successHandler
- Success handler.failureHandler
- Failure handler.requestOptions
- (nullable) Request options.functionExecutor
- True if the action should be executed on the function exector. Otherwise false (the usual case, which will use the action executor).public <T> void asyncFunction(com.sap.cloud.server.odata.core.Function0<T> function, com.sap.cloud.server.odata.core.Action1<T> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, RequestOptions requestOptions, boolean actionExecutor)
T
- Function return type.function
- Function to be invoked.successHandler
- Success handler.failureHandler
- Failure handler.requestOptions
- (nullable) Request options.actionExecutor
- True if the function should be executed on the action exector. Otherwise false (the usual case, which will use the function executor).public void applyChanges(ChangeSet changes)
changes
- Changes parameter.public void applyChanges(ChangeSet changes, HttpHeaders headers)
changes
- Changes parameter.headers
- Headers parameter.public void applyChanges(ChangeSet changes, HttpHeaders headers, RequestOptions options)
Apply the changes from a change set to the target system.
public void applyChangesExample() { NorthwindService service = this.getService(); Supplier__List suppliers = service.getSuppliers(new DataQuery().top(2)); Product__List products = service.getProducts(new DataQuery().top(3)); Product product1 = products.get(0).copy(); Product product2 = products.get(1).copy(); Product product3 = products.get(2).copy(); product1.setProductName("Blueberry Muffins"); product2.setProductName("Strawberry Yoghurt"); product3.setProductName("Raspberry Pie"); ChangeSet entityCreates = new ChangeSet(); entityCreates.createEntity(product1); entityCreates.createEntity(product2); entityCreates.createEntity(product3); service.applyChanges(entityCreates); ChangeSet entityChanges = new ChangeSet(); product2.setProductName("Blackberry Yoghurt"); entityChanges.updateEntity(product2); entityChanges.deleteEntity(product3); service.applyChanges(entityChanges); ChangeSet linkChanges = new ChangeSet(); Supplier supplier1 = suppliers.get(0); Supplier supplier2 = suppliers.get(1); linkChanges.createLink(product1, Product.supplier, supplier1); linkChanges.updateLink(product1, Product.supplier, supplier2); linkChanges.deleteLink(product1, Product.supplier); service.applyChanges(linkChanges); }
public void applyChangesExample() { DataService service = this.getService(); EntitySet suppliersEntitySet = service.getEntitySet("Suppliers"); EntitySet productsEntitySet = service.getEntitySet("Products"); EntityType productEntityType = productsEntitySet.getEntityType(); Property productNameProperty = productEntityType.getProperty("ProductName"); Property supplierProperty = productEntityType.getProperty("Supplier"); EntityValueList suppliers = service.executeQuery(new DataQuery() .from(suppliersEntitySet).top(2)) .getEntityList(); EntityValueList products = service.executeQuery(new DataQuery() .from(productsEntitySet).top(3)) .getEntityList(); EntityValue product1 = products.get(0).copyEntity(); EntityValue product2 = products.get(1).copyEntity(); EntityValue product3 = products.get(1).copyEntity(); productNameProperty.setString(product1, "Blueberry Yoghurt"); productNameProperty.setString(product2, "Strawberry Yoghurt"); productNameProperty.setString(product3, "Raspberry Pie"); ChangeSet entityCreates = new ChangeSet(); entityCreates.createEntity(product1); entityCreates.createEntity(product2); entityCreates.createEntity(product3); service.applyChanges(entityCreates); ChangeSet entityChanges = new ChangeSet(); productNameProperty.setString(product2, "Blackberry Yoghurt"); entityChanges.updateEntity(product2); entityChanges.deleteEntity(product3); service.applyChanges(entityChanges); ChangeSet linkChanges = new ChangeSet(); EntityValue supplier1 = suppliers.get(0); EntityValue supplier2 = suppliers.get(1); linkChanges.createLink(product1, supplierProperty, supplier1); linkChanges.updateLink(product1, supplierProperty, supplier2); linkChanges.deleteLink(product1, supplierProperty); service.applyChanges(linkChanges); }
changes
- The change set.headers
- Optional request-specific headers.options
- Optional request-specific options.public void applyChangesAsync(ChangeSet changes, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
changes
- Changes parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void applyChangesAsync(ChangeSet changes, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
changes
- Changes parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void applyChangesAsync(ChangeSet changes, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.applyChanges
.
changes
- Change set.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void createEntity(EntityValue entity)
entity
- Entity parameter.public void createEntity(EntityValue entity, HttpHeaders headers)
entity
- Entity parameter.headers
- Headers parameter.public void createEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Create an entity in the target system.
Automatically calls CsdlDocument.resolveEntity
to ensure that EntityValue.entitySet
is available.
public void createEntityExample() { NorthwindService service = this.getService(); Customer customer = new Customer(); customer.setCompanyName("Enterprise Inc."); customer.setContactName("Jean-Luc Picard"); service.createEntity(customer); }
public void createEntityInSetExample() { NorthwindService service = this.getService(); Customer customer = new Customer(); customer.setCompanyName("Voyager Inc."); customer.setContactName("Kathryn Janeway"); service.createEntity(customer.inSet(NorthwindServiceMetadata.EntitySets.customers)); }
public void createEntityExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property companyNameProperty = customerEntityType.getProperty("CompanyName"); Property contactNameProperty = customerEntityType.getProperty("ContactName"); EntityValue customer = EntityValue.ofType(customerEntityType); companyNameProperty.setString(customer, "Enterprise Inc."); contactNameProperty.setString(customer, "Jean-Luc Picard"); service.createEntity(customer); }
public void createEntityInSetExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property companyNameProperty = customerEntityType.getProperty("CompanyName"); Property contactNameProperty = customerEntityType.getProperty("ContactName"); EntityValue customer = EntityValue.ofType(customerEntityType); companyNameProperty.setString(customer, "Voyager Inc."); contactNameProperty.setString(customer, "Kathryn Janeway"); service.createEntity(customer.inSet(customersEntitySet)); }
entity
- Entity to be created.headers
- Optional request-specific headers.options
- Optional request-specific options.public void createEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void createEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void createEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.createEntity
.
entity
- Entity value.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void createLink(EntityValue from, Property property, EntityValue to)
from
- From parameter.property
- Property parameter.to
- To parameter.public void createLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers)
from
- From parameter.property
- Property parameter.to
- To parameter.headers
- Headers parameter.public void createLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers, RequestOptions options)
Create a link from a source entity to a target entity in the target system.
public void createLinkExample() { NorthwindService service = this.getService(); Category category = service.getCategory(new DataQuery().skip(1).top(1)); Product product = service.getProduct(new DataQuery().top(1)); service.createLink(category, Category.products, product); }
public void createLinkExample() { DataService service = this.getService(); EntitySet categoriesEntitySet = service.getEntitySet("Categories"); EntitySet productsEntitySet = service.getEntitySet("Products"); EntityType categoryEntityType = categoriesEntitySet.getEntityType(); Property productsProperty = categoryEntityType.getProperty("Products"); EntityValue category = service.executeQuery(new DataQuery() .from(categoriesEntitySet).skip(1).top(1)) .getRequiredEntity(); EntityValue product = service.executeQuery(new DataQuery() .from(productsEntitySet).top(1)) .getRequiredEntity(); service.createLink(category, productsProperty, product); }
from
- Source entity for the link to be created.property
- Source navigation property for the link to be created.to
- Target entity for the link to be created.headers
- Optional request-specific headers.options
- Optional request-specific options.public void createLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
from
- From parameter.property
- Property parameter.to
- To parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void createLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
from
- From parameter.property
- Property parameter.to
- To parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void createLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.createLink
.
from
- Source entity.property
- Source property.to
- Target entity.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void createMedia(EntityValue entity, StreamBase content)
entity
- Entity parameter.content
- Content parameter.public void createMedia(EntityValue entity, StreamBase content, HttpHeaders headers)
entity
- Entity parameter.content
- Content parameter.headers
- Headers parameter.public void createMedia(EntityValue entity, StreamBase content, HttpHeaders headers, RequestOptions options)
Create a media entity with the specified content.
If the entity
has non-stream structural properties in addition to the key properties and media content, such as label
in the examples below,
then this function will send two requests to the server: a first request to upload (POST) the media stream,
and a second request (PATCH/PUT) to update the non-stream properties. It is not currently supported to make these two calls atomic.
Caution: Having too many threads simultaneously creating streams
may result in out-of-memory conditions on memory-constrained devices.
public void createMediaExample() { MediaService service = this.getService(); Image image = new Image(); image.setLabel("Smiley"); ByteStream content = ByteStream.fromBinary(com.sap.cloud.server.odata.core.StringFunction.toBinary(":-)")); content.setMediaType("text/plain"); service.createMedia(image, content); }
public void createMediaExample() { DataService service = this.getService(); EntitySet imagesEntitySet = service.getEntitySet("Images"); EntityType imageEntityType = imagesEntitySet.getEntityType(); Property labelProperty = imageEntityType.getProperty("label"); EntityValue image = EntityValue.ofType(imageEntityType); labelProperty.setString(image, "Smiley"); ByteStream content = ByteStream.fromBinary(com.sap.cloud.server.odata.core.StringFunction.toBinary(":-)")); content.setMediaType("text/plain"); service.createMedia(image, content); }
entity
- Entity to be created.content
- Initial content. Must be a ByteStream
or CharStream
. Will be closed before this function returns.headers
- Optional request-specific headers.options
- Optional request-specific options.public void createMediaAsync(EntityValue entity, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.content
- Content parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void createMediaAsync(EntityValue entity, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.content
- Content parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void createMediaAsync(EntityValue entity, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.createMedia
.
entity
- Media entity.content
- Stream with content to be uploaded.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void createRelatedEntity(EntityValue entity, EntityValue parent, Property property)
entity
- Entity parameter.parent
- Parent parameter.property
- Property parameter.public void createRelatedEntity(EntityValue entity, EntityValue parent, Property property, HttpHeaders headers)
entity
- Entity parameter.parent
- Parent parameter.property
- Property parameter.headers
- Headers parameter.public void createRelatedEntity(EntityValue entity, EntityValue parent, Property property, HttpHeaders headers, RequestOptions options)
Create an entity in the target system, related to a parent entity via a parent navigation property.
public void createRelatedEntityExample() { NorthwindService service = this.getService(); Customer customer = service.getCustomer(new DataQuery().top(1) .filter(Customer.customerID.equal("ALFKI"))); Order__List orders = service.getOrders(new DataQuery().top(1)); Order newOrder = orders.first().copy(); service.createRelatedEntity(newOrder, customer, Customer.orders); }
public void createRelatedEntityExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntitySet ordersEntitySet = service.getEntitySet("Orders"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property customerIDProperty = customerEntityType.getProperty("CustomerID"); Property ordersProperty = customerEntityType.getProperty("Orders"); EntityValueList customers = service.executeQuery(new DataQuery() .from(customersEntitySet).filter(customerIDProperty.equal("ALFKI"))) .getEntityList(); EntityValueList orders = service.executeQuery(new DataQuery() .from(ordersEntitySet).top(1)) .getEntityList(); EntityValue customer = customers.first(); EntityValue newOrder = orders.first().copyEntity(); service.createRelatedEntity(newOrder, customer, ordersProperty); }
entity
- Entity to be created.parent
- Previously created parent entity.property
- Parent's navigation property.headers
- Optional request-specific headers.options
- Optional request-specific options.public void createRelatedEntityAsync(EntityValue entity, EntityValue parent, Property property, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.parent
- Parent parameter.property
- Property parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void createRelatedEntityAsync(EntityValue entity, EntityValue parent, Property property, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.parent
- Parent parameter.property
- Property parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void createRelatedEntityAsync(EntityValue entity, EntityValue parent, Property property, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.createRelatedEntity
.
entity
- Entity to be created..parent
- Parent entity.property
- Parent property.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void createRelatedMedia(EntityValue entity, StreamBase content, EntityValue parent, Property property)
entity
- Entity parameter.content
- Content parameter.parent
- Parent parameter.property
- Property parameter.public void createRelatedMedia(EntityValue entity, StreamBase content, EntityValue parent, Property property, HttpHeaders headers)
entity
- Entity parameter.content
- Content parameter.parent
- Parent parameter.property
- Property parameter.headers
- Headers parameter.public void createRelatedMedia(EntityValue entity, StreamBase content, EntityValue parent, Property property, HttpHeaders headers, RequestOptions options)
Create an media entity in the target system, related to a parent entity via a parent navigation property.
public void createRelatedMediaExample() { MediaService service = this.getService(); Artist artist = new Artist(); artist.setFirstName("Salvador"); artist.setLastName("Dali"); artist.setDateOfBirth(LocalDate.of(1904, 5, 11)); artist.setPlaceOfBirth(GeographyPoint.withLatitudeLongitude(42.266667d, 2.965d)); service.createEntity(artist); Image image = new Image(); image.setLabel("Dream"); ByteStream content = ByteStream.fromBinary(com.sap.cloud.server.odata.core.StringFunction.toBinary("Dream Caused by the Flight of a Bee around a Pomegranate a Second Before Awakening")); content.setMediaType("text/plain"); service.createRelatedMedia(image, content, artist, Artist.images); }
public void createRelatedMediaExample() { DataService service = this.getService(); EntitySet artistsEntitySet = service.getEntitySet("Artists"); EntityType artistEntityType = artistsEntitySet.getEntityType(); Property firstNameProperty = artistEntityType.getProperty("firstName"); Property lastNameProperty = artistEntityType.getProperty("lastName"); Property dateOfBirthProperty = artistEntityType.getProperty("dateOfBirth"); Property placeOfBirthProperty = artistEntityType.getProperty("placeOfBirth"); Property imagesProperty = artistEntityType.getProperty("images"); EntitySet imagesEntitySet = service.getEntitySet("Images"); EntityType imageEntityType = imagesEntitySet.getEntityType(); Property labelProperty = imageEntityType.getProperty("label"); EntityValue artist = EntityValue.ofType(artistEntityType); firstNameProperty.setString(artist, "Maurits"); lastNameProperty.setString(artist, "Escher"); dateOfBirthProperty.setValue(artist, LocalDate.of(1898, 6, 17)); placeOfBirthProperty.setValue(artist, GeographyPoint.withLatitudeLongitude(53.2d, 5.783333d)); service.createEntity(artist); EntityValue image = EntityValue.ofType(imageEntityType); labelProperty.setString(image, "Hands"); ByteStream content = ByteStream.fromBinary(com.sap.cloud.server.odata.core.StringFunction.toBinary("Drawing Hands")); content.setMediaType("text/plain"); service.createRelatedMedia(image, content, artist, imagesProperty); }
entity
- Entity to be created.content
- Initial content. Must be a ByteStream
or CharStream
. Will be closed before this function returns.parent
- Previously created parent entity.property
- Parent's navigation property.headers
- Optional request-specific headers.options
- Optional request-specific options.public void deleteByQuery(DataQuery query)
query
- Query parameter.public void deleteByQuery(DataQuery query, HttpHeaders headers)
query
- Query parameter.headers
- Headers parameter.public void deleteByQuery(DataQuery query, HttpHeaders headers, RequestOptions options)
Execute query to delete data from the target system.
query
- Data query specifying the information to be deleted.headers
- Optional request-specific headers.options
- Optional request-specific options.public void deleteByQueryAsync(DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
query
- Query parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void deleteByQueryAsync(DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
query
- Query parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void deleteByQueryAsync(DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.deleteByQuery
.
query
- Data query.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void deleteEntity(EntityValue entity)
entity
- Entity parameter.public void deleteEntity(EntityValue entity, HttpHeaders headers)
entity
- Entity parameter.headers
- Headers parameter.public void deleteEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Delete an entity from the target system.
public void deleteEntityExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery().top(1).selectKey() .filter(Customer.contactName.equal("William Riker")); Customer customer = service.getCustomer(query); service.deleteEntity(customer); }
public void deleteEntityExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property contactNameProperty = customerEntityType.getProperty("ContactName"); DataQuery query = new DataQuery().top(1).selectKey().from(customersEntitySet) .filter(contactNameProperty.equal("William Riker")); EntityValue customer = service.executeQuery(query).getRequiredEntity(); service.deleteEntity(customer); }
entity
- Entity to be deleted.headers
- Optional request-specific headers.options
- Optional request-specific options.public void deleteEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void deleteEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void deleteEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.deleteEntity
.
entity
- Entity value.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void deleteLink(EntityValue from, Property property)
from
- From parameter.property
- Property parameter.public void deleteLink(EntityValue from, Property property, EntityValue to)
from
- From parameter.property
- Property parameter.to
- To parameter.public void deleteLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers)
from
- From parameter.property
- Property parameter.to
- To parameter.headers
- Headers parameter.public void deleteLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers, RequestOptions options)
Delete a link from a source entity to a target entity.
public void deleteLinkExample1() { NorthwindService service = this.getService(); Product product = service.getProduct(new DataQuery().top(1)); service.deleteLink(product, Product.supplier); }
public void deleteLinkExample2() { NorthwindService service = this.getService(); Category category = service.getCategory(new DataQuery().skip(1).top(1)); Product product = service.getProduct(new DataQuery().top(1)); service.deleteLink(category, Category.products, product); }
public void deleteLinkExample1() { DataService service = this.getService(); EntitySet productsEntitySet = service.getEntitySet("Products"); EntityType productEntityType = productsEntitySet.getEntityType(); Property supplierProperty = productEntityType.getProperty("Supplier"); EntityValue product = service.executeQuery(new DataQuery() .from(productsEntitySet).top(1)) .getRequiredEntity(); service.deleteLink(product, supplierProperty); }
public void deleteLinkExample2() { DataService service = this.getService(); EntitySet categoriesEntitySet = service.getEntitySet("Categories"); EntitySet productsEntitySet = service.getEntitySet("Products"); EntityType categoryEntityType = categoriesEntitySet.getEntityType(); Property productsProperty = categoryEntityType.getProperty("Products"); EntityValue category = service.executeQuery(new DataQuery() .from(categoriesEntitySet).skip(1).top(1)) .getRequiredEntity(); EntityValue product = service.executeQuery(new DataQuery() .from(productsEntitySet).top(1)) .getRequiredEntity(); service.deleteLink(category, productsProperty, product); }
from
- Source entity for the link to be deleted.property
- Source navigation property for the link to be deleted.to
- Target entity for the link to be deleted. Can be omitted for a single-valued navigation property.headers
- Optional request-specific headers.options
- Optional request-specific options.public void deleteLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
from
- From parameter.property
- Property parameter.to
- To parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void deleteLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
from
- From parameter.property
- Property parameter.to
- To parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void deleteLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.deleteLink
.
from
- Source entity.property
- Source property.to
- Target entity.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void deleteStream(EntityValue entity, StreamLink link)
entity
- Entity parameter.link
- Link parameter.public void deleteStream(EntityValue entity, StreamLink link, HttpHeaders headers)
entity
- Entity parameter.link
- Link parameter.headers
- Headers parameter.public void deleteStream(EntityValue entity, StreamLink link, HttpHeaders headers, RequestOptions options)
Delete the content of a stream property from the target system.
entity
- Entity containing the stream property whose content is to be deleted.link
- Stream link for the stream to be deleted.headers
- Optional request-specific headers.options
- Optional request-specific options.public void deleteStreamAsync(EntityValue entity, StreamLink link, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.link
- Link parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void deleteStreamAsync(EntityValue entity, StreamLink link, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.link
- Link parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void deleteStreamAsync(EntityValue entity, StreamLink link, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.deleteStream
.
entity
- Entity with stream property.link
- Stream link.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public ByteStream downloadMedia(EntityValue entity)
entity
- Entity parameter.public ByteStream downloadMedia(EntityValue entity, HttpHeaders headers)
entity
- Entity parameter.headers
- Headers parameter.public ByteStream downloadMedia(EntityValue entity, HttpHeaders headers, RequestOptions options)
Obtain a stream for downloading the content of a media entity from the target system.
Caution: streams are often used for large content that may not fit (all at once) in available application memory.
Having too many threads simultaneously downloading streams, or using ByteStream.readAndClose
,
may result in out-of-memory conditions on memory-constrained devices.
public void downloadMediaExample() { MediaService service = this.getService(); DataQuery query = new DataQuery().filter(Image.label.equal("Smiley")) .top(1); Image image = service.getImage(query); ByteStream stream = service.downloadMedia(image); byte[] data = stream.readAndClose(); assert BinaryOperator.equal(data, com.sap.cloud.server.odata.core.StringFunction.toBinary(";-)")); assert NullableString.hasValue(stream.getMediaType(), "text/plain"); }
public void downloadMediaExample() { DataService service = this.getService(); EntitySet imagesEntitySet = service.getEntitySet("Images"); EntityType imageEntityType = imagesEntitySet.getEntityType(); Property labelProperty = imageEntityType.getProperty("label"); DataQuery query = new DataQuery().from(imagesEntitySet) .filter(labelProperty.equal("Smiley")).top(1); EntityValue image = service.executeQuery(query).getRequiredEntity(); ByteStream stream = service.downloadMedia(image); byte[] data = stream.readAndClose(); assert BinaryOperator.equal(data, com.sap.cloud.server.odata.core.StringFunction.toBinary(";-)")); assert NullableString.hasValue(stream.getMediaType(), "text/plain"); }
entity
- Entity whose content is to be downloaded.headers
- Optional request-specific headers.options
- Optional request-specific options.public void downloadMediaAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action1<byte[]> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void downloadMediaAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action1<byte[]> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void downloadMediaAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action1<byte[]> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.downloadMedia
.
entity
- Media entity.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public ByteStream downloadStream(EntityValue entity, StreamLink link)
entity
- Entity parameter.link
- Link parameter.public ByteStream downloadStream(EntityValue entity, StreamLink link, HttpHeaders headers)
entity
- Entity parameter.link
- Link parameter.headers
- Headers parameter.public ByteStream downloadStream(EntityValue entity, StreamLink link, HttpHeaders headers, RequestOptions options)
Obtain a stream for downloading the content of a stream property from the target system.
Caution: streams are often used for large content that may not fit (all at once) in available application memory.
Having too many threads simultaneously downloading streams, or using ByteStream.readAndClose
,
may result in out-of-memory conditions on memory-constrained devices.
public void downloadStreamExample() { MediaService service = this.getService(); DataQuery query = new DataQuery().filter(Video.label.equal("Happier")) .top(1); Video video = service.getVideo(query); ByteStream stream = service.downloadStream(video, video.getContent()); byte[] data = stream.readAndClose(); assert BinaryOperator.equal(data, com.sap.cloud.server.odata.core.StringFunction.toBinary("...")); assert NullableString.hasValue(stream.getMediaType(), "text/plain"); }
public void downloadStreamExample() { DataService service = this.getService(); EntitySet videosEntitySet = service.getEntitySet("Videos"); EntityType videoEntityType = videosEntitySet.getEntityType(); Property labelProperty = videoEntityType.getProperty("label"); Property contentProperty = videoEntityType.getProperty("content"); DataQuery query = new DataQuery().from(videosEntitySet) .filter(labelProperty.equal("Happier")).top(1); EntityValue video = service.executeQuery(query).getRequiredEntity(); StreamLink link = contentProperty.getStreamLink(video); ByteStream stream = service.downloadStream(video, link); byte[] data = stream.readAndClose(); assert BinaryOperator.equal(data, com.sap.cloud.server.odata.core.StringFunction.toBinary("...")); assert NullableString.hasValue(stream.getMediaType(), "text/plain"); }
entity
- Entity containing the stream property whose content is to be downloaded.link
- Stream link for the stream to be downloaded.headers
- Optional request-specific headers.options
- Optional request-specific options.public void downloadStreamAsync(EntityValue entity, StreamLink link, com.sap.cloud.server.odata.core.Action1<byte[]> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.link
- Link parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void downloadStreamAsync(EntityValue entity, StreamLink link, com.sap.cloud.server.odata.core.Action1<byte[]> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.link
- Link parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void downloadStreamAsync(EntityValue entity, StreamLink link, com.sap.cloud.server.odata.core.Action1<byte[]> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.downloadStream
.
entity
- Entity with stream property.link
- Stream link.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public DataContext entityContext(EntitySet entitySet)
entitySet
- EntitySet parameter.public DataContext entityContext(EntitySet entitySet, StructureType derivedType)
entitySet
- EntitySet parameter.derivedType
- DerivedType parameter.public DataContext entityContext(EntitySet entitySet, StructureType derivedType, int format)
entitySet
- EntitySet parameter.derivedType
- DerivedType parameter.format
- Format parameter.public DataContext entityContext(EntitySet entitySet, StructureType derivedType, int format, int version)
Return a data context for a specified entity set, data format and data version.
entitySet
- Entity set for entity value to be parsed or formatted.derivedType
- (nullable) Derived type for query results.format
- Data format.version
- Data version.public DataValue executeMethod(DataMethod method)
method
- Method parameter.public DataValue executeMethod(DataMethod method, ParameterList parameters)
method
- Method parameter.parameters
- Parameters parameter.public DataValue executeMethod(DataMethod method, ParameterList parameters, HttpHeaders headers)
method
- Method parameter.parameters
- Parameters parameter.headers
- Headers parameter.public DataValue executeMethod(DataMethod method, ParameterList parameters, HttpHeaders headers, RequestOptions options)
Execute a data method (action or function) in the target system. Actions may have backend side-effects. Functions should not have backend side-effects.
method
- Data method.parameters
- Method parameters.headers
- Optional request-specific headers.options
- Optional request-specific options.null
if the method has no result.public void executeMethodAsync(DataMethod method, ParameterList parameters, com.sap.cloud.server.odata.core.Action1<DataValue> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
method
- Method parameter.parameters
- Parameters parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void executeMethodAsync(DataMethod method, ParameterList parameters, com.sap.cloud.server.odata.core.Action1<DataValue> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
method
- Method parameter.parameters
- Parameters parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void executeMethodAsync(DataMethod method, ParameterList parameters, com.sap.cloud.server.odata.core.Action1<DataValue> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.executeMethod
.
method
- Data method.parameters
- Method parameters.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public QueryResult executeQuery(DataQuery query)
query
- Query parameter.public QueryResult executeQuery(DataQuery query, HttpHeaders headers)
query
- Query parameter.headers
- Headers parameter.public QueryResult executeQuery(DataQuery query, HttpHeaders headers, RequestOptions options)
Execute a data query to get data from the target system.
query
- Data query specifying the information to be returned.headers
- Optional request-specific headers.options
- Optional request-specific options.public void executeQueryAsync(DataQuery query, com.sap.cloud.server.odata.core.Action1<QueryResult> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
query
- Query parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void executeQueryAsync(DataQuery query, com.sap.cloud.server.odata.core.Action1<QueryResult> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
query
- Query parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void executeQueryAsync(DataQuery query, com.sap.cloud.server.odata.core.Action1<QueryResult> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.executeQuery
.
query
- Data query.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public CsdlDocument fetchMetadata()
public CsdlDocument fetchMetadata(HttpHeaders headers)
headers
- Headers parameter.public CsdlDocument fetchMetadata(HttpHeaders headers, RequestOptions options)
Fetch latest service metadata and return it, but don't change the DataService.metadata
property.
headers
- Optional request-specific headers.options
- Optional request-specific options.public void fetchMetadataAsync(com.sap.cloud.server.odata.core.Action1<CsdlDocument> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void fetchMetadataAsync(com.sap.cloud.server.odata.core.Action1<CsdlDocument> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void fetchMetadataAsync(com.sap.cloud.server.odata.core.Action1<CsdlDocument> successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.fetchMetadata
.
successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public DataMethod getDataMethod(java.lang.String name)
Lookup a data method by qualified name (for function/action definitions) or by unqualified name (for function/action imports).
If the data method does not exist it indicates a fundamental implementation problem, therefore a non-catchable FatalException
will be thrown, and the app intentionally crashes.
The reason behind this drastic behaviour is to avoid mismatch between server and client.
It is still possible to avoid the FatalException
by looking up data methods before calling this function like in the
following code snippet:
public void checkDataMethodExistsExample() { DataService service = this.getService(); com.sap.cloud.server.odata.csdl.CsdlDocument csdlDocument = service.getMetadata(); if (csdlDocument.getDataMethods() .has("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person.UpdatePersonLastName")) { Ignore.valueOf_any(service.getDataMethod("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Person.UpdatePersonLastName")); } else { } }
DataService.metadata
.dataMethods
, for looking up data methods that might not exist.
name
- Name of the data method to be returned.public DataTransaction getDataTransaction()
Return current transaction for this data service.
public EntitySet getEntitySet(java.lang.String name)
Lookup an entity set (or singleton entity) by name. If the entity set does not exist it indicates a fundamental
implementation problem, therefore a non-catchable FatalException
will be thrown, and the app intentionally crashes.
The reason behind this drastic behaviour is to avoid mismatch between server and client.
It is still possible to avoid the FatalException
by looking up entity sets before calling this method like in the
following code snippet:
Note that OData singleton entities are represented by entity sets where EntitySet.isSingleton
is true
.
public void checkEntitySetExistsExample() { DataService service = this.getService(); if (service.getMetadata().getEntitySets().has("Categories")) { Ignore.valueOf_any(service.getEntitySet("Categories")); } else { } }
DataService.metadata
.entitySets
, for looking up entity sets that might not exist.
name
- Name of the entity set to be returned.public CsdlDocument getMetadata()
Return service metadata.
public MetadataLock getMetadataLock()
Return a readers/writer lock that can be used to prevent readers from using the data service while the DataService.metadata
is being refreshed.
DataService.metadata
is being refreshed.public java.lang.String getName()
Return service name.
public DataServiceProvider getProvider()
Return the data service provider.
public boolean hasMetadata()
Return has service metadata been loaded.
public void loadEntity(EntityValue entity)
entity
- Entity parameter.public void loadEntity(EntityValue entity, DataQuery query)
entity
- Entity parameter.query
- Query parameter.public void loadEntity(EntityValue entity, DataQuery query, HttpHeaders headers)
entity
- Entity parameter.query
- Query parameter.headers
- Headers parameter.public void loadEntity(EntityValue entity, DataQuery query, HttpHeaders headers, RequestOptions options)
Reload an existing entity from the target system.
public void loadEntityExample() { NorthwindService service = this.getService(); Customer customer = new Customer(); customer.setCustomerID("ALFKI"); service.loadEntity(customer); this.showCustomer(customer); }
public void loadEntityExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property customerIDProperty = customerEntityType.getProperty("CustomerID"); EntityValue customer = EntityValue.ofType(customerEntityType); customerIDProperty.setString(customer, "ALFKI"); service.loadEntity(customer); this.showCustomer(customer); }
entity
- Previously loaded entity, whose properties will be modified to reflect the loaded state.query
- (nullable) Optional data query, to specify loading criteria (especially for navigation properties).headers
- Optional request-specific headers.options
- Optional request-specific options.public void loadEntityAsync(EntityValue entity, DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.query
- Query parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void loadEntityAsync(EntityValue entity, DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.query
- Query parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void loadEntityAsync(EntityValue entity, DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.loadEntity
.
entity
- Entity value.query
- (nullable) Data query.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void loadMetadata()
public void loadMetadata(HttpHeaders headers)
headers
- Headers parameter.public void loadMetadata(HttpHeaders headers, RequestOptions options)
Load service metadata into DataService.provider
(if not already loaded).
headers
- Optional request-specific headers.options
- Optional request-specific options.public void loadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void loadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void loadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.loadMetadata
.
successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void loadProperty(Property property, EntityValue into)
property
- Property parameter.into
- Into parameter.public void loadProperty(Property property, EntityValue into, DataQuery query)
property
- Property parameter.into
- Into parameter.query
- Query parameter.public void loadProperty(Property property, EntityValue into, DataQuery query, HttpHeaders headers)
property
- Property parameter.into
- Into parameter.query
- Query parameter.headers
- Headers parameter.public void loadProperty(Property property, EntityValue into, DataQuery query, HttpHeaders headers, RequestOptions options)
Load the value of a property into an existing entity. This can be applied to both structural and navigation properties.
public void loadPropertyExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .filter(Customer.customerID.equal("ALFKI") .or(Customer.customerID.equal("ANATR"))); Customer__List customers = service.getCustomers(query); int countOrders = 0; for (Customer customer : customers) { this.showCustomer(customer); service.loadProperty(Customer.orders, customer); Order__List orders = customer.getOrders(); for (Order order : orders) { int orderID = order.getOrderID(); Example.show(" Order ", Example.formatInt(orderID)); countOrders++; } } assert countOrders > 0; }
public void loadPropertyInBatchExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery() .select(Customer.customerID, Customer.companyName, Customer.contactName) .filter(Customer.customerID.equal("ALFKI") .or(Customer.customerID.equal("ANATR"))); Customer__List customers = service.getCustomers(query); Customer customer1 = customers.get(0); Customer customer2 = customers.get(1); DataQuery query1 = new DataQuery().load(customer1, Customer.orders); DataQuery query2 = new DataQuery().load(customer2, Customer.orders); RequestBatch batch = new RequestBatch(); batch.addQuery(query1); batch.addQuery(query2); service.processBatch(batch); QueryResult result1 = batch.getQueryResult(query1); QueryResult result2 = batch.getQueryResult(query2); Order__List orders1 = Order.list(result1.getEntityList()); Order__List orders2 = Order.list(result2.getEntityList()); assert orders1.length() != 0; assert orders2.length() != 0; customer1.setOrders(orders1); customer2.setOrders(orders2); }
public void loadPropertyExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property customerIDProperty = customerEntityType.getProperty("CustomerID"); Property companyNameProperty = customerEntityType.getProperty("CompanyName"); Property contactNameProperty = customerEntityType.getProperty("ContactName"); Property ordersProperty = customerEntityType.getProperty("Orders"); Property orderIDProperty = ordersProperty.getItemEntityType() .getProperty("OrderID"); DataQuery query = new DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet) .filter(customerIDProperty.equal("ALFKI") .or(customerIDProperty.equal("ANATR"))); EntityValueList customers = service.executeQuery(query).getEntityList(); int countOrders = 0; for (EntityValue customer : customers) { this.showCustomer(customer); service.loadProperty(ordersProperty, customer); EntityValueList orders = ordersProperty.getEntityList(customer); for (EntityValue order : orders) { int orderID = orderIDProperty.getInt(order); Example.show(" Order ", Example.formatInt(orderID)); countOrders++; } } assert countOrders > 0; }
public void loadPropertyInBatchExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property customerIDProperty = customerEntityType.getProperty("CustomerID"); Property companyNameProperty = customerEntityType.getProperty("CompanyName"); Property contactNameProperty = customerEntityType.getProperty("ContactName"); Property ordersProperty = customerEntityType.getProperty("Orders"); DataQuery query = new DataQuery() .select(customerIDProperty, companyNameProperty, contactNameProperty) .from(customersEntitySet) .filter(customerIDProperty.equal("ALFKI") .or(customerIDProperty.equal("ANATR"))); EntityValueList customers = service.executeQuery(query).getEntityList(); EntityValue customer1 = customers.get(0); EntityValue customer2 = customers.get(1); DataQuery query1 = new DataQuery().load(customer1, ordersProperty); DataQuery query2 = new DataQuery().load(customer2, ordersProperty); RequestBatch batch = new RequestBatch(); batch.addQuery(query1); batch.addQuery(query2); service.processBatch(batch); QueryResult result1 = batch.getQueryResult(query1); QueryResult result2 = batch.getQueryResult(query2); EntityValueList orders1 = result1.getEntityList(); EntityValueList orders2 = result2.getEntityList(); assert orders1.length() != 0; assert orders2.length() != 0; ordersProperty.setEntityList(customer1, orders1); ordersProperty.setEntityList(customer2, orders2); }
property
- Property to load.into
- Existing entity.query
- (nullable) Optional data query, to specify loading criteria (especially for navigation properties).headers
- Optional request-specific headers.options
- Optional request-specific options.public void loadPropertyAsync(Property property, EntityValue into, DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
property
- Property parameter.into
- Into parameter.query
- Query parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void loadPropertyAsync(Property property, EntityValue into, DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
property
- Property parameter.into
- Into parameter.query
- Query parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void loadPropertyAsync(Property property, EntityValue into, DataQuery query, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.loadProperty
.
property
- Entity property.into
- Entity value.query
- (nullable) Data query.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public java.lang.String metadataText(int format)
Return metadata document text of the service.
format
- Metadata format. Only XML is presently supported.public void pingServer()
public void pingServer(HttpHeaders headers)
headers
- Headers parameter.public void pingServer(HttpHeaders headers, RequestOptions options)
Ping the server.
headers
- Optional request-specific headers.options
- Optional request-specific options.public void pingServerAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void pingServerAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void pingServerAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.pingServer
.
successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void processBatch(RequestBatch batch)
batch
- Batch parameter.public void processBatch(RequestBatch batch, HttpHeaders headers)
batch
- Batch parameter.headers
- Headers parameter.public void processBatch(RequestBatch batch, HttpHeaders headers, RequestOptions options)
Execute a request batch in the target system.
public void processBatchExample() { NorthwindService service = this.getService(); Supplier supplier1 = service.getSupplier(new DataQuery().top(1)); Supplier supplier2 = supplier1.copy(); Supplier supplier3 = supplier1.copy(); Supplier supplier4 = supplier1.copy(); supplier2.setCompanyName("Alpha Inc."); supplier3.setCompanyName("Beta Inc."); service.createEntity(supplier2); service.createEntity(supplier3); supplier3.setCompanyName("Gamma Inc."); Product product1 = service.getProduct(new DataQuery().top(1)); Product product2 = product1.copy(); product2.setProductName("Delta Cake"); RequestBatch batch = new RequestBatch(); ChangeSet changes = new ChangeSet(); changes.createEntity(supplier4); changes.updateEntity(supplier3); changes.deleteEntity(supplier2); changes.createEntity(product2); changes.createLink(product2, Product.supplier, supplier4); changes.updateLink(product2, Product.supplier, supplier3); changes.deleteLink(product2, Product.supplier, supplier3); DataQuery query = new DataQuery() .from(NorthwindServiceMetadata.EntitySets.suppliers); batch.addChanges(changes); batch.addQuery(query); service.processBatch(batch); Supplier__List suppliers = Supplier.list(batch.getQueryResult(query) .getEntityList()); Example.show("There are now ", Example.formatInt(suppliers.length()), " suppliers."); }
public void processBatchExample() { DataService service = this.getService(); EntitySet suppliersEntitySet = service.getEntitySet("Suppliers"); EntitySet productsEntitySet = service.getEntitySet("Products"); EntityType supplierEntityType = suppliersEntitySet.getEntityType(); Property companyNameProperty = supplierEntityType.getProperty("CompanyName"); EntityType productEntityType = productsEntitySet.getEntityType(); Property productNameProperty = productEntityType.getProperty("ProductName"); Property supplierProperty = productEntityType.getProperty("Supplier"); EntityValue supplier1 = service.executeQuery(new DataQuery() .from(suppliersEntitySet).top(1)) .getRequiredEntity(); EntityValue supplier2 = supplier1.copyEntity(); EntityValue supplier3 = supplier1.copyEntity(); EntityValue supplier4 = supplier1.copyEntity(); companyNameProperty.setString(supplier2, "Alpha Inc."); companyNameProperty.setString(supplier3, "Beta Inc."); service.createEntity(supplier2); service.createEntity(supplier3); companyNameProperty.setString(supplier3, "Gamma Inc."); EntityValue product1 = service.executeQuery(new DataQuery() .from(productsEntitySet).top(1)) .getRequiredEntity(); EntityValue product2 = product1.copyEntity(); productNameProperty.setString(product2, "Delta Cake"); RequestBatch batch = new RequestBatch(); ChangeSet changes = new ChangeSet(); changes.createEntity(supplier4); changes.updateEntity(supplier3); changes.deleteEntity(supplier2); changes.createEntity(product2); changes.createLink(product2, supplierProperty, supplier4); DataQuery query = new DataQuery().from(suppliersEntitySet); batch.addChanges(changes); batch.addQuery(query); service.processBatch(batch); EntityValueList suppliers = batch.getQueryResult(query).getEntityList(); Example.show("There are now ", Example.formatInt(suppliers.length()), " suppliers."); }
batch
- The request batch.headers
- Optional request-specific headers.options
- Optional request-specific options.public void processBatchAsync(RequestBatch batch, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
batch
- Batch parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void processBatchAsync(RequestBatch batch, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
batch
- Batch parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void processBatchAsync(RequestBatch batch, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.processBatch
.
batch
- Request batch.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public DataContext queryContext(int version)
Return a data context for parsing a data query.
version
- Data version.public void refreshMetadata()
Reload latest metadata from the backend server. If the metadata was previously loaded (or was obtained from generated proxy classes), then a compatibility check is performed.
If the latest metadata is not compatible with the previous metadata, CsdlException
will be thrown.
If the latest metadata is compatible with the previous metadata, the latest metadata will be applied.
It is generally recommended to use this function during application startup to check if the server's metadata
has been updated since the client application was constructed. If an application wishes to use the
data service for actions or updates, while refreshing the metadata in another thread,
the code using the data service for actions or updates should perform those operations while holding a read lock on the DataService.metadataLock
.
Execution of functions or queries will automatically obtain a read lock on DataService.metadataLock
.
Compatible metadata changes include:
Other additions, changes, and removals are considered incompatible by default, including:
Addition of enumeration members can be pre-approved by a caller using the dynamic API before calling refreshMetadata
(see CsdlDocument.hasOpenEnumerations
).
If an application uses generated proxy classes, then generating them with the "-open:enumerations" option
will automate the necessary pre-approval. The hasOpenEnumerations
flag should only be explicitly set when using the dynamic API.
Explicitly setting the hasOpenEnumerations
flag when using generated proxy classes (generated without the "-open:enumerations" option) could result in runtime exceptions.
Changes to model elements can be pre-approved by a caller using the dynamic API before calling refreshMetadata
(see CsdlDocument.canChangeAnything
).
Applications using generated proxy classes should not pre-approve such changes, as they are likely to result in application instability.
For example, if a property's data type is changed, it could result in runtime exceptions since proxy class properties have a pre-determined
type that is embedded into the application's compiled code.
Removal of model elements can be pre-approved by the caller before calling refreshMetadata
(see CsdlDocument.canRemoveAnything
),
or preferably by setting the canBeRemoved
flag on model elements that the application is prepared for the removal of.
Application developers should take care not to pre-approve the removal of model elements unless the application
is coded to check at runtime for the possible removal of those elements. The allowance for removals is intended to support "newer"
versions of client applications communicating with "older" service implementations but in the general case may require the application to have
some embedded knowledge of the changes that were made to the service metadata between the older and newer service implementations. If a newer client
application makes unconditional use of a model element that did not exist in an older service implementation, then the non-existence of that model element
after calling refreshMetadata
could result in runtime exceptions.
If refreshMetadata succeeds, then any added model elements will have isExtension == true
, and any removed model elements will have isRemoved == true
.
Changed model elements will not be distinguishable.
public void saveEntity(EntityValue entity)
entity
- Entity parameter.public void saveEntity(EntityValue entity, HttpHeaders headers)
entity
- Entity parameter.headers
- Headers parameter.public void saveEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Create (if EntityValue.isNew
) or update (if existing) an entity in the target system.
entity
- Entity to be created or updated.headers
- Optional request-specific headers.options
- Optional request-specific options.public void saveEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void saveEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void saveEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.saveEntity
.
entity
- Entity value.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public java.lang.String serviceDocument(int format)
Return the service document, in XML or JSON format.
format
- Data format (XML or JSON).public void unloadMetadata()
Unload service metadata DataService.provider
(if previously loaded).
public void unloadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void unloadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void unloadMetadataAsync(com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.unloadMetadata
.
successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void updateEntity(EntityValue entity)
entity
- Entity parameter.public void updateEntity(EntityValue entity, HttpHeaders headers)
entity
- Entity parameter.headers
- Headers parameter.public void updateEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Update an entity in the target system.
public void updateEntityExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery().top(1) .filter(Customer.contactName.equal("Jean-Luc Picard")); Customer customer = service.getCustomer(query); customer.setContactName("Beverly Crusher"); service.updateEntity(customer); }
public void updateEntityExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property contactNameProperty = customerEntityType.getProperty("ContactName"); DataQuery query = new DataQuery().top(1).from(customersEntitySet) .filter(contactNameProperty.equal("Jean-Luc Picard")); EntityValue customer = service.executeQuery(query).getRequiredEntity(); contactNameProperty.setString(customer, "Beverly Crusher"); service.updateEntity(customer); }
public void updateEntityWithReplaceExample() { NorthwindService service = this.getService(); DataQuery query = new DataQuery().top(1) .filter(Customer.contactName.equal("Beverly Crusher")); Customer customer = service.getCustomer(query); customer.setContactName("William Riker"); RequestOptions options = new RequestOptions(); options.setUpdateMode(UpdateMode.REPLACE); service.updateEntity(customer, com.sap.cloud.server.odata.http.HttpHeaders.empty, options); }
public void updateEntityWithReplaceExample() { DataService service = this.getService(); EntitySet customersEntitySet = service.getEntitySet("Customers"); EntityType customerEntityType = customersEntitySet.getEntityType(); Property contactNameProperty = customerEntityType.getProperty("ContactName"); DataQuery query = new DataQuery().top(1).from(customersEntitySet) .filter(contactNameProperty.equal("Beverly Crusher")); EntityValue customer = service.executeQuery(query).getRequiredEntity(); contactNameProperty.setString(customer, "William Riker"); RequestOptions options = new RequestOptions(); options.setUpdateMode(UpdateMode.REPLACE); service.updateEntity(customer, com.sap.cloud.server.odata.http.HttpHeaders.empty, options); }
entity
- Entity to be updated.headers
- Optional request-specific headers.options
- Optional request-specific options.public void updateEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void updateEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void updateEntityAsync(EntityValue entity, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.updateEntity
.
entity
- Entity value.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void updateLink(EntityValue from, Property property, EntityValue to)
from
- From parameter.property
- Property parameter.to
- To parameter.public void updateLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers)
from
- From parameter.property
- Property parameter.to
- To parameter.headers
- Headers parameter.public void updateLink(EntityValue from, Property property, EntityValue to, HttpHeaders headers, RequestOptions options)
Update a link from a source entity to a target entity.
public void updateLinkExample() { NorthwindService service = this.getService(); Product product = service.getProduct(new DataQuery().top(1)); Category category = service.getCategory(new DataQuery().skip(2).top(1)); service.updateLink(product, Product.category, category); }
public void updateLinkExample() { DataService service = this.getService(); EntitySet productsEntitySet = service.getEntitySet("Products"); EntitySet categoriesEntitySet = service.getEntitySet("Categories"); EntityType productEntityType = productsEntitySet.getEntityType(); Property categoryProperty = productEntityType.getProperty("Category"); EntityValue product = service.executeQuery(new DataQuery() .from(productsEntitySet).top(1)) .getRequiredEntity(); EntityValue category = service.executeQuery(new DataQuery() .from(categoriesEntitySet).skip(2).top(1)) .getRequiredEntity(); service.updateLink(product, categoryProperty, category); }
from
- Source entity for the link to be updated.property
- Source navigation property for the link to be updated. This must be a one-to-one navigation property.to
- Target entity for the link to be updated.headers
- Optional request-specific headers.options
- Optional request-specific options.public void updateLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
from
- From parameter.property
- Property parameter.to
- To parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void updateLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
from
- From parameter.property
- Property parameter.to
- To parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void updateLinkAsync(EntityValue from, Property property, EntityValue to, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.updateLink
.
from
- Source entity.property
- Source property.to
- Target entity.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void uploadMedia(EntityValue entity, StreamBase content)
entity
- Entity parameter.content
- Content parameter.public void uploadMedia(EntityValue entity, StreamBase content, HttpHeaders headers)
entity
- Entity parameter.content
- Content parameter.headers
- Headers parameter.public void uploadMedia(EntityValue entity, StreamBase content, HttpHeaders headers, RequestOptions options)
Upload content for a media entity to the target system.
Caution: Having too many threads simultaneously uploading streams
may result in out-of-memory conditions on memory-constrained devices.
Note: this function cannot be used to create a media entity. See DataService.createMedia
.
public void uploadMediaExample() { MediaService service = this.getService(); DataQuery query = new DataQuery().filter(Image.label.equal("Smiley")) .top(1); Image image = service.getImage(query); ByteStream content = ByteStream.fromBinary(com.sap.cloud.server.odata.core.StringFunction.toBinary(";-)")); content.setMediaType("text/plain"); service.uploadMedia(image, content); }
public void uploadMediaExample() { DataService service = this.getService(); EntitySet imagesEntitySet = service.getEntitySet("Images"); EntityType imageEntityType = imagesEntitySet.getEntityType(); Property labelProperty = imageEntityType.getProperty("label"); DataQuery query = new DataQuery().from(imagesEntitySet) .filter(labelProperty.equal("Smiley")).top(1); EntityValue image = service.executeQuery(query).getRequiredEntity(); ByteStream content = ByteStream.fromBinary(com.sap.cloud.server.odata.core.StringFunction.toBinary(";-)")); content.setMediaType("text/plain"); service.uploadMedia(image, content); }
content
- Upload stream content. Will be closed before this function returns.entity
- Entity whose content is to be uploaded.headers
- Optional request-specific headers.options
- Optional request-specific options.public void uploadMediaAsync(EntityValue entity, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.content
- Content parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void uploadMediaAsync(EntityValue entity, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.content
- Content parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void uploadMediaAsync(EntityValue entity, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.uploadMedia
.
entity
- Media entity.content
- Stream with content to be uploaded.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void uploadStream(EntityValue entity, StreamLink link, StreamBase content)
entity
- Entity parameter.link
- Link parameter.content
- Content parameter.public void uploadStream(EntityValue entity, StreamLink link, StreamBase content, HttpHeaders headers)
entity
- Entity parameter.link
- Link parameter.content
- Content parameter.headers
- Headers parameter.public void uploadStream(EntityValue entity, StreamLink link, StreamBase content, HttpHeaders headers, RequestOptions options)
Upload content for a stream property to the target system. Caution: Having too many threads simultaneously uploading streams may result in out-of-memory conditions on memory-constrained devices.
public void uploadStreamExample() { MediaService service = this.getService(); Video video = new Video(); video.setLabel("Happy"); ByteStream content = ByteStream.fromBinary(com.sap.cloud.server.odata.core.StringFunction.toBinary("...")); content.setMediaType("text/plain"); service.createEntity(video); String contentETagAfterCreate = video.getContent().getEntityTag(); assert contentETagAfterCreate == null; service.uploadStream(video, video.getContent(), content); service.loadEntity(video); String contentETagAfterUpload = video.getContent().getEntityTag(); assert contentETagAfterUpload != null; video.setLabel("Happier"); service.updateEntity(video); String contentETagAfterUpdate = video.getContent().getEntityTag(); assert NullableString.equal(contentETagAfterUpdate, contentETagAfterUpload); }
public void uploadStreamExample() { DataService service = this.getService(); EntitySet videosEntitySet = service.getEntitySet("Videos"); EntityType videoEntityType = videosEntitySet.getEntityType(); Property labelProperty = videoEntityType.getProperty("label"); Property contentProperty = videoEntityType.getProperty("content"); EntityValue video = EntityValue.ofType(videoEntityType); labelProperty.setString(video, "Happy"); ByteStream content = ByteStream.fromBinary(com.sap.cloud.server.odata.core.StringFunction.toBinary("...")); content.setMediaType("text/plain"); service.createEntity(video); StreamLink link = contentProperty.getStreamLink(video); String contentETagAfterCreate = link.getEntityTag(); assert contentETagAfterCreate == null; service.uploadStream(video, link, content); service.loadEntity(video); String contentETagAfterUpload = link.getEntityTag(); assert contentETagAfterUpload != null; labelProperty.setString(video, "Happier"); service.updateEntity(video); String contentETagAfterUpdate = link.getEntityTag(); assert NullableString.equal(contentETagAfterUpdate, contentETagAfterUpload); }
entity
- Entity containing the stream property whose content is to be uploaded.link
- Stream link for the stream to be uploaded.content
- Upload stream content. Will be closed before this function returns.headers
- Optional request-specific headers.options
- Optional request-specific options.public void uploadStreamAsync(EntityValue entity, StreamLink link, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler)
entity
- Entity parameter.link
- Link parameter.content
- Content parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.public void uploadStreamAsync(EntityValue entity, StreamLink link, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers)
entity
- Entity parameter.link
- Link parameter.content
- Content parameter.successHandler
- SuccessHandler parameter.failureHandler
- FailureHandler parameter.headers
- Headers parameter.public void uploadStreamAsync(EntityValue entity, StreamLink link, StreamBase content, com.sap.cloud.server.odata.core.Action0 successHandler, com.sap.cloud.server.odata.core.Action1<java.lang.RuntimeException> failureHandler, HttpHeaders headers, RequestOptions options)
Asynchronous equivalent of DataService.uploadStream
.
entity
- Entity with stream property.link
- Stream link.content
- Stream with content to be uploaded.successHandler
- Success handler.failureHandler
- Failure handler.headers
- Request headers.options
- Request options.public void upsertEntity(EntityValue entity)
entity
- Entity parameter.public void upsertEntity(EntityValue entity, HttpHeaders headers)
entity
- Entity parameter.headers
- Headers parameter.public void upsertEntity(EntityValue entity, HttpHeaders headers, RequestOptions options)
Upsert an entity in the target system (update if it exists already, otherwise insert).
entity
- Entity to be created.headers
- Request-specific headers.options
- Request-specific options.