import VersioningState from "@arcgis/core/versionManagement/VersioningState.js";
const VersioningState = await $arcgis.import("@arcgis/core/versionManagement/VersioningState.js");
@arcgis/core/versionManagement/VersioningState
This class provides functionality for managing versions in a versioned geodatabase. It includes methods for starting and stopping editing, changing versions, undoing and redoing edits, and retrieving version information.
const [utils, WebMap] = await $arcgis.import([
"@arcgis/core/versionManagement/versionAdapters/utils.js",
"@arcgis/core/WebMap.js"
]);
const webmap = new WebMap({
portalItem: { // autocasts as new PortalItem()
id: "e691172598f04ea8881cd2a4adaa45ba"
}
});
const versioningStates = await utils.createVersioningStates(webmap, false);
Constructors
-
Parameterproperties Objectoptional
See the properties for a list of all the properties that may be passed into the constructor.
Property Overview
| Name | Type | Summary | Class |
|---|---|---|---|
The current version. | VersioningState | ||
Contains information on the current version. | VersioningState | ||
Contains the default version's name and guid. | VersioningState | ||
The absolute URL of the REST endpoint for the feature service housing the version management service. | VersioningState | ||
If true, current version is the default version. | VersioningState | ||
The Error object returned if an error occurred while loading. | VersioningState | ||
Represents the status of a load operation. | VersioningState | ||
A list of warnings which occurred while loading. | VersioningState | ||
Indicates whether the instance has loaded. | VersioningState | ||
The state of the current version. | VersioningState | ||
The absolute URL of the REST endpoint for the version management service. | VersioningState | ||
If the set to | VersioningState | ||
Contains list of all available versions. | VersioningState | ||
Contains metadata about the version management service. | VersioningState | ||
Contains a collection of all versionable in the versioning state class. | VersioningState |
Property Details
-
currentVersion
PropertycurrentVersion VersionIdentifier |Date -
The current version.
-
currentVersionInfo
PropertycurrentVersionInfo VersionInfo |null |undefined -
Contains information on the current version.
-
defaultVersionIdentifier
PropertydefaultVersionIdentifier VersionIdentifierreadonly -
Contains the default version's name and guid.
-
featureServiceUrl
PropertyfeatureServiceUrl String -
The absolute URL of the REST endpoint for the feature service housing the version management service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online.
-
isDefault
PropertyisDefault Booleanreadonly -
If true, current version is the default version.
-
The Error object returned if an error occurred while loading.
- Default Value:null
-
loadStatus
PropertyloadStatus Stringreadonly -
Represents the status of a load operation.
Value Description not-loaded The object's resources have not loaded. loading The object's resources are currently loading. loaded The object's resources have loaded without errors. failed The object's resources failed to load. See loadError for more details. Possible Values:"not-loaded" |"loading" |"failed" |"loaded"
- Default Value:"not-loaded"
-
A list of warnings which occurred while loading.
-
state
Propertystate String -
The state of the current version.
Possible Values:"lock-none" |"lock-read" |"lock-write"
-
url
Propertyurl String -
The absolute URL of the REST endpoint for the version management service. The URL may either point to a resource on ArcGIS Enterprise or ArcGIS Online.
-
usePersistentReadSessions
PropertyusePersistentReadSessions Boolean -
If the set to
true, the current version will have a read lock. Additionally, when switching versions, the new current version will also have a read lock.
-
versionInfos
PropertyversionInfos VersionInfo[] -
Contains list of all available versions.
-
versionManagementService
PropertyversionManagementService VersionManagementService -
Contains metadata about the version management service.
-
versionableItems
PropertyversionableItems Collection<VersionAdapter> -
Contains a collection of all versionable in the versioning state class.
Method Overview
| Name | Return Type | Summary | Class |
|---|---|---|---|
Promise<Boolean> | The alter operation allows you to change the geodatabase version's name, description, owner, and access permissions. | VersioningState | |
Cancels a load() operation if it is already in progress. | VersioningState | ||
Promise<Map<VersionAdapter, ServiceResult>> | Method used to change a layer's version/moment or network's version/moment. | VersioningState | |
Promise<Boolean> | Deletes a version given the following parameters. | VersioningState | |
Method used to get extended information about a version. | VersioningState | ||
Promise<VersionInfo[]> | Returns all versions accessible to the currently logged-in user. | VersioningState | |
| VersioningState | ||
| VersioningState | ||
| VersioningState | ||
Promise | Loads the resources referenced by this class. | VersioningState | |
Promise | Triggers the loading of the version management service instance. | VersioningState | |
Promise<ServiceResult> | This method redos the last edit made while in an edit session. | VersioningState | |
Promise<ServiceResult> | Using the specified session ID an exclusive lock is obtained for the session on the version. | VersioningState | |
Promise<ServiceResult> | Using the specified session id, the exclusive lock for the version is downgraded to a shared lock. | VersioningState | |
Promise<ServiceResult> | This method undos the last edit made while in an edit session. | VersioningState | |
Promise |
| VersioningState |
Method Details
-
alterVersion
MethodalterVersion(versionIdentifier, props){Promise<Boolean>} -
The alter operation allows you to change the geodatabase version's name, description, owner, and access permissions.
License
- This method requires the feature service and version management service to be published with ArcGIS Enterprise version 11.2 or higher.
- Organization members must be assigned a license for the ArcGIS Advanced Editing user type extension to use this method.
ParametersSpecificationversionIdentifier VersionIdentifierIdentifier for a version.
props ObjectContains properties that will be altered.
SpecificationownerName StringoptionalThe new owner name of the version.
versionName StringoptionalThe new name for the version.
description StringoptionalThe new description for the version.
access StringoptionalThe new access permissions of the version.
Possible Values:"hidden"|"private"|"protected"|"public"
ReturnsType Description Promise<Boolean> - Returns true if version was altered successfully.
Exampleconst result = await versioningState.alterVersion( { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }, { versionName: "versionName", ownerName: "newOwner", description: "newDescription", access: "public" } );
-
Cancels a load() operation if it is already in progress.
-
changeVersion
MethodchangeVersion(toVersion){Promise<Map<VersionAdapter, ServiceResult>>} -
Method used to change a layer's version/moment or network's version/moment. Method allows changing version from named version to named version, or from default version to a moment and vice versa.
ParametertoVersion Date|VersionIdentifierIncoming Version or Date.
ReturnsType Description Promise<Map<VersionAdapter, ServiceResult>> - Returns a map of VersionAdapter and ServiceResult.
Exampleawait versioningState.changeVersion( { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"} );
-
deleteVersion
MethoddeleteVersion(versionIdentifier){Promise<Boolean>} -
Deletes a version given the following parameters.
License
- This method requires the feature service and version management service to be published with ArcGIS Enterprise version 11.2 or higher.
- Organization members must be assigned a license for the ArcGIS Advanced Editing user type extension to use this method.
ParameterversionIdentifier VersionIdentifierIdentifier for a version.
ReturnsType Description Promise<Boolean> - Specifies if the selected version was deleted.
ExampleversioningState.deleteVersion({ name: "versionName", guid: "{422D1B63-D795-4478-A4B1-AD6109377075}" });
-
getVersionInfoExtended
MethodgetVersionInfoExtended(){Promise<(VersionInfoExtendedJSON|null|undefined)>} -
Method used to get extended information about a version.
ReturnsType Description Promise<(VersionInfoExtendedJSON|null|undefined)> - Contains extended info about given version.
-
getVersionInfos
MethodgetVersionInfos(refresh){Promise<VersionInfo[]>} -
Returns all versions accessible to the currently logged-in user.
Parameterrefresh BooleanIf refresh is true, a new REST call will be made to the server to get the available versions.
ReturnsType Description Promise<VersionInfo[]> - Contains extended info about given version.
-
isFulfilled
MethodisFulfilled(){Boolean} -
isFulfilled()may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected). If it is fulfilled,truewill be returned.ReturnsType Description Boolean Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
-
Loads the resources referenced by this class. This method automatically executes for a View and all of the resources it references in Map if the view is constructed with a map instance.
This method must be called by the developer when accessing a resource that will not be loaded in a View.
The
load()method only triggers the loading of the resource the first time it is called. The subsequent calls return the same promise.It's possible to provide a
signalto stop being interested into aLoadableinstance load status. When the signal is aborted, the instance does not stop its loading process, only cancelLoad can abort it.Parametersoptional Additional options.
Specificationsignal AbortSignal|null|undefinedoptionalSignal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named
AbortErrorwhen an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.ReturnsType Description Promise Resolves when the resources have loaded.
-
Triggers the loading of the version management service instance.
Fully loads the Version Management Service definition.
Parametersoptional Additional options.
Specificationsignal AbortSignal|null|undefinedoptionalSignal object that can be used to abort the asynchronous task. The returned promise will be rejected with an Error named
AbortErrorwhen an abort is signaled. See also AbortController for more information on how to construct a controller that can be used to deliver abort signals.ReturnsType Description Promise Resolves when the Feature Service is loaded.
-
redo
Methodredo(){Promise<ServiceResult>} -
This method redos the last edit made while in an edit session.
ReturnsType Description Promise<ServiceResult> - Specifies if redo was successful.
-
startEditing
MethodstartEditing(){Promise<ServiceResult>} -
Using the specified session ID an exclusive lock is obtained for the session on the version. The exclusive lock can only be obtained if no other shared or exclusive locks are present and the session currently holds a shared lock. The exclusive lock ensures read and write isolation for the session holding the lock. The exclusive lock is downgraded to a shared lock by using the stopEditing operation.
ReturnsType Description Promise<ServiceResult> - Specifies if start editing was successful.
Exampleawait versioningState.startEditing();
-
stopEditing
MethodstopEditing(saveEdits){Promise<ServiceResult>} -
Using the specified session id, the exclusive lock for the version is downgraded to a shared lock. The saveEdits parameter specifies if the edits for the session should be saved (true) or discarded (false).
ParametersaveEdits BooleanIf set to true edits will be saved, if false edits will not be saved.
ReturnsType Description Promise<ServiceResult> - Specifies if stop editing was successful.
Exampleawait versioningState.stopEditing(true);
-
undo
Methodundo(){Promise<ServiceResult>} -
This method undos the last edit made while in an edit session.
ReturnsType Description Promise<ServiceResult> - Specifies if undo was successful.
-
when()may be leveraged once an instance of the class is created. This method takes two input parameters: aonFulfilledfunction and anonRejectedfunction. TheonFulfilledexecutes when the instance of the class loads. TheonRejectedexecutes if the instance of the class fails to load.ParametersReturnsType Description Promise Returns a new promise for the result of onFulfilledthat may be used to chain additional functions.Example// Although this example uses MapView, any class instance that is a promise may use when() in the same way let view = new MapView(); view.when(function(){ // This function will execute once the promise is resolved }, function(error){ // This function will execute if the promise is rejected due to an error });
Type Definitions
-
VersionInfo
Type DefinitionVersionInfo Object -
This contains basic information about a given version.
- Properties
-
versionIdentifier Object
The identifier of a version.
optionaldescription StringDescription of the version.
optionalaccess StringAccess type accepts values of private, public, hidden, and protected.
optionalversionId StringThe id of the version that was edited.
optionalcreationDate NumberThe date the version was created on.
optionalmodifiedDate NumberThe date when the version was last modified or changed.
optionalreconcileDate NumberThe date when the version was last reconciled with the parent version or the default version.
optionalevaluationDate NumberThe date when the version was last evaluated for conflicts or discrepancies during the reconciliation process.
optionalpreviousAncestorDate NumberThe date of the most recent ancestor version, if applicable.
optionalcommonAncestorDate NumberThe date of the common ancestor version, which is the shared ancestor between two or more versions during the reconciliation process.
-
VersionInfoExtendedJSON
Type DefinitionVersionInfoExtendedJSON Object -
This contains extended information about a given version.
- Properties
-
versionIdentifier Object
The identifier of a version.
optionaldescription StringDescription of the version.
optionalaccess StringThe access type permissions of the version.
Possible Values:"hidden"|"private"|"protected"|"public"
optionalversionId StringThe id of the version that was edited.
optionalcreationDate NumberThe date the version was created on.
optionalmodifiedDate NumberThe date when the version was last modified or changed.
optionalreconcileDate NumberThe date when the version was last reconciled with the parent version or the default version.
optionalevaluationDate NumberThe date when the version was last evaluated for conflicts or discrepancies during the reconciliation process.
optionalpreviousAncestorDate NumberThe date of the most recent ancestor version, if applicable.
optionalcommonAncestorDate NumberThe date of the common ancestor version, which is the shared ancestor between two or more versions during the reconciliation process.
optionalisBeingEdited BooleanSpecifies if the version is currently being edited.
optionalisBeingRead BooleanSpecifies if the version is currently being read.
optionalhasConflicts BooleanSpecifies if the version is has conflicts.
optionalhasUninspectedConflicts BooleanSpecifies if the version has UninspectedConflicts.
optionalisLocked BooleanSpecifies if the version currently has a lock.
optionallockOwner StringSpecifies which user is the current lock owner.
optionallockDate NumberSpecifies the date at which the version was locked.