import VersioningState from "@arcgis/core/versionManagement/VersioningState.js";const VersioningState = await $arcgis.import("@arcgis/core/versionManagement/VersioningState.js");- Inheritance:
- VersioningState→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.30
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.
Example
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
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| properties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
VersionInfo | null | undefined | | |
declaredClass readonly inherited | ||
defaultVersionIdentifier readonly | | |
| | ||
isDefault readonly | | |
loaded readonly | | |
loadError readonly inherited | ||
loadStatus readonly inherited | "not-loaded" | "loading" | "failed" | "loaded" | |
loadWarnings readonly inherited | any[] | |
"lock-none" | "lock-read" | "lock-write" | | |
| | ||
| | ||
| | ||
| | ||
| |
currentVersionInfo
- Type
- VersionInfo | null | undefined
Contains information on the current version.
defaultVersionIdentifier
- Type
- VersionIdentifier
Contains the default version's name and guid.
featureServiceUrl
- Type
- 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.
loaded
- Type
- boolean
Indicates whether the instance has loaded. When true,
the properties of the object can be accessed. A WebMap is considered loaded
when its WebDocument2D.layers and WebDocument2D.basemap are created, but not
yet loaded.
- Default value
- false
loadError
The Error object returned if an error occurred while loading.
loadStatus
- Type
- "not-loaded" | "loading" | "failed" | "loaded"
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. |
- Default value
- "not-loaded"
loadWarnings
- Type
- any[]
A list of warnings which occurred while loading.
url
- Type
- 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
- Type
- 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.
- Default value
- false
versionableItems
- Type
- Collection<VersionAdapter>
Contains a collection of all versionable in the versioning state class.
Methods
| Method | Signature | Class |
|---|---|---|
fromJSON inherited static | fromJSON(json: any): any | |
alterVersion(versionIdentifier: VersionIdentifier, props: AlterVersionParametersProperties): Promise<boolean> | | |
cancelLoad inherited | cancelLoad(): this | |
changeVersion(toVersion: VersionIdentifier | Date): Promise<Map<VersionAdapter, ServiceResult>> | | |
deleteVersion(versionIdentifier: VersionIdentifier): Promise<boolean> | | |
getVersionInfoExtended(): Promise<VersionInfoExtendedJSON | null | undefined> | | |
getVersionInfos(refresh?: boolean): Promise<VersionInfo[]> | | |
isFulfilled inherited | isFulfilled(): boolean | |
isRejected inherited | isRejected(): boolean | |
isResolved inherited | isResolved(): boolean | |
load(options?: AbortOptions | null | undefined): Promise<this> | | |
redo(): Promise<ServiceResult> | | |
startEditing(): Promise<ServiceResult> | | |
stopEditing(saveEdits: boolean): Promise<ServiceResult> | | |
toJSON inherited | toJSON(): any | |
undo(): Promise<ServiceResult> | | |
when inherited | when<TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2> |
fromJSON
- Signature
-
fromJSON (json: any): any
Creates a new instance of this class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- any
Returns a new instance of this class.
alterVersion
- Signature
-
alterVersion (versionIdentifier: VersionIdentifier, props: AlterVersionParametersProperties): 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.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | | |
| props | Contains properties that will be altered. | |
Example
const result = await versioningState.alterVersion( { name: "newVersion", guid: "{49C6AC87-CDA8-46D4-A79B-449105981209}" }, { versionName: "versionName", ownerName: "newOwner", description: "newDescription", access: "public" } ); cancelLoad
- Signature
-
cancelLoad (): this
Cancels a load() operation if it is already in progress.
- Returns
- this
changeVersion
- Signature
-
changeVersion (toVersion: VersionIdentifier | Date): 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.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| toVersion | Incoming Version or Date. | |
- Returns
- Promise<Map<VersionAdapter, ServiceResult>>
Returns a map of VersionAdapter and ServiceResult.
Example
await versioningState.changeVersion( { name: "admin.version", guid: "{422D1B63-D795-4478-A4B1-AD6109377074}"}); deleteVersion
- Signature
-
deleteVersion (versionIdentifier: 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.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| versionIdentifier | Identifier for a version. | |
Example
versioningState.deleteVersion({ name: "versionName", guid: "{422D1B63-D795-4478-A4B1-AD6109377075}"}); getVersionInfoExtended
- Signature
-
getVersionInfoExtended (): Promise<VersionInfoExtendedJSON | null | undefined>
Method used to get extended information about a version.
- Returns
- Promise<VersionInfoExtendedJSON | null | undefined>
Contains extended info about given version.
getVersionInfos
- Signature
-
getVersionInfos (refresh?: boolean): Promise<VersionInfo[]>
Returns all versions accessible to the currently logged-in user.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| refresh | If refresh is true, a new REST call will be made to the server to get the available versions. | |
- Returns
- Promise<VersionInfo[]>
Contains extended info about given version.
isFulfilled
- Signature
-
isFulfilled (): boolean
isFulfilled() may be used to verify if creating an instance of the class is fulfilled (either resolved or rejected).
If it is fulfilled, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been fulfilled (either resolved or rejected).
isRejected
- Signature
-
isRejected (): boolean
isRejected() may be used to verify if creating an instance of the class is rejected.
If it is rejected, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been rejected.
isResolved
- Signature
-
isResolved (): boolean
isResolved() may be used to verify if creating an instance of the class is resolved.
If it is resolved, true will be returned.
- Returns
- boolean
Indicates whether creating an instance of the class has been resolved.
redo
- Signature
-
redo (): Promise<ServiceResult>
This method redos the last edit made while in an edit session.
- Returns
- Promise<ServiceResult>
Specifies if redo was successful.
startEditing
- Signature
-
startEditing (): 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.
- Returns
- Promise<ServiceResult>
Specifies if start editing was successful.
Example
await versioningState.startEditing(); stopEditing
- Signature
-
stopEditing (saveEdits: boolean): 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).
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| saveEdits | If set to true edits will be saved, if false edits will not be saved. | |
- Returns
- Promise<ServiceResult>
Specifies if stop editing was successful.
Example
await versioningState.stopEditing(true); toJSON
- Signature
-
toJSON (): any
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
- Returns
- any
The ArcGIS portal JSON representation of an instance of this class.
undo
- Signature
-
undo (): Promise<ServiceResult>
This method undos the last edit made while in an edit session.
- Returns
- Promise<ServiceResult>
Specifies if undo was successful.
when
- Signature
-
when <TResult1 = this, TResult2 = never>(onFulfilled?: OnFulfilledCallback<this, TResult1> | null | undefined, onRejected?: OnRejectedCallback<TResult2> | null | undefined): Promise<TResult1 | TResult2>
when() may be leveraged once an instance of the class is created. This method takes two input parameters: an onFulfilled function and an onRejected function.
The onFulfilled executes when the instance of the class loads. The
onRejected executes if the instance of the class fails to load.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| onFulfilled | OnFulfilledCallback<this, TResult1> | null | undefined | The function to call when the promise resolves. | |
| onRejected | The function to execute when the promise fails. | |
- Returns
- Promise<TResult1 | TResult2>
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 waylet 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});