public class InMemoryDatabase extends java.lang.Object implements DataServiceProvider
A data service provider using in-memory storage. Since data is not persisted across process restarts, this provider should be used only for testing (or for temporary data).
Constructor and Description |
---|
InMemoryDatabase(java.lang.String name)
Construct a new metadata-only service 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 |
beginTransaction()
Begin a server transaction.
|
void |
bindEntities(EntityValue entity)
|
void |
bindEntities(EntityValue entity,
Property bindingProperty)
|
void |
bindEntities(EntityValue entity,
Property bindingProperty,
boolean afterCreate)
|
void |
bindEntities(EntityValue entity,
Property bindingProperty,
boolean afterCreate,
boolean afterUpdate)
This function may be used in the implementation of entity binding calls, e.g.
|
void |
bindEntitiesAfterCreate(EntityValue entity)
|
void |
bindEntitiesAfterCreate(EntityValue entity,
Property bindingProperty)
This function may be used in the implementation of entity binding calls after the main create action of
InMemoryDatabase.createEntity . |
void |
bindEntitiesAfterUpdate(EntityValue entity)
|
void |
bindEntitiesAfterUpdate(EntityValue entity,
Property bindingProperty)
This function may be used in the implementation of entity binding calls after the main update action of
InMemoryDatabase.updateEntity . |
void |
commit()
Commit the current server transaction.
|
void |
createChildren(EntityValue entity)
|
void |
createChildren(EntityValue entity,
Property childProperty)
This function may be used in the implementation of "deep insert" calls, e.g.
|
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 |
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.
|
void |
createLinkUsingForeignKeys(EntityValue source,
Property sourceProperty,
EntityValue target)
Default implementation of 'createLink' using foreign keys from referential constraints in service metadata.
|
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 in the target system.
|
void |
createParents(EntityValue entity)
|
void |
createParents(EntityValue entity,
Property parentProperty)
This function may be used in the implementation of "deep insert" calls, e.g.
|
void |
createSchema()
Create in memory the database schema artifacts (e.g.
|
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 |
deleteChildren(EntityValue entity)
|
void |
deleteChildren(EntityValue entity,
Property childProperty)
This function may be used in the implementation of "on delete" actions, e.g.
|
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 |
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 |
deleteLinkUsingForeignKeys(EntityValue source,
Property sourceProperty,
EntityValue target)
Default implementation of 'deleteLink' using foreign keys from referential constraints in service metadata.
|
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.
|
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.
|
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.
|
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,
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.
|
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 |
expandItem(EntityValue entity,
ExpandItem item)
Override this function to implement item expansion for this service.
|
void |
expandItems(DataQuery query,
DataValue result)
|
CsdlDocument |
fetchMetadata(HttpHeaders headers,
RequestOptions options)
Fetch latest service metadata and return it, but don't change the
InMemoryDatabase.metadata property. |
boolean |
getAutoBindEntities()
Return should this provider automatically bind entities in
InMemoryDatabase.createEntity or InMemoryDatabase.updateEntity , if bound entities are provided by the client. |
boolean |
getAutoCreateChildren()
Return should this provider automatically create children in
InMemoryDatabase.createEntity ("deep insert" calls), if nested children are provided by the client. |
boolean |
getAutoCreateParents()
Return should this provider automatically create parents in
InMemoryDatabase.createEntity ("deep insert" calls), if nested parents are provided by the client. |
boolean |
getAutoDeleteChildren()
Return should this provider automatically delete children in
InMemoryDatabase.deleteEntity ("on delete" actions), if specified with OnDelete in the service metadata. |
boolean |
getAutoExpandItems()
Return should this provider automatically expand children in
InMemoryDatabase.executeQuery , if requested in the client's query. |
boolean |
getAutoGenerateKeys()
Return should this provider automatically generate primary keys? Defaults to
true . |
boolean |
getAutoUnbindEntities()
Return should this provider automatically unbind entities in
InMemoryDatabase.createEntity or InMemoryDatabase.updateEntity , if unbound entities are provided by the client. |
DataTransaction |
getDataTransaction()
Return the current server transaction.
|
boolean |
getEnableChangeTracking()
Return should this provider be enabled for change tracking? Defaults to
true . |
CsdlDocument |
getMetadata()
Return service metadata.
|
java.lang.String |
getServiceName()
Return service name.
|
boolean |
getUseClientProvidedKeys()
Return should
InMemoryDatabase.createEntity use client-provided keys (when available), in preference to server-generated keys? Defaults to false . |
boolean |
hasMetadata()
Return has service metadata been loaded.
|
boolean |
isMetricProvider()
Return is this provider used for data metrics?
|
void |
loadMetadata(HttpHeaders headers,
RequestOptions options)
Load service metadata (if not already loaded).
|
java.lang.String |
metadataText(int format)
Return metadata document text of the service.
|
void |
pingServer(HttpHeaders headers,
RequestOptions options)
Ping the server.
|
void |
processBatch(RequestBatch batch,
HttpHeaders headers,
RequestOptions options)
Execute a request batch in the target system.
|
DataContext |
queryContext(int version)
Return a data context for parsing a data query.
|
void |
rollback()
Rollback the current server transaction.
|
EntityValue |
selectEntity(EntityValue entity)
Return newly loaded copy of
entity with all structural properties selected. |
java.lang.String |
serviceDocument(int format)
Return the service document, in XML or JSON format.
|
void |
setAutoBindEntities(boolean value)
Set should this provider automatically bind entities in
InMemoryDatabase.createEntity or InMemoryDatabase.updateEntity , if bound entities are provided by the client. |
void |
setAutoCreateChildren(boolean value)
Set should this provider automatically create children in
InMemoryDatabase.createEntity ("deep insert" calls), if nested children are provided by the client. |
void |
setAutoCreateParents(boolean value)
Set should this provider automatically create parents in
InMemoryDatabase.createEntity ("deep insert" calls), if nested parents are provided by the client. |
void |
setAutoDeleteChildren(boolean value)
Set should this provider automatically delete children in
InMemoryDatabase.deleteEntity ("on delete" actions), if specified with OnDelete in the service metadata. |
void |
setAutoExpandItems(boolean value)
Set should this provider automatically expand children in
InMemoryDatabase.executeQuery , if requested in the client's query. |
void |
setAutoGenerateKeys(boolean value)
Set should this provider automatically generate primary keys? Defaults to
true . |
void |
setAutoUnbindEntities(boolean value)
Set should this provider automatically unbind entities in
InMemoryDatabase.createEntity or InMemoryDatabase.updateEntity , if unbound entities are provided by the client. |
void |
setEnableChangeTracking(boolean value)
Set should this provider be enabled for change tracking? Defaults to
true . |
void |
setMetadata(CsdlDocument value)
Set service metadata.
|
void |
setMetricProvider(boolean value)
Set is this provider used for data metrics?
|
void |
setUseClientProvidedKeys(boolean value)
Set should
InMemoryDatabase.createEntity use client-provided keys (when available), in preference to server-generated keys? Defaults to false . |
void |
unbindEntities(EntityValue entity)
|
void |
unbindEntities(EntityValue entity,
Property bindingProperty)
This function may be used in the implementation of entity binding calls, e.g.
|
void |
unloadMetadata()
Unload service metadata (if previously loaded).
|
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 |
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 |
updateLinkUsingForeignKeys(EntityValue source,
Property sourceProperty,
EntityValue target)
Default implementation of 'updateLink' using foreign keys from referential constraints in service metadata.
|
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
Caution: Having too many threads simultaneously uploading streams
may result in out-of-memory conditions on memory-constrained devices.
|
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.
|
public InMemoryDatabase(java.lang.String name)
Construct a new metadata-only service provider.
name
- Service name.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.
changes
- The change set.headers
- Optional request-specific headers.options
- Optional request-specific options.public void beginTransaction()
Begin a server transaction.
beginTransaction
in interface DataServiceProvider
public void bindEntities(EntityValue entity)
entity
- Entity parameter.public void bindEntities(EntityValue entity, Property bindingProperty)
entity
- Entity parameter.bindingProperty
- BindingProperty parameter.public void bindEntities(EntityValue entity, Property bindingProperty, boolean afterCreate)
entity
- Entity parameter.bindingProperty
- BindingProperty parameter.afterCreate
- AfterCreate parameter.public void bindEntities(EntityValue entity, Property bindingProperty, boolean afterCreate, boolean afterUpdate)
This function may be used in the implementation of entity binding calls, e.g. by EntityValue.bindEntity
.
It relies on the existence of appropriate referential constraints in the service metadata, or an appropriately set join entity set.
entity
- Source entity, which may contain inline bindings for the binding property.bindingProperty
- (nullable) Binding property. If null
, then all of the source's navigation properties are considered.afterCreate
- Is this call for binding after createEntity has created entity
? Defaults to false.afterUpdate
- Is this call for binding after updateEntity has updated entity
? Defaults to false.public void bindEntitiesAfterCreate(EntityValue entity)
entity
- Entity parameter.public void bindEntitiesAfterCreate(EntityValue entity, Property bindingProperty)
This function may be used in the implementation of entity binding calls after the main create action of InMemoryDatabase.createEntity
.
It relies on the existence of appropriate referential constraints in the service metadata.
entity
- Source entity, which may contain inline bindings for the binding property.bindingProperty
- (nullable) Binding property. If null
, then all of the source's navigation properties are considered.public void bindEntitiesAfterUpdate(EntityValue entity)
entity
- Entity parameter.public void bindEntitiesAfterUpdate(EntityValue entity, Property bindingProperty)
This function may be used in the implementation of entity binding calls after the main update action of InMemoryDatabase.updateEntity
.
It relies on the existence of appropriate referential constraints in the service metadata.
entity
- Source entity, which may contain inline bindings for the binding property.bindingProperty
- (nullable) Binding property. If null
, then all of the source's navigation properties are considered.public void commit()
Commit the current server transaction.
commit
in interface DataServiceProvider
public void createChildren(EntityValue entity)
entity
- Entity parameter.public void createChildren(EntityValue entity, Property childProperty)
This function may be used in the implementation of "deep insert" calls, e.g. by InMemoryDatabase.createEntity
.
This function will execute "deep insert" if the parent-child entity relationship is fulfilled through join set.
entity
- Parent entity, which may contain inline children for the child property.childProperty
- (nullable) Child property. If null
, then all of the parent's navigation properties are considered.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.
DataServiceException
if the entity set hasn't been explicitly provided before calling createEntity
and there isn't a unique entity set for the entity type.
createEntity
in interface DataServiceProvider
entity
- Entity to be created.headers
- Request-specific headers.options
- Request-specific 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.
createLink
in interface DataServiceProvider
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
- Request-specific headers.options
- Request-specific options.public void createLinkUsingForeignKeys(EntityValue source, Property sourceProperty, EntityValue target)
Default implementation of 'createLink' using foreign keys from referential constraints in service metadata.
source
- Source entity for the link to be created.sourceProperty
- Source navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.target
- Target entity for the link to be created.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 in the target system.
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.
createMedia
in interface DataServiceProvider
entity
- Entity to be created.content
- Initial content. Must be a ByteStream
or CharStream
. Will be closed before this function returns.headers
- Request-specific headers.options
- Request-specific options.public void createParents(EntityValue entity)
entity
- Entity parameter.public void createParents(EntityValue entity, Property parentProperty)
This function may be used in the implementation of "deep insert" calls, e.g. by InMemoryDatabase.createEntity
.
This function will not execute "deep insert" if the parent-child entity relationship is fulfilled through join set.
entity
- Child entity, which may contain inline parent(s) via the parent property.parentProperty
- (nullable) Child property. If null
, then all of the parent's navigation properties are considered.public void createSchema()
Create in memory the database schema artifacts (e.g. tables) for this provider.
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.
deleteByQuery
in interface DataServiceProvider
query
- Data query specifying the information to be deleted.headers
- Request-specific headers.options
- Request-specific options.public void deleteChildren(EntityValue entity)
entity
- Entity parameter.public void deleteChildren(EntityValue entity, Property childProperty)
This function may be used in the implementation of "on delete" actions, e.g. by InMemoryDatabase.deleteEntity
.
entity
- Parent entity.childProperty
- (nullable) Child property. If `null`, then all of the parent's navigation properties are considered.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.
deleteEntity
in interface DataServiceProvider
entity
- Entity to be deleted.headers
- Request-specific headers.options
- Request-specific options.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.
deleteLink
in interface DataServiceProvider
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.headers
- Request-specific headers.options
- Request-specific options.public void deleteLinkUsingForeignKeys(EntityValue source, Property sourceProperty, EntityValue target)
Default implementation of 'deleteLink' using foreign keys from referential constraints in service metadata.
source
- Source entity for the link to be created.sourceProperty
- Source navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.target
- Target entity for the link to be created.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.
deleteStream
in interface DataServiceProvider
entity
- Entity containing the stream property whose content is to be deleted.headers
- Request-specific headers.options
- Request-specific options.link
- Stream link for the stream to be deleted.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.
downloadMedia
in interface DataServiceProvider
entity
- Entity whose content is to be downloaded.headers
- Request-specific headers.options
- Request-specific 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.
downloadStream
in interface DataServiceProvider
entity
- Entity containing the stream property whose content is to be downloaded.link
- Stream link for the stream to be downloaded.headers
- Request-specific headers.options
- Request-specific options.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.
entityContext
in interface DataServiceProvider
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, 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.
DataServiceException
or DataNetworkException
if an error occurs during action invocation.
executeMethod
in interface DataServiceProvider
method
- Data method.parameters
- Method parameters.headers
- Request-specific headers.options
- Request-specific 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.
executeQuery
in interface DataServiceProvider
query
- Data query specifying the information to be returned.headers
- Request-specific headers.options
- Request-specific options.public void expandItem(EntityValue entity, ExpandItem item)
Override this function to implement item expansion for this service. If not overridden, referential constraints are used to implement automatic expansion.
entity
- Entity whose item is to be expanded.item
- Item to be expanded.public void expandItems(DataQuery query, DataValue result)
If query
contains any DataQuery.expandItems
, apply them to result
.
query
- Query which may optionally contain expand items.result
- (nullable) Query result, to which item expansion may be applied (if not null
, the result should be an entity value or entity list).public CsdlDocument fetchMetadata(HttpHeaders headers, RequestOptions options)
Fetch latest service metadata and return it, but don't change the InMemoryDatabase.metadata
property.
fetchMetadata
in interface DataServiceProvider
headers
- Optional request-specific headers.options
- Optional request-specific options.public boolean getAutoBindEntities()
Return should this provider automatically bind entities in InMemoryDatabase.createEntity
or InMemoryDatabase.updateEntity
, if bound entities are provided by the client. Defaults to true
.
InMemoryDatabase.createEntity
or InMemoryDatabase.updateEntity
, if bound entities are provided by the client. Defaults to true
.public boolean getAutoCreateChildren()
Return should this provider automatically create children in InMemoryDatabase.createEntity
("deep insert" calls), if nested children are provided by the client. Defaults to true
.
InMemoryDatabase.createEntity
("deep insert" calls), if nested children are provided by the client. Defaults to true
.public boolean getAutoCreateParents()
Return should this provider automatically create parents in InMemoryDatabase.createEntity
("deep insert" calls), if nested parents are provided by the client. Defaults to true
.
InMemoryDatabase.createEntity
("deep insert" calls), if nested parents are provided by the client. Defaults to true
.public boolean getAutoDeleteChildren()
Return should this provider automatically delete children in InMemoryDatabase.deleteEntity
("on delete" actions), if specified with OnDelete in the service metadata. Defaults to true
.
InMemoryDatabase.deleteEntity
("on delete" actions), if specified with OnDelete in the service metadata. Defaults to true
.public boolean getAutoExpandItems()
Return should this provider automatically expand children in InMemoryDatabase.executeQuery
, if requested in the client's query. Defaults to true
.
InMemoryDatabase.executeQuery
, if requested in the client's query. Defaults to true
.public boolean getAutoGenerateKeys()
Return should this provider automatically generate primary keys? Defaults to true
.
If the provider doesn't generate keys, then the client will have to generate them.
public boolean getAutoUnbindEntities()
Return should this provider automatically unbind entities in InMemoryDatabase.createEntity
or InMemoryDatabase.updateEntity
, if unbound entities are provided by the client. Defaults to true
.
InMemoryDatabase.createEntity
or InMemoryDatabase.updateEntity
, if unbound entities are provided by the client. Defaults to true
.public DataTransaction getDataTransaction()
Return the current server transaction.
getDataTransaction
in interface DataServiceProvider
public boolean getEnableChangeTracking()
Return should this provider be enabled for change tracking? Defaults to true
.
true
.public CsdlDocument getMetadata()
Return service metadata.
getMetadata
in interface DataServiceProvider
public java.lang.String getServiceName()
Return service name.
getServiceName
in interface DataServiceProvider
public boolean getUseClientProvidedKeys()
Return should InMemoryDatabase.createEntity
use client-provided keys (when available), in preference to server-generated keys? Defaults to false
.
InMemoryDatabase.createEntity
use client-provided keys (when available), in preference to server-generated keys? Defaults to false
.public boolean hasMetadata()
Return has service metadata been loaded.
hasMetadata
in interface DataServiceProvider
public boolean isMetricProvider()
Return is this provider used for data metrics?
public void loadMetadata(HttpHeaders headers, RequestOptions options)
Load service metadata (if not already loaded).
loadMetadata
in interface DataServiceProvider
headers
- Optional request-specific headers.options
- Optional request-specific options.public java.lang.String metadataText(int format)
Return metadata document text of the service.
metadataText
in interface DataServiceProvider
format
- Metadata format. Only XML is presently supported.public void pingServer(HttpHeaders headers, RequestOptions options)
Ping the server.
pingServer
in interface DataServiceProvider
headers
- Optional request-specific headers.options
- Optional request-specific options.public void processBatch(RequestBatch batch, HttpHeaders headers, RequestOptions options)
Execute a request batch in the target system.
processBatch
in interface DataServiceProvider
batch
- The request batch.headers
- Request-specific headers.options
- Request-specific options.public DataContext queryContext(int version)
Return a data context for parsing a data query.
queryContext
in interface DataServiceProvider
version
- Data version.public void rollback()
Rollback the current server transaction.
rollback
in interface DataServiceProvider
public EntityValue selectEntity(EntityValue entity)
Return newly loaded copy of entity
with all structural properties selected.
entity
- Entity value.entity
with all structural properties selected.public java.lang.String serviceDocument(int format)
Return the service document, in XML or JSON format.
serviceDocument
in interface DataServiceProvider
format
- Data format (XML or JSON).public void setAutoBindEntities(boolean value)
Set should this provider automatically bind entities in InMemoryDatabase.createEntity
or InMemoryDatabase.updateEntity
, if bound entities are provided by the client. Defaults to true
.
value
- Should this provider automatically bind entities in InMemoryDatabase.createEntity
or InMemoryDatabase.updateEntity
, if bound entities are provided by the client. Defaults to true
.public void setAutoCreateChildren(boolean value)
Set should this provider automatically create children in InMemoryDatabase.createEntity
("deep insert" calls), if nested children are provided by the client. Defaults to true
.
value
- Should this provider automatically create children in InMemoryDatabase.createEntity
("deep insert" calls), if nested children are provided by the client. Defaults to true
.public void setAutoCreateParents(boolean value)
Set should this provider automatically create parents in InMemoryDatabase.createEntity
("deep insert" calls), if nested parents are provided by the client. Defaults to true
.
value
- Should this provider automatically create parents in InMemoryDatabase.createEntity
("deep insert" calls), if nested parents are provided by the client. Defaults to true
.public void setAutoDeleteChildren(boolean value)
Set should this provider automatically delete children in InMemoryDatabase.deleteEntity
("on delete" actions), if specified with OnDelete in the service metadata. Defaults to true
.
value
- Should this provider automatically delete children in InMemoryDatabase.deleteEntity
("on delete" actions), if specified with OnDelete in the service metadata. Defaults to true
.public void setAutoExpandItems(boolean value)
Set should this provider automatically expand children in InMemoryDatabase.executeQuery
, if requested in the client's query. Defaults to true
.
value
- Should this provider automatically expand children in InMemoryDatabase.executeQuery
, if requested in the client's query. Defaults to true
.public void setAutoGenerateKeys(boolean value)
Set should this provider automatically generate primary keys? Defaults to true
.
If the provider doesn't generate keys, then the client will have to generate them.
value
- Should this provider automatically generate primary keys? Defaults to `true`.public void setAutoUnbindEntities(boolean value)
Set should this provider automatically unbind entities in InMemoryDatabase.createEntity
or InMemoryDatabase.updateEntity
, if unbound entities are provided by the client. Defaults to true
.
value
- Should this provider automatically unbind entities in InMemoryDatabase.createEntity
or InMemoryDatabase.updateEntity
, if unbound entities are provided by the client. Defaults to true
.public void setEnableChangeTracking(boolean value)
Set should this provider be enabled for change tracking? Defaults to true
.
value
- Should this provider be enabled for change tracking? Defaults to true
.public void setMetadata(CsdlDocument value)
Set service metadata.
setMetadata
in interface DataServiceProvider
value
- Service metadata.public void setMetricProvider(boolean value)
Set is this provider used for data metrics?
value
- Is this provider used for data metrics?public void setUseClientProvidedKeys(boolean value)
Set should InMemoryDatabase.createEntity
use client-provided keys (when available), in preference to server-generated keys? Defaults to false
.
value
- Should InMemoryDatabase.createEntity
use client-provided keys (when available), in preference to server-generated keys? Defaults to false
.public void unbindEntities(EntityValue entity)
entity
- Entity parameter.public void unbindEntities(EntityValue entity, Property bindingProperty)
This function may be used in the implementation of entity binding calls, e.g. by EntityValue.unbindEntity
.
It relies on the existence of appropriate referential constraints in the service metadata.
entity
- Source entity, which may contain inline bindings for the binding property.bindingProperty
- (nullable) Binding property. If null
, then all of the source's navigation properties are considered.public void unloadMetadata()
Unload service metadata (if previously loaded).
unloadMetadata
in interface DataServiceProvider
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.
updateEntity
in interface DataServiceProvider
entity
- Entity to be updated.headers
- Request-specific headers.options
- Request-specific 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.
updateLink
in interface DataServiceProvider
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
- Request-specific headers.options
- Request-specific options.public void updateLinkUsingForeignKeys(EntityValue source, Property sourceProperty, EntityValue target)
Default implementation of 'updateLink' using foreign keys from referential constraints in service metadata.
source
- Source entity for the link to be created.sourceProperty
- Source navigation property for the link to be created. This may be a one-to-one or one-to-many navigation property.target
- Target entity for the link to be created.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
.
uploadMedia
in interface DataServiceProvider
entity
- Entity whose content is to be uploaded.content
- Upload stream content. Will be closed before this function returns.headers
- Request-specific headers.options
- Request-specific 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.
uploadStream
in interface DataServiceProvider
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
- Request-specific headers.options
- Request-specific options.