public interface ProcedureContext
Procedure.execute(ProcedureContext)
Modifier and Type | Method and Description |
---|---|
void |
disableDatasetValidation(Adaptation aDataset)
Deprecated.
Since 6.0.0,
incremental validation is no longer
triggered by a procedure. As a consequence
this method has no effects.
|
Adaptation |
doCopy(Adaptation aDataSet)
Copies the specified dataset.
|
Adaptation |
doCopy(AdaptationReference aName,
Adaptation aDataSet)
Copies the specified dataset and gives it the specified reference.
|
Adaptation |
doCreateChild(AdaptationName aParentName,
AdaptationReference requestedNameOrNull)
Creates a new dataset that is the child of the parent specified by
aParentName . |
Adaptation |
doCreateChild(AdaptationName aParentName,
AdaptationReference requestedNameOrNull,
Profile owner)
Creates a new dataset that is the child of the parent specified by
aParentName . |
Adaptation |
doCreateOcculting(ValueContext aKey,
AdaptationTable aTable)
Creates an occulting record in the specified table.
|
Adaptation |
doCreateOccurrence(ValueContext aContent,
AdaptationTable aTable)
Creates a record in the specified table.
|
Adaptation |
doCreateOverwriting(ValueContext aContent,
AdaptationTable aTable)
Deprecated.
|
Adaptation |
doCreateRoot(SchemaLocation aSchemaLocation,
AdaptationReference requestedNameOrNull,
Profile owner)
Creates a new root dataset.
|
Adaptation |
doCreateRoot(ValueContext aContent,
AdaptationTable aTable)
Deprecated.
|
void |
doDelete(AdaptationName aName,
boolean isDeletingChildren)
Deletes the specified dataset or record.
|
void |
doExport(ExportSpec aSpec)
Performs an export to an XML or CSV document.
|
void |
doExportArchive(Archive anArchive)
Exports the current dataspace or snapshot to the specified EBX® archive.
|
void |
doExportArchive(ArchiveExportSpec exportSpec)
Performs an export to an EBX® archive.
|
ImportResult |
doImport(ImportSpec aSpec)
Imports XML or CSV content.
|
void |
doImportArchive(Archive anArchive)
Imports the EBX® archive into the current dataspace.
|
void |
doImportArchive(ArchiveImportSpec importSpec)
Imports the EBX® archive into the current dataspace with specifications.
|
void |
doMergeToParent(AdaptationHome aSource)
Merges the specified dataspace to the current dataspace.
|
void |
doMergeToParent(MergeSpecForHome aMergeSpec)
Performs the specified merge into the current dataspace.
|
Adaptation |
doModifyContent(Adaptation aTarget,
ValueContext aContent)
Modifies the content as specified.
|
Adaptation |
doOccult(Adaptation aRecord)
Occults the specified record.
|
AdaptationHome |
getAdaptationHome()
Returns the current dataspace.
|
int |
getCommitThreshold() |
ValueContextForUpdate |
getContext(AdaptationName aName)
Provides an interface for reading and/or updating persisted content.
|
ValueContextForUpdate |
getContext(boolean isTriggerActivation,
ValueContextForUpdate contextToCopy,
AdaptationTable aTable)
Provides an interface for setting values on a context that conforms to any record of the
specified table.
|
ValueContextForUpdate |
getContextForNewOccurrence(Adaptation recordToCopy,
AdaptationTable aTable)
Provides an interface for copying a context from an existing record.
|
ValueContextForUpdate |
getContextForNewOccurrence(AdaptationTable aTable)
Provides an interface for setting values on a context that conforms to any record of the
specified table.
|
String |
getExecutionInformation() |
Date |
getExecutionTimestamp()
Returns the timestamp of the current procedure execution.
|
String |
getExecutionUUIDString()
Returns a universally unique identifier (UUID) for the current procedure execution.
|
Session |
getSession()
Returns the current session context.
|
boolean |
isAllPrivileges()
Default value is
false . |
boolean |
isBlockingConstraintsDisabled()
Returns
true if blocking constraints are disabled; by default, blocking constraints are enabled. |
boolean |
isDatabaseHistoryActivation() |
boolean |
isHistoryActivation() |
boolean |
isPrivilegeToModifyReferenceBranch()
Deprecated.
Since version 5.0.0, the 'Reference' dataspace no longer has restricted behavior
concerning direct modifications. This method always returns
true . |
boolean |
isReadOnly()
Returns
true if called within a ReadOnlyProcedure . |
boolean |
isTriggerActivation() |
void |
setAllPrivileges(boolean allPrivileges)
If
true , disables all permission checks for future operations
performed by the current run. |
default void |
setBatch()
Deprecated.
since 6.0. This method used to make sense only for relational tables;
it now has no use.
|
void |
setBlockingConstraintsDisabled(boolean isDisabled)
Disables or enables blocking constraints
defined in the data model.
|
void |
setCommitThreshold(int commitThreshold)
Sets the maximum size of the transaction so that intermediate commits occur
during the execution of the procedure.
|
void |
setDatabaseHistoryActivation(boolean isActivated)
Enables database history.
|
void |
setExecutionInformation(String aString)
Specifies some additional information about the current execution.
|
void |
setHistoryActivation(boolean isActivated)
Specifies whether the detailed XML audit trail is activated.
|
void |
setInstanceActivation(Adaptation aDataSet,
boolean activationState)
Activates or deactivates the specified dataset.
|
void |
setInstanceDescription(Adaptation aDataSet,
UserMessage aDescription)
Specifies a description for the specified dataset.
|
void |
setInstanceLabel(Adaptation aDataSet,
UserMessage aLabel)
Specifies a label for the specified dataset.
|
void |
setInstanceOwner(Adaptation aDataSet,
Profile newOwner)
Defines the owner of the specified dataset.
|
void |
setPrivilegeToModifyReferenceBranch(boolean enable)
Deprecated.
Since version 5.0.0, the 'Reference' dataspace no longer has restricted behavior
concerning direct modifications. This method does nothing.
|
void |
setTriggerActivation(boolean isActivated)
Enables or disables triggers.
|
Adaptation doCreateRoot(SchemaLocation aSchemaLocation, AdaptationReference requestedNameOrNull, Profile owner) throws OperationException
aSchemaLocation
- Specifies the data model of the dataset to create. It must refer to a valid existing
XML data model.requestedNameOrNull
- Specifies the public and persistent reference of the dataset to
create. If null
, the reference is allocated randomly.owner
- Specifies the profile that will own the newly created dataset (required).IllegalArgumentException
- if the identifier does not conform to AdaptationReference.MAX_LENGTH
and AdaptationReference.REFERENCE_PATTERN
.OperationException
doCreateChild(AdaptationName, AdaptationReference)
,
doCreateChild(AdaptationName, AdaptationReference, Profile)
Adaptation doCreateChild(AdaptationName aParentName, AdaptationReference requestedNameOrNull) throws OperationException
aParentName
.aParentName
- Specifies the parent of the dataset to create. It must refer to an existing dataset
in the current dataspace.requestedNameOrNull
- Specifies the public and persistent reference of the dataset to
create. If null
, this reference is allocated randomly.IllegalArgumentException
- if identifier does not conform to AdaptationReference.MAX_LENGTH
and AdaptationReference.REFERENCE_PATTERN
.OperationException
doCreateRoot(SchemaLocation, AdaptationReference, Profile)
,
doCreateChild(AdaptationName, AdaptationReference, Profile)
Adaptation doCreateChild(AdaptationName aParentName, AdaptationReference requestedNameOrNull, Profile owner) throws OperationException
aParentName
.aParentName
- Specifies the parent of the dataset to create. It must refer to an existing dataset
in the current dataspace.requestedNameOrNull
- Specifies the public and persistent reference of the dataset to
create. If null
, this reference is allocated randomly.owner
- Specifies the profile that will own the newly created dataset. If null
,
the owner of this dataset will be the profile that owns its parent.IllegalArgumentException
- if identifier does not conform to AdaptationReference.MAX_LENGTH
and AdaptationReference.REFERENCE_PATTERN
.OperationException
doCreateChild(AdaptationName, AdaptationReference)
,
doCreateRoot(SchemaLocation, AdaptationReference, Profile)
Adaptation doCopy(Adaptation aDataSet) throws OperationException
This method is equivalent to:
Adaptation.doCopy(null, aDataSet);
OperationException
- if a record is specified instead of a dataset.doCopy(AdaptationReference, Adaptation)
Adaptation doCopy(AdaptationReference aName, Adaptation aDataSet) throws OperationException
This method disables all blocking constraints defined in the data model during the copy operation. Only structural constraints remain blocking if records are copied into mapped tables.
aName
- reference of the newly created dataset; if null
, the reference
is allocated randomly.OperationException
- if a record is specified instead of a dataset.setBlockingConstraintsDisabled(boolean)
void setInstanceLabel(Adaptation aDataSet, UserMessage aLabel) throws OperationException
OperationException
setInstanceDescription(Adaptation, UserMessage)
void setInstanceDescription(Adaptation aDataSet, UserMessage aDescription) throws OperationException
OperationException
setInstanceLabel(Adaptation, UserMessage)
void setInstanceOwner(Adaptation aDataSet, Profile newOwner) throws OperationException
newOwner
- New owner can be either a user or a role.OperationException
void setInstanceActivation(Adaptation aDataSet, boolean activationState) throws OperationException
OperationException
Adaptation doCreateOccurrence(ValueContext aContent, AdaptationTable aTable) throws OperationException, ConstraintViolationException
Access rights on the table node for the current session are not checked when
calling this method, even in a context which is not with "all privileges".
SessionPermissions.getNodeAccessPermission(SchemaNode, Adaptation)
should be used before executing this method to explicitly perform this check
if required.
aContent
- Specifies the content of the record to create. It must at least define its
primary key. An object of this type is obtained by calling a
getContext...(...)
method, such as
getContextForNewOccurrence(AdaptationTable)
.aTable
- Specifies the table where the record is to be created.ConstraintViolationException
- If the record to create contains values that do not comply with
constraints in blocking mode.OperationException
Adaptation doCreateRoot(ValueContext aContent, AdaptationTable aTable) throws OperationException
This method is deprecated since it has the same contract and effect as
doCreateOccurrence(ValueContext, AdaptationTable)
.
OperationException
Adaptation doCreateOverwriting(ValueContext aContent, AdaptationTable aTable) throws OperationException
This method is deprecated since it has the same contract and effect as
doCreateOccurrence(ValueContext, AdaptationTable)
.
OperationException
Adaptation doCreateOcculting(ValueContext aKey, AdaptationTable aTable) throws OperationException
Access rights on the table node for the current session are not checked when
calling this method, even in a context which is not with "all privileges".
SessionPermissions.getNodeAccessPermission(SchemaNode, Adaptation)
should be used before executing this method to explicitly perform this check
if required.
aKey
- Specifies the key of the parent record to occult.
An object of this type is obtained by calling the method
getContext(AdaptationName)
(the parent reference must be
given as the argument), or
getContextForNewOccurrence(AdaptationTable)
.aTable
- Specifies the table in which the occulting record is created.OperationException
getContextForNewOccurrence(AdaptationTable)
Adaptation doOccult(Adaptation aRecord) throws OperationException
Depending on the record specified, this method performs one of the following operations:
Access rights on the table node for the current session are not checked when
calling this method, even in a context which is not with "all privileges".
SessionPermissions.getNodeAccessPermission(SchemaNode, Adaptation)
should be used before executing this method to explicitly perform this check
if required.
aRecord
- the record to be occulted.OperationException
Adaptation doModifyContent(Adaptation aTarget, ValueContext aContent) throws OperationException, ConstraintViolationException
Caution: to access the modified record or dataset, it is necessary to use
only the returned object, since the aContent
object passed as an argument
will not be aware of the modification.
aTarget
- The content to modify.aContent
- Specifies the modifications to apply.
An object of this type is typically obtained by calling the method
getContext(AdaptationName)
(with the dataset or record to be modified
passed as the parameter).OperationException
- if specified record is null
or is in occulting mode.ConstraintViolationException
- if the specified record to modify contains values that do not comply with
constraints in blocking mode.getContext(AdaptationName)
void doDelete(AdaptationName aName, boolean isDeletingChildren) throws OperationException, ConstraintViolationException
If deleting a record that is an
inherited record,
this method will create an
occulting record
(see method doOccult(Adaptation)
).
Access rights on the table node for the current session are not checked when
calling this method, even in a context which is not with "all privileges".
SessionPermissions.getNodeAccessPermission(SchemaNode, Adaptation)
should be used before executing this method to explicitly perform this check
if required.
aName
- reference of the dataset or record to be deleted.isDeletingChildren
- if set to true
, all children will be deleted recursively.ConstraintViolationException
- if the specified record or dataset is being referenced
by a foreign key constraint (osd:tableRef
) in blocking mode.OperationException
AdaptationHome getAdaptationHome()
ImportResult doImport(ImportSpec aSpec) throws OperationException
For XML content, this operation is tolerant of the implicit schema of the XML source. That is, if some elements do not exist in target's data model, they are simply ignored.
Access rights on the table node for the current session are not checked when
calling this method, even in a context which is not with "all privileges".
SessionPermissions.getNodeAccessPermission(SchemaNode, Adaptation)
should be used before executing this method to explicitly perform this check
if required.
aSpec
- definition of the import.OperationException
- if an error occurs during the operation (for example, if an integrity constraint
is violated in the source content).doExport(ExportSpec)
void doExport(ExportSpec aSpec) throws OperationException
aSpec
- definition of the export.OperationException
- if an error occurs during the operation.doImport(ImportSpec)
void doExportArchive(Archive anArchive) throws OperationException
OperationException
doExportArchive(ArchiveExportSpec)
void doExportArchive(ArchiveExportSpec exportSpec) throws OperationException
It is possible to perform a data transformation upon export
by specifying a NodeDataTransformer
on the data model.
OperationException
doImportArchive(ArchiveImportSpec)
void doImportArchive(Archive anArchive) throws OperationException
This method is equivalent to:
ProcedureContext.doImportArchive(ArchiveImportSpecModeDEFAULT);
OperationException
doImportArchive(ArchiveImportSpec)
,
ArchiveImportSpecMode.DEFAULT
void doImportArchive(ArchiveImportSpec importSpec) throws OperationException
The import mode is specified using the method
ArchiveImportSpec.setMode(ArchiveImportSpecMode)
.
This method disables all blocking constraints defined in the data model during the import archive operation. Only structural constraints remain blocking if records are being imported into mapped tables.
This method disables all permission checks using setAllPrivileges(boolean)
.
Therefore, before calling this method, it is important to guarantee that the current session
is actually able to execute the import.
For more information, see ServicePermissionRule
and Session.isUserInRole(Profile)
.
OperationException
doExportArchive(ArchiveExportSpec)
,
ArchiveImportSpecMode
void doMergeToParent(AdaptationHome aSource) throws OperationException
This method is equivalent to doMergeToParent(MergeSpecForHome)
,
with all datasets selected in the source dataspace associated with the MergeSpecForHome
.
OperationException
doMergeToParent(MergeSpecForHome)
void doMergeToParent(MergeSpecForHome aMergeSpec) throws OperationException
For the selected content to be merged, every change between the initial snapshot of the source and its current state is applied to the current dataspace. The changes are applied even if they conflict with the changes performed on the current dataspace in the meantime.
IllegalArgumentException
- when MergeSpecForHome
is null
or when MergeSpecForHome.getHomeToMerge()
is:
null
,OperationException
- when the merge cannot be completed successfully.doMergeToParent(AdaptationHome)
int getCommitThreshold()
setCommitThreshold(int)
void setCommitThreshold(int commitThreshold)
Attention: Doing intermediate commits breaks transaction atomicity. It can leave the database in an intermediate state and clients can see the committed intermediate states. This is particularly true for direct SQL access to tables in mapped modes (history and replica tables). Consequently, this method must be used only in particular cases where atomicity does not matter, for example, in the case of a repeatable data import in an environment without any SQL clients.
If commitThreshold > 0
, a commit will occur every time the number of current
changes is equal to commitThreshold
.
If commitThreshold = 0
, only one commit occurs (after the procedure
execution returns).
If unspecified, the commit threshold is '0'.
Records are gathered by blocks and a change refers to one modified block.
This means that if several records are updated (created, modified, or deleted) in the same block,
they will be counted as only one change. Since a block groups up to 256 records,
the number of actual records creates, updates, and deletes (Ncud
)
in a single commit can obtained by the following formula:
commitThreshold <= Ncud <= 256 * commitThreshold
For example, for an initial import, if the commit threshold is set to '50', a commit will occur periodically, each for a maximum of 12800 record creations.
All database updates are executed just before the database commit.
onCommit
replication activated, an additional change must be counted for each
record create, update, or delete.
onDemand
replication refresh is requested, no change is counted;
see ReplicationUnit.performRefresh(ProcedureContext)
.
IllegalArgumentException
- if commitThreshold < 0
.boolean isHistoryActivation()
setHistoryActivation(boolean)
void setHistoryActivation(boolean isActivated)
By default, the detailed XML audit trail is deactivated.
boolean isDatabaseHistoryActivation()
setDatabaseHistoryActivation(boolean)
void setDatabaseHistoryActivation(boolean isActivated)
true
.boolean isTriggerActivation()
setTriggerActivation(boolean)
void setTriggerActivation(boolean isActivated)
If not specified, triggers are enabled.
Disabling triggers means disabling all trigger methods
defined by InstanceTrigger
and by TableTrigger
,
except for TableTrigger.handleBeforeTransactionCommit(BeforeTransactionCommitContext)
,
which is always executed.
boolean isReadOnly()
true
if called within a ReadOnlyProcedure
.boolean isBlockingConstraintsDisabled()
true
if blocking constraints are disabled; by default, blocking constraints are enabled.setBlockingConstraintsDisabled(boolean)
void setBlockingConstraintsDisabled(boolean isDisabled)
If not disabled by this method, blocking constraints defined in the data model using the property
will be checked before any operation is performed and throw a<osd:validation> <blocksCommit>onInsertUpdateOrDelete</blocksCommit> </osd:validation>
ConstraintViolationException
if it does not comply with such a constraint.
Disabling blocking constraints means disabling all constraints explicitly defined in data model as blocking commits.
This method does not disable structural constraints that automatically become blocking constraints in relational tables, or when table history or replication is activated.
This method has no effect for archive imports and dataset copying. This is because all blocking constraints are always disabled when importing archives and copying datasets.
isBlockingConstraintsDisabled()
,
ConstraintViolationException
void disableDatasetValidation(Adaptation aDataset)
default void setBatch()
String getExecutionInformation()
setExecutionInformation(String)
void setExecutionInformation(String aString)
If specified, the information is displayed in the history log. If unspecified, only the procedure class name is displayed.
The execution information plays a similar role as session tracking info, but more locally, that is, in the context of a single execution.
Session.getTrackingInfo()
boolean isAllPrivileges()
false
.setAllPrivileges(boolean)
void setAllPrivileges(boolean allPrivileges)
true
, disables all permission checks for future operations
performed by the current run. If false
, sets the default mode
that enables the usual permission checks.
Caution: When a procedure disables all permission checks, the client code must check that the current user session is actually allowed to run the procedure.
boolean isPrivilegeToModifyReferenceBranch()
true
.void setPrivilegeToModifyReferenceBranch(boolean enable)
ValueContextForUpdate getContextForNewOccurrence(AdaptationTable aTable)
This method is equivalent to getContext(isTriggerActivation(), null, aTable)
.
ValueContextForUpdate getContextForNewOccurrence(Adaptation recordToCopy, AdaptationTable aTable)
If a trigger has been specified, the method TableTrigger.handleNewContext(NewTransientOccurrenceContext)
is invoked, unless triggers have been disabled
.
See TableTrigger.handleNewContext(NewTransientOccurrenceContext)
documentation note.
ValueContextForUpdate getContext(boolean isTriggerActivation, ValueContextForUpdate contextToCopy, AdaptationTable aTable)
isTriggerActivation
- if false
, the method
TableTrigger.handleNewContext(NewTransientOccurrenceContext)
is not invoked. See also isTriggerActivation()
.contextToCopy
- if not null
, the content is copied to the context to be returned.aTable
- the new context conforms to the data model of this table.doCreateOccurrence(ValueContext, AdaptationTable)
ValueContextForUpdate getContext(AdaptationName aName)
Date getExecutionTimestamp()
String getExecutionUUIDString()
The UUID format used is the hexadecimal representation of UUID Leach-Salz variant, version 1 (time-based).
For more information, see the Internet-Draft UUIDs and GUIDs or the standards body definition at ISO/IEC 11578:1996 .
Session getSession()