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.
20 lines
9.0 KiB
20 lines
9.0 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/Logger ../core/MapUtils ../core/MultiOriginJSONSupport ../core/promiseUtils ../core/urlUtils ../core/uuid ../core/accessorSupport/decorators/property ../core/has ../core/RandomLCG ../core/accessorSupport/decorators/reader ../core/accessorSupport/decorators/subclass ../core/accessorSupport/decorators/writer ../core/accessorSupport/PropertyOrigin ./Layer ./knowledgeGraph/KnowledgeGraphLayerDataManager ./knowledgeGraph/KnowledgeGraphSublayer ./knowledgeGraph/supportUtils ./mixins/ArcGISService ./mixins/BlendLayer ./mixins/CustomParametersMixin ./mixins/OperationalLayer ./mixins/PortalLayer ./mixins/RefreshableLayer ./mixins/ScaleRangeLayer ./support/commonProperties ../rest/knowledgeGraphService ../chunks/persistableUrlUtils".split(" "), |
|
function(g,q,u,r,x,e,y,v,z,h,Q,R,A,B,C,l,D,E,n,w,F,G,H,I,J,K,L,M,N,t){async function O(a){a=await w.serializeInclusionDefinitionToIdCollectionsMapPbf(a);return new Blob([a],{type:"application/x-protobuf"})}function P(a){var b=`definitionSetMap-${z.generateUUID()}.dat`;b=v.join("knowledgeGraphLayer",b);return a.resourceFromPath(b)}e=class extends G.BlendLayer(L.ScaleRangeLayer(K.RefreshableLayer(F.ArcGISService(I.OperationalLayer(J.PortalLayer(e.MultiOriginJSONMixin(H.CustomParametersMixin(D)))))))){constructor(a){super(a); |
|
this._graphTypeLookup=new Map;this._namedTypesModified=!1;this.knowledgeGraph=this.definitionSetMap=this.dataManager=null;this.layers=new (q.ofType(n));this.memberRelationshipTypes=this.memberEntityTypes=null;this.operationalLayerType="KnowledgeGraphLayer";this.sublayerIdsCache=new Map;this.tables=new (q.ofType(n));this.type="knowledge-graph";this.url=null}load(a){this.addResolvingPromise(this._doLoad(a));return Promise.resolve(this)}async _doLoad(a){try{await this.loadFromPortal({supportedTypes:["Knowledge Graph Layer"]}, |
|
a)}catch(b){y.throwIfAbortError(b)}await this._fetchMetadata();await this._initializeLayerProperties();this.loadLayerAssumingLocalCache()}async _fetchMetadata(){if(!this.url)throw new u("knowledge-graph:missing-url","KnowledgeGraphLayer must be created with a url");this.knowledgeGraph=await N.fetchKnowledgeGraph(this.url);this._forEachGraphType(a=>{a.name&&this._graphTypeLookup.set(a.name,a)})}async _initializeLayerProperties(){this.originIdOf("inclusionModeDefinition")===l.OriginId.USER?this._validateInclusionModeDefinition(): |
|
await this._initializeInclusionModeDefinition();this._setMemberTypes();this.dataManager=new E.KnowledgeGraphLayerDataManager({knowledgeGraph:this.knowledgeGraph,inclusionModeDefinition:this.inclusionModeDefinition})}async _initializeInclusionModeDefinition(){const a=this.definitionSetMap?await w.fetchAndConvertSerializedKgIdMap(this.definitionSetMap,!0):{generateAllSublayers:!0,namedTypeDefinitions:new Map};[...this.layers.toArray(),...this.tables.toArray()].forEach(b=>{(b=this._graphTypeLookup.get(b.graphTypeName))&& |
|
!a.namedTypeDefinitions.has(b.name)&&a.namedTypeDefinitions.set(b.name,{useAllData:!0})});this.setAtOrigin("inclusionModeDefinition",a,l.idToName(this.originIdOf("definitionSetMap")))}_validateInclusionModeDefinition(){const {inclusionModeDefinition:a}=this;if(a){var {namedTypeDefinitions:b}=a;if(0<b?.size)b.forEach((c,d)=>{c=this._graphTypeLookup.get(d);c?"relationship"!==c.type&&"entity"!==c.type&&(r.getLogger(this).warn(`A named type, ${d}, was in the inclusion list that wasn't properly modeled and will be removed`), |
|
b.delete(d)):(r.getLogger(this).warn(`A named type, ${d}, was in the inclusion list that wasn't in the data model and will be removed`),b.delete(d))});else if(!a.generateAllSublayers)throw new u("knowledge-graph:composite-layer-constructor","If an explicit inclusion definition is defined, at least one namedTypeDefinition must also be defined");}}_setMemberTypes(){let a=[],b=[];const {inclusionModeDefinition:c}=this,d=c?.namedTypeDefinitions;!c||c.generateAllSublayers?(a=this.knowledgeGraph.dataModel?.entityTypes?? |
|
[],b=this.knowledgeGraph.dataModel?.relationshipTypes??[]):d&&0<d.size&&d.forEach((f,k)=>{f=this._graphTypeLookup.get(k);switch(f?.type){case "relationship":b.push(f);break;case "entity":a.push(f)}});this.memberEntityTypes=a;this.memberRelationshipTypes=b}_forEachGraphType(a){const b=this.knowledgeGraph.dataModel?.relationshipTypes??[];[...(this.knowledgeGraph.dataModel?.entityTypes??[]),...b].forEach(c=>{a(c)})}_refreshNamedTypes(){this._namedTypesModified=!0;for(const a of this.layers)a.emit("refresh", |
|
{dataChanged:!0});for(const a of this.tables)a.emit("refresh",{dataChanged:!0})}async _handleNewRecords(a){const b=[];this.dataManager.addToLayer(a);for(const c of a)this.sublayerIdsCache.has(c.typeName)||(this.sublayerIdsCache.set(c.typeName,new Set),b.push(c.typeName)),this.sublayerIdsCache.get(c.typeName).add(c.id);for(const c of b)if(a=this._graphTypeLookup.get(c))this._addSublayer(a).title=c,"entity"===a.type?this.dataManager.entityTypeNames.add(c):this.dataManager.relationshipTypeNames.add(c), |
|
this.dataManager.sublayerCaches.set(c,new Map);this._refreshNamedTypes()}_createSublayers(a,b,c){a.forEach(d=>{const f=this._createSublayer(d);c(f)&&b.push(f);this._updateSublayerCaches(d)})}_addSublayer(a){a=this._createSublayer(a);a.geometryType?this.layers.push(a):this.tables.push(a);return a}_createSublayer(a){return new n({objectType:a,parentCompositeLayer:this,graphType:a.type,title:a.name})}_updateSublayers(a,b){b.forEach(c=>{c.parentCompositeLayer=this;const d=a.find(f=>f.type===c.graphType&& |
|
f.name===c.graphTypeName);d&&(c.objectType=d,c.read({title:d.name},{origin:"service"}),this._updateSublayerCaches(d))})}_updateSublayerCaches(a){const b=this.dataManager.sublayerCaches;b.has(a.name)||b.set(a.name,new Map)}_saveUrlAsNewResource(a,b,c,d){a[b]="\x3cpending\x3e";c.pendingOperations.push(O(this.inclusionModeDefinition).then(f=>{const k=P(d);a[b]=k.itemRelativeUrl;c.toAdd.push({resource:k,content:{type:"blob",blob:f},compress:!1,finish:p=>{this.definitionSetMap=p.url}})}))}_displaysAllRecords(a){for(const [, |
|
{useAllData:b}]of a.namedTypeDefinitions)if(!b)return!1;return!0}readDefinitionSetMap(a,b,c){return t.fromJSON(a,c)}writeDefinitionSetMap(a,b,c,d){const f=d?.portalItem,k=d?.resources,p=l.nameToId(d?.origin);if(f&&k&&null!=p){var {inclusionModeDefinition:m}=this;!m||this._displaysAllRecords(m)?this.definitionSetMap=null:(m=this.originIdOf("inclusionModeDefinition"),m===l.OriginId.USER||this._namedTypesModified||p<m?this._saveUrlAsNewResource(b,c,k,f):p===m&&a&&(a=t.toJSON(a,d),v.isAbsolute(a)?this._saveUrlAsNewResource(b, |
|
c,k,f):b[c]=a))}else a&&(b[c]=t.toJSON(a,d))}set inclusionModeDefinition(a){"loaded"===this.loadStatus||"failed"===this.loadStatus?r.getLogger(this).error("#inclusionModeDefinition","inclusionModeDefinition cannot be changed after the layer is loaded."):this._set("inclusionModeDefinition",a)}loadLayerAssumingLocalCache(){const a=[...this.memberEntityTypes,...this.memberRelationshipTypes];this.originIdOf("layers")===l.OriginId.DEFAULTS?this._createSublayers(a,this.layers,b=>!!b.geometryType):this._updateSublayers(a, |
|
this.layers);this.originIdOf("tables")===l.OriginId.DEFAULTS?this._createSublayers(a,this.tables,b=>!b.geometryType):this._updateSublayers(a,this.tables);this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.forEach((b,c)=>{const d=x.getOrCreateMapValue(this.sublayerIdsCache,c,()=>new Set);b.members?.forEach(f=>{d.add(f.id)})})}async addRecords(a){await this._handleNewRecords(a)}async removeRecords(a){const b=[];for(const c of a)!1===this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(c.typeName)?.useAllData&& |
|
this.dataManager.inclusionModeDefinition?.namedTypeDefinitions?.get(c.typeName)?.members?.has(c.id)&&b.push(c);this.dataManager.removeFromLayer(b);for(const c of b)this.sublayerIdsCache.get(c.typeName)?.delete(c.id);this._refreshNamedTypes();return b}};g.__decorate([h.property()],e.prototype,"dataManager",void 0);g.__decorate([h.property({json:{write:{ignoreOrigin:!0,writerEnsuresNonNull:!0}}})],e.prototype,"definitionSetMap",void 0);g.__decorate([A.reader("definitionSetMap")],e.prototype,"readDefinitionSetMap", |
|
null);g.__decorate([C.writer("definitionSetMap")],e.prototype,"writeDefinitionSetMap",null);g.__decorate([h.property()],e.prototype,"inclusionModeDefinition",null);g.__decorate([h.property()],e.prototype,"knowledgeGraph",void 0);g.__decorate([h.property({type:q.ofType(n),json:{write:{ignoreOrigin:!0}}})],e.prototype,"layers",void 0);g.__decorate([h.property()],e.prototype,"memberEntityTypes",void 0);g.__decorate([h.property()],e.prototype,"memberRelationshipTypes",void 0);g.__decorate([h.property({type:["KnowledgeGraphLayer"]})], |
|
e.prototype,"operationalLayerType",void 0);g.__decorate([h.property()],e.prototype,"sublayerIdsCache",void 0);g.__decorate([h.property({type:q.ofType(n),json:{write:{ignoreOrigin:!0}}})],e.prototype,"tables",void 0);g.__decorate([h.property({json:{read:!1}})],e.prototype,"type",void 0);g.__decorate([h.property(M.url)],e.prototype,"url",void 0);return e=g.__decorate([B.subclass("esri.layers.KnowledgeGraphLayer")],e)}); |