Package com.orchestranetworks.service

# Interface ValueContextForUpdate

All Superinterfaces:
  `ValueContext`

public interface ValueContextForUpdate extends ValueContext
This container interface provides the possibility of setting values on persisted or transient content whose structure and types conform to an underlying data model.

#### Path interpretation

This interface has the following specificity regarding the way `paths` are interpreted in path-based methods (`ValueContext.getValue(Path)`, `ValueContext.getNode(Path)`, `setValue(Object, Path)`, etc.): if the specified path is absolute and this context is a record, it starts at the record root (not the dataset root).

See Also:
  - `ProcedureContext.getContext(AdaptationName)`
  - `ProcedureContext.getContextForNewOccurrence(AdaptationTable)`

- ## Nested Class Summary

  Nested Classes
  Modifier and Type
  Interface
  Description
  `static enum`
  `ValueContextForUpdate.ValidationPolicy`
  Defines the policy for validating this content.

- ## Method Summary

  Modifier and Type
  Method
  Description
  `ValidationReport`
  `getValidationReport()`
  Returns the validation report of this content.
  `ValidationReport`
  `getValidationReport(ValueContextForUpdate.ValidationPolicy aPolicy)`
  Returns the validation report of this content.
  `void`
  `setPrivilegeForNode(Path aNodePath)`
  Disables all permission checks for the specified node during the current operation.
  `void`
  `setValue(Object aValue, Path aPath)`
  Sets the value of the specified node.
  `void`
  `setValue(Object aValue, SchemaNode aNode)`
  Sets the value of the specified node.
  `void`
  `setValueEnablingPrivilegeForNode(Object aValue, Path aNodePath)`
  Utility method to set a value for the specified node while disabling all permission checks for this node.
  `void`
  `setValueFromXsString(String aString, Path aPath)`
  Sets the string value specified.
  `void`
  `setValueFromXsString(String aString, SchemaNode aNode)`
  Sets the string value specified.

  ### Methods inherited from interface com.orchestranetworks.instance.ValueContext

  `getAdaptationInstance, getAdaptationTable, getHome, getNode, getNode, getValue, getValue, getValue`

- ## Method Details

  - ### setValue

    void setValue(Object aValue, Path aPath) throws UnavailableContentError, PathAccessException, IllegalArgumentException
    Sets the value of the specified node. The value's Java type must be consistent with the data model node type.

    For a terminal node, the value `AdaptationValue.INHERIT_VALUE` can be set to specify that a node inherits its value from the parent dataset (this is the default value for any newly created dataset).

    The container will validate the value against the data model type and constraints when the transaction is committed.

    Permissions on the specified node will be evaluated before committing the changes, except when some extra privileges are granted in the containing trigger or procedure context. See `setPrivilegeForNode(Path)` and `ProcedureContext.setAllPrivileges(boolean)` for more information.

    ##### Access and mapping rules

    The access and mapping rules between XML Schema and Java are described in the chapter Mapping to Java.

    Throws:
      `UnavailableContentError` - If content has become unavailable due to a data model error.
      `PathAccessException` - If the specified node does not exist.
      `IllegalArgumentException` - If:
      - the specified node cannot be written;
      - the specified value is not consistent with the data model node type;
      - the specified node is under an aggregated list;
      - the specified node is under a terminal node and the value to set is the value `AdaptationValue.INHERIT_VALUE`.

  - ### setValue

    void setValue(Object aValue, SchemaNode aNode) throws UnavailableContentError, PathAccessException, IllegalArgumentException
    Sets the value of the specified node.
    Throws:
      `UnavailableContentError`
      `PathAccessException`
      `IllegalArgumentException`
    Since:
      6.0.0
    See Also:
      - `setValue(Object, Path)`

  - ### setValueFromXsString

    void setValueFromXsString(String aString, Path aPath) throws UnavailableContentError, PathAccessException
    Sets the string value specified. The string must comply with the standard representation of the associated type, as specified by XML Schema.

    This method first converts the specified string, then invokes `setValue(Object, Path)`.

    Permissions on the specified node will be evaluated before committing the changes, except when some extra privileges are granted in the containing trigger or procedure context. See `setPrivilegeForNode(Path)` and `ProcedureContext.setAllPrivileges(boolean)` for more information.

    ##### Access and mapping rules

    The access and mapping rules between XML Schema and Java are described in the chapter Mapping to Java.

    Throws:
      `UnavailableContentError`
      `PathAccessException`
    See Also:
      - `SchemaNode.parseXsString(String)`

  - ### setValueFromXsString

    void setValueFromXsString(String aString, SchemaNode aNode) throws UnavailableContentError, PathAccessException
    Sets the string value specified.
    Throws:
      `UnavailableContentError`
      `PathAccessException`
    Since:
      6.0.0
    See Also:
      - `setValueFromXsString(java.lang.String, com.orchestranetworks.schema.Path)`

  - ### setPrivilegeForNode

    void setPrivilegeForNode(Path aNodePath) throws PathAccessException, IllegalArgumentException
    Disables all permission checks for the specified node during the current operation.

    ##### Privilege scope

    The privilege is granted for the whole update or create operation of the current record or dataset, but does not apply to the UI. This implies that permission checks for the specified node will be skipped until the operation is over. This privilege can be granted by a trigger, or in a procedure.

    For instance, given a user with read-only permission on the specified node:

    - an import user service launched by this user could still set a value for this node.
    - a procedure executed with this user session and with `setAllPrivileges(false)` could still set a value for this node.
    - a SOAP data service call with this user session could still set a value for this node.
    - any trigger with no privilege granted could still set a value for this node when multiple triggers are specified by the data model. Indeed, all triggers implied in the operation are affected by the privilege.
    Throws:
      `PathAccessException` - If the specified node does not exist.
      `IllegalArgumentException` - If the specified node is not terminal or `null`.
    Since:
      5.8.0

  - ### setValueEnablingPrivilegeForNode

    void setValueEnablingPrivilegeForNode(Object aValue, Path aNodePath) throws UnavailableContentError, PathAccessException, IllegalArgumentException
    Utility method to set a value for the specified node while disabling all permission checks for this node.

    This is the same as calling `setPrivilegeForNode(Path)` and `setValue(Object, Path)` successively. As a consequence, the privilege is granted beyond the invocation of this method, as specified by `setPrivilegeForNode(Path)`.

    Throws:
      `UnavailableContentError` - If content has become unavailable due to a data model error.
      `PathAccessException` - If the specified node does not exist.
      `IllegalArgumentException` - If:
      - the specified node cannot be written;
      - the specified value is not consistent with the data model node type;
      - the specified node is under an aggregated list;
      - the specified node is under a terminal node and the value to set is the `AdaptationValue.INHERIT_VALUE`.
    Since:
      5.9.0
    See Also:
      - Privilege scope

  - ### getValidationReport

    ValidationReport getValidationReport()
    Returns the validation report of this content.

    This method is equivalent to:

    > `ValueContextForUpdate#getValidationReport(ValidationPolicy.ALL);`

    Since:
      6.0.0
    See Also:
      - `getValidationReport(ValidationPolicy)`

  - ### getValidationReport

    ValidationReport getValidationReport(ValueContextForUpdate.ValidationPolicy aPolicy)
    Returns the validation report of this content.

    If this is a `dataset`, the validation takes into account the constraints defined by the underlying data model and only on the fields that are outside a table. That is, tables are not validated when validating a dataset.

    If this is a `table record`, all the constraints defined under the table and the `record-level checks in the table controls` are taken into account.

    Important:

    - Values of nodes that define an auto-increment (specified in the data model using the `osd:autoIncrement` element) or a function (specified in the data model using an `osd:function` element) are not set if this content is a new `table record`. That is, constraints defined by these nodes are not checked if this content is a new `table record`.
    - The validation message threshold defined in the EBX® main configuration file is ignored. That is, the validation of this content is not interrupted when the threshold is reached by a constraint and a severity.
    - A `validation item` with a `severity fatal` is added to the returned validation report if an unexpected error occurs during the validation of this content.

    The report returned by this method is not affected by modifications performed after this method is called. The rules for ensuring that data in EBX® remains valid, despite potential concurrent updates, are explained in the section Consistency and validation.

    Since:
      6.0.0
    See Also:
      - `Adaptation.getValidationReport()`