@itwin/core-backend 4.8.0-dev.9 → 4.9.0-dev.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +45 -1
- package/lib/cjs/BackendHubAccess.d.ts +18 -16
- package/lib/cjs/BackendHubAccess.d.ts.map +1 -1
- package/lib/cjs/BackendHubAccess.js +16 -15
- package/lib/cjs/BackendHubAccess.js.map +1 -1
- package/lib/cjs/BackendLoggerCategory.js.map +1 -1
- package/lib/cjs/BisCoreSchema.js.map +1 -1
- package/lib/cjs/BlobContainerService.js.map +1 -1
- package/lib/cjs/BriefcaseManager.d.ts.map +1 -1
- package/lib/cjs/BriefcaseManager.js +19 -11
- package/lib/cjs/BriefcaseManager.js.map +1 -1
- package/lib/cjs/Category.d.ts +0 -6
- package/lib/cjs/Category.d.ts.map +1 -1
- package/lib/cjs/Category.js +0 -6
- package/lib/cjs/Category.js.map +1 -1
- package/lib/cjs/ChangeSummaryManager.d.ts.map +1 -1
- package/lib/cjs/ChangeSummaryManager.js +13 -11
- package/lib/cjs/ChangeSummaryManager.js.map +1 -1
- package/lib/cjs/ChangedElementsDb.d.ts.map +1 -1
- package/lib/cjs/ChangedElementsDb.js +5 -3
- package/lib/cjs/ChangedElementsDb.js.map +1 -1
- package/lib/cjs/ChangedElementsManager.js.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.d.ts.map +1 -1
- package/lib/cjs/ChangesetECAdaptor.js +242 -237
- package/lib/cjs/ChangesetECAdaptor.js.map +1 -1
- package/lib/cjs/ChannelControl.d.ts +4 -26
- package/lib/cjs/ChannelControl.d.ts.map +1 -1
- package/lib/cjs/ChannelControl.js +2 -101
- package/lib/cjs/ChannelControl.js.map +1 -1
- package/lib/cjs/CheckpointManager.d.ts.map +1 -1
- package/lib/cjs/CheckpointManager.js +5 -3
- package/lib/cjs/CheckpointManager.js.map +1 -1
- package/lib/cjs/ClassRegistry.d.ts.map +1 -1
- package/lib/cjs/ClassRegistry.js +8 -7
- package/lib/cjs/ClassRegistry.js.map +1 -1
- package/lib/cjs/CloudSqlite.d.ts +1 -1
- package/lib/cjs/CloudSqlite.d.ts.map +1 -1
- package/lib/cjs/CloudSqlite.js +2 -2
- package/lib/cjs/CloudSqlite.js.map +1 -1
- package/lib/cjs/CodeService.js.map +1 -1
- package/lib/cjs/CodeSpecs.js.map +1 -1
- package/lib/cjs/ConcurrentQuery.js.map +1 -1
- package/lib/cjs/CustomViewState3dCreator.js.map +1 -1
- package/lib/cjs/DevTools.d.ts.map +1 -1
- package/lib/cjs/DevTools.js +2 -1
- package/lib/cjs/DevTools.js.map +1 -1
- package/lib/cjs/DisplayStyle.d.ts +0 -3
- package/lib/cjs/DisplayStyle.d.ts.map +1 -1
- package/lib/cjs/DisplayStyle.js +0 -3
- package/lib/cjs/DisplayStyle.js.map +1 -1
- package/lib/cjs/ECDb.d.ts +6 -1
- package/lib/cjs/ECDb.d.ts.map +1 -1
- package/lib/cjs/ECDb.js +19 -14
- package/lib/cjs/ECDb.js.map +1 -1
- package/lib/cjs/ECSchemaXmlContext.js +2 -2
- package/lib/cjs/ECSchemaXmlContext.js.map +1 -1
- package/lib/cjs/ECSqlStatement.d.ts +6 -3
- package/lib/cjs/ECSqlStatement.d.ts.map +1 -1
- package/lib/cjs/ECSqlStatement.js +3 -3
- package/lib/cjs/ECSqlStatement.js.map +1 -1
- package/lib/cjs/Element.d.ts +2 -59
- package/lib/cjs/Element.d.ts.map +1 -1
- package/lib/cjs/Element.js +7 -63
- package/lib/cjs/Element.js.map +1 -1
- package/lib/cjs/ElementAspect.d.ts +0 -5
- package/lib/cjs/ElementAspect.d.ts.map +1 -1
- package/lib/cjs/ElementAspect.js +4 -8
- package/lib/cjs/ElementAspect.js.map +1 -1
- package/lib/cjs/ElementGraphics.d.ts.map +1 -1
- package/lib/cjs/ElementGraphics.js +2 -1
- package/lib/cjs/ElementGraphics.js.map +1 -1
- package/lib/cjs/ElementTreeWalker.d.ts +19 -0
- package/lib/cjs/ElementTreeWalker.d.ts.map +1 -1
- package/lib/cjs/ElementTreeWalker.js +23 -9
- package/lib/cjs/ElementTreeWalker.js.map +1 -1
- package/lib/cjs/Entity.js.map +1 -1
- package/lib/cjs/EntityReferences.js.map +1 -1
- package/lib/cjs/ExportGraphics.js.map +1 -1
- package/lib/cjs/ExternalSource.js.map +1 -1
- package/lib/cjs/GeoCoordConfig.d.ts.map +1 -1
- package/lib/cjs/GeoCoordConfig.js +2 -1
- package/lib/cjs/GeoCoordConfig.js.map +1 -1
- package/lib/cjs/GeographicCRSServices.js +2 -2
- package/lib/cjs/GeographicCRSServices.js.map +1 -1
- package/lib/cjs/GeometrySummary.d.ts.map +1 -1
- package/lib/cjs/GeometrySummary.js +49 -48
- package/lib/cjs/GeometrySummary.js.map +1 -1
- package/lib/cjs/HubMock.js.map +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelDb.d.ts +24 -94
- package/lib/cjs/IModelDb.d.ts.map +1 -1
- package/lib/cjs/IModelDb.js +196 -151
- package/lib/cjs/IModelDb.js.map +1 -1
- package/lib/cjs/IModelElementCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelElementCloneContext.js +5 -4
- package/lib/cjs/IModelElementCloneContext.js.map +1 -1
- package/lib/cjs/IModelHost.d.ts +5 -3
- package/lib/cjs/IModelHost.d.ts.map +1 -1
- package/lib/cjs/IModelHost.js +16 -18
- package/lib/cjs/IModelHost.js.map +1 -1
- package/lib/cjs/IModelJsFs.js.map +1 -1
- package/lib/cjs/IpcHost.d.ts.map +1 -1
- package/lib/cjs/IpcHost.js +15 -13
- package/lib/cjs/IpcHost.js.map +1 -1
- package/lib/cjs/LineStyle.js.map +1 -1
- package/lib/cjs/LocalHub.d.ts +2 -2
- package/lib/cjs/LocalHub.d.ts.map +1 -1
- package/lib/cjs/LocalHub.js +18 -18
- package/lib/cjs/LocalHub.js.map +1 -1
- package/lib/cjs/LocalhostIpcHost.js.map +1 -1
- package/lib/cjs/LockControl.d.ts +73 -0
- package/lib/cjs/LockControl.d.ts.map +1 -0
- package/lib/cjs/LockControl.js +11 -0
- package/lib/cjs/LockControl.js.map +1 -0
- package/lib/cjs/Material.d.ts +2 -5
- package/lib/cjs/Material.d.ts.map +1 -1
- package/lib/cjs/Material.js +1 -4
- package/lib/cjs/Material.js.map +1 -1
- package/lib/cjs/Model.d.ts +0 -22
- package/lib/cjs/Model.d.ts.map +1 -1
- package/lib/cjs/Model.js +5 -26
- package/lib/cjs/Model.js.map +1 -1
- package/lib/cjs/NativeAppStorage.js.map +1 -1
- package/lib/cjs/NativeHost.js.map +1 -1
- package/lib/cjs/NavigationRelationship.js.map +1 -1
- package/lib/cjs/PromiseMemoizer.js.map +1 -1
- package/lib/cjs/PropertyStore.js.map +1 -1
- package/lib/cjs/Relationship.d.ts +0 -12
- package/lib/cjs/Relationship.d.ts.map +1 -1
- package/lib/cjs/Relationship.js +5 -16
- package/lib/cjs/Relationship.js.map +1 -1
- package/lib/cjs/RpcBackend.js.map +1 -1
- package/lib/cjs/SQLiteDb.d.ts +6 -1
- package/lib/cjs/SQLiteDb.d.ts.map +1 -1
- package/lib/cjs/SQLiteDb.js +23 -16
- package/lib/cjs/SQLiteDb.js.map +1 -1
- package/lib/cjs/Schema.js.map +1 -1
- package/lib/cjs/SchemaSync.d.ts +3 -0
- package/lib/cjs/SchemaSync.d.ts.map +1 -1
- package/lib/cjs/SchemaSync.js +24 -11
- package/lib/cjs/SchemaSync.js.map +1 -1
- package/lib/cjs/SchemaUtils.js +3 -3
- package/lib/cjs/SchemaUtils.js.map +1 -1
- package/lib/cjs/SqliteChangesetReader.d.ts.map +1 -1
- package/lib/cjs/SqliteChangesetReader.js +2 -2
- package/lib/cjs/SqliteChangesetReader.js.map +1 -1
- package/lib/cjs/SqliteStatement.js +2 -2
- package/lib/cjs/SqliteStatement.js.map +1 -1
- package/lib/cjs/TextAnnotationElement.js.map +1 -1
- package/lib/cjs/TextAnnotationGeometry.js.map +1 -1
- package/lib/cjs/TextAnnotationLayout.js.map +1 -1
- package/lib/cjs/Texture.js.map +1 -1
- package/lib/cjs/TileStorage.js.map +1 -1
- package/lib/cjs/TxnManager.d.ts +2 -1
- package/lib/cjs/TxnManager.d.ts.map +1 -1
- package/lib/cjs/TxnManager.js +4 -2
- package/lib/cjs/TxnManager.js.map +1 -1
- package/lib/cjs/ViewDefinition.d.ts +1 -18
- package/lib/cjs/ViewDefinition.d.ts.map +1 -1
- package/lib/cjs/ViewDefinition.js +1 -18
- package/lib/cjs/ViewDefinition.js.map +1 -1
- package/lib/cjs/ViewStateHydrator.js.map +1 -1
- package/lib/cjs/ViewStore.d.ts.map +1 -1
- package/lib/cjs/ViewStore.js +6 -5
- package/lib/cjs/ViewStore.js.map +1 -1
- package/lib/cjs/assets/IModelChange.02.00.00.ecschema.xml +90 -90
- package/lib/cjs/assets/Settings/Schemas/Base.Schema.json +32 -32
- package/lib/cjs/assets/Settings/Schemas/Gcs.schema.json +27 -27
- package/lib/cjs/assets/Settings/Schemas/Workspace.Schema.json +94 -94
- package/lib/cjs/assets/Settings/backend.setting.json5 +21 -21
- package/lib/cjs/core-backend.d.ts +2 -1
- package/lib/cjs/core-backend.d.ts.map +1 -1
- package/lib/cjs/core-backend.js +3 -5
- package/lib/cjs/core-backend.js.map +1 -1
- package/lib/cjs/domains/FunctionalElements.d.ts +0 -10
- package/lib/cjs/domains/FunctionalElements.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalElements.js +0 -10
- package/lib/cjs/domains/FunctionalElements.js.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.d.ts.map +1 -1
- package/lib/cjs/domains/FunctionalSchema.js +2 -1
- package/lib/cjs/domains/FunctionalSchema.js.map +1 -1
- package/lib/cjs/domains/GenericElements.d.ts +0 -18
- package/lib/cjs/domains/GenericElements.d.ts.map +1 -1
- package/lib/cjs/domains/GenericElements.js +0 -18
- package/lib/cjs/domains/GenericElements.js.map +1 -1
- package/lib/cjs/domains/GenericSchema.js.map +1 -1
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts +24 -0
- package/lib/cjs/internal/ChangesetConflictArgs.d.ts.map +1 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js +7 -0
- package/lib/cjs/internal/ChangesetConflictArgs.js.map +1 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts +34 -0
- package/lib/cjs/internal/ChannelAdmin.d.ts.map +1 -0
- package/lib/cjs/internal/ChannelAdmin.js +117 -0
- package/lib/cjs/internal/ChannelAdmin.js.map +1 -0
- package/lib/cjs/internal/NativePlatform.d.ts +15 -0
- package/lib/cjs/internal/NativePlatform.d.ts.map +1 -0
- package/lib/cjs/internal/NativePlatform.js +49 -0
- package/lib/cjs/internal/NativePlatform.js.map +1 -0
- package/lib/cjs/internal/NoLocks.d.ts +6 -0
- package/lib/cjs/internal/NoLocks.d.ts.map +1 -0
- package/lib/cjs/internal/NoLocks.js +31 -0
- package/lib/cjs/internal/NoLocks.js.map +1 -0
- package/lib/cjs/{ServerBasedLocks.d.ts → internal/ServerBasedLocks.d.ts} +10 -16
- package/lib/cjs/internal/ServerBasedLocks.d.ts.map +1 -0
- package/lib/cjs/{ServerBasedLocks.js → internal/ServerBasedLocks.js} +29 -18
- package/lib/cjs/internal/ServerBasedLocks.js.map +1 -0
- package/lib/cjs/internal/Symbols.d.ts +11 -0
- package/lib/cjs/internal/Symbols.d.ts.map +1 -0
- package/lib/cjs/internal/Symbols.js +21 -0
- package/lib/cjs/internal/Symbols.js.map +1 -0
- package/lib/cjs/internal/cross-package.d.ts +4 -0
- package/lib/cjs/internal/cross-package.d.ts.map +1 -0
- package/lib/cjs/internal/cross-package.js +16 -0
- package/lib/cjs/internal/cross-package.js.map +1 -0
- package/lib/cjs/internal/workspace/SettingsImpl.d.ts +2 -2
- package/lib/cjs/internal/workspace/SettingsImpl.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/SettingsImpl.js +3 -3
- package/lib/cjs/internal/workspace/SettingsImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js +2 -2
- package/lib/cjs/internal/workspace/SettingsSchemasImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceImpl.js +31 -27
- package/lib/cjs/internal/workspace/WorkspaceImpl.js.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.d.ts.map +1 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js +2 -1
- package/lib/cjs/internal/workspace/WorkspaceSqliteDb.js.map +1 -1
- package/lib/cjs/rpc/multipart.js.map +1 -1
- package/lib/cjs/rpc/tracing.d.ts.map +1 -1
- package/lib/cjs/rpc/tracing.js +5 -2
- package/lib/cjs/rpc/tracing.js.map +1 -1
- package/lib/cjs/rpc/web/logging.js.map +1 -1
- package/lib/cjs/rpc/web/request.js.map +1 -1
- package/lib/cjs/rpc/web/response.js.map +1 -1
- package/lib/cjs/rpc-impl/DevToolsRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts +1 -0
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js +9 -4
- package/lib/cjs/rpc-impl/IModelReadRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.d.ts.map +1 -1
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js +5 -3
- package/lib/cjs/rpc-impl/IModelTileRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/RpcBriefcaseUtility.js.map +1 -1
- package/lib/cjs/rpc-impl/SnapshotIModelRpcImpl.js.map +1 -1
- package/lib/cjs/rpc-impl/WipRpcImpl.js.map +1 -1
- package/lib/cjs/workspace/Settings.d.ts +3 -3
- package/lib/cjs/workspace/Settings.d.ts.map +1 -1
- package/lib/cjs/workspace/Settings.js +1 -1
- package/lib/cjs/workspace/Settings.js.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.d.ts +2 -2
- package/lib/cjs/workspace/SettingsSchemas.d.ts.map +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js +1 -1
- package/lib/cjs/workspace/SettingsSchemas.js.map +1 -1
- package/lib/cjs/workspace/Workspace.d.ts +4 -4
- package/lib/cjs/workspace/Workspace.d.ts.map +1 -1
- package/lib/cjs/workspace/Workspace.js +1 -1
- package/lib/cjs/workspace/Workspace.js.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.d.ts +2 -2
- package/lib/cjs/workspace/WorkspaceEditor.d.ts.map +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js +1 -1
- package/lib/cjs/workspace/WorkspaceEditor.js.map +1 -1
- package/package.json +13 -13
- package/lib/cjs/ServerBasedLocks.d.ts.map +0 -1
- package/lib/cjs/ServerBasedLocks.js.map +0 -1
- package/lib/cjs/internal/ImplementationProhibited.d.ts +0 -44
- package/lib/cjs/internal/ImplementationProhibited.d.ts.map +0 -1
- package/lib/cjs/internal/ImplementationProhibited.js +0 -51
- package/lib/cjs/internal/ImplementationProhibited.js.map +0 -1
package/lib/cjs/ElementAspect.js
CHANGED
|
@@ -11,13 +11,13 @@ exports.ExternalSourceAspect = exports.ChannelRootAspect = exports.ElementMultiA
|
|
|
11
11
|
const core_common_1 = require("@itwin/core-common");
|
|
12
12
|
const Entity_1 = require("./Entity");
|
|
13
13
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
14
|
+
const Symbols_1 = require("./internal/Symbols");
|
|
14
15
|
/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.
|
|
15
16
|
* Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.
|
|
16
17
|
* BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.
|
|
17
18
|
* @public
|
|
18
19
|
*/
|
|
19
20
|
class ElementAspect extends Entity_1.Entity {
|
|
20
|
-
/** @internal */
|
|
21
21
|
static get className() { return "ElementAspect"; }
|
|
22
22
|
/** Construct an aspect from its JSON representation and its containing iModel. */
|
|
23
23
|
constructor(props, iModel) {
|
|
@@ -36,7 +36,7 @@ class ElementAspect extends Entity_1.Entity {
|
|
|
36
36
|
*/
|
|
37
37
|
static onInsert(arg) {
|
|
38
38
|
const { props, iModel } = arg;
|
|
39
|
-
iModel.channels.
|
|
39
|
+
iModel.channels[Symbols_1._verifyChannel](arg.model);
|
|
40
40
|
iModel.locks.checkExclusiveLock(props.element.id, "element", "insert aspect");
|
|
41
41
|
}
|
|
42
42
|
/** Called after a new ElementAspect was inserted.
|
|
@@ -51,7 +51,7 @@ class ElementAspect extends Entity_1.Entity {
|
|
|
51
51
|
*/
|
|
52
52
|
static onUpdate(arg) {
|
|
53
53
|
const { props, iModel } = arg;
|
|
54
|
-
iModel.channels.
|
|
54
|
+
iModel.channels[Symbols_1._verifyChannel](arg.model);
|
|
55
55
|
iModel.locks.checkExclusiveLock(props.element.id, "element", "update aspect");
|
|
56
56
|
}
|
|
57
57
|
/** Called after an ElementAspect was updated.
|
|
@@ -66,7 +66,7 @@ class ElementAspect extends Entity_1.Entity {
|
|
|
66
66
|
*/
|
|
67
67
|
static onDelete(arg) {
|
|
68
68
|
const { aspectId, iModel } = arg;
|
|
69
|
-
iModel.channels.
|
|
69
|
+
iModel.channels[Symbols_1._verifyChannel](arg.model);
|
|
70
70
|
const { element } = iModel.elements.getAspect(aspectId);
|
|
71
71
|
iModel.locks.checkExclusiveLock(element.id, "element", "delete aspect");
|
|
72
72
|
}
|
|
@@ -81,7 +81,6 @@ exports.ElementAspect = ElementAspect;
|
|
|
81
81
|
* @public
|
|
82
82
|
*/
|
|
83
83
|
class ElementUniqueAspect extends ElementAspect {
|
|
84
|
-
/** @internal */
|
|
85
84
|
static get className() { return "ElementUniqueAspect"; }
|
|
86
85
|
}
|
|
87
86
|
exports.ElementUniqueAspect = ElementUniqueAspect;
|
|
@@ -89,7 +88,6 @@ exports.ElementUniqueAspect = ElementUniqueAspect;
|
|
|
89
88
|
* @public
|
|
90
89
|
*/
|
|
91
90
|
class ElementMultiAspect extends ElementAspect {
|
|
92
|
-
/** @internal */
|
|
93
91
|
static get className() { return "ElementMultiAspect"; }
|
|
94
92
|
}
|
|
95
93
|
exports.ElementMultiAspect = ElementMultiAspect;
|
|
@@ -97,7 +95,6 @@ exports.ElementMultiAspect = ElementMultiAspect;
|
|
|
97
95
|
* @public
|
|
98
96
|
*/
|
|
99
97
|
class ChannelRootAspect extends ElementUniqueAspect {
|
|
100
|
-
/** @internal */
|
|
101
98
|
static get className() { return "ChannelRootAspect"; }
|
|
102
99
|
/** Insert a ChannelRootAspect on the specified element.
|
|
103
100
|
* @deprecated in 4.0 use [[ChannelControl.makeChannelRoot]]. This method does not enforce the rule that channels may not nest and is therefore dangerous.
|
|
@@ -113,7 +110,6 @@ exports.ChannelRootAspect = ChannelRootAspect;
|
|
|
113
110
|
* @public
|
|
114
111
|
*/
|
|
115
112
|
class ExternalSourceAspect extends ElementMultiAspect {
|
|
116
|
-
/** @internal */
|
|
117
113
|
static get className() { return "ExternalSourceAspect"; }
|
|
118
114
|
/** Construct an aspect from its JSON representation and its containing iModel. */
|
|
119
115
|
constructor(props, iModel) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,qCAAkC;AAGlC,sDAA2D;AA0B3D;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IACvC,gBAAgB;IACT,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IAG1E,kFAAkF;IAClF,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAA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AC;IACb,CAAC;IAEkB,mBAAmB,CAAC,YAAgC;QACrE,KAAK,CAAC,mBAAmB,CAAC,YAAY,CAAC,CAAC;QACxC,IAAI,IAAI,CAAC,KAAK;YACZ,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC,CAAC;QACzC,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE,CAAC,CAAC;QACzC,IAAI,IAAI,CAAC,MAAM;YACb,YAAY,CAAC,UAAU,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;IAC5C,CAAC;CACF;AAvGD,oDAuGC;AAED,cAAc;AACd,WAAiB,oBAAoB;IACnC;;OAEG;IACH,IAAY,IASX;IATD,WAAY,IAAI;QACd,oFAAoF;QACpF,2BAAmB,CAAA;QACnB,yFAAyF;QACzF,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,oCAApB,oBAAoB,QAcpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module ElementAspects\n */\n\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\nimport { Entity } from \"./Entity\";\nimport { IModelDb } from \"./IModelDb\";\nimport { ECSqlStatement } from \"./ECSqlStatement\";\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\n\n/** Argument for the `ElementAspect.onXxx` static methods\n * @beta\n */\nexport interface OnAspectArg {\n /** The iModel for the aspect affected by this event. */\n iModel: IModelDb;\n /** The model for the aspect affected by this event */\n model: Id64String;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\n * @beta\n */\nexport interface OnAspectPropsArg extends OnAspectArg {\n /** The new properties of the aspect affected by this event. */\n props: Readonly<ElementAspectProps>;\n}\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\n * @beta\n */\nexport interface OnAspectIdArg extends OnAspectArg {\n /** The Id of the aspect affected by this event */\n aspectId: Id64String;\n}\n\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\n * @public\n */\nexport class ElementAspect extends Entity {\n /** @internal */\n public static override get className(): string { return \"ElementAspect\"; }\n public element: RelatedElement;\n\n /** Construct an aspect from its JSON representation and its containing iModel. */\n constructor(props: ElementAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n }\n\n public override toJSON(): ElementAspectProps {\n const val = super.toJSON() as ElementAspectProps;\n val.element = this.element;\n return val;\n }\n\n /** Called before a new ElementAspect is inserted.\n * @note throw an exception to disallow the insert\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInsert(arg: OnAspectPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels.verifyChannel(arg.model);\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"insert aspect\");\n }\n\n /** Called after a new ElementAspect was inserted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onInserted(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is updated.\n * @note throw an exception to disallow the update\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdate(arg: OnAspectPropsArg): void {\n const { props, iModel } = arg;\n iModel.channels.verifyChannel(arg.model);\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"update aspect\");\n }\n\n /** Called after an ElementAspect was updated.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\n\n /** Called before an ElementAspect is deleted.\n * @note throw an exception to disallow the delete\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDelete(arg: OnAspectIdArg): void {\n const { aspectId, iModel } = arg;\n iModel.channels.verifyChannel(arg.model);\n const { element } = iModel.elements.getAspect(aspectId);\n iModel.locks.checkExclusiveLock(element.id, \"element\", \"delete aspect\");\n }\n\n /** Called after an ElementAspect was deleted.\n * @note If you override this method, you must call super.\n * @beta\n */\n protected static onDeleted(_arg: OnAspectIdArg): void { }\n}\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\n * @public\n */\nexport class ElementUniqueAspect extends ElementAspect {\n /** @internal */\n public static override get className(): string { return \"ElementUniqueAspect\"; }\n}\n\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\n * @public\n */\nexport class ElementMultiAspect extends ElementAspect {\n /** @internal */\n public static override get className(): string { return \"ElementMultiAspect\"; }\n}\n\n/**\n * @public\n */\nexport class ChannelRootAspect extends ElementUniqueAspect {\n /** @internal */\n public static override get className(): string { return \"ChannelRootAspect\"; }\n /** Insert a ChannelRootAspect on the specified element.\n * @deprecated in 4.0 use [[ChannelControl.makeChannelRoot]]. This method does not enforce the rule that channels may not nest and is therefore dangerous.\n */\n public static insert(iModel: IModelDb, ownerId: Id64String, channelName: string) {\n const props: ChannelRootAspectProps = { classFullName: this.classFullName, element: { id: ownerId }, owner: channelName };\n iModel.elements.insertAspect(props);\n }\n}\n\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\n * @public\n */\nexport class ExternalSourceAspect extends ElementMultiAspect {\n /** @internal */\n public static override get className(): string { return \"ExternalSourceAspect\"; }\n\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\n */\n public scope: RelatedElement;\n /** The identifier of the object in the source repository. */\n public identifier: string;\n /** The kind of object within the source repository. */\n public kind: string;\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\n public checksum?: string;\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\n * If present, this value must be guaranteed to change when any of the source object's content changes.\n */\n public version?: string;\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process.\n * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel.\n * This will be a breaking change, since application code will have to change from supplying a string to supplying an object.\n */\n public jsonProperties?: string;\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\n public source?: RelatedElement;\n\n /** Construct an aspect from its JSON representation and its containing iModel. */\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\n super(props, iModel);\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\n this.source = RelatedElement.fromJSON(props.source);\n this.identifier = props.identifier;\n this.kind = props.kind;\n this.checksum = props.checksum;\n this.version = props.version;\n this.jsonProperties = props.jsonProperties;\n }\n\n /** @deprecated in 3.x. findAllBySource */\n public static findBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): { elementId?: Id64String, aspectId?: Id64String } {\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\n let elementId: Id64String | undefined;\n let aspectId: Id64String | undefined;\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\n statement.bindId(\"scope\", scope);\n statement.bindString(\"kind\", kind);\n statement.bindString(\"identifier\", identifier);\n if (DbResult.BE_SQLITE_ROW === statement.step()) {\n elementId = statement.getValue(0).getId();\n aspectId = statement.getValue(1).getId();\n }\n });\n return { elementId, aspectId };\n }\n\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\n * Therefore, the result array could have more than one entry with the same elementId.\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\n * @param iModelDb The iModel to query\n * @param scope The scope of the ExternalSourceAspects to find\n * @param kind The kind of the ExternalSourceAspects to find\n * @param identifier The identifier of the ExternalSourceAspects to find\n * @returns the query results\n */\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\n statement.bindId(\"scope\", scope);\n statement.bindString(\"kind\", kind);\n statement.bindString(\"identifier\", identifier);\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\n }\n });\n return found;\n }\n\n public override toJSON(): ExternalSourceAspectProps {\n const val = super.toJSON() as ExternalSourceAspectProps;\n val.scope = this.scope;\n val.source = this.source;\n val.identifier = this.identifier;\n val.kind = this.kind;\n val.checksum = this.checksum;\n val.version = this.version;\n val.jsonProperties = this.jsonProperties;\n return val;\n }\n\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\n super.collectReferenceIds(referenceIds);\n if (this.scope)\n referenceIds.addElement(this.scope.id);\n referenceIds.addElement(this.element.id);\n if (this.source)\n referenceIds.addElement(this.source.id);\n }\n}\n\n/** @public */\nexport namespace ExternalSourceAspect { // eslint-disable-line no-redeclare\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\n * @public\n */\n export enum Kind {\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\n Element = \"Element\",\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\n Relationship = \"Relationship\",\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\n * @see [[ExternalSourceAspect.scope]]\n */\n Scope = \"Scope\",\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementAspect.js","sourceRoot":"","sources":["../../src/ElementAspect.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAA+I;AAC/I,qCAAkC;AAGlC,sDAA2D;AAC3D,gDAAoD;AA0BpD;;;;GAIG;AACH,MAAa,aAAc,SAAQ,eAAM;IAChC,MAAM,KAAc,SAAS,KAAa,OAAO,eAAe,CAAC,CAAC,CAAC;IAG1E,kFAAkF;IAClF,YAAY,KAAyB,EAAE,MAAgB;QACrD,KAAK,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,4BAAc,CAAC,QAAQ,CAAC,KAAK,CAAC,OAAO,CAAE,CAAC,CAAC,+DAA+D;IACzH,CAAC;IAEe,MAAM;QACpB,MAAM,GAAG,GAAG,KAAK,CAAC,MAAM,EAAwB,CAAC;QACjD,GAAG,CAAC,OAAO,GAAG,IAAI,CAAC,OAAO,CAAC;QAC3B,OAAO,GAAG,CAAC;IACb,CAAC;IAED;;;;OAIG;IACO,MAAM,CAAC,QAAQ,CAAC,GAAqB;QAC7C,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,GAAG,CAAC;QAC9B,MAAM,CAAC,QAAQ,CAAC,wBAAc,CAAC,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;QAC3C,MAAM,CAAC,KAAK,CAAC,kBAAkB,CAAC,KAAK,CAAC,OAAO,CAAC,EAAE,EAAE,SAA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F,qCAA6B,CAAA;QAC7B;;WAEG;QACH,uBAAe,CAAA;IACjB,CAAC,EATW,IAAI,GAAJ,yBAAI,KAAJ,yBAAI,QASf;AACH,CAAC,EAdgB,oBAAoB,oCAApB,oBAAoB,QAcpC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module ElementAspects\r\n */\r\n\r\nimport { ChannelRootAspectProps, ElementAspectProps, EntityReferenceSet, ExternalSourceAspectProps, RelatedElement } from \"@itwin/core-common\";\r\nimport { Entity } from \"./Entity\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { ECSqlStatement } from \"./ECSqlStatement\";\r\nimport { DbResult, Id64String } from \"@itwin/core-bentley\";\r\nimport { _verifyChannel } from \"./internal/Symbols\";\r\n\r\n/** Argument for the `ElementAspect.onXxx` static methods\r\n * @beta\r\n */\r\nexport interface OnAspectArg {\r\n /** The iModel for the aspect affected by this event. */\r\n iModel: IModelDb;\r\n /** The model for the aspect affected by this event */\r\n model: Id64String;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that supply the properties of an aspect to be inserted or updated.\r\n * @beta\r\n */\r\nexport interface OnAspectPropsArg extends OnAspectArg {\r\n /** The new properties of the aspect affected by this event. */\r\n props: Readonly<ElementAspectProps>;\r\n}\r\n/** Argument for the `ElementAspect.onXxx` static methods that only supply the Id of the affected aspect.\r\n * @beta\r\n */\r\nexport interface OnAspectIdArg extends OnAspectArg {\r\n /** The Id of the aspect affected by this event */\r\n aspectId: Id64String;\r\n}\r\n\r\n/** An Element Aspect is a class that defines a set of properties that are related to (and owned by) a single element.\r\n * Semantically, an ElementAspect can be considered part of the Element. Thus, an ElementAspect is deleted if its owning Element is deleted.\r\n * BIS Guideline: Subclass ElementUniqueAspect or ElementMultiAspect rather than subclassing ElementAspect directly.\r\n * @public\r\n */\r\nexport class ElementAspect extends Entity {\r\n public static override get className(): string { return \"ElementAspect\"; }\r\n public element: RelatedElement;\r\n\r\n /** Construct an aspect from its JSON representation and its containing iModel. */\r\n constructor(props: ElementAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.element = RelatedElement.fromJSON(props.element)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n }\r\n\r\n public override toJSON(): ElementAspectProps {\r\n const val = super.toJSON() as ElementAspectProps;\r\n val.element = this.element;\r\n return val;\r\n }\r\n\r\n /** Called before a new ElementAspect is inserted.\r\n * @note throw an exception to disallow the insert\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInsert(arg: OnAspectPropsArg): void {\r\n const { props, iModel } = arg;\r\n iModel.channels[_verifyChannel](arg.model);\r\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"insert aspect\");\r\n }\r\n\r\n /** Called after a new ElementAspect was inserted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onInserted(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is updated.\r\n * @note throw an exception to disallow the update\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdate(arg: OnAspectPropsArg): void {\r\n const { props, iModel } = arg;\r\n iModel.channels[_verifyChannel](arg.model);\r\n iModel.locks.checkExclusiveLock(props.element.id, \"element\", \"update aspect\");\r\n }\r\n\r\n /** Called after an ElementAspect was updated.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onUpdated(_arg: OnAspectPropsArg): void { }\r\n\r\n /** Called before an ElementAspect is deleted.\r\n * @note throw an exception to disallow the delete\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDelete(arg: OnAspectIdArg): void {\r\n const { aspectId, iModel } = arg;\r\n iModel.channels[_verifyChannel](arg.model);\r\n const { element } = iModel.elements.getAspect(aspectId);\r\n iModel.locks.checkExclusiveLock(element.id, \"element\", \"delete aspect\");\r\n }\r\n\r\n /** Called after an ElementAspect was deleted.\r\n * @note If you override this method, you must call super.\r\n * @beta\r\n */\r\n protected static onDeleted(_arg: OnAspectIdArg): void { }\r\n}\r\n/** An Element Unique Aspect is an ElementAspect where there can be only zero or one instance of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementUniqueAspect extends ElementAspect {\r\n public static override get className(): string { return \"ElementUniqueAspect\"; }\r\n}\r\n\r\n/** An Element Multi-Aspect is an ElementAspect where there can be **n** instances of the Element Aspect class per Element.\r\n * @public\r\n */\r\nexport class ElementMultiAspect extends ElementAspect {\r\n public static override get className(): string { return \"ElementMultiAspect\"; }\r\n}\r\n\r\n/**\r\n * @public\r\n */\r\nexport class ChannelRootAspect extends ElementUniqueAspect {\r\n public static override get className(): string { return \"ChannelRootAspect\"; }\r\n /** Insert a ChannelRootAspect on the specified element.\r\n * @deprecated in 4.0 use [[ChannelControl.makeChannelRoot]]. This method does not enforce the rule that channels may not nest and is therefore dangerous.\r\n */\r\n public static insert(iModel: IModelDb, ownerId: Id64String, channelName: string) {\r\n const props: ChannelRootAspectProps = { classFullName: this.classFullName, element: { id: ownerId }, owner: channelName };\r\n iModel.elements.insertAspect(props);\r\n }\r\n}\r\n\r\n/** An ElementMultiAspect that stores synchronization information for an Element originating from an external source.\r\n * @note The associated ECClass was added to the BisCore schema in version 1.0.2\r\n * @public\r\n */\r\nexport class ExternalSourceAspect extends ElementMultiAspect {\r\n public static override get className(): string { return \"ExternalSourceAspect\"; }\r\n\r\n /** An element that scopes the combination of `kind` and `identifier` to uniquely identify the object from the external source.\r\n * @note Warning: in a future major release the `scope` property will be optional, since the scope is intended to be potentially invalid.\r\n * all references should treat it as potentially undefined, but we cannot change the type yet since that is a breaking change.\r\n */\r\n public scope: RelatedElement;\r\n /** The identifier of the object in the source repository. */\r\n public identifier: string;\r\n /** The kind of object within the source repository. */\r\n public kind: string;\r\n /** The cryptographic hash (any algorithm) of the source object's content. If defined, it must be guaranteed to change when the source object's content changes. */\r\n public checksum?: string;\r\n /** An optional value that is typically a version number or a pseudo version number like last modified time.\r\n * It will be used by the synchronization process to detect that a source object is unchanged so that computing a cryptographic hash can be avoided.\r\n * If present, this value must be guaranteed to change when any of the source object's content changes.\r\n */\r\n public version?: string;\r\n /** A place where additional JSON properties can be stored. For example, provenance information or properties relating to the synchronization process.\r\n * @note Warning: in a future major release, the type of `jsonProperties` will be changed to object, and itwin.js will automatically stringify it when writing to the iModel.\r\n * This will be a breaking change, since application code will have to change from supplying a string to supplying an object.\r\n */\r\n public jsonProperties?: string;\r\n /** The source of the imported/synchronized object. Should point to an instance of [ExternalSource]($backend). */\r\n public source?: RelatedElement;\r\n\r\n /** Construct an aspect from its JSON representation and its containing iModel. */\r\n constructor(props: ExternalSourceAspectProps, iModel: IModelDb) {\r\n super(props, iModel);\r\n this.scope = RelatedElement.fromJSON(props.scope)!; // eslint-disable-line @typescript-eslint/no-non-null-assertion\r\n this.source = RelatedElement.fromJSON(props.source);\r\n this.identifier = props.identifier;\r\n this.kind = props.kind;\r\n this.checksum = props.checksum;\r\n this.version = props.version;\r\n this.jsonProperties = props.jsonProperties;\r\n }\r\n\r\n /** @deprecated in 3.x. findAllBySource */\r\n public static findBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): { elementId?: Id64String, aspectId?: Id64String } {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n let elementId: Id64String | undefined;\r\n let aspectId: Id64String | undefined;\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n if (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n elementId = statement.getValue(0).getId();\r\n aspectId = statement.getValue(1).getId();\r\n }\r\n });\r\n return { elementId, aspectId };\r\n }\r\n\r\n /** Look up the elements that contain one or more ExternalSourceAspect with the specified Scope, Kind, and Identifier.\r\n * The result of this function is an array of all of the ExternalSourceAspects that were found, each associated with the owning element.\r\n * A given element could have more than one ExternalSourceAspect with the given scope, kind, and identifier.\r\n * Also, many elements could have ExternalSourceAspect with the same scope, kind, and identifier.\r\n * Therefore, the result array could have more than one entry with the same elementId.\r\n * Aspects are never shared. Each aspect has its own unique ECInstanceId.\r\n * @param iModelDb The iModel to query\r\n * @param scope The scope of the ExternalSourceAspects to find\r\n * @param kind The kind of the ExternalSourceAspects to find\r\n * @param identifier The identifier of the ExternalSourceAspects to find\r\n * @returns the query results\r\n */\r\n public static findAllBySource(iModelDb: IModelDb, scope: Id64String, kind: string, identifier: string): Array<{ elementId: Id64String, aspectId: Id64String }> {\r\n const sql = `SELECT Element.Id, ECInstanceId FROM ${ExternalSourceAspect.classFullName} WHERE (Scope.Id=:scope AND Kind=:kind AND Identifier=:identifier)`;\r\n const found: Array<{ elementId: Id64String, aspectId: Id64String }> = [];\r\n iModelDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\r\n statement.bindId(\"scope\", scope);\r\n statement.bindString(\"kind\", kind);\r\n statement.bindString(\"identifier\", identifier);\r\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\r\n found.push({ elementId: statement.getValue(0).getId(), aspectId: statement.getValue(1).getId() });\r\n }\r\n });\r\n return found;\r\n }\r\n\r\n public override toJSON(): ExternalSourceAspectProps {\r\n const val = super.toJSON() as ExternalSourceAspectProps;\r\n val.scope = this.scope;\r\n val.source = this.source;\r\n val.identifier = this.identifier;\r\n val.kind = this.kind;\r\n val.checksum = this.checksum;\r\n val.version = this.version;\r\n val.jsonProperties = this.jsonProperties;\r\n return val;\r\n }\r\n\r\n protected override collectReferenceIds(referenceIds: EntityReferenceSet): void {\r\n super.collectReferenceIds(referenceIds);\r\n if (this.scope)\r\n referenceIds.addElement(this.scope.id);\r\n referenceIds.addElement(this.element.id);\r\n if (this.source)\r\n referenceIds.addElement(this.source.id);\r\n }\r\n}\r\n\r\n/** @public */\r\nexport namespace ExternalSourceAspect { // eslint-disable-line no-redeclare\r\n /** Standard values for the `Kind` property of `ExternalSourceAspect`.\r\n * @public\r\n */\r\n export enum Kind {\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Element]] provenance */\r\n Element = \"Element\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing [[Relationship]] provenance */\r\n Relationship = \"Relationship\",\r\n /** Indicates that the [[ExternalSourceAspect]] is storing *scope* provenance\r\n * @see [[ExternalSourceAspect.scope]]\r\n */\r\n Scope = \"Scope\",\r\n }\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementGraphics.d.ts","sourceRoot":"","sources":["../../src/ElementGraphics.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,2BAA2B,EAAe,MAAM,oBAAoB,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"ElementGraphics.d.ts","sourceRoot":"","sources":["../../src/ElementGraphics.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,2BAA2B,EAAe,MAAM,oBAAoB,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AAGtC;;GAEG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,2BAA2B,EAAE,MAAM,EAAE,QAAQ,GAAG,OAAO,CAAC,UAAU,GAAG,SAAS,CAAC,CA0BrI"}
|
|
@@ -7,11 +7,12 @@ exports.generateElementGraphics = void 0;
|
|
|
7
7
|
*--------------------------------------------------------------------------------------------*/
|
|
8
8
|
const core_bentley_1 = require("@itwin/core-bentley");
|
|
9
9
|
const core_common_1 = require("@itwin/core-common");
|
|
10
|
+
const Symbols_1 = require("./internal/Symbols");
|
|
10
11
|
/** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.
|
|
11
12
|
* @internal
|
|
12
13
|
*/
|
|
13
14
|
async function generateElementGraphics(request, iModel) {
|
|
14
|
-
const result = await iModel.
|
|
15
|
+
const result = await iModel[Symbols_1._nativeDb].generateElementGraphics(request); // ###TODO update package versions in addon
|
|
15
16
|
let error;
|
|
16
17
|
switch (result.status) {
|
|
17
18
|
case 2 /* ElementGraphicsStatus.NoGeometry */:
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../src/ElementGraphics.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAA2D;AAC3D,oDAA8E;
|
|
1
|
+
{"version":3,"file":"ElementGraphics.js","sourceRoot":"","sources":["../../src/ElementGraphics.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F,sDAA2D;AAC3D,oDAA8E;AAG9E,gDAA+C;AAE/C;;GAEG;AACI,KAAK,UAAU,uBAAuB,CAAC,OAAoC,EAAE,MAAgB;IAClG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,mBAAS,CAAC,CAAC,uBAAuB,CAAC,OAAc,CAAC,CAAC,CAAC,2CAA2C;IAE3H,IAAI,KAAyB,CAAC;IAC9B,QAAQ,MAAM,CAAC,MAAM,EAAE,CAAC;QACtB,8CAAsC;QACtC;YACE,OAAO,SAAS,CAAC;QACnB;YACE,OAAO,MAAM,CAAC,OAAO,CAAC;QACxB;YACE,KAAK,GAAG,cAAc,CAAC;YACvB,MAAM;QACR;YACE,KAAK,GAAG,8BAA8B,CAAC;YACvC,MAAM;QACR;YACE,KAAK,GAAG,cAAc,OAAO,CAAC,SAAS,YAAY,CAAC;YACpD,MAAM;QACR;YACE,KAAK,GAAG,yBAAyB,OAAO,CAAC,EAAE,GAAG,CAAC;YAC/C,MAAM;IACV,CAAC;IAED,IAAA,qBAAM,EAAC,SAAS,KAAK,KAAK,CAAC,CAAC;IAC5B,MAAM,IAAI,yBAAW,CAAC,2BAAY,CAAC,UAAU,EAAE,KAAK,CAAC,CAAC;AACxD,CAAC;AA1BD,0DA0BC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\nimport { assert, IModelStatus } from \"@itwin/core-bentley\";\r\nimport { ElementGraphicsRequestProps, IModelError } from \"@itwin/core-common\";\r\nimport { ElementGraphicsStatus } from \"@bentley/imodeljs-native\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { _nativeDb } from \"./internal/Symbols\";\r\n\r\n/** See [[IModelDb.generateElementGraphics]] and IModelTileRpcImpl.requestElementGraphics.\r\n * @internal\r\n */\r\nexport async function generateElementGraphics(request: ElementGraphicsRequestProps, iModel: IModelDb): Promise<Uint8Array | undefined> {\r\n const result = await iModel[_nativeDb].generateElementGraphics(request as any); // ###TODO update package versions in addon\r\n\r\n let error: string | undefined;\r\n switch (result.status) {\r\n case ElementGraphicsStatus.NoGeometry:\r\n case ElementGraphicsStatus.Canceled:\r\n return undefined;\r\n case ElementGraphicsStatus.Success:\r\n return result.content;\r\n case ElementGraphicsStatus.InvalidJson:\r\n error = \"Invalid JSON\";\r\n break;\r\n case ElementGraphicsStatus.UnknownMajorFormatVersion:\r\n error = \"Unknown major format version\";\r\n break;\r\n case ElementGraphicsStatus.ElementNotFound:\r\n error = `Element Id ${request.elementId} not found`;\r\n break;\r\n case ElementGraphicsStatus.DuplicateRequestId:\r\n error = `Duplicate request Id \"${request.id}\"`;\r\n break;\r\n }\r\n\r\n assert(undefined !== error);\r\n throw new IModelError(IModelStatus.BadRequest, error);\r\n}\r\n"]}
|
|
@@ -144,15 +144,34 @@ export declare class ElementSubTreeDeleter extends ElementTreeTopDown {
|
|
|
144
144
|
*/
|
|
145
145
|
deleteSpecialElementSubTrees(): void;
|
|
146
146
|
}
|
|
147
|
+
/** Arguments supplied to [[deleteElementTree]].
|
|
148
|
+
* @beta
|
|
149
|
+
*/
|
|
150
|
+
export interface DeleteElementTreeArgs {
|
|
151
|
+
/** The iModel containing the elements to delete. */
|
|
152
|
+
iModel: IModelDb;
|
|
153
|
+
/** The Id of the root element of the tree to delete. */
|
|
154
|
+
topElement: Id64String;
|
|
155
|
+
/** The maximum number of passes to make when deleting definition elements.
|
|
156
|
+
* Default: 5
|
|
157
|
+
*/
|
|
158
|
+
maxPasses?: number;
|
|
159
|
+
}
|
|
147
160
|
/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.
|
|
148
161
|
* @param iModel The iModel
|
|
149
162
|
* @param topElement The parent of the sub-tree
|
|
150
163
|
* @beta
|
|
151
164
|
*/
|
|
152
165
|
export declare function deleteElementTree(iModel: IModelDb, topElement: Id64String): void;
|
|
166
|
+
/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.
|
|
167
|
+
* @param args Specifies the iModel and top element.
|
|
168
|
+
* @beta
|
|
169
|
+
*/
|
|
170
|
+
export declare function deleteElementTree(args: DeleteElementTreeArgs): void;
|
|
153
171
|
/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.
|
|
154
172
|
* If the filter selects the top element itself, then the entire tree (including the top element) is deleted.
|
|
155
173
|
* That has the same effect as calling [[deleteElementTree]] on the top element.
|
|
174
|
+
* @note The caller may have to call this function multiple times if there are multiple layers of dependencies among definition elements.
|
|
156
175
|
* @param iModel The iModel
|
|
157
176
|
* @param topElement Where to start the search.
|
|
158
177
|
* @param filter Callback that selects sub-trees that should be deleted.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementTreeWalker.d.ts","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EAAoB,SAAS,EAAE,UAAU,EAAoB,MAAM,qBAAqB,CAAC;AAIhG,OAAO,EAAE,QAAQ,EAAE,MAAM,YAAY,CAAC;AACtC,OAAO,EAAmB,KAAK,EAAE,MAAM,SAAS,CAAC;A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AAM,CAAC;CACpB;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,GAAG,IAAI,CAAC;AAClF;;;GAGG;AACH,wBAAgB,iBAAiB,CAAC,IAAI,EAAE,qBAAqB,GAAG,IAAI,CAAC;AAyBrE;;;;;;;;GAQG;AACH,wBAAgB,qBAAqB,CAAC,MAAM,EAAE,QAAQ,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,0BAA0B,GAAG,IAAI,CAIxH"}
|
|
@@ -387,20 +387,34 @@ class ElementSubTreeDeleter extends ElementTreeTopDown {
|
|
|
387
387
|
}
|
|
388
388
|
}
|
|
389
389
|
exports.ElementSubTreeDeleter = ElementSubTreeDeleter;
|
|
390
|
-
/**
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
390
|
+
/** @internal */
|
|
391
|
+
function deleteElementTree(arg0, arg1) {
|
|
392
|
+
let maxPasses;
|
|
393
|
+
let iModel;
|
|
394
|
+
let topElement;
|
|
395
|
+
if (arg0 instanceof IModelDb_1.IModelDb) {
|
|
396
|
+
(0, core_bentley_1.assert)(typeof arg1 === "string");
|
|
397
|
+
iModel = arg0;
|
|
398
|
+
topElement = arg1;
|
|
399
|
+
}
|
|
400
|
+
else {
|
|
401
|
+
iModel = arg0.iModel;
|
|
402
|
+
topElement = arg0.topElement;
|
|
403
|
+
maxPasses = arg0.maxPasses;
|
|
404
|
+
}
|
|
405
|
+
maxPasses = maxPasses ?? 5;
|
|
406
|
+
let pass = 0;
|
|
407
|
+
do {
|
|
408
|
+
const del = new ElementTreeDeleter(iModel);
|
|
409
|
+
del.deleteNormalElements(topElement);
|
|
410
|
+
del.deleteSpecialElements();
|
|
411
|
+
} while ((iModel.elements.tryGetElement(topElement) !== undefined) && (++pass < maxPasses));
|
|
399
412
|
}
|
|
400
413
|
exports.deleteElementTree = deleteElementTree;
|
|
401
414
|
/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.
|
|
402
415
|
* If the filter selects the top element itself, then the entire tree (including the top element) is deleted.
|
|
403
416
|
* That has the same effect as calling [[deleteElementTree]] on the top element.
|
|
417
|
+
* @note The caller may have to call this function multiple times if there are multiple layers of dependencies among definition elements.
|
|
404
418
|
* @param iModel The iModel
|
|
405
419
|
* @param topElement Where to start the search.
|
|
406
420
|
* @param filter Callback that selects sub-trees that should be deleted.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ElementTreeWalker.js","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAgG;AAChG,oDAA4C;AAC5C,mEAAgE;AAChE,uCAA0G;AAC1G,yCAAsC;AACtC,mCAAiD;AAEjD,MAAM,cAAc,GAAG,GAAG,6CAAqB,CAAC,QAAQ,oBAAoB,CAAC;AAK7E,SAAS,yBAAyB,CAAC,MAAgB,EAAE,GAAc;IACjE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAClD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;YAEnB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QACvB,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnB,OAAO,CAAC,GAAG,yBAAyB,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;A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,EAAE,CAAC;IAC5C,CAAC;CACF;AApCD,sDAoCC;AAED;;;;GAIG;AACH,SAAgB,iBAAiB,CAAC,MAAgB,EAAE,UAAsB;IACxE,MAAM,GAAG,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC3C,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;IACrC,GAAG,CAAC,qBAAqB,EAAE,CAAC;AAC9B,CAAC;AAJD,8CAIC;AAED;;;;;;;GAOG;AACH,SAAgB,qBAAqB,CAAC,MAAgB,EAAE,UAAsB,EAAE,MAAkC;IAChH,MAAM,GAAG,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,GAAG,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAC5C,GAAG,CAAC,4BAA4B,EAAE,CAAC;AACrC,CAAC;AAJD,sDAIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Elements\n */\nimport { assert, DbResult, Id64Array, Id64String, Logger, LogLevel } from \"@itwin/core-bentley\";\nimport { IModel } from \"@itwin/core-common\";\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\nimport { DefinitionContainer, DefinitionElement, DefinitionPartition, Element, Subject } from \"./Element\";\nimport { IModelDb } from \"./IModelDb\";\nimport { DefinitionModel, Model } from \"./Model\";\n\nconst loggerCategory = `${BackendLoggerCategory.IModelDb}.ElementTreeWalker`;\n\n/** @beta */\nexport interface ElementTreeWalkerModelInfo { model: Model, isDefinitionModel: boolean }\n\nfunction sortChildrenBeforeParents(iModel: IModelDb, ids: Id64Array): Array<Id64Array> {\n const children: Id64Array = [];\n const parents: Id64Array = [];\n for (const eid of ids) {\n const parentId = iModel.elements.queryParent(eid);\n if (parentId !== undefined && ids.includes(parentId))\n children.push(eid);\n else\n parents.push(eid);\n }\n\n if (children.length === 0)\n return [parents];\n\n return [...sortChildrenBeforeParents(iModel, children), parents];\n}\n\nfunction isModelEmpty(iModel: IModelDb, modelId: Id64String): boolean {\n return iModel.withPreparedStatement(`select count(*) from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\n stmt.bindId(1, modelId);\n stmt.step();\n return stmt.getValue(0).getInteger() === 0;\n });\n}\n\nfunction isDefinitionModel(model: Model): boolean {\n return (model.id !== IModel.repositoryModelId) && (model instanceof DefinitionModel);\n}\n\nenum ElementPruningClassification { PRUNING_CLASS_Normal = 0, PRUNING_CLASS_Subject = 1, PRUNING_CLASS_Definition = 2, PRUNING_CLASS_DefinitionPartition = 3, }\n\nfunction classifyElementForPruning(iModel: IModelDb, elementId: Id64String): ElementPruningClassification {\n const el = iModel.elements.getElement(elementId);\n // DefinitionContainer is submodeled by a DefinitionModel and so it must be classified as PRUNING_CLASS_DefinitionPartition for tree-walking purposes.\n // Since DefinitionContainer is-a DefinitionElement the (el instanceof DefinitionElement) case below would classify it as PRUNING_CLASS_Definition.\n // That is why we special-case it here.\n if (el instanceof DefinitionContainer)\n return ElementPruningClassification.PRUNING_CLASS_DefinitionPartition;\n return (el instanceof Subject) ? ElementPruningClassification.PRUNING_CLASS_Subject :\n (el instanceof DefinitionElement) ? ElementPruningClassification.PRUNING_CLASS_Definition :\n (el instanceof DefinitionPartition) ? ElementPruningClassification.PRUNING_CLASS_DefinitionPartition :\n ElementPruningClassification.PRUNING_CLASS_Normal;\n}\n\n/** Records the path that a tree search took to reach an element or model. This object is immutable.\n * @beta\n */\nexport class ElementTreeWalkerScope {\n public readonly topElement: Id64String = \"\";\n /** path of parent elements and enclosing models */\n public readonly path: Array<Id64String | ElementTreeWalkerModelInfo> = [];\n /** cached info about the immediately enclosing model (i.e., the last model in path) */\n public readonly enclosingModelInfo: ElementTreeWalkerModelInfo;\n\n constructor(topElement: Id64String, model: Model);\n constructor(enclosingScope: ElementTreeWalkerScope, newScope: Id64String | Model);\n constructor(arg1: Id64String | ElementTreeWalkerScope, arg2: Model | Id64String) {\n if (typeof arg1 === \"string\") {\n // normal constructor\n assert(arg2 instanceof Model);\n this.topElement = arg1;\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\n } else if (arg1 instanceof ElementTreeWalkerScope) {\n // copy-like constructor\n this.topElement = arg1.topElement;\n this.path = [...arg1.path];\n if (typeof arg2 === \"string\") {\n // with new parent\n this.path.push(arg2);\n this.enclosingModelInfo = arg1.enclosingModelInfo;\n } else {\n // with new enclosing model\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\n }\n } else {\n throw new Error(\"invalid constructor signature\");\n }\n }\n\n public get enclosingModel(): Model { return this.enclosingModelInfo.model; }\n public get inDefinitionModel(): boolean { return this.enclosingModelInfo.isDefinitionModel; } // NB: this will return false for the RepositoryModel!\n public get inRepositoryModel(): boolean { return this.enclosingModelInfo.model.id === IModelDb.repositoryModelId; }\n\n public static createTopScope(iModel: IModelDb, topElementId: Id64String) {\n const topElement = iModel.elements.getElement(topElementId);\n const topElementModel = iModel.models.getModel(topElement.model);\n return new ElementTreeWalkerScope(topElementId, topElementModel);\n }\n\n private fmtItem(v: Id64String | ElementTreeWalkerModelInfo): string {\n if (typeof v === \"string\")\n return `element ${v}`;\n return `model ${v.model.id} ${v.isDefinitionModel ? \"(DEFN)\" : \"\"}`;\n }\n\n public toString(): string {\n return `[ ${this.path.map((v) => this.fmtItem(v)).join(\" / \")} ]`;\n }\n}\n\nfunction fmtElement(iModel: IModelDb, elementId: Id64String): string {\n const el = iModel.elements.getElement(elementId);\n return `${el.id} ${el.classFullName} ${el.getDisplayLabel()}`;\n}\n\nfunction fmtModel(model: Model): string {\n return `${model.id} ${model.classFullName} ${model.name}`;\n}\n\nlet isTraceEnabledChecked = -1;\n\nfunction isTraceEnabled(): boolean {\n if (isTraceEnabledChecked === -1)\n isTraceEnabledChecked = Logger.isEnabled(loggerCategory, LogLevel.Trace) ? 1 : 0;\n return isTraceEnabledChecked === 1;\n}\n\nfunction logElement(op: string, iModel: IModelDb, elementId: Id64String, scope?: ElementTreeWalkerScope, logChildren?: boolean): void {\n if (!isTraceEnabled())\n return;\n\n Logger.logTrace(loggerCategory, `${op} ${fmtElement(iModel, elementId)} ${scope ? scope.toString() : \"\"}`);\n\n if (logChildren)\n iModel.elements.queryChildren(elementId).forEach((c) => logElement(\" - \", iModel, c, undefined, true));\n}\n\nfunction logModel(op: string, iModel: IModelDb, modelId: Id64String, scope?: ElementTreeWalkerScope, logElements?: boolean): void {\n if (!isTraceEnabled())\n return;\n const model: Model = iModel.models.getModel(modelId);\n Logger.logTrace(loggerCategory, `${op} ${fmtModel(model)} ${scope ? scope.toString() : \"\"}`);\n\n if (logElements) {\n iModel.withPreparedStatement(`select ecinstanceid from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\n stmt.bindId(1, modelId);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n logElement(\" - \", iModel, stmt.getValue(0).getId());\n }\n });\n }\n}\n\n/** Does a depth-first search on the tree defined by an element and its sub-models and children.\n * Sub-models are visited before their modeled elements, and children are visited before their parents.\n *\n * The following callbacks allow the subclass to exclude elements and sub-trees from the search:\n * * [[ElementTreeBottomUp.shouldExploreModel]], [[ElementTreeBottomUp.shouldExploreChildren]]\n * * [[ElementTreeBottomUp.shouldVisitElement]], [[ElementTreeBottomUp.shouldVisitModel]]\n *\n * The [[ElementTreeBottomUp.visitElement]] and [[ElementTreeBottomUp.visitModel]] callbacks allow\n * the subclass to process the elements and models that are encountered in the search.\n * @beta\n */\nexport abstract class ElementTreeBottomUp {\n constructor(protected _iModel: IModelDb) { }\n\n /** Return true if the search should recurse into this model */\n protected shouldExploreModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should recurse into the children (if any) of this element */\n protected shouldExploreChildren(_parentId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should visit this element */\n protected shouldVisitElement(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\n /** Return true if the search should visit this model */\n protected shouldVisitModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\n\n /** Called to visit a model */\n protected abstract visitModel(model: Model, scope: ElementTreeWalkerScope): void;\n\n /** Called to visit an element */\n protected abstract visitElement(elementId: Id64String, scope: ElementTreeWalkerScope): void;\n\n /** The main tree-walking function */\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\n const subModel = this._iModel.models.tryGetModel<Model>(element);\n if (subModel !== undefined) {\n if (this.shouldExploreModel(subModel, scope))\n this._processSubModel(subModel, scope);\n\n if (this.shouldVisitModel(subModel, scope))\n this.visitModel(subModel, scope);\n }\n\n if (this.shouldExploreChildren(element, scope))\n this._processChildren(element, scope);\n\n if (this.shouldVisitElement(element, scope))\n this.visitElement(element, scope);\n }\n\n /** process the children of the specified parent element */\n private _processChildren(parentElement: Id64String, parentScope: ElementTreeWalkerScope): void {\n const children = this._iModel.elements.queryChildren(parentElement);\n if (children.length === 0)\n return;\n\n const childrenScope = new ElementTreeWalkerScope(parentScope, parentElement);\n\n for (const childElement of children)\n this.processElementTree(childElement, childrenScope);\n }\n\n /** process the elements in the specified model */\n private _processSubModel(model: Model, parenScope: ElementTreeWalkerScope): void {\n const scope = new ElementTreeWalkerScope(parenScope, model);\n // Visit only the top-level parents. processElementTree will visit their children (bottom-up).\n model.iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\n stmt.bindId(1, model.id);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, scope);\n }\n });\n }\n}\n\n/** Helper class that manages the deletion of definitions and subjects */\nclass SpecialElements {\n public definitionModels: Id64Array = [];\n public definitions: Id64Array = [];\n public subjects: Id64Array = [];\n\n public recordSpecialElement(iModel: IModelDb, elementId: Id64String): boolean {\n // Defer Definitions and Subjects\n const cls = classifyElementForPruning(iModel, elementId);\n if (cls === ElementPruningClassification.PRUNING_CLASS_Subject) {\n this.subjects.push(elementId);\n return true;\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_Definition) {\n this.definitions.push(elementId);\n return true;\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_DefinitionPartition) {\n this.definitionModels.push(elementId);\n return true;\n }\n return false; // not a special element\n }\n\n /** Delete special elements - This calls Elements.deleteDefinitionElements to process the collected definition elements as a group and then\n * calls Models.deleteModel on collected definition models. It then deletes all collected Subjects by calling Element.deleteElement on them.\n * @note Caller must ensure that the special elements were recorded in a depth-first search.\n */\n public deleteSpecialElements(iModel: IModelDb) {\n // It's dangerous to pass a mixture of SubCategories and Categories to deleteDefinitionElements.\n // That function will delete the Categories first, which automatically deletes all their child\n // SubCategories (in native code). If a SubCategory in the list is one of those children, then\n // deleteDefinitionElements will try and fail with an exception to delete that SubCategory in a subsequent step.\n // To work around this, we delete the SubCategories first, then everything else.\n // A similar problem occurs when you pass other kinds of elements to deleteDefinitionElements, where some are\n // children and others are parents. deleteDefinitionElements does not preserve the order that you specify,\n // and it does not process children before parents.\n for (const definitions of sortChildrenBeforeParents(iModel, this.definitions)) {\n if (isTraceEnabled())\n definitions.forEach((e) => logElement(\"try delete\", iModel, e));\n\n iModel.elements.deleteDefinitionElements(definitions); // will not delete definitions that are still in use.\n }\n\n for (const m of this.definitionModels) {\n if (!isModelEmpty(iModel, m)) {\n logModel(\"Model not empty - cannot delete - may contain Definitions that are still in use\", iModel, m, undefined, true);\n } else {\n logModel(\"delete\", iModel, m);\n iModel.models.deleteModel(m);\n iModel.elements.deleteElement(m);\n }\n }\n\n for (const e of this.subjects) {\n if (iModel.elements.queryChildren(e).length !== 0) {\n logElement(\"Subject still has children - cannot delete - may have child DefinitionModels\", iModel, e, undefined, true);\n } else {\n logElement(\"delete\", iModel, e);\n iModel.elements.deleteElement(e);\n }\n }\n }\n\n}\n\n/** Deletes an entire element tree, including sub-models and child elements.\n * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.\n * Call deleteNormalElements on each tree. Then call deleteSpecialElements.\n * @see deleteElementTree for a simple way to use this class.\n * @beta\n */\nexport class ElementTreeDeleter extends ElementTreeBottomUp {\n protected _special: SpecialElements = new SpecialElements();\n\n protected override shouldExploreModel(_model: Model): boolean { return true; }\n protected override shouldVisitElement(_elementId: Id64String): boolean { return true; }\n\n protected override visitModel(model: Model, _scope: ElementTreeWalkerScope): void {\n if (isDefinitionModel(model))\n return; // we recorded definition models in visitElement when we encountered the DefinitionPartition elements.\n\n // visitElement has already deleted the elements in the model. So, now it's safe to delete the model itself.\n logModel(\"delete\", this._iModel, model.id, _scope);\n model.delete();\n }\n\n protected override visitElement(elementId: Id64String, _scope: ElementTreeWalkerScope): void {\n if (!this._special.recordSpecialElement(this._iModel, elementId)) {\n logElement(\"delete\", this._iModel, elementId, _scope);\n this._iModel.elements.deleteElement(elementId);\n }\n }\n\n /**\n * Delete the \"normal\" elements and record the special elements for deferred processing.\n * @param topElement The parent of the sub-tree to be deleted. Top element itself is also deleted.\n * @param scope How the parent was found\n * @see deleteSpecialElements\n */\n public deleteNormalElements(topElement: Id64String, scope?: ElementTreeWalkerScope): void {\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\n this.processElementTree(topElement, topScope); //\n }\n\n /** Delete all special elements that were found and deferred by deleteNormalElements. Call this\n * function once after all element trees are processed by deleteNormalElements.\n */\n public deleteSpecialElements(): void {\n this._special.deleteSpecialElements(this._iModel);\n }\n\n}\n\n/** Does a breadth-first search on the tree defined by an element and its sub-models and children.\n * Parents are visited first, then children, then sub-models.\n * The subclass can \"prune\" sub-trees from the search. When a sub-tree is \"pruned\" the search does *not* recurse into it.\n * If a sub-tree is not pruned, then the search does recurse into it.\n * @beta\n */\nabstract class ElementTreeTopDown {\n constructor(protected _iModel: IModelDb) { }\n\n /** Should the search *not* recurse into this sub-tree? */\n protected shouldPrune(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return false; }\n\n protected abstract prune(_elementId: Id64String, _scope: ElementTreeWalkerScope): void;\n\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\n\n if (this.shouldPrune(element, scope)) {\n this.prune(element, scope);\n return;\n }\n\n this._processChildren(element, scope);\n\n const subModel = this._iModel.models.tryGetModel<Model>(element);\n if (subModel !== undefined) {\n this._processSubModel(subModel, scope);\n }\n }\n\n private _processChildren(element: Id64String, scope: ElementTreeWalkerScope) {\n let parentScope: ElementTreeWalkerScope | undefined;\n for (const childElement of this._iModel.elements.queryChildren(element)) {\n if (parentScope === undefined)\n parentScope = new ElementTreeWalkerScope(scope, element);\n this.processElementTree(childElement, parentScope);\n }\n }\n\n private _processSubModel(subModel: Model, scope: ElementTreeWalkerScope) {\n const subModelScope = new ElementTreeWalkerScope(scope, subModel);\n // Visit only the top-level parents. processElementTree will recurse into their children.\n this._iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\n stmt.bindId(1, subModel.id);\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\n const elementId = stmt.getValue(0).getId();\n this.processElementTree(elementId, subModelScope);\n }\n });\n }\n\n}\n\n/** Signature of the filter function used by ElementSubTreeDeleter.\n * @param elementId The sub-tree parent element.\n * @param scope The path followed by the top-down search to the element\n * @return true if the element and its children and sub-models should be deleted.\n * @beta\n */\nexport type ElementSubTreeDeleteFilter = (elementId: Id64String, scope: ElementTreeWalkerScope) => boolean;\n\n/** Performs a breadth-first search to visit elements in top-down order.\n * When the supplied filter function chooses an element, ElementTreeDeleter is used to delete it and its sub-tree.\n * @beta\n */\nexport class ElementSubTreeDeleter extends ElementTreeTopDown {\n private _treeDeleter: ElementTreeDeleter;\n private _shouldPruneCb: ElementSubTreeDeleteFilter;\n\n /** Construct an ElementSubTreeDeleter.\n * @param iModel The iModel\n * @param topElement Where to start the search.\n * @param shouldPruneCb Callback that selects sub-trees that should be deleted.\n * @see deleteElementSubTrees for a simple way to use this class.\n */\n public constructor(iModel: IModelDb, shouldPruneCb: ElementSubTreeDeleteFilter) {\n super(iModel);\n this._treeDeleter = new ElementTreeDeleter(this._iModel);\n this._shouldPruneCb = shouldPruneCb;\n }\n\n protected override shouldPrune(elementId: Id64String, scope: ElementTreeWalkerScope): boolean { return this._shouldPruneCb(elementId, scope); }\n\n protected prune(elementId: Id64String, scope: ElementTreeWalkerScope): void {\n this._treeDeleter.deleteNormalElements(elementId, scope);\n }\n\n /** Traverses the tree of elements beginning with the top element, and deletes all selected sub-trees.\n * Normal elements are deleted. Any special elements that are encountered are deferred.\n * Call deleteSpecialElementSubTrees after all top elements have been processed. */\n public deleteNormalElementSubTrees(topElement: Id64String, scope?: ElementTreeWalkerScope) {\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\n this.processElementTree(topElement, topScope); // deletes normal elements and their sub-trees, defers special elements\n }\n\n /** Delete all special elements and their sub-trees that were found in the course of processing.\n * The sub-trees were already expanded by ElementTreeDeleter.deleteNormalElements.\n */\n public deleteSpecialElementSubTrees() {\n this._treeDeleter.deleteSpecialElements();\n }\n}\n\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\n * @param iModel The iModel\n * @param topElement The parent of the sub-tree\n * @beta\n */\nexport function deleteElementTree(iModel: IModelDb, topElement: Id64String): void {\n const del = new ElementTreeDeleter(iModel);\n del.deleteNormalElements(topElement);\n del.deleteSpecialElements();\n}\n\n/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.\n * If the filter selects the top element itself, then the entire tree (including the top element) is deleted.\n * That has the same effect as calling [[deleteElementTree]] on the top element.\n * @param iModel The iModel\n * @param topElement Where to start the search.\n * @param filter Callback that selects sub-trees that should be deleted.\n * @beta\n */\nexport function deleteElementSubTrees(iModel: IModelDb, topElement: Id64String, filter: ElementSubTreeDeleteFilter): void {\n const del = new ElementSubTreeDeleter(iModel, filter);\n del.deleteNormalElementSubTrees(topElement);\n del.deleteSpecialElementSubTrees();\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ElementTreeWalker.js","sourceRoot":"","sources":["../../src/ElementTreeWalker.ts"],"names":[],"mappings":";;;AAAA;;;+FAG+F;AAC/F;;GAEG;AACH,sDAAgG;AAChG,oDAA4C;AAC5C,mEAAgE;AAChE,uCAA0G;AAC1G,yCAAsC;AACtC,mCAAiD;AAEjD,MAAM,cAAc,GAAG,GAAG,6CAAqB,CAAC,QAAQ,oBAAoB,CAAC;AAK7E,SAAS,yBAAyB,CAAC,MAAgB,EAAE,GAAc;IACjE,MAAM,QAAQ,GAAc,EAAE,CAAC;IAC/B,MAAM,OAAO,GAAc,EAAE,CAAC;IAC9B,KAAK,MAAM,GAAG,IAAI,GAAG,EAAE,CAAC;QACtB,MAAM,QAAQ,GAAG,MAAM,CAAC,QAAQ,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;QAClD,IAAI,QAAQ,KAAK,SAAS,IAAI,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC;YAClD,QAAQ,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;;YAEnB,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;IACtB,CAAC;IAED,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC;QACvB,OAAO,CAAC,OAAO,CAAC,CAAC;IAEnB,OAAO,CAAC,GAAG,yBAAyB,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,OAAO,CAAC,CAAC;AACnE,CAAC;AAED,SAAS,YAAY,CAAC,MAAgB,EAAE,OAAmB;IACzD,OAAO,MAAM,CAAC,qBAAqB,CAAC,wBAAwB,iBAAO,CAAC,aAAa,qBAAqB,EAAE,CAAC,IAAI,EAAE,EAAE;QAC/G,IAAI,CAAC,MAAM,CAAC,CAAC,EAAE,OAAO,CAAC,CAAC;QACxB,IAAI,CAAC,IAAI,EAAE,CAAC;QACZ,OAAO,IAAI,CAAC,QAAQ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,CAAC;QACjC,MAAM,GAAG,IAAI,CAAC;QACd,UAAU,GAAG,IAAI,CAAC;IACpB,CAAC;SAAM,CAAC;QACN,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC;QACrB,UAAU,GAAG,IAAI,CAAC,UAAU,CAAC;QAC7B,SAAS,GAAG,IAAI,CAAC,SAAS,CAAC;IAC7B,CAAC;IAED,SAAS,GAAG,SAAS,IAAI,CAAC,CAAC;IAC3B,IAAI,IAAI,GAAG,CAAC,CAAC;IACb,GAAG,CAAC;QACF,MAAM,GAAG,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;QAC3C,GAAG,CAAC,oBAAoB,CAAC,UAAU,CAAC,CAAC;QACrC,GAAG,CAAC,qBAAqB,EAAE,CAAC;IAC9B,CAAC,QAAQ,CAAC,MAAM,CAAC,QAAQ,CAAC,aAAa,CAAC,UAAU,CAAC,KAAK,SAAS,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,SAAS,CAAC,EAAE;AAC9F,CAAC;AArBD,8CAqBC;AAED;;;;;;;;GAQG;AACH,SAAgB,qBAAqB,CAAC,MAAgB,EAAE,UAAsB,EAAE,MAAkC;IAChH,MAAM,GAAG,GAAG,IAAI,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACtD,GAAG,CAAC,2BAA2B,CAAC,UAAU,CAAC,CAAC;IAC5C,GAAG,CAAC,4BAA4B,EAAE,CAAC;AACrC,CAAC;AAJD,sDAIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Elements\r\n */\r\nimport { assert, DbResult, Id64Array, Id64String, Logger, LogLevel } from \"@itwin/core-bentley\";\r\nimport { IModel } from \"@itwin/core-common\";\r\nimport { BackendLoggerCategory } from \"./BackendLoggerCategory\";\r\nimport { DefinitionContainer, DefinitionElement, DefinitionPartition, Element, Subject } from \"./Element\";\r\nimport { IModelDb } from \"./IModelDb\";\r\nimport { DefinitionModel, Model } from \"./Model\";\r\n\r\nconst loggerCategory = `${BackendLoggerCategory.IModelDb}.ElementTreeWalker`;\r\n\r\n/** @beta */\r\nexport interface ElementTreeWalkerModelInfo { model: Model, isDefinitionModel: boolean }\r\n\r\nfunction sortChildrenBeforeParents(iModel: IModelDb, ids: Id64Array): Array<Id64Array> {\r\n const children: Id64Array = [];\r\n const parents: Id64Array = [];\r\n for (const eid of ids) {\r\n const parentId = iModel.elements.queryParent(eid);\r\n if (parentId !== undefined && ids.includes(parentId))\r\n children.push(eid);\r\n else\r\n parents.push(eid);\r\n }\r\n\r\n if (children.length === 0)\r\n return [parents];\r\n\r\n return [...sortChildrenBeforeParents(iModel, children), parents];\r\n}\r\n\r\nfunction isModelEmpty(iModel: IModelDb, modelId: Id64String): boolean {\r\n return iModel.withPreparedStatement(`select count(*) from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\r\n stmt.bindId(1, modelId);\r\n stmt.step();\r\n return stmt.getValue(0).getInteger() === 0;\r\n });\r\n}\r\n\r\nfunction isDefinitionModel(model: Model): boolean {\r\n return (model.id !== IModel.repositoryModelId) && (model instanceof DefinitionModel);\r\n}\r\n\r\nenum ElementPruningClassification { PRUNING_CLASS_Normal = 0, PRUNING_CLASS_Subject = 1, PRUNING_CLASS_Definition = 2, PRUNING_CLASS_DefinitionPartition = 3, }\r\n\r\nfunction classifyElementForPruning(iModel: IModelDb, elementId: Id64String): ElementPruningClassification {\r\n const el = iModel.elements.getElement(elementId);\r\n // DefinitionContainer is submodeled by a DefinitionModel and so it must be classified as PRUNING_CLASS_DefinitionPartition for tree-walking purposes.\r\n // Since DefinitionContainer is-a DefinitionElement the (el instanceof DefinitionElement) case below would classify it as PRUNING_CLASS_Definition.\r\n // That is why we special-case it here.\r\n if (el instanceof DefinitionContainer)\r\n return ElementPruningClassification.PRUNING_CLASS_DefinitionPartition;\r\n return (el instanceof Subject) ? ElementPruningClassification.PRUNING_CLASS_Subject :\r\n (el instanceof DefinitionElement) ? ElementPruningClassification.PRUNING_CLASS_Definition :\r\n (el instanceof DefinitionPartition) ? ElementPruningClassification.PRUNING_CLASS_DefinitionPartition :\r\n ElementPruningClassification.PRUNING_CLASS_Normal;\r\n}\r\n\r\n/** Records the path that a tree search took to reach an element or model. This object is immutable.\r\n * @beta\r\n */\r\nexport class ElementTreeWalkerScope {\r\n public readonly topElement: Id64String = \"\";\r\n /** path of parent elements and enclosing models */\r\n public readonly path: Array<Id64String | ElementTreeWalkerModelInfo> = [];\r\n /** cached info about the immediately enclosing model (i.e., the last model in path) */\r\n public readonly enclosingModelInfo: ElementTreeWalkerModelInfo;\r\n\r\n constructor(topElement: Id64String, model: Model);\r\n constructor(enclosingScope: ElementTreeWalkerScope, newScope: Id64String | Model);\r\n constructor(arg1: Id64String | ElementTreeWalkerScope, arg2: Model | Id64String) {\r\n if (typeof arg1 === \"string\") {\r\n // normal constructor\r\n assert(arg2 instanceof Model);\r\n this.topElement = arg1;\r\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\r\n } else if (arg1 instanceof ElementTreeWalkerScope) {\r\n // copy-like constructor\r\n this.topElement = arg1.topElement;\r\n this.path = [...arg1.path];\r\n if (typeof arg2 === \"string\") {\r\n // with new parent\r\n this.path.push(arg2);\r\n this.enclosingModelInfo = arg1.enclosingModelInfo;\r\n } else {\r\n // with new enclosing model\r\n this.path.push(this.enclosingModelInfo = { model: arg2, isDefinitionModel: isDefinitionModel(arg2) });\r\n }\r\n } else {\r\n throw new Error(\"invalid constructor signature\");\r\n }\r\n }\r\n\r\n public get enclosingModel(): Model { return this.enclosingModelInfo.model; }\r\n public get inDefinitionModel(): boolean { return this.enclosingModelInfo.isDefinitionModel; } // NB: this will return false for the RepositoryModel!\r\n public get inRepositoryModel(): boolean { return this.enclosingModelInfo.model.id === IModelDb.repositoryModelId; }\r\n\r\n public static createTopScope(iModel: IModelDb, topElementId: Id64String) {\r\n const topElement = iModel.elements.getElement(topElementId);\r\n const topElementModel = iModel.models.getModel(topElement.model);\r\n return new ElementTreeWalkerScope(topElementId, topElementModel);\r\n }\r\n\r\n private fmtItem(v: Id64String | ElementTreeWalkerModelInfo): string {\r\n if (typeof v === \"string\")\r\n return `element ${v}`;\r\n return `model ${v.model.id} ${v.isDefinitionModel ? \"(DEFN)\" : \"\"}`;\r\n }\r\n\r\n public toString(): string {\r\n return `[ ${this.path.map((v) => this.fmtItem(v)).join(\" / \")} ]`;\r\n }\r\n}\r\n\r\nfunction fmtElement(iModel: IModelDb, elementId: Id64String): string {\r\n const el = iModel.elements.getElement(elementId);\r\n return `${el.id} ${el.classFullName} ${el.getDisplayLabel()}`;\r\n}\r\n\r\nfunction fmtModel(model: Model): string {\r\n return `${model.id} ${model.classFullName} ${model.name}`;\r\n}\r\n\r\nlet isTraceEnabledChecked = -1;\r\n\r\nfunction isTraceEnabled(): boolean {\r\n if (isTraceEnabledChecked === -1)\r\n isTraceEnabledChecked = Logger.isEnabled(loggerCategory, LogLevel.Trace) ? 1 : 0;\r\n return isTraceEnabledChecked === 1;\r\n}\r\n\r\nfunction logElement(op: string, iModel: IModelDb, elementId: Id64String, scope?: ElementTreeWalkerScope, logChildren?: boolean): void {\r\n if (!isTraceEnabled())\r\n return;\r\n\r\n Logger.logTrace(loggerCategory, `${op} ${fmtElement(iModel, elementId)} ${scope ? scope.toString() : \"\"}`);\r\n\r\n if (logChildren)\r\n iModel.elements.queryChildren(elementId).forEach((c) => logElement(\" - \", iModel, c, undefined, true));\r\n}\r\n\r\nfunction logModel(op: string, iModel: IModelDb, modelId: Id64String, scope?: ElementTreeWalkerScope, logElements?: boolean): void {\r\n if (!isTraceEnabled())\r\n return;\r\n const model: Model = iModel.models.getModel(modelId);\r\n Logger.logTrace(loggerCategory, `${op} ${fmtModel(model)} ${scope ? scope.toString() : \"\"}`);\r\n\r\n if (logElements) {\r\n iModel.withPreparedStatement(`select ecinstanceid from ${Element.classFullName} where Model.Id = ?`, (stmt) => {\r\n stmt.bindId(1, modelId);\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n logElement(\" - \", iModel, stmt.getValue(0).getId());\r\n }\r\n });\r\n }\r\n}\r\n\r\n/** Does a depth-first search on the tree defined by an element and its sub-models and children.\r\n * Sub-models are visited before their modeled elements, and children are visited before their parents.\r\n *\r\n * The following callbacks allow the subclass to exclude elements and sub-trees from the search:\r\n * * [[ElementTreeBottomUp.shouldExploreModel]], [[ElementTreeBottomUp.shouldExploreChildren]]\r\n * * [[ElementTreeBottomUp.shouldVisitElement]], [[ElementTreeBottomUp.shouldVisitModel]]\r\n *\r\n * The [[ElementTreeBottomUp.visitElement]] and [[ElementTreeBottomUp.visitModel]] callbacks allow\r\n * the subclass to process the elements and models that are encountered in the search.\r\n * @beta\r\n */\r\nexport abstract class ElementTreeBottomUp {\r\n constructor(protected _iModel: IModelDb) { }\r\n\r\n /** Return true if the search should recurse into this model */\r\n protected shouldExploreModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\r\n /** Return true if the search should recurse into the children (if any) of this element */\r\n protected shouldExploreChildren(_parentId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\r\n /** Return true if the search should visit this element */\r\n protected shouldVisitElement(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return true; }\r\n /** Return true if the search should visit this model */\r\n protected shouldVisitModel(_model: Model, _scope: ElementTreeWalkerScope): boolean { return true; }\r\n\r\n /** Called to visit a model */\r\n protected abstract visitModel(model: Model, scope: ElementTreeWalkerScope): void;\r\n\r\n /** Called to visit an element */\r\n protected abstract visitElement(elementId: Id64String, scope: ElementTreeWalkerScope): void;\r\n\r\n /** The main tree-walking function */\r\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\r\n const subModel = this._iModel.models.tryGetModel<Model>(element);\r\n if (subModel !== undefined) {\r\n if (this.shouldExploreModel(subModel, scope))\r\n this._processSubModel(subModel, scope);\r\n\r\n if (this.shouldVisitModel(subModel, scope))\r\n this.visitModel(subModel, scope);\r\n }\r\n\r\n if (this.shouldExploreChildren(element, scope))\r\n this._processChildren(element, scope);\r\n\r\n if (this.shouldVisitElement(element, scope))\r\n this.visitElement(element, scope);\r\n }\r\n\r\n /** process the children of the specified parent element */\r\n private _processChildren(parentElement: Id64String, parentScope: ElementTreeWalkerScope): void {\r\n const children = this._iModel.elements.queryChildren(parentElement);\r\n if (children.length === 0)\r\n return;\r\n\r\n const childrenScope = new ElementTreeWalkerScope(parentScope, parentElement);\r\n\r\n for (const childElement of children)\r\n this.processElementTree(childElement, childrenScope);\r\n }\r\n\r\n /** process the elements in the specified model */\r\n private _processSubModel(model: Model, parenScope: ElementTreeWalkerScope): void {\r\n const scope = new ElementTreeWalkerScope(parenScope, model);\r\n // Visit only the top-level parents. processElementTree will visit their children (bottom-up).\r\n model.iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\r\n stmt.bindId(1, model.id);\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const elementId = stmt.getValue(0).getId();\r\n this.processElementTree(elementId, scope);\r\n }\r\n });\r\n }\r\n}\r\n\r\n/** Helper class that manages the deletion of definitions and subjects */\r\nclass SpecialElements {\r\n public definitionModels: Id64Array = [];\r\n public definitions: Id64Array = [];\r\n public subjects: Id64Array = [];\r\n\r\n public recordSpecialElement(iModel: IModelDb, elementId: Id64String): boolean {\r\n // Defer Definitions and Subjects\r\n const cls = classifyElementForPruning(iModel, elementId);\r\n if (cls === ElementPruningClassification.PRUNING_CLASS_Subject) {\r\n this.subjects.push(elementId);\r\n return true;\r\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_Definition) {\r\n this.definitions.push(elementId);\r\n return true;\r\n } else if (cls === ElementPruningClassification.PRUNING_CLASS_DefinitionPartition) {\r\n this.definitionModels.push(elementId);\r\n return true;\r\n }\r\n return false; // not a special element\r\n }\r\n\r\n /** Delete special elements - This calls Elements.deleteDefinitionElements to process the collected definition elements as a group and then\r\n * calls Models.deleteModel on collected definition models. It then deletes all collected Subjects by calling Element.deleteElement on them.\r\n * @note Caller must ensure that the special elements were recorded in a depth-first search.\r\n */\r\n public deleteSpecialElements(iModel: IModelDb) {\r\n // It's dangerous to pass a mixture of SubCategories and Categories to deleteDefinitionElements.\r\n // That function will delete the Categories first, which automatically deletes all their child\r\n // SubCategories (in native code). If a SubCategory in the list is one of those children, then\r\n // deleteDefinitionElements will try and fail with an exception to delete that SubCategory in a subsequent step.\r\n // To work around this, we delete the SubCategories first, then everything else.\r\n // A similar problem occurs when you pass other kinds of elements to deleteDefinitionElements, where some are\r\n // children and others are parents. deleteDefinitionElements does not preserve the order that you specify,\r\n // and it does not process children before parents.\r\n for (const definitions of sortChildrenBeforeParents(iModel, this.definitions)) {\r\n if (isTraceEnabled())\r\n definitions.forEach((e) => logElement(\"try delete\", iModel, e));\r\n\r\n iModel.elements.deleteDefinitionElements(definitions); // will not delete definitions that are still in use.\r\n }\r\n\r\n for (const m of this.definitionModels) {\r\n if (!isModelEmpty(iModel, m)) {\r\n logModel(\"Model not empty - cannot delete - may contain Definitions that are still in use\", iModel, m, undefined, true);\r\n } else {\r\n logModel(\"delete\", iModel, m);\r\n iModel.models.deleteModel(m);\r\n iModel.elements.deleteElement(m);\r\n }\r\n }\r\n\r\n for (const e of this.subjects) {\r\n if (iModel.elements.queryChildren(e).length !== 0) {\r\n logElement(\"Subject still has children - cannot delete - may have child DefinitionModels\", iModel, e, undefined, true);\r\n } else {\r\n logElement(\"delete\", iModel, e);\r\n iModel.elements.deleteElement(e);\r\n }\r\n }\r\n }\r\n\r\n}\r\n\r\n/** Deletes an entire element tree, including sub-models and child elements.\r\n * Items are deleted in bottom-up order. Definitions and Subjects are deleted after normal elements.\r\n * Call deleteNormalElements on each tree. Then call deleteSpecialElements.\r\n * @see deleteElementTree for a simple way to use this class.\r\n * @beta\r\n */\r\nexport class ElementTreeDeleter extends ElementTreeBottomUp {\r\n protected _special: SpecialElements = new SpecialElements();\r\n\r\n protected override shouldExploreModel(_model: Model): boolean { return true; }\r\n protected override shouldVisitElement(_elementId: Id64String): boolean { return true; }\r\n\r\n protected override visitModel(model: Model, _scope: ElementTreeWalkerScope): void {\r\n if (isDefinitionModel(model))\r\n return; // we recorded definition models in visitElement when we encountered the DefinitionPartition elements.\r\n\r\n // visitElement has already deleted the elements in the model. So, now it's safe to delete the model itself.\r\n logModel(\"delete\", this._iModel, model.id, _scope);\r\n model.delete();\r\n }\r\n\r\n protected override visitElement(elementId: Id64String, _scope: ElementTreeWalkerScope): void {\r\n if (!this._special.recordSpecialElement(this._iModel, elementId)) {\r\n logElement(\"delete\", this._iModel, elementId, _scope);\r\n this._iModel.elements.deleteElement(elementId);\r\n }\r\n }\r\n\r\n /**\r\n * Delete the \"normal\" elements and record the special elements for deferred processing.\r\n * @param topElement The parent of the sub-tree to be deleted. Top element itself is also deleted.\r\n * @param scope How the parent was found\r\n * @see deleteSpecialElements\r\n */\r\n public deleteNormalElements(topElement: Id64String, scope?: ElementTreeWalkerScope): void {\r\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\r\n this.processElementTree(topElement, topScope); //\r\n }\r\n\r\n /** Delete all special elements that were found and deferred by deleteNormalElements. Call this\r\n * function once after all element trees are processed by deleteNormalElements.\r\n */\r\n public deleteSpecialElements(): void {\r\n this._special.deleteSpecialElements(this._iModel);\r\n }\r\n\r\n}\r\n\r\n/** Does a breadth-first search on the tree defined by an element and its sub-models and children.\r\n * Parents are visited first, then children, then sub-models.\r\n * The subclass can \"prune\" sub-trees from the search. When a sub-tree is \"pruned\" the search does *not* recurse into it.\r\n * If a sub-tree is not pruned, then the search does recurse into it.\r\n * @beta\r\n */\r\nabstract class ElementTreeTopDown {\r\n constructor(protected _iModel: IModelDb) { }\r\n\r\n /** Should the search *not* recurse into this sub-tree? */\r\n protected shouldPrune(_elementId: Id64String, _scope: ElementTreeWalkerScope): boolean { return false; }\r\n\r\n protected abstract prune(_elementId: Id64String, _scope: ElementTreeWalkerScope): void;\r\n\r\n protected processElementTree(element: Id64String, scope: ElementTreeWalkerScope) {\r\n\r\n if (this.shouldPrune(element, scope)) {\r\n this.prune(element, scope);\r\n return;\r\n }\r\n\r\n this._processChildren(element, scope);\r\n\r\n const subModel = this._iModel.models.tryGetModel<Model>(element);\r\n if (subModel !== undefined) {\r\n this._processSubModel(subModel, scope);\r\n }\r\n }\r\n\r\n private _processChildren(element: Id64String, scope: ElementTreeWalkerScope) {\r\n let parentScope: ElementTreeWalkerScope | undefined;\r\n for (const childElement of this._iModel.elements.queryChildren(element)) {\r\n if (parentScope === undefined)\r\n parentScope = new ElementTreeWalkerScope(scope, element);\r\n this.processElementTree(childElement, parentScope);\r\n }\r\n }\r\n\r\n private _processSubModel(subModel: Model, scope: ElementTreeWalkerScope) {\r\n const subModelScope = new ElementTreeWalkerScope(scope, subModel);\r\n // Visit only the top-level parents. processElementTree will recurse into their children.\r\n this._iModel.withPreparedStatement(`select ECInstanceId from bis:Element where Model.id=? and Parent.Id is null`, (stmt) => {\r\n stmt.bindId(1, subModel.id);\r\n while (stmt.step() === DbResult.BE_SQLITE_ROW) {\r\n const elementId = stmt.getValue(0).getId();\r\n this.processElementTree(elementId, subModelScope);\r\n }\r\n });\r\n }\r\n\r\n}\r\n\r\n/** Signature of the filter function used by ElementSubTreeDeleter.\r\n * @param elementId The sub-tree parent element.\r\n * @param scope The path followed by the top-down search to the element\r\n * @return true if the element and its children and sub-models should be deleted.\r\n * @beta\r\n */\r\nexport type ElementSubTreeDeleteFilter = (elementId: Id64String, scope: ElementTreeWalkerScope) => boolean;\r\n\r\n/** Performs a breadth-first search to visit elements in top-down order.\r\n * When the supplied filter function chooses an element, ElementTreeDeleter is used to delete it and its sub-tree.\r\n * @beta\r\n */\r\nexport class ElementSubTreeDeleter extends ElementTreeTopDown {\r\n private _treeDeleter: ElementTreeDeleter;\r\n private _shouldPruneCb: ElementSubTreeDeleteFilter;\r\n\r\n /** Construct an ElementSubTreeDeleter.\r\n * @param iModel The iModel\r\n * @param topElement Where to start the search.\r\n * @param shouldPruneCb Callback that selects sub-trees that should be deleted.\r\n * @see deleteElementSubTrees for a simple way to use this class.\r\n */\r\n public constructor(iModel: IModelDb, shouldPruneCb: ElementSubTreeDeleteFilter) {\r\n super(iModel);\r\n this._treeDeleter = new ElementTreeDeleter(this._iModel);\r\n this._shouldPruneCb = shouldPruneCb;\r\n }\r\n\r\n protected override shouldPrune(elementId: Id64String, scope: ElementTreeWalkerScope): boolean { return this._shouldPruneCb(elementId, scope); }\r\n\r\n protected prune(elementId: Id64String, scope: ElementTreeWalkerScope): void {\r\n this._treeDeleter.deleteNormalElements(elementId, scope);\r\n }\r\n\r\n /** Traverses the tree of elements beginning with the top element, and deletes all selected sub-trees.\r\n * Normal elements are deleted. Any special elements that are encountered are deferred.\r\n * Call deleteSpecialElementSubTrees after all top elements have been processed. */\r\n public deleteNormalElementSubTrees(topElement: Id64String, scope?: ElementTreeWalkerScope) {\r\n const topScope = scope ?? ElementTreeWalkerScope.createTopScope(this._iModel, topElement);\r\n this.processElementTree(topElement, topScope); // deletes normal elements and their sub-trees, defers special elements\r\n }\r\n\r\n /** Delete all special elements and their sub-trees that were found in the course of processing.\r\n * The sub-trees were already expanded by ElementTreeDeleter.deleteNormalElements.\r\n */\r\n public deleteSpecialElementSubTrees() {\r\n this._treeDeleter.deleteSpecialElements();\r\n }\r\n}\r\n\r\n/** Arguments supplied to [[deleteElementTree]].\r\n * @beta\r\n */\r\nexport interface DeleteElementTreeArgs {\r\n /** The iModel containing the elements to delete. */\r\n iModel: IModelDb;\r\n /** The Id of the root element of the tree to delete. */\r\n topElement: Id64String;\r\n /** The maximum number of passes to make when deleting definition elements.\r\n * Default: 5\r\n */\r\n maxPasses?: number;\r\n}\r\n\r\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\r\n * @param iModel The iModel\r\n * @param topElement The parent of the sub-tree\r\n * @beta\r\n */\r\nexport function deleteElementTree(iModel: IModelDb, topElement: Id64String): void;\r\n/** Deletes an element tree starting with the specified top element. The top element is also deleted. Uses ElementTreeDeleter.\r\n * @param args Specifies the iModel and top element.\r\n * @beta\r\n */\r\nexport function deleteElementTree(args: DeleteElementTreeArgs): void;\r\n/** @internal */\r\nexport function deleteElementTree(arg0: DeleteElementTreeArgs | IModelDb, arg1?: Id64String): void {\r\n let maxPasses;\r\n let iModel: IModelDb;\r\n let topElement: Id64String;\r\n if (arg0 instanceof IModelDb) {\r\n assert(typeof arg1 === \"string\");\r\n iModel = arg0;\r\n topElement = arg1;\r\n } else {\r\n iModel = arg0.iModel;\r\n topElement = arg0.topElement;\r\n maxPasses = arg0.maxPasses;\r\n }\r\n\r\n maxPasses = maxPasses ?? 5;\r\n let pass = 0;\r\n do {\r\n const del = new ElementTreeDeleter(iModel);\r\n del.deleteNormalElements(topElement);\r\n del.deleteSpecialElements();\r\n } while ((iModel.elements.tryGetElement(topElement) !== undefined) && (++pass < maxPasses));\r\n}\r\n\r\n/** Deletes all element sub-trees that are selected by the supplied filter. Uses ElementSubTreeDeleter.\r\n * If the filter selects the top element itself, then the entire tree (including the top element) is deleted.\r\n * That has the same effect as calling [[deleteElementTree]] on the top element.\r\n * @note The caller may have to call this function multiple times if there are multiple layers of dependencies among definition elements.\r\n * @param iModel The iModel\r\n * @param topElement Where to start the search.\r\n * @param filter Callback that selects sub-trees that should be deleted.\r\n * @beta\r\n */\r\nexport function deleteElementSubTrees(iModel: IModelDb, topElement: Id64String, filter: ElementSubTreeDeleteFilter): void {\r\n const del = new ElementSubTreeDeleter(iModel, filter);\r\n del.deleteNormalElementSubTrees(topElement);\r\n del.deleteSpecialElementSubTrees();\r\n}\r\n"]}
|
package/lib/cjs/Entity.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[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mBAAmB,CAAC,YAAY,CAAC,CAAC;QACvC,OAAO,YAAY,CAAC;IACtB,CAAC;IASD;;;;;;;OAOG;IACO,mBAAmB,CAAC,aAAiC;QAC7D,OAAO,CAAC,2BAA2B;IACrC,CAAC;CAQF;AArID,wBAqIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport { EntityProps, EntityReferenceSet, PropertyCallback, PropertyMetaData } from \"@itwin/core-common\";\nimport type { IModelDb } from \"./IModelDb\";\nimport { Schema } from \"./Schema\";\n\n/** Represents one of the fundamental building block in an [[IModelDb]]: as an [[Element]], [[Model]], or [[Relationship]].\n * Every subclass of Entity represents one BIS [ECClass]($ecschema-metadata).\n * An Entity is typically instantiated from an [EntityProps]($common) and can be converted back to this representation via [[Entity.toJSON]].\n * @public\n */\nexport class Entity {\n /** An immutable property used to discriminate between [[Entity]] and [EntityProps]($common), used to inform the TypeScript compiler that these two types\n * are never substitutable for one another. To obtain an EntityProps from an Entity, use [[Entity.toJSON]].\n */\n public readonly isInstanceOfEntity = true as const;\n /** The Schema that defines this class. */\n public static schema: typeof Schema;\n\n private get _ctor(): typeof Entity { return this.constructor as typeof Entity; }\n\n /** The name of the BIS class associated with this class.\n * @note Every subclass of Entity **MUST** override this method to identify its BIS class.\n * Failure to do so will ordinarily result in an error when the class is registered, since there may only\n * be one JavaScript class for a given BIS class (usually the errant class will collide with its superclass.)\n */\n public static get className(): string { return \"Entity\"; }\n\n /** When working with an Entity it can be useful to set property values directly, bypassing the compiler's type checking.\n * This property makes such code slightly less tedious to read and write.\n * @internal\n */\n public get asAny(): any { return this; }\n\n /** The name of the BIS Schema that defines this class */\n public get schemaName(): string { return this._ctor.schema.schemaName; }\n\n /** The name of the BIS class associated with this class. */\n public get className(): string { return this._ctor.className; }\n\n /** The [[IModelDb]] that contains this Entity */\n public iModel: IModelDb;\n\n /** The Id of this Entity. May be invalid if the Entity has not yet been saved in the database. */\n public id: Id64String;\n\n protected constructor(props: EntityProps, iModel: IModelDb) {\n this.iModel = iModel;\n this.id = Id64.fromJSON(props.id);\n // copy all auto-handled properties from input to the object being constructed\n this.forEachProperty((propName: string, meta: PropertyMetaData) => (this as any)[propName] = meta.createProperty((props as any)[propName]), false);\n }\n\n /** Invoke the constructor of the specified `Entity` subclass.\n * @internal\n */\n public static instantiate(subclass: typeof Entity, props: EntityProps, iModel: IModelDb): Entity {\n return new subclass(props, iModel);\n }\n\n /** Obtain the JSON representation of this Entity. Subclasses of [[Entity]] typically override this method to return their corresponding sub-type of [EntityProps]($common) -\n * for example, [[GeometricElement.toJSON]] returns a [GeometricElementProps]($common).\n */\n public toJSON(): EntityProps {\n const val: any = {};\n val.classFullName = this.classFullName;\n if (Id64.isValid(this.id))\n val.id = this.id;\n this.forEachProperty((propName: string) => val[propName] = (this as any)[propName], false);\n return val;\n }\n\n /** Call a function for each property of this Entity.\n * @param func The callback to be invoked on each property\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\n */\n public forEachProperty(func: PropertyCallback, includeCustom: boolean = true) {\n this.iModel.forEachMetaData(this.classFullName, true, func, includeCustom);\n }\n\n /** Get the full BIS class name of this Entity in the form \"schema:class\" */\n public static get classFullName(): string { return `${this.schema.schemaName}:${this.className}`; }\n\n /** Get the full BIS class name of this Entity in the form \"schema:class\". */\n public get classFullName(): string { return this._ctor.classFullName; }\n\n /** @internal */\n public static get protectedOperations(): string[] { return []; }\n\n /** return whether this Entity class is a subclass of another Entity class\n * @note the subclass-ness is checked according to JavaScript inheritance, to check the underlying raw EC class's\n * inheritance, you can use [ECClass.is]($ecschema-metadata)\n * @note this should have a type of `is<T extends typeof Entity>(otherClass: T): this is T` but can't because of\n * typescript's restriction on the `this` type in static methods\n */\n public static is(otherClass: typeof Entity): boolean {\n // inline of @itwin/core-bentley's isSubclassOf due to protected constructor.\n return this === otherClass || this.prototype instanceof otherClass;\n }\n\n /** whether this JavaScript class was generated for this ECClass because there was no registered custom implementation\n * ClassRegistry overrides this when generating a class\n * @internal\n */\n public static get isGeneratedClass() { return false; }\n\n /** Get the set of this entity's *entity references*, [EntityReferenceSet]($backend). An *entity reference* is any id\n * stored on the entity, in its EC properties or json fields.\n * This is important for cloning operations but can be useful in other situations as well.\n * @see this.collectReferenceIds\n * @beta\n */\n public getReferenceIds(): EntityReferenceSet {\n const referenceIds = new EntityReferenceSet();\n this.collectReferenceIds(referenceIds);\n return referenceIds;\n }\n\n /** kept rename for older transformer versions\n * @deprecated in 3.x . Use [[getReferenceIds]] instead\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/unbound-method\n public getReferenceConcreteIds = this.getReferenceIds;\n\n /** Collect the Ids of this entity's *references* at this level of the class hierarchy.\n * A *reference* is any entity referenced by this entity's EC Data, including json fields.\n * This is important for cloning operations but can be useful in other situations as well.\n * @param _referenceIds The Id64Set to populate with reference Ids.\n * @note This should be overridden (with `super` called) at each level the class hierarchy that introduces references.\n * @see getReferenceIds\n * @beta\n */\n protected collectReferenceIds(_referenceIds: EntityReferenceSet): void {\n return; // no references by default\n }\n\n /** kept rename for older transformer versions\n * @deprecated in 3.x . Use [[collectReferenceIds]] instead\n * @internal\n */\n // eslint-disable-next-line @typescript-eslint/unbound-method\n protected collectReferenceConcreteIds = this.collectReferenceIds;\n}\n\n/** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.\n * @public\n */\nexport type EntityClassType<T> = Function & { prototype: T };\n"]}
|
|
1
|
+
{"version":3,"file":"Entity.js","sourceRoot":"","sources":["../../src/Entity.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAAuD;AACvD,oDAAyG;AAIzG;;;;GAIG;AACH,MA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AmB,CAAC,aAAiC;QAC7D,OAAO,CAAC,2BAA2B;IACrC,CAAC;CAQF;AArID,wBAqIC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport { EntityProps, EntityReferenceSet, PropertyCallback, PropertyMetaData } from \"@itwin/core-common\";\r\nimport type { IModelDb } from \"./IModelDb\";\r\nimport { Schema } from \"./Schema\";\r\n\r\n/** Represents one of the fundamental building block in an [[IModelDb]]: as an [[Element]], [[Model]], or [[Relationship]].\r\n * Every subclass of Entity represents one BIS [ECClass]($ecschema-metadata).\r\n * An Entity is typically instantiated from an [EntityProps]($common) and can be converted back to this representation via [[Entity.toJSON]].\r\n * @public\r\n */\r\nexport class Entity {\r\n /** An immutable property used to discriminate between [[Entity]] and [EntityProps]($common), used to inform the TypeScript compiler that these two types\r\n * are never substitutable for one another. To obtain an EntityProps from an Entity, use [[Entity.toJSON]].\r\n */\r\n public readonly isInstanceOfEntity = true as const;\r\n /** The Schema that defines this class. */\r\n public static schema: typeof Schema;\r\n\r\n private get _ctor(): typeof Entity { return this.constructor as typeof Entity; }\r\n\r\n /** The name of the BIS class associated with this class.\r\n * @note Every subclass of Entity **MUST** override this method to identify its BIS class.\r\n * Failure to do so will ordinarily result in an error when the class is registered, since there may only\r\n * be one JavaScript class for a given BIS class (usually the errant class will collide with its superclass.)\r\n */\r\n public static get className(): string { return \"Entity\"; }\r\n\r\n /** When working with an Entity it can be useful to set property values directly, bypassing the compiler's type checking.\r\n * This property makes such code slightly less tedious to read and write.\r\n * @internal\r\n */\r\n public get asAny(): any { return this; }\r\n\r\n /** The name of the BIS Schema that defines this class */\r\n public get schemaName(): string { return this._ctor.schema.schemaName; }\r\n\r\n /** The name of the BIS class associated with this class. */\r\n public get className(): string { return this._ctor.className; }\r\n\r\n /** The [[IModelDb]] that contains this Entity */\r\n public iModel: IModelDb;\r\n\r\n /** The Id of this Entity. May be invalid if the Entity has not yet been saved in the database. */\r\n public id: Id64String;\r\n\r\n protected constructor(props: EntityProps, iModel: IModelDb) {\r\n this.iModel = iModel;\r\n this.id = Id64.fromJSON(props.id);\r\n // copy all auto-handled properties from input to the object being constructed\r\n this.forEachProperty((propName: string, meta: PropertyMetaData) => (this as any)[propName] = meta.createProperty((props as any)[propName]), false);\r\n }\r\n\r\n /** Invoke the constructor of the specified `Entity` subclass.\r\n * @internal\r\n */\r\n public static instantiate(subclass: typeof Entity, props: EntityProps, iModel: IModelDb): Entity {\r\n return new subclass(props, iModel);\r\n }\r\n\r\n /** Obtain the JSON representation of this Entity. Subclasses of [[Entity]] typically override this method to return their corresponding sub-type of [EntityProps]($common) -\r\n * for example, [[GeometricElement.toJSON]] returns a [GeometricElementProps]($common).\r\n */\r\n public toJSON(): EntityProps {\r\n const val: any = {};\r\n val.classFullName = this.classFullName;\r\n if (Id64.isValid(this.id))\r\n val.id = this.id;\r\n this.forEachProperty((propName: string) => val[propName] = (this as any)[propName], false);\r\n return val;\r\n }\r\n\r\n /** Call a function for each property of this Entity.\r\n * @param func The callback to be invoked on each property\r\n * @param includeCustom If true (default), include custom-handled properties in the iteration. Otherwise, skip custom-handled properties.\r\n * @note Custom-handled properties are core properties that have behavior enforced by C++ handlers.\r\n */\r\n public forEachProperty(func: PropertyCallback, includeCustom: boolean = true) {\r\n this.iModel.forEachMetaData(this.classFullName, true, func, includeCustom);\r\n }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\" */\r\n public static get classFullName(): string { return `${this.schema.schemaName}:${this.className}`; }\r\n\r\n /** Get the full BIS class name of this Entity in the form \"schema:class\". */\r\n public get classFullName(): string { return this._ctor.classFullName; }\r\n\r\n /** @internal */\r\n public static get protectedOperations(): string[] { return []; }\r\n\r\n /** return whether this Entity class is a subclass of another Entity class\r\n * @note the subclass-ness is checked according to JavaScript inheritance, to check the underlying raw EC class's\r\n * inheritance, you can use [ECClass.is]($ecschema-metadata)\r\n * @note this should have a type of `is<T extends typeof Entity>(otherClass: T): this is T` but can't because of\r\n * typescript's restriction on the `this` type in static methods\r\n */\r\n public static is(otherClass: typeof Entity): boolean {\r\n // inline of @itwin/core-bentley's isSubclassOf due to protected constructor.\r\n return this === otherClass || this.prototype instanceof otherClass;\r\n }\r\n\r\n /** whether this JavaScript class was generated for this ECClass because there was no registered custom implementation\r\n * ClassRegistry overrides this when generating a class\r\n * @internal\r\n */\r\n public static get isGeneratedClass() { return false; }\r\n\r\n /** Get the set of this entity's *entity references*, [EntityReferenceSet]($backend). An *entity reference* is any id\r\n * stored on the entity, in its EC properties or json fields.\r\n * This is important for cloning operations but can be useful in other situations as well.\r\n * @see this.collectReferenceIds\r\n * @beta\r\n */\r\n public getReferenceIds(): EntityReferenceSet {\r\n const referenceIds = new EntityReferenceSet();\r\n this.collectReferenceIds(referenceIds);\r\n return referenceIds;\r\n }\r\n\r\n /** kept rename for older transformer versions\r\n * @deprecated in 3.x . Use [[getReferenceIds]] instead\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n public getReferenceConcreteIds = this.getReferenceIds;\r\n\r\n /** Collect the Ids of this entity's *references* at this level of the class hierarchy.\r\n * A *reference* is any entity referenced by this entity's EC Data, including json fields.\r\n * This is important for cloning operations but can be useful in other situations as well.\r\n * @param _referenceIds The Id64Set to populate with reference Ids.\r\n * @note This should be overridden (with `super` called) at each level the class hierarchy that introduces references.\r\n * @see getReferenceIds\r\n * @beta\r\n */\r\n protected collectReferenceIds(_referenceIds: EntityReferenceSet): void {\r\n return; // no references by default\r\n }\r\n\r\n /** kept rename for older transformer versions\r\n * @deprecated in 3.x . Use [[collectReferenceIds]] instead\r\n * @internal\r\n */\r\n // eslint-disable-next-line @typescript-eslint/unbound-method\r\n protected collectReferenceConcreteIds = this.collectReferenceIds;\r\n}\r\n\r\n/** Parameter type that can accept both abstract constructor types and non-abstract constructor types for `instanceof` to test.\r\n * @public\r\n */\r\nexport type EntityClassType<T> = Function & { prototype: T };\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EntityReferences.js","sourceRoot":"","sources":["../../src/EntityReferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAwH;AACxH,sDAAuD;AAEvD,mCAAgC;AAChC,uCAAoC;AACpC,mDAAgD;AAChD,iDAAiE;AACjE,iCAAiC;AAcjC;;;GAGG;AACH,IAAiB,gBAAgB,CAmEhC;AAnED,WAAiB,gBAAgB;IAC/B,SAAgB,OAAO,CAAC,EAAmB;QACzC,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,KAAK,CAAC;IAC7C,CAAC;IAFe,wBAAO,UAEtB,CAAA;IACD,SAAgB,SAAS,CAAC,EAAmB;QAC3C,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,OAAO,CAAC;IAC/C,CAAC;IAFe,0BAAS,YAExB,CAAA;IACD,SAAgB,eAAe,CAAC,EAAmB;QACjD,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,aAAa,CAAC;IACrD,CAAC;IAFe,gCAAe,kBAE9B,CAAA;IACD,SAAgB,cAAc,CAAC,EAAmB;QAChD,OAAO,EAAE,CAAC,CAAC,CAAC,KAAK,iCAAmB,CAAC,YAAY,CAAC;IACpD,CAAC;IAFe,+BAAc,iBAE7B,CAAA;IACD,SAAgB,MAAM,CAAC,EAAmB;QACxC,OAAO,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IACrB,CAAC;IAFe,uBAAM,SAErB,CAAA;IAED,0DAA0D;IAC1D,SAAgB,KAAK,CAAC,EAAmB;QACvC,4EAA4E;QAC5E,OAAO,CAAC,EAAE,CAAC,CAAC,CAAwB,EAAE,EAAE,CAA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KAAK,CAAC;aAC9B,IAAI,WAAW,CAAC,EAAE,CAAC,2BAAY,CAAC;YACnC,OAAO,iCAAmB,CAAC,YAAY,CAAC;;YAExC,MAAM,CAAC,KAAK,EAAE,iEAAiE,CAAC,CAAC;IACrF,CAAC;IAXe,8BAAa,gBAW5B,CAAA;AACH,CAAC,EAnEgB,gBAAgB,gCAAhB,gBAAgB,QAmEhC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n* See LICENSE.md in the project root for license terms and full copyright notice.\n*--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module Schema\n */\n\nimport { ConcreteEntityTypes, ElementAspectProps, ElementProps, EntityReference, ModelProps } from \"@itwin/core-common\";\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\nimport type { Entity } from \"./Entity\";\nimport { Model } from \"./Model\";\nimport { Element } from \"./Element\";\nimport { ElementAspect } from \"./ElementAspect\";\nimport { Relationship, RelationshipProps } from \"./Relationship\";\nimport * as assert from \"assert\";\n\n/** Concrete classes that can be created, with the notable exception of CodeSpecs since it is does not derive from Entity\n * other entity classes. In the future if there is a need\n * to manage them this way, it can be added\n * @alpha\n */\nexport type ConcreteEntity = Element | Model | ElementAspect | Relationship;\n\n/** Props for a [[ConcreteEntity]]\n * @alpha\n */\nexport type ConcreteEntityProps = ElementProps | ModelProps | ElementAspectProps | RelationshipProps;\n\n/**\n * Utilities for the [EntityReference]($common) type which is a kind of strings\n * @alpha\n */\nexport namespace EntityReferences {\n export function isModel(id: EntityReference) {\n return id[0] === ConcreteEntityTypes.Model;\n }\n export function isElement(id: EntityReference) {\n return id[0] === ConcreteEntityTypes.Element;\n }\n export function isElementAspect(id: EntityReference) {\n return id[0] === ConcreteEntityTypes.ElementAspect;\n }\n export function isRelationship(id: EntityReference) {\n return id[0] === ConcreteEntityTypes.Relationship;\n }\n export function toId64(id: EntityReference) {\n return id.slice(1);\n }\n\n /** split a concrete entity id into its type and raw id */\n export function split(id: EntityReference): [ConcreteEntityTypes, Id64String] {\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\n return [id[0] as ConcreteEntityTypes, id.slice(1)];\n }\n\n /** used by the transformer to figure out where to check for the existence in a db of a concrete element id\n * @internal\n */\n export function isValid(id: EntityReference): boolean {\n return Id64.isValid(toId64(id));\n }\n\n /** create the invalid id for a concrete entity type\n * @internal\n */\n export function makeInvalid(type: ConcreteEntityTypes): EntityReference {\n return `${type}${Id64.invalid}`;\n }\n\n /** create an EntityReference given an entity */\n export function from(entity: ConcreteEntity): EntityReference {\n const type = typeFromClass(entity.constructor as typeof Entity);\n return `${type}${entity.id}`;\n }\n\n /** create an EntityReference given an id and a JavaScript class */\n export function fromClass(id: Id64String, entityClass: typeof Entity): EntityReference {\n const type = typeFromClass(entityClass);\n return `${type}${id}`;\n }\n\n /** Create an EntityReference quickly from an exact reference type and id */\n export function fromEntityType(id: Id64String, type: ConcreteEntityTypes): EntityReference {\n return `${type}${id}`;\n }\n\n /** @internal the argument entityClass be concrete (i.e. not the Entity abstract base class) */\n export function typeFromClass(entityClass: typeof Entity): ConcreteEntityTypes {\n if (entityClass.is(Element))\n return ConcreteEntityTypes.Element;\n else if (entityClass.is(ElementAspect))\n return ConcreteEntityTypes.ElementAspect;\n else if (entityClass.is(Model))\n return ConcreteEntityTypes.Model;\n else if (entityClass.is(Relationship))\n return ConcreteEntityTypes.Relationship;\n else\n assert(false, \"unknown or abstract entity type passed to EntityReferences.from\");\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"EntityReferences.js","sourceRoot":"","sources":["../../src/EntityReferences.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,oDAAwH;AACxH,sDAAuD;AAEvD,mCAAgC;AAChC,uCAAoC;AACpC,mDAAgD;AAChD,iDAAiE;AACjE,iCAAiC;AAcjC;;;GAGG;AACH,IAAiB,gBAAgB,CAmEhC;AAnED,WAAiB,gBAAgB;IAC/B,S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AI,GAAG,aAAa,CAAC,MAAM,CAAC,WAA4B,CAAC,CAAC;QAChE,OAAO,GAAG,IAAI,GAAG,MAAM,CAAC,EAAE,EAAE,CAAC;IAC/B,CAAC;IAHe,qBAAI,OAGnB,CAAA;IAED,mEAAmE;IACnE,SAAgB,SAAS,CAAC,EAAc,EAAE,WAA0B;QAClE,MAAM,IAAI,GAAG,aAAa,CAAC,WAAW,CAAC,CAAC;QACxC,OAAO,GAAG,IAAI,GAAG,EAAE,EAAE,CAAC;IACxB,CAAC;IAHe,0BAAS,YAGxB,CAAA;IAED,4EAA4E;IAC5E,SAAgB,cAAc,CAAC,EAAc,EAAE,IAAyB;QACtE,OAAO,GAAG,IAAI,GAAG,EAAE,EAAE,CAAC;IACxB,CAAC;IAFe,+BAAc,iBAE7B,CAAA;IAED,+FAA+F;IAC/F,SAAgB,aAAa,CAAC,WAA0B;QACtD,IAAI,WAAW,CAAC,EAAE,CAAC,iBAAO,CAAC;YACzB,OAAO,iCAAmB,CAAC,OAAO,CAAC;aAChC,IAAI,WAAW,CAAC,EAAE,CAAC,6BAAa,CAAC;YACpC,OAAO,iCAAmB,CAAC,aAAa,CAAC;aACtC,IAAI,WAAW,CAAC,EAAE,CAAC,aAAK,CAAC;YAC5B,OAAO,iCAAmB,CAAC,KAAK,CAAC;aAC9B,IAAI,WAAW,CAAC,EAAE,CAAC,2BAAY,CAAC;YACnC,OAAO,iCAAmB,CAAC,YAAY,CAAC;;YAExC,MAAM,CAAC,KAAK,EAAE,iEAAiE,CAAC,CAAC;IACrF,CAAC;IAXe,8BAAa,gBAW5B,CAAA;AACH,CAAC,EAnEgB,gBAAgB,gCAAhB,gBAAgB,QAmEhC","sourcesContent":["/*---------------------------------------------------------------------------------------------\r\n* Copyright (c) Bentley Systems, Incorporated. All rights reserved.\r\n* See LICENSE.md in the project root for license terms and full copyright notice.\r\n*--------------------------------------------------------------------------------------------*/\r\n/** @packageDocumentation\r\n * @module Schema\r\n */\r\n\r\nimport { ConcreteEntityTypes, ElementAspectProps, ElementProps, EntityReference, ModelProps } from \"@itwin/core-common\";\r\nimport { Id64, Id64String } from \"@itwin/core-bentley\";\r\nimport type { Entity } from \"./Entity\";\r\nimport { Model } from \"./Model\";\r\nimport { Element } from \"./Element\";\r\nimport { ElementAspect } from \"./ElementAspect\";\r\nimport { Relationship, RelationshipProps } from \"./Relationship\";\r\nimport * as assert from \"assert\";\r\n\r\n/** Concrete classes that can be created, with the notable exception of CodeSpecs since it is does not derive from Entity\r\n * other entity classes. In the future if there is a need\r\n * to manage them this way, it can be added\r\n * @alpha\r\n */\r\nexport type ConcreteEntity = Element | Model | ElementAspect | Relationship;\r\n\r\n/** Props for a [[ConcreteEntity]]\r\n * @alpha\r\n */\r\nexport type ConcreteEntityProps = ElementProps | ModelProps | ElementAspectProps | RelationshipProps;\r\n\r\n/**\r\n * Utilities for the [EntityReference]($common) type which is a kind of strings\r\n * @alpha\r\n */\r\nexport namespace EntityReferences {\r\n export function isModel(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Model;\r\n }\r\n export function isElement(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Element;\r\n }\r\n export function isElementAspect(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.ElementAspect;\r\n }\r\n export function isRelationship(id: EntityReference) {\r\n return id[0] === ConcreteEntityTypes.Relationship;\r\n }\r\n export function toId64(id: EntityReference) {\r\n return id.slice(1);\r\n }\r\n\r\n /** split a concrete entity id into its type and raw id */\r\n export function split(id: EntityReference): [ConcreteEntityTypes, Id64String] {\r\n // eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion\r\n return [id[0] as ConcreteEntityTypes, id.slice(1)];\r\n }\r\n\r\n /** used by the transformer to figure out where to check for the existence in a db of a concrete element id\r\n * @internal\r\n */\r\n export function isValid(id: EntityReference): boolean {\r\n return Id64.isValid(toId64(id));\r\n }\r\n\r\n /** create the invalid id for a concrete entity type\r\n * @internal\r\n */\r\n export function makeInvalid(type: ConcreteEntityTypes): EntityReference {\r\n return `${type}${Id64.invalid}`;\r\n }\r\n\r\n /** create an EntityReference given an entity */\r\n export function from(entity: ConcreteEntity): EntityReference {\r\n const type = typeFromClass(entity.constructor as typeof Entity);\r\n return `${type}${entity.id}`;\r\n }\r\n\r\n /** create an EntityReference given an id and a JavaScript class */\r\n export function fromClass(id: Id64String, entityClass: typeof Entity): EntityReference {\r\n const type = typeFromClass(entityClass);\r\n return `${type}${id}`;\r\n }\r\n\r\n /** Create an EntityReference quickly from an exact reference type and id */\r\n export function fromEntityType(id: Id64String, type: ConcreteEntityTypes): EntityReference {\r\n return `${type}${id}`;\r\n }\r\n\r\n /** @internal the argument entityClass be concrete (i.e. not the Entity abstract base class) */\r\n export function typeFromClass(entityClass: typeof Entity): ConcreteEntityTypes {\r\n if (entityClass.is(Element))\r\n return ConcreteEntityTypes.Element;\r\n else if (entityClass.is(ElementAspect))\r\n return ConcreteEntityTypes.ElementAspect;\r\n else if (entityClass.is(Model))\r\n return ConcreteEntityTypes.Model;\r\n else if (entityClass.is(Relationship))\r\n return ConcreteEntityTypes.Relationship;\r\n else\r\n assert(false, \"unknown or abstract entity type passed to EntityReferences.from\");\r\n }\r\n}\r\n"]}
|