@arcgis/core
Version:
ArcGIS Maps SDK for JavaScript: A complete 2D and 3D mapping and data visualization API
3 lines (2 loc) • 10.5 kB
JavaScript
/* COPYRIGHT Esri - https://js.arcgis.com/5.0.8/LICENSE.txt */
import{__decorate as e}from"tslib";import t from"../core/Error.js";import{JSONSupport as i}from"../core/JSONSupport.js";import{watch as r}from"../core/reactiveUtils.js";import{property as s,subclass as o}from"../core/accessorSupport/decorators.js";import c from"../layers/FeatureLayer.js";import{emitApplyEditsEvent as a}from"../layers/mixins/EditBusLayer.js";import n from"./UtilityNetwork.js";import l from"./support/Circuit.js";import{isVersionInEditSession as u,currentSessionId as d,isSafeToEditVersion as m}from"../versionManagement/support/versionManagementUtils.js";let h=class extends i{constructor(e){super(e),this._circuitTable=null,this._circuitSectionTable=null,this._subcircuitTable=null,this.telecomDomainNetwork=null,this.utilityNetwork=null}initialize(){this.addHandles([r(()=>[this.gdbVersion,this.historicMoment],()=>{this._setLayerVersionAndMoment(this._circuitTable),this._setLayerVersionAndMoment(this._circuitSectionTable),this._setLayerVersionAndMoment(this._subcircuitTable)})])}get _circuitTableUrl(){if(null==this.telecomDomainNetwork)return null;const e=this.telecomDomainNetwork.circuitSources?.find(e=>"esriUNFCUTCircuit"===e.utilityNetworkFeatureClassUsageType)?.layerId??null;return null==e?null:`${this.featureServiceUrl}/${e}`}get _circuitSectionTableUrl(){if(null==this.telecomDomainNetwork)return null;const e=this.telecomDomainNetwork.circuitSources?.find(e=>"esriUNFCUTCircuitSection"===e.utilityNetworkFeatureClassUsageType)?.layerId??null;return null==e?null:`${this.featureServiceUrl}/${e}`}get _subcircuitTableUrl(){if(null==this.telecomDomainNetwork)return null;const e=this.telecomDomainNetwork.circuitSources?.find(e=>"esriUNFCUTSubcircuit"===e.utilityNetworkFeatureClassUsageType)?.layerId??null;return null==e?null:`${this.featureServiceUrl}/${e}`}get networkServiceUrl(){return this.utilityNetwork?.networkServiceUrl??null}get featureServiceUrl(){return this.utilityNetwork?.featureServiceUrl??null}get gdbVersion(){return this.utilityNetwork?.gdbVersion??null}get historicMoment(){return this.utilityNetwork?.historicMoment??null}get telecomDomainNetworkName(){return this.telecomDomainNetwork?.domainNetworkName??null}get circuitTable(){if(null!=this._circuitTable)return this._circuitTable;if(null==this._circuitTableUrl)throw new t("circuit-manager:missing-circuit-table-url","Unable to load the circuit table; cannot get layer url from `telecomDomainNetwork.","Ensure `telecomDomainNetwork` was provided to the circuit manager.");return this._circuitTable=new c({url:this._circuitTableUrl,gdbVersion:this.gdbVersion,historicMoment:this.historicMoment}),this._circuitTable}get circuitSectionTable(){if(null!=this._circuitSectionTable)return this._circuitSectionTable;if(null==this._circuitSectionTableUrl)throw new t("circuit-manager:missing-circuit-section-table-url","Unable to load the circuit section table; cannot get layer url from `telecomDomainNetwork.","Ensure `telecomDomainNetwork` was provided to the circuit manager.");return this._circuitSectionTable=new c({url:this._circuitSectionTableUrl,gdbVersion:this.gdbVersion,historicMoment:this.historicMoment}),this._circuitSectionTable}get subcircuitTable(){if(null!=this._subcircuitTable)return this._subcircuitTable;if(null==this._subcircuitTableUrl)throw new t("circuit-manager:missing-subcircuit-table-url","Unable to load the subcircuit table; cannot get layer url from `telecomDomainNetwork.","Ensure `telecomDomainNetwork` was provided to the circuit manager.");return this._subcircuitTable=new c({url:this._subcircuitTableUrl,gdbVersion:this.gdbVersion,historicMoment:this.historicMoment}),this._subcircuitTable}async loadCircuitTable(){return this.circuitTable.load()}async loadCircuitSectionTable(){return this.circuitSectionTable.load()}async loadSubcircuitTable(){return this.subcircuitTable.load()}getCircuit(e,t=!1){return new l(t?{circuitManager:this,name:e,sections:new Map}:{circuitManager:this,name:e})}async create(e){const[{createCircuit:t},{default:i}]=await Promise.all([import("../rest/networks/circuits/createCircuit.js"),import("../rest/networks/circuits/support/CreateAlterCircuitParameters.js"),this.loadCircuitTable()]),r=i.from({circuit:e,domainNetworkName:this.telecomDomainNetworkName});u(this.featureServiceUrl,this.gdbVersion||null)?(r.sessionId=d,await m(this.featureServiceUrl,this.gdbVersion,!0)):r.sessionId=null,r.gdbVersion=this.gdbVersion;const s=a(this.featureServiceUrl,null,this.gdbVersion,!1),o=await t(this.networkServiceUrl,r);e.circuitManager=this,this._setCircuitGlobalIdFromEdits(e,o.serviceEdits||[]),s.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:o.exceededTransferLimit,historicMoment:o.moment,editedFeatures:o.serviceEdits||void 0})}async alter(e){if(null==e.globalId)throw new t("circuit-manager:alter-without-globalid","A circuit being altered must have a globalId","To ensure the circuit has a globalId, query the circuit first");const[{alterCircuit:i},{default:r}]=await Promise.all([import("../rest/networks/circuits/alterCircuit.js"),import("../rest/networks/circuits/support/CreateAlterCircuitParameters.js")]),s=r.from({circuit:e,domainNetworkName:this.telecomDomainNetworkName});u(this.featureServiceUrl,this.gdbVersion||null)?(s.sessionId=d,await m(this.featureServiceUrl,this.gdbVersion,!0)):s.sessionId=null,s.gdbVersion=this.gdbVersion;const o=a(this.featureServiceUrl,null,this.gdbVersion,!1),c=await i(this.networkServiceUrl,s);e.circuitManager=this,o.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:c.exceededTransferLimit,historicMoment:c.moment,editedFeatures:c.serviceEdits||void 0})}async delete(e){const[{deleteCircuits:t},{default:i}]=await Promise.all([import("../rest/networks/circuits/deleteCircuits.js"),import("../rest/networks/circuits/support/DeleteCircuitsParameters.js")]),r=i.from({circuits:e,domainNetworkName:this.telecomDomainNetworkName});u(this.featureServiceUrl,this.gdbVersion||null)?(r.sessionId=d,await m(this.featureServiceUrl,this.gdbVersion,!0)):r.sessionId=null,r.gdbVersion=this.gdbVersion;const s=a(this.featureServiceUrl,null,this.gdbVersion,!1),o=await t(this.networkServiceUrl,r);s.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:o.exceededTransferLimit,historicMoment:o.moment,editedFeatures:o.serviceEdits||void 0})}async export(e){const[{exportCircuits:t},{default:i}]=await Promise.all([import("../rest/networks/circuits/exportCircuits.js"),import("../rest/networks/circuits/support/ExportCircuitsParameters.js")]),r=i.from(e);u(this.featureServiceUrl,this.gdbVersion||null)?(r.sessionId=d,await m(this.featureServiceUrl,this.gdbVersion,!0)):r.sessionId=null,r.domainNetworkName=this.telecomDomainNetworkName,r.gdbVersion=this.gdbVersion,r.moment=this.historicMoment;const s=a(this.featureServiceUrl,null,this.gdbVersion,!1),o=await t(this.networkServiceUrl,r);return s.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:o.exceededTransferLimit,historicMoment:o.moment,editedFeatures:o.serviceEdits||void 0}),o.circuits}async verify(e){const[{verifyCircuits:t},{default:i}]=await Promise.all([import("../rest/networks/circuits/verifyCircuits.js"),import("../rest/networks/circuits/support/VerifyCircuitsParameters.js")]),r=i.from(e);u(this.featureServiceUrl,this.gdbVersion||null)?(r.sessionId=d,await m(this.featureServiceUrl,this.gdbVersion,!0)):r.sessionId=null,r.domainNetworkName=this.telecomDomainNetworkName,r.gdbVersion=this.gdbVersion;const s=a(this.featureServiceUrl,null,this.gdbVersion,!1),o=await t(this.networkServiceUrl,r);return s.resolve({edits:null,addedFeatures:[],updatedFeatures:[],deletedFeatures:[],addedAttachments:[],updatedAttachments:[],deletedAttachments:[],exceededTransferLimit:o.exceededTransferLimit,historicMoment:o.moment,editedFeatures:o.serviceEdits||void 0}),o.circuits}async queryCircuits(e){const[{queryCircuits:t},{default:i}]=await Promise.all([import("../rest/networks/circuits/queryCircuits.js"),import("../rest/networks/circuits/support/QueryCircuitsParameters.js")]),r=Array.isArray(e)?{circuits:e}:e,s=i.from(r);u(this.featureServiceUrl,this.gdbVersion||null)?s.sessionId=d:s.sessionId=null,s.domainNetworkName=this.telecomDomainNetworkName,s.resultTypes=["circuit"],s.gdbVersion=this.gdbVersion,s.moment=this.historicMoment;const o=await t(this.networkServiceUrl,s);return o.circuits?.forEach(e=>e.circuitManager=this),o.circuits||[]}async queryCircuitNames(e){const[{queryCircuits:t},{default:i}]=await Promise.all([import("../rest/networks/circuits/queryCircuits.js"),import("../rest/networks/circuits/support/QueryCircuitsParameters.js")]),r=i.from(e);u(this.featureServiceUrl,this.gdbVersion||null)?r.sessionId=d:r.sessionId=null,r.domainNetworkName=this.telecomDomainNetworkName,r.resultTypes=["name"],r.gdbVersion=this.gdbVersion,r.moment=this.historicMoment;return(await t(this.networkServiceUrl,r)).circuitNames||[]}_setLayerVersionAndMoment(e){null!=e&&(e.gdbVersion!==this.gdbVersion&&(e.gdbVersion=this.gdbVersion),e.historicMoment!==this.historicMoment&&(e.historicMoment=this.historicMoment))}_setCircuitGlobalIdFromEdits(e,t){const i=this.circuitTable.fieldsIndex.get("Name").name,r=this.circuitTable.globalIdField,s=t?.find(({layerId:e})=>e===this.circuitTable.layerId)?.editedFeatures.adds.find(({attributes:t})=>t[i].toLocaleLowerCase()===e.name.toLocaleLowerCase());e.globalId=s?.attributes[r]??null}};e([s()],h.prototype,"_circuitTable",void 0),e([s()],h.prototype,"_circuitSectionTable",void 0),e([s()],h.prototype,"_subcircuitTable",void 0),e([s({constructOnly:!0})],h.prototype,"telecomDomainNetwork",void 0),e([s({type:n,constructOnly:!0})],h.prototype,"utilityNetwork",void 0),e([s()],h.prototype,"networkServiceUrl",null),e([s()],h.prototype,"featureServiceUrl",null),e([s()],h.prototype,"gdbVersion",null),e([s()],h.prototype,"historicMoment",null),e([s()],h.prototype,"telecomDomainNetworkName",null),e([s()],h.prototype,"circuitTable",null),e([s()],h.prototype,"circuitSectionTable",null),e([s()],h.prototype,"subcircuitTable",null),h=e([o("esri.networks.CircuitManager")],h);const b=h;export{b as default};