public class EntityValue extends StructureBase implements BindingPath
Encapsulates an OData entity value.
Constructor and Description |
---|
EntityValue()
|
EntityValue(boolean withDefaults)
|
EntityValue(boolean withDefaults,
EntityType type)
Construct a new entity value.
|
Modifier and Type | Method and Description |
---|---|
void |
bindEntity(EntityValue entity,
Property to)
Bind an entity to a property of the current entity.
|
static EntityValue |
castOptional(DataValue value)
For internal use only.
|
static EntityValue |
castRequired(DataValue value)
For internal use only.
|
static int |
compareKeys(EntityValue left,
EntityValue right)
Compare two entities for sorting by primary key.
|
EntityValue |
copyEntity()
Return a copy of this entity value (only structural properties are copied).
|
void |
copyKey(EntityValue from)
For internal use only.
|
void |
copyProperties(EntityValue from)
Copy structural/dynamic property values from source entity into this entity.
|
static boolean |
equal(EntityValue left,
EntityValue right)
Return
true if two entity values have equal structural properties. |
static boolean |
equalKeys(EntityValue left,
EntityValue right)
Return
true if two entity values have equal key properties. |
boolean |
getAllowConflicts()
Return
true if create/update/delete conflicts (duplicate key conflicts or optimistic concurrency conflicts) for this entity should not log/throw exceptions. |
java.lang.String |
getBackendEtag()
Return (nullable) Entity tag from backend system (may differ from
entityTag for entities used with SQLDatabaseProvider ). |
java.lang.String |
getCanonicalURL()
Return the canonical URL for this entity, relative to the service root URL.
|
DataType |
getDataType()
Return data type with a
DataType.code of DataType.ENTITY_VALUE. |
GlobalDateTime |
getDeltaTime()
Return (nullable) Can be used to hold the "last modified time" for a changed entity.
|
java.lang.String |
getEditLink()
Return (nullable) The edit link for this value, preferably relative to the service root URL.
|
java.lang.String |
getEntityID()
Return (nullable) OData entity id (IRI) for this entity, preferably relative to the service root URL.
|
EntityKey |
getEntityKey()
Return the entity key for this value.
|
EntitySet |
getEntitySet()
Return the entity set for this value.
|
java.lang.String |
getEntityTag()
Return (nullable) Server-generated entity tag for this entity.
|
EntityType |
getEntityType()
Return the entity type metadata for this value (
EntityValue.dataType cast to EntityType ). |
boolean |
getInErrorState()
Return
true if this entity is in error state, for example due to the failed backend execution of an uploaded offline create/update/delete operation. |
java.lang.Object |
getInternalData()
For internal use only.
|
StreamLink |
getMediaStream()
Return stream link for media entities.
|
boolean |
getMustBeModified()
Return
true if the entity must be modified by an update request, even if it is apparently unchanged. |
boolean |
getMustBeReloaded()
Return
true if the entity state must be reloaded (via loadEntity ) after a create/update request. |
boolean |
getNoLocalCascade()
Return
true if operations on this entity should not be locally cascaded to children. |
EntityValue |
getOldEntity()
Return (nullable) Contains the original values for all structural properties of this entity value.
|
EntityValue |
getParentEntity()
Return (nullable) Parent entity when this entity is to be created as a related child.
|
Property |
getParentProperty()
Return (nullable) Parent property when this entity is to be created as a related child.
|
java.lang.String |
getReadLink()
Return (nullable) The read link for this value, preferably relative to the service root URL.
|
int |
getSystemFlags()
For internal use only.
|
long |
getSystemKey()
Return system-generated unique numeric key for this entity.
|
int |
getTypeCode()
Return data type code of the wrapped value, equivalent to
dataType.code . |
boolean |
hasChangedBindings()
Return
true if this entity has binding-related changes. |
boolean |
hasConflict()
Return
true if a create/update/delete conflict was detected for this entity. |
boolean |
hasKey()
Return
true if this entity has a value for all key properties. |
java.lang.Boolean |
hasLocalRelatives()
Return (nullable)
true if the entity is related to entities which are local (entities that have local requests executed that have either not been sent
or have been sent but not yet downloaded). |
boolean |
hasPendingChanges()
Return
true if there are unsent requests in the request queue. |
java.lang.Boolean |
hasRelativesWithPendingChanges()
Return (nullable)
true if the entity is related to entities that have unsent requests in the request queue. |
EntityValue |
inSet(EntitySet set)
Change the entity set for this entity.
|
boolean |
isBinding()
Return
true if this object is an entity binding. |
boolean |
isCreated()
Return
true if this entity has just been created in the local database or backend system. |
boolean |
isDeleted()
Return
true if this entity has just been deleted from the local database or backend system. |
boolean |
isLocal()
Return
true if a change (create, update or delete) has been submitted to the local database, but not yet synchronized to the backend system. |
boolean |
isNew()
Return
true if this entity has been newly instantiated, but not yet created, updated or deleted
in the local database or backend system. |
boolean |
isNewOrChanged(Property property)
|
boolean |
isPatch()
Return
true if this entity is a patch, which DataServlet.updateEntity should apply. |
boolean |
isPatched()
Return
true if this entity was patched, before DataServlet.updateEntity was called. |
boolean |
isReference()
Return
true if this object is an entity reference. |
boolean |
isResolved()
Return 'true' if the entity was already resolved by CsdlDocument's resolveEntity
|
boolean |
isResolving()
Return 'true' if the entity is being resolved by CsdlDocument's resolveEntity
|
boolean |
isUpdated()
Return
true if this entity has just been updated in the local database or backend system. |
boolean |
isUpsert()
Return 'true' if the entity is being upserted
|
static EntityValue |
ofType(EntityType type)
Construct a new entity value of the specified type.
|
void |
rememberOld()
Remember the values of structural properties of this entity as the
EntityValue.oldEntity . |
void |
setAllowConflicts(boolean value)
Set
true if create/update/delete conflicts (duplicate key conflicts or optimistic concurrency conflicts) for this entity should not log/throw exceptions. |
void |
setBackendEtag(java.lang.String value)
Set entity tag from backend system (may differ from
entityTag for entities used with SQLDatabaseProvider ). |
void |
setBinding(boolean value)
Set
true if this object is an entity binding. |
void |
setChangedBindings(boolean value)
Set
true if this entity has binding-related changes. |
void |
setConflict(boolean value)
Set
true if a create/update/delete conflict was detected for this entity. |
void |
setCreated(boolean value)
Set
true if this entity has just been created in the local database or backend system. |
void |
setDeleted(boolean value)
Set
true if this entity has just been deleted from the local database or backend system. |
void |
setDeltaTime(GlobalDateTime value)
Set can be used to hold the "last modified time" for a changed entity.
|
void |
setEditLink(java.lang.String value)
Set the edit link for this value, preferably relative to the service root URL.
|
void |
setEntityID(java.lang.String value)
Set OData entity id (IRI) for this entity, preferably relative to the service root URL.
|
void |
setEntitySet(EntitySet value)
Set the entity set for this value.
|
void |
setEntityTag(java.lang.String value)
Set server-generated entity tag for this entity.
|
void |
setInErrorState(boolean value)
Set
true if this entity is in error state, for example due to the failed backend execution of an uploaded offline create/update/delete operation. |
void |
setInternalData(java.lang.Object value)
For internal use only.
|
void |
setLocal(boolean value)
Set
true if a change (create, update or delete) has been submitted to the local database, but not yet synchronized to the backend system. |
void |
setLocalRelatives(java.lang.Boolean value)
Set
true if the entity is related to entities which are local (entities that have local requests executed that have either not been sent
or have been sent but not yet downloaded). |
void |
setMediaStream(StreamLink value)
Set stream link for media entities.
|
void |
setMustBeModified(boolean value)
Set
true if the entity must be modified by an update request, even if it is apparently unchanged. |
void |
setMustBeReloaded(boolean value)
Set
true if the entity state must be reloaded (via loadEntity ) after a create/update request. |
void |
setNew(boolean value)
Set
true if this entity has been newly instantiated, but not yet created, updated or deleted
in the local database or backend system. |
void |
setNoLocalCascade(boolean value)
Set
true if operations on this entity should not be locally cascaded to children. |
void |
setOldEntity(EntityValue value)
Set contains the original values for all structural properties of this entity value.
|
void |
setParentEntity(EntityValue value)
Set parent entity when this entity is to be created as a related child.
|
void |
setParentProperty(Property value)
Set parent property when this entity is to be created as a related child.
|
void |
setPatch(boolean value)
Set
true if this entity is a patch, which DataServlet.updateEntity should apply. |
void |
setPatched(boolean value)
Set
true if this entity was patched, before DataServlet.updateEntity was called. |
void |
setPendingChanges(boolean value)
Set
true if there are unsent requests in the request queue. |
void |
setReadLink(java.lang.String value)
Set the read link for this value, preferably relative to the service root URL.
|
void |
setReference(boolean value)
Set
true if this object is an entity reference. |
void |
setRelativesWithPendingChanges(java.lang.Boolean value)
Set
true if the entity is related to entities that have unsent requests in the request queue. |
void |
setResolved(boolean value)
Set 'true' if the entity was already resolved by CsdlDocument's resolveEntity
|
void |
setResolving(boolean value)
Set 'true' if the entity is being resolved by CsdlDocument's resolveEntity
|
void |
setSystemFlags(int value)
For internal use only.
|
void |
setSystemKey(long value)
Set system-generated unique numeric key for this entity.
|
void |
setUpdated(boolean value)
Set
true if this entity has just been updated in the local database or backend system. |
void |
setUpsert(boolean value)
Set 'true' if the entity is being upserted
|
java.lang.String |
toString()
Convert this data value to a string.
|
void |
unbindEntity(EntityValue entity,
Property from)
Unbind an entity from a property of the current entity.
|
void |
withBackendState(com.sap.cloud.server.odata.core.Action0 action)
Execute
action with entity.entityTag temporarily changed to be equal to backendEtag , and 'entity.oldEntity' == null . |
EntityValue |
withKey(EntityKey key)
Change the primary key for this entity.
|
void |
withLock(com.sap.cloud.server.odata.core.Action0 work)
Perform some
work within an instance-level exclusive lock. |
getDataValue, getDynamic, getDynamicProperties, getNextLink, getOptionalValue, getRequiredValue, getStreamLink, getStructureType, getValuePath, hasDataType, hasDataValue, hasDynamicProperties, hasNextLink, isNull, isProxy, setDataValue, setDefaultValues, setDefaultValues, setDefaultValues, setDefaultValues, setDefaultValues, setDefaultValues, setDynamic, setDynamicProperties, setNull, setOptionalValue, setRequiredValue, setValuePath, unsetDataValue
cloneMutable, equals, hashCode
public EntityValue()
public EntityValue(boolean withDefaults)
withDefaults
- WithDefaults parameter.public EntityValue(boolean withDefaults, EntityType type)
Construct a new entity value.
This constructor is intended for use by custom entity value subclasses.
Use EntityValue.ofType
for regular construction.
withDefaults
- Should EntityValue.setDefaultValues
be called to initialize properties with default values?type
- (nullable) Entity type. Should not be null
except when called by generated proxy base classes.public void bindEntity(EntityValue entity, Property to)
Bind an entity to a property of the current entity.
This can be used before DataService.createEntity
or DataService.updateEntity
to create or update the bindings of navigation properties.
public void bindEntityExample() { NorthwindService service = this.getService(); DataQuery categoryQuery = new DataQuery().top(1).expand(Category.products); Category category = service.getCategory(categoryQuery); DataQuery productQuery = new DataQuery().top(1); Product product = service.getProduct(productQuery); category.bindEntity(product, Category.products); service.updateEntity(category); }
public void bindEntityExample() { DataService service = this.getService(); EntitySet categoriesEntitySet = service.getEntitySet("Categories"); EntitySet productsEntitySet = service.getEntitySet("Products"); EntityType categoryEntityType = categoriesEntitySet.getEntityType(); Property productsProperty = categoryEntityType.getProperty("Products"); DataQuery categoryQuery = new DataQuery().from(categoriesEntitySet).top(1) .expand(productsProperty); EntityValue category = service.executeQuery(categoryQuery) .getRequiredEntity(); DataQuery productQuery = new DataQuery().from(productsEntitySet).top(1); EntityValue product = service.executeQuery(productQuery) .getRequiredEntity(); category.bindEntity(product, productsProperty); service.updateEntity(category); }
entity
- Entity to be bound.to
- Property the entity will be bound to.public static EntityValue castOptional(DataValue value)
For internal use only.
value
- (internal use only)public static EntityValue castRequired(DataValue value)
For internal use only.
value
- (internal use only)public static int compareKeys(EntityValue left, EntityValue right)
Compare two entities for sorting by primary key.
left
- (nullable) First entity for comparison.right
- (nullable) Second entity for comparison.left
is equal to right
in sorted order, a negative value (e.g. -1) if left
is less than right
in sorted order, or a positive value (e.g. 1) if left
is greater than right
in sorted order.public EntityValue copyEntity()
Return a copy of this entity value (only structural properties are copied).
public void copyKey(EntityValue from)
For internal use only.
from
- (internal use only)public void copyProperties(EntityValue from)
Copy structural/dynamic property values from source entity into this entity.
from
- Source entity.public static boolean equal(EntityValue left, EntityValue right)
Return true
if two entity values have equal structural properties.
left
- (nullable) First entity value.right
- (nullable) Second entity value.true
if two entity values have equal structural properties.public static boolean equalKeys(EntityValue left, EntityValue right)
Return true
if two entity values have equal key properties.
left
- (nullable) First entity value.right
- (nullable) Second entity value.true
if two entity values have equal key properties.public boolean getAllowConflicts()
Return true
if create/update/delete conflicts (duplicate key conflicts or optimistic concurrency conflicts) for this entity should not log/throw exceptions.
true
if create/update/delete conflicts (duplicate key conflicts or optimistic concurrency conflicts) for this entity should not log/throw exceptions.public java.lang.String getBackendEtag()
Return (nullable) Entity tag from backend system (may differ from entityTag
for entities used with SQLDatabaseProvider
).
entityTag
for entities used with SQLDatabaseProvider
).public java.lang.String getCanonicalURL()
Return the canonical URL for this entity, relative to the service root URL. Uses OData V4 URL conventions.
Use QueryFormatter.formatCanonicalURL
to obtain a canonical URL that is OData version-appropriate.
public DataType getDataType()
Return data type with a DataType.code
of DataType.ENTITY_VALUE.
getDataType
in class DataValue
DataType.code
of DataType.ENTITY_VALUE.public GlobalDateTime getDeltaTime()
Return (nullable) Can be used to hold the "last modified time" for a changed entity.
public java.lang.String getEditLink()
Return (nullable) The edit link for this value, preferably relative to the service root URL.
If an entity does not have an explicit edit link, then writers should use the EntityValue.valuePath
,
or if that is not set, then a canonical URL (refer to the OData specification).
public java.lang.String getEntityID()
Return (nullable) OData entity id (IRI) for this entity, preferably relative to the service root URL. If an entity does not have an explicit entity id, then callers should use the canonical URL.
public EntityKey getEntityKey()
Return the entity key for this value.
public EntitySet getEntitySet()
Return the entity set for this value.
public java.lang.String getEntityTag()
Return (nullable) Server-generated entity tag for this entity.
If non-null, it is used for conflict detection during
DataService.updateEntity
and DataService.deleteEntity
calls.
public EntityType getEntityType()
Return the entity type metadata for this value (EntityValue.dataType
cast to EntityType
).
EntityValue.dataType
cast to EntityType
).public boolean getInErrorState()
Return true
if this entity is in error state, for example due to the failed backend execution of an uploaded offline create/update/delete operation.
If true, then one of EntityValue.isCreated
, EntityValue.isUpdated
or EntityValue.isDeleted
should also be true to indicate the kind of failed operation.
In some cases (e.g. system unable to distinguish create from update due to "upsert" behaviour) then EntityValue.isCreated
, EntityValue.isUpdated
and EntityValue.isDeleted
might all be false
.
true
if this entity is in error state, for example due to the failed backend execution of an uploaded offline create/update/delete operation.public java.lang.Object getInternalData()
For internal use only.
public StreamLink getMediaStream()
Return stream link for media entities. Should not be used with non-media entities.
public boolean getMustBeModified()
Return true
if the entity must be modified by an update request, even if it is apparently unchanged.
This ensures that DataService.updateEntity
will force an update in the backend database/system.
true
if the entity must be modified by an update request, even if it is apparently unchanged.public boolean getMustBeReloaded()
Return true
if the entity state must be reloaded (via loadEntity
) after a create/update request.
ServiceOptions.loadIfCreateStatus
, ServiceOptions.loadIfUpdateStatus
.
public boolean getNoLocalCascade()
Return true
if operations on this entity should not be locally cascaded to children.
true
if operations on this entity should not be locally cascaded to children.public EntityValue getOldEntity()
Return (nullable) Contains the original values for all structural properties of this entity value.
Used by DataService.updateEntity
to determine the changed properties for PATCH requests.
public EntityValue getParentEntity()
Return (nullable) Parent entity when this entity is to be created as a related child.
public Property getParentProperty()
Return (nullable) Parent property when this entity is to be created as a related child.
public java.lang.String getReadLink()
Return (nullable) The read link for this value, preferably relative to the service root URL.
If an entity does not have an explicit read link, then readers should use the EntityValue.valuePath
,
or if that is not set, then a canonical URL (refer to the OData specification).
public int getSystemFlags()
For internal use only.
public long getSystemKey()
Return system-generated unique numeric key for this entity. For internal use. Should not be changed by application code.
public int getTypeCode()
Return data type code of the wrapped value, equivalent to dataType.code
.
getTypeCode
in class DataValue
dataType.code
.public boolean hasChangedBindings()
Return true
if this entity has binding-related changes.
public boolean hasConflict()
Return true
if a create/update/delete conflict was detected for this entity.
true
if a create/update/delete conflict was detected for this entity.public boolean hasKey()
Return true
if this entity has a value for all key properties.
true
if this entity has a value for all key properties.public java.lang.Boolean hasLocalRelatives()
Return (nullable) true
if the entity is related to entities which are local (entities that have local requests executed that have either not been sent
or have been sent but not yet downloaded).
true
if the entity is related to entities which are local (entities that have local requests executed that have either not been sentpublic boolean hasPendingChanges()
Return true
if there are unsent requests in the request queue.
true
if there are unsent requests in the request queue.public java.lang.Boolean hasRelativesWithPendingChanges()
Return (nullable) true
if the entity is related to entities that have unsent requests in the request queue.
true
if the entity is related to entities that have unsent requests in the request queue.public EntityValue inSet(EntitySet set)
Change the entity set for this entity.
Having a non-null entity set is optional if only one entity set in the DataService
uses the entity type,
but is required (before DataService.createEntity
is called) if multiple entity sets use the same entity type.
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 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)); }
set
- Entity set.public boolean isBinding()
Return true
if this object is an entity binding.
The isReference
property should also be true
for bindings.
public boolean isCreated()
Return true
if this entity has just been created in the local database or backend system.
true
if this entity has just been created in the local database or backend system.public boolean isDeleted()
Return true
if this entity has just been deleted from the local database or backend system.
true
if this entity has just been deleted from the local database or backend system.public boolean isLocal()
Return true
if a change (create, update or delete) has been submitted to the local database, but not yet synchronized to the backend system.
true
if a change (create, update or delete) has been submitted to the local database, but not yet synchronized to the backend system.public boolean isNew()
Return true
if this entity has been newly instantiated, but not yet created, updated or deleted
in the local database or backend system.
true
if this entity has been newly instantiated, but not yet created, updated or deletedpublic boolean isNewOrChanged(Property property)
Return true
if the value of property property
is new or changed, relative to EntityValue.oldEntity
.
isNewOrChanged
in class StructureBase
property
- Structural property.true
if the value of property property
is new or changed, relative to EntityValue.oldEntity
.public boolean isPatch()
Return true
if this entity is a patch, which DataServlet.updateEntity
should apply.
true
if this entity is a patch, which DataServlet.updateEntity
should apply.public boolean isPatched()
Return true
if this entity was patched, before DataServlet.updateEntity
was called.
true
if this entity was patched, before DataServlet.updateEntity
was called.public boolean isReference()
Return true
if this object is an entity reference. If true
, the EntityValue.editLink
and/or EntityValue.readLink
will be non-null, or the key properties will be available.
Non-key properties will not be available.
true
if this object is an entity reference. If true
, the EntityValue.editLink
and/or EntityValue.readLink
will be non-null, or the key properties will be available.public boolean isResolved()
Return 'true' if the entity was already resolved by CsdlDocument's resolveEntity
public boolean isResolving()
Return 'true' if the entity is being resolved by CsdlDocument's resolveEntity
public boolean isUpdated()
Return true
if this entity has just been updated in the local database or backend system.
true
if this entity has just been updated in the local database or backend system.public boolean isUpsert()
Return 'true' if the entity is being upserted
public static EntityValue ofType(EntityType type)
Construct a new entity value of the specified type.
type
- Entity type for the new value.public void rememberOld()
Remember the values of structural properties of this entity as the EntityValue.oldEntity
.
public void setAllowConflicts(boolean value)
Set true
if create/update/delete conflicts (duplicate key conflicts or optimistic concurrency conflicts) for this entity should not log/throw exceptions.
value
- true
if create/update/delete conflicts (duplicate key conflicts or optimistic concurrency conflicts) for this entity should not log/throw exceptions.public void setBackendEtag(java.lang.String value)
Set entity tag from backend system (may differ from entityTag
for entities used with SQLDatabaseProvider
).
value
- Entity tag from backend system (may differ from entityTag
for entities used with SQLDatabaseProvider
).public void setBinding(boolean value)
Set true
if this object is an entity binding.
The isReference
property should also be true
for bindings.
value
- `true` if this object is an entity binding.public void setChangedBindings(boolean value)
Set true
if this entity has binding-related changes.
value
- `true` if this entity has binding-related changes.public void setConflict(boolean value)
Set true
if a create/update/delete conflict was detected for this entity.
value
- true
if a create/update/delete conflict was detected for this entity.public void setCreated(boolean value)
Set true
if this entity has just been created in the local database or backend system.
value
- true
if this entity has just been created in the local database or backend system.public void setDeleted(boolean value)
Set true
if this entity has just been deleted from the local database or backend system.
value
- true
if this entity has just been deleted from the local database or backend system.public void setDeltaTime(GlobalDateTime value)
Set can be used to hold the "last modified time" for a changed entity.
value
- Can be used to hold the "last modified time" for a changed entity.public void setEditLink(java.lang.String value)
Set the edit link for this value, preferably relative to the service root URL.
If an entity does not have an explicit edit link, then writers should use the EntityValue.valuePath
,
or if that is not set, then a canonical URL (refer to the OData specification).
value
- The edit link for this value, preferably relative to the service root URL.public void setEntityID(java.lang.String value)
Set OData entity id (IRI) for this entity, preferably relative to the service root URL. If an entity does not have an explicit entity id, then callers should use the canonical URL.
value
- OData entity id (IRI) for this entity, preferably relative to the service root URL.public void setEntitySet(EntitySet value)
Set the entity set for this value.
value
- The entity set for this value.public void setEntityTag(java.lang.String value)
Set server-generated entity tag for this entity.
If non-null, it is used for conflict detection during
DataService.updateEntity
and DataService.deleteEntity
calls.
value
- Server-generated entity tag for this entity.public void setInErrorState(boolean value)
Set true
if this entity is in error state, for example due to the failed backend execution of an uploaded offline create/update/delete operation.
If true, then one of EntityValue.isCreated
, EntityValue.isUpdated
or EntityValue.isDeleted
should also be true to indicate the kind of failed operation.
In some cases (e.g. system unable to distinguish create from update due to "upsert" behaviour) then EntityValue.isCreated
, EntityValue.isUpdated
and EntityValue.isDeleted
might all be false
.
value
- true
if this entity is in error state, for example due to the failed backend execution of an uploaded offline create/update/delete operation.public void setInternalData(java.lang.Object value)
For internal use only.
value
- (internal use only)public void setLocal(boolean value)
Set true
if a change (create, update or delete) has been submitted to the local database, but not yet synchronized to the backend system.
value
- true
if a change (create, update or delete) has been submitted to the local database, but not yet synchronized to the backend system.public void setLocalRelatives(java.lang.Boolean value)
Set true
if the entity is related to entities which are local (entities that have local requests executed that have either not been sent
or have been sent but not yet downloaded).
value
- true
if the entity is related to entities which are local (entities that have local requests executed that have either not been sentpublic void setMediaStream(StreamLink value)
Set stream link for media entities. Should not be used with non-media entities.
value
- Stream link for media entities. Should not be used with non-media entities.public void setMustBeModified(boolean value)
Set true
if the entity must be modified by an update request, even if it is apparently unchanged.
This ensures that DataService.updateEntity
will force an update in the backend database/system.
value
- true
if the entity must be modified by an update request, even if it is apparently unchanged.public void setMustBeReloaded(boolean value)
Set true
if the entity state must be reloaded (via loadEntity
) after a create/update request.
ServiceOptions.loadIfCreateStatus
, ServiceOptions.loadIfUpdateStatus
.
value
- `true` if the entity state must be reloaded (via `loadEntity`) after a create/update request.public void setNew(boolean value)
Set true
if this entity has been newly instantiated, but not yet created, updated or deleted
in the local database or backend system.
value
- true
if this entity has been newly instantiated, but not yet created, updated or deletedpublic void setNoLocalCascade(boolean value)
Set true
if operations on this entity should not be locally cascaded to children.
value
- true
if operations on this entity should not be locally cascaded to children.public void setOldEntity(EntityValue value)
Set contains the original values for all structural properties of this entity value.
Used by DataService.updateEntity
to determine the changed properties for PATCH requests.
value
- Contains the original values for all structural properties of this entity value.public void setParentEntity(EntityValue value)
Set parent entity when this entity is to be created as a related child.
value
- Parent entity when this entity is to be created as a related child.public void setParentProperty(Property value)
Set parent property when this entity is to be created as a related child.
value
- Parent property when this entity is to be created as a related child.public void setPatch(boolean value)
Set true
if this entity is a patch, which DataServlet.updateEntity
should apply.
value
- true
if this entity is a patch, which DataServlet.updateEntity
should apply.public void setPatched(boolean value)
Set true
if this entity was patched, before DataServlet.updateEntity
was called.
value
- true
if this entity was patched, before DataServlet.updateEntity
was called.public void setPendingChanges(boolean value)
Set true
if there are unsent requests in the request queue.
value
- true
if there are unsent requests in the request queue.public void setReadLink(java.lang.String value)
Set the read link for this value, preferably relative to the service root URL.
If an entity does not have an explicit read link, then readers should use the EntityValue.valuePath
,
or if that is not set, then a canonical URL (refer to the OData specification).
value
- The read link for this value, preferably relative to the service root URL.public void setReference(boolean value)
Set true
if this object is an entity reference. If true
, the EntityValue.editLink
and/or EntityValue.readLink
will be non-null, or the key properties will be available.
Non-key properties will not be available.
value
- true
if this object is an entity reference. If true
, the EntityValue.editLink
and/or EntityValue.readLink
will be non-null, or the key properties will be available.public void setRelativesWithPendingChanges(java.lang.Boolean value)
Set true
if the entity is related to entities that have unsent requests in the request queue.
value
- true
if the entity is related to entities that have unsent requests in the request queue.public void setResolved(boolean value)
Set 'true' if the entity was already resolved by CsdlDocument's resolveEntity
value
- 'true' if the entity was already resolved by CsdlDocument's resolveEntitypublic void setResolving(boolean value)
Set 'true' if the entity is being resolved by CsdlDocument's resolveEntity
value
- 'true' if the entity is being resolved by CsdlDocument's resolveEntitypublic void setSystemFlags(int value)
For internal use only.
value
- (internal use only)public void setSystemKey(long value)
Set system-generated unique numeric key for this entity. For internal use. Should not be changed by application code.
value
- System-generated unique numeric key for this entity.public void setUpdated(boolean value)
Set true
if this entity has just been updated in the local database or backend system.
value
- true
if this entity has just been updated in the local database or backend system.public void setUpsert(boolean value)
Set 'true' if the entity is being upserted
value
- 'true' if the entity is being upsertedpublic java.lang.String toString()
Convert this data value to a string.
If the EntityValue.dataType
is defined by XML Schema Part 2: Datatypes, then the corresponding lexical format is used.
JSON format is used for structured values (arrays and objects).
public void unbindEntity(EntityValue entity, Property from)
Unbind an entity from a property of the current entity.
This can be used before DataService.createEntity
or DataService.updateEntity
to create or update the bindings of navigation properties.
public void unbindEntityExample() { NorthwindService service = this.getService(); DataQuery categoryQuery = new DataQuery().top(1).expand(Category.products); Category category = service.getCategory(categoryQuery); Product__List products = category.getProducts(); if (products.length() != 0) { Product product = products.first(); category.unbindEntity(product, Category.products); } service.updateEntity(category); }
public void unbindEntityExample() { DataService service = this.getService(); EntitySet categoriesEntitySet = service.getEntitySet("Categories"); EntityType categoryEntityType = categoriesEntitySet.getEntityType(); Property productsProperty = categoryEntityType.getProperty("Products"); DataQuery categoryQuery = new DataQuery().from(categoriesEntitySet).top(1) .expand(productsProperty); EntityValue category = service.executeQuery(categoryQuery) .getRequiredEntity(); EntityValueList products = productsProperty.getEntityList(category); if (products.length() != 0) { EntityValue product = products.first(); category.unbindEntity(product, productsProperty); } service.updateEntity(category); }
entity
- (nullable) Entity to be unbound. Can be null
for unbinding an entity from a single-valued navigation property.from
- Property the entity will be unbound from.public void withBackendState(com.sap.cloud.server.odata.core.Action0 action)
Execute action
with entity.entityTag
temporarily changed to be equal to backendEtag
, and 'entity.oldEntity' == null
.
After execution, restore entity.entityTag
and entity.oldEntity
.
action
- Action to be executed with backend state.public EntityValue withKey(EntityKey key)
Change the primary key for this entity.
key
- Primary keypublic void withLock(com.sap.cloud.server.odata.core.Action0 work)
Perform some work
within an instance-level exclusive lock.
work
- Work to be executed within an instance-level exclusive lock.