You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
15 lines
6.2 KiB
15 lines
6.2 KiB
// All material copyright Esri, All Rights Reserved, unless otherwise specified. |
|
// See https://js.arcgis.com/4.30/esri/copyright.txt for details. |
|
//>>built |
|
define("../chunks/tslib.es6 ../core/Collection ../core/Error ../core/JSONSupport ../core/Loadable ../core/Logger ../core/accessorSupport/decorators/property ../core/has ../core/RandomLCG ../core/accessorSupport/decorators/subclass".split(" "),function(c,k,l,b,m,g,e,q,r,n){b=class extends b.JSONSupportMixin(m){constructor(a){super(a);this.currentVersionInfo=this.currentVersion=this.url=this.featureServiceUrl=this.versionManagementService=null;this.versionInfos=[];this.versionableItems=new k;this.usePersistentReadSessions= |
|
!1;this.state="lock-none"}initialize(){this.url=this.versionManagementService.url;this.featureServiceUrl=this.url.replace(/\/VersionManagementServer/i,"/FeatureServer");this.addHandles([this.versionableItems.on("before-add",a=>{a.item.featureServiceUrl.toLowerCase()!==this.featureServiceUrl.toLowerCase()&&(a.preventDefault(),g.getLogger(this).error("#add()","Cannot add versionAdapter, feature service urls do not match."))}),this.versionableItems.on("before-remove",a=>{0===this.versionableItems.items.length&& |
|
this.currentVersion&&"name"in this.currentVersion&&"none"!==this.versionManagementService.getLockType(this.currentVersion)&&(a.preventDefault(),g.getLogger(this).error("#remove()","Cannot remove last versionAdapter."))})])}load(a){this.addResolvingPromise(this._setUpState(a));return Promise.resolve(this)}get defaultVersionIdentifier(){return this.versionManagementService.defaultVersionIdentifier}get isDefault(){return!this.currentVersion||!!this.currentVersion&&"name"in this.currentVersion&&this.currentVersion.name=== |
|
this.defaultVersionIdentifier.name}async getVersionInfos(a=!1){a&&(this.versionInfos=await this.versionManagementService.getVersionInfos());return this.versionInfos}async alterVersion(a,d){if(this.currentVersion&&"guid"in this.currentVersion&&a.guid===this.currentVersion.guid)return!1;(a=await this.versionManagementService.alterVersion(a,d))&&await this.getVersionInfos(!0);return a}async deleteVersion(a){if(this.currentVersion&&"guid"in this.currentVersion&&a.guid===this.currentVersion.guid)return!1; |
|
(a=await this.versionManagementService.deleteVersion(a))&&await this.getVersionInfos(!0);return a}async getVersionInfoExtended(){return this.currentVersion&&"name"in this.currentVersion?this.versionManagementService.getVersionInfoExtended(this.currentVersion):this.versionManagementService.getVersionInfoExtended(this.defaultVersionIdentifier)}async startEditing(){if(this._isDefaultOrHistoricVersion())return{success:!1};if(!this.usePersistentReadSessions){var a=await this.versionManagementService.startReadingWithResult(this.currentVersion); |
|
if(a.success)this.state="lock-read";else return a}a=await this.versionManagementService.startEditingWithResult(this.currentVersion);a.success&&(this.state="lock-write");return a}async stopEditing(a){if(this._isDefaultOrHistoricVersion())return{success:!1};a=await this.versionManagementService.stopEditingWithResult(this.currentVersion,a);if(a.success)this.state="lock-read";else return a;return this.usePersistentReadSessions?a:(a=await this.versionManagementService.stopReadingWithResult(this.currentVersion), |
|
a.success&&(this.state="lock-none"),a)}async changeVersion(a){let d=null;if(this.usePersistentReadSessions){if(this._isDefaultOrHistoricVersion(a))a&&"name"in a?(d=await this.versionManagementService.getVersionInfoExtended(a),this.state="public"===d?.access?"lock-none":"lock-read"):this.state="lock-read";else if(!await this.versionManagementService.startReading(a))throw new l("Failed to acquire read lock for version: "+a);this._isDefaultOrHistoricVersion(this.currentVersion)||await this.versionManagementService.stopReading(this.currentVersion)}const h= |
|
await this.versionManagementService.changeVersionWithResult(this.versionableItems,this.currentVersion,a);let f=!1;h.forEach((p,t)=>{f=f||p.success});f&&(this.currentVersion=a,this.currentVersionInfo=d||await this.getVersionInfoExtended(),this._isDefaultOrHistoricVersion()?this.state=this.currentVersion&&"name"in this.currentVersion?"public"===this.currentVersionInfo?.access?"lock-none":"lock-read":"lock-read":this.state="read"!==this.versionManagementService.getLockType(this.currentVersion)?"lock-none": |
|
"lock-read");return h}async undo(){return this._isDefaultOrHistoricVersion()?{success:!1}:(this.versionManagementService.undo(this.currentVersion),{success:!0})}async redo(){return this._isDefaultOrHistoricVersion()?{success:!1}:(this.versionManagementService.redo(this.currentVersion),{success:!0})}async _setUpState(a){await this.versionManagementService.load(a);this.state="lock-none";this.currentVersionInfo=await this.getVersionInfoExtended();this.versionableItems.forEach(d=>{this.currentVersion? |
|
"name"in this.currentVersion?(d.gdbVersion=this.currentVersion.name,d.historicMoment=null):(d.historicMoment=this.currentVersion,d.gdbVersion=null):(d.gdbVersion=null,d.historicMoment=null)});this.usePersistentReadSessions&&(this._isDefaultOrHistoricVersion()?this.state=this.currentVersion&&"name"in this.currentVersion?"public"===this.currentVersionInfo?.access?"lock-none":"lock-read":"lock-read":await this.versionManagementService.startReading(this.currentVersion)&&(this.state="lock-read"))}_isDefaultOrHistoricVersion(a= |
|
this.currentVersion){return!(a&&"name"in a)||a.name===this.versionManagementService.defaultVersionIdentifier.name}};c.__decorate([e.property()],b.prototype,"versionManagementService",void 0);c.__decorate([e.property()],b.prototype,"featureServiceUrl",void 0);c.__decorate([e.property()],b.prototype,"url",void 0);c.__decorate([e.property()],b.prototype,"currentVersion",void 0);c.__decorate([e.property()],b.prototype,"currentVersionInfo",void 0);c.__decorate([e.property()],b.prototype,"versionInfos", |
|
void 0);c.__decorate([e.property()],b.prototype,"versionableItems",void 0);c.__decorate([e.property()],b.prototype,"usePersistentReadSessions",void 0);c.__decorate([e.property()],b.prototype,"state",void 0);c.__decorate([e.property({readOnly:!0})],b.prototype,"defaultVersionIdentifier",null);c.__decorate([e.property({readOnly:!0})],b.prototype,"isDefault",null);return b=c.__decorate([n.subclass("esri.versionManagement.VersioningState")],b)}); |