@itwin/imodel-transformer 2.0.0-dev.77 → 2.0.0-dev.78
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.
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelImporter.d.ts","sourceRoot":"","sources":["../src/IModelImporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,EACL,QAAQ,EAGR,UAAU,EAEV,UAAU,EAEX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAIL,kBAAkB,EAClB,YAAY,EACZ,WAAW,EAGX,UAAU,EAGX,MAAM,oBAAoB,CAAC;AAE5B,OAAO,EACL,wBAAwB,EACxB,OAAO,EACP,aAAa,EACb,kBAAkB,EAClB,MAAM,EAEN,QAAQ,EAER,iBAAiB,EAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,wBAAwB,CAAC;AAEzE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAWjE,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAoBjE;;GAEG;AACH,MAAM,WAAW,sBAAuB,SAAQ,UAAU;IACxD,2DAA2D;IAC3D,QAAQ,CAAC,MAAM,EAAE,wBAAwB,CAAC;IAC1C,6DAA6D;IAC7D,QAAQ,CAAC,eAAe,EAAE,QAAQ,CAAC;IACnC,6DAA6D;IAC7D,QAAQ,CAAC,SAAS,EAAE,WAAW,CAAC,UAAU,CAAC,CAAC;CAC7C;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED;;GAEG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;OAIG;IACH,wBAAwB,CAAC,EAAE,OAAO,GAAG;QAAE,eAAe,EAAE,OAAO,CAAA;KAAE,CAAC;IAClE,iDAAiD;IACjD,8BAA8B,CAAC,EAAE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ACnC,mBAAmB,EAAE,aAAa,GACjC,OAAO,CAAC,IAAI,CAAC,CAOf;IAED,8CAA8C;IAC9C,OAAO,CAAC,4BAA4B;IAMpC;;OAEG;IACU,kBAAkB,CAC7B,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAAC,UAAU,CAAC,CAyCrB;IAED;;;OAGG;IACH,UAAgB,oBAAoB,CAClC,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAAC,UAAU,CAAC,CAuBrB;IAED;;OAEG;IACH,UAAgB,oBAAoB,CAClC,iBAAiB,EAAE,iBAAiB,GACnC,OAAO,CAAC,IAAI,CAAC,CAgBf;IAED,gEAAgE;IAChE,UAAgB,oBAAoB,CAClC,iBAAiB,EAAE,0BAA0B,GAC5C,OAAO,CAAC,IAAI,CAAC,CAWf;IAED,gEAAgE;IACnD,kBAAkB,CAC7B,iBAAiB,EAAE,0BAA0B,GAC5C,OAAO,CAAC,IAAI,CAAC,CAEf;IAED,4CAA4C;IAC5C,OAAO,CAAC,2BAA2B;IAInC,kCAAkC;YACpB,aAAa;IAS3B;;OAEG;IACH,UAAgB,UAAU,IAAI,OAAO,CAAC,IAAI,CAAC,CAAG;IAE9C;;;OAGG;IACI,qBAAqB,IAAI,IAAI,CA0EnC;IAED;;;OAGG;IACI,gBAAgB,CAAC,OAAO,EAAE,uBAAuB,GAAG,IAAI,CAQ9D;IAED,OAAO,CAAC,0BAA0B;IASlC;;;;;;OAMG;IACI,QAAQ,IAAI,IAAI,CAEtB;CACF;AAED;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,aAAa,CAAC,EAAE,GAAG,CAAC,MAAM,CAAC,GAC1B,OAAO,CAkCT"}
|
package/lib/IModelImporter.js
CHANGED
|
@@ -368,6 +368,10 @@ export class IModelImporter {
|
|
|
368
368
|
deleteElementRoots(roots) {
|
|
369
369
|
const result = this._editTxn.deleteElements(roots);
|
|
370
370
|
if (result.status !== BulkDeleteElementsStatus.Success) {
|
|
371
|
+
// Constraint violations list the blocking elements. Other failures leave every requested root undeleted.
|
|
372
|
+
const failedIds = result.failures.length > 0
|
|
373
|
+
? new Set(result.failures.map((failure) => failure.elementId))
|
|
374
|
+
: new Set(roots);
|
|
371
375
|
ITwinError.throwError({
|
|
372
376
|
iTwinErrorId: {
|
|
373
377
|
scope: IModelTransformerErrorScope,
|
|
@@ -375,11 +379,11 @@ export class IModelImporter {
|
|
|
375
379
|
},
|
|
376
380
|
message: `Bulk element deletion failed: status ${BulkDeleteElementsStatus[result.status]}, ` +
|
|
377
381
|
`SQLite status ${result.sqlDeleteStatus}, failed element IDs: ${[
|
|
378
|
-
...
|
|
382
|
+
...failedIds,
|
|
379
383
|
].join(", ")}`,
|
|
380
384
|
status: result.status,
|
|
381
385
|
sqlDeleteStatus: result.sqlDeleteStatus,
|
|
382
|
-
failedIds
|
|
386
|
+
failedIds,
|
|
383
387
|
});
|
|
384
388
|
}
|
|
385
389
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelImporter.js","sourceRoot":"","sources":["../src/IModelImporter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,EAEL,IAAI,EACJ,IAAI,EAEJ,YAAY,EACZ,UAAU,EACV,MAAM,GACP,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,mBAAmB,EACnB,mBAAmB,EACnB,SAAS,EAIT,MAAM,EACN,WAAW,EAEX,cAAc,GAEf,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EACL,wBAAwB,EAKxB,gBAAgB,EAChB,QAAQ,EAIR,WAAW,GACZ,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EAAE,MAAM,IAAI,MAAM,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,EAAE,oBAAoB,EAAE,MAAM,2BAA2B,CAAC;AAC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C,EAAE,KAAK,QAAQ,CAAC,uBAAuB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC","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 iModels\n */\nimport {\n DbResult,\n Guid,\n Id64,\n Id64String,\n IModelStatus,\n ITwinError,\n Logger,\n} from \"@itwin/core-bentley\";\nimport {\n Base64EncodedString,\n ConcreteEntityTypes,\n ECJsNames,\n ElementAspectProps,\n ElementProps,\n EntityProps,\n IModel,\n IModelError,\n ModelProps,\n RelatedElement,\n SubCategoryProps,\n} from \"@itwin/core-common\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory.js\";\nimport {\n BulkDeleteElementsStatus,\n EditTxn,\n ElementAspect,\n ElementMultiAspect,\n Entity,\n EntityReferences,\n IModelDb,\n Relationship,\n RelationshipProps,\n SourceAndTarget,\n SubCategory,\n} from \"@itwin/core-backend\";\nimport type { RelationshipPropsForDelete } from \"./IModelTransformer.js\";\nimport { strict as assert } from \"node:assert\";\nimport { ElementAspectCleanup } from \"./ElementAspectCleanup.js\";\nimport {\n EntityClass,\n PropertyType,\n RelationshipClass,\n} from \"@itwin/ecschema-metadata\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"./IModelTransformerError.js\";\nimport { planBulkDelete } from \"./ElementBulkDelete.js\";\nimport { EntityExistenceCache } from \"./EntityExistenceCache.js\";\n\nconst loggerCategory: string = TransformerLoggerCategory.IModelImporter;\n\n/** Lists the first kept references for a log message. */\nfunction formatKeptReferences(\n keptReferences: ReadonlyMap<Id64String, Id64String>\n): string {\n const maxListed = 10;\n const listed = [...keptReferences]\n .slice(0, maxListed)\n .map(\n ([elementId, referencingId]) =>\n `${elementId} (referenced by ${referencingId})`\n )\n .join(\", \");\n const unlisted = keptReferences.size - maxListed;\n return unlisted > 0 ? `${listed}, and ${unlisted} more` : listed;\n}\n\n/** Error thrown when native bulk deletion fails to delete one or more requested element trees.\n * @beta\n */\nexport interface ElementBulkDeleteError extends ITwinError {\n /** Status returned by the native bulk-delete operation. */\n readonly status: BulkDeleteElementsStatus;\n /** SQLite status returned by the native delete statement. */\n readonly sqlDeleteStatus: DbResult;\n /** Target roots that the native operation did not delete. */\n readonly failedIds: ReadonlySet<Id64String>;\n}\n\n/** Options provided to [[IModelImporter.optimizeGeometry]] specifying post-processing optimizations to be applied to the iModel's geometry.\n * @beta\n */\nexport interface OptimizeGeometryOptions {\n /** If true, identify any [GeometryPart]($backend)s that are referenced exactly once. For each such part,\n * replace the reference in the element's geometry stream with the part's own geometry stream, then delete the part.\n */\n inlineUniqueGeometryParts?: boolean;\n}\n\n/** Options provided to the [[IModelImporter]] constructor.\n * @beta\n */\nexport interface IModelImportOptions {\n /** If `true` (the default), compute the projectExtents of the target iModel after elements are imported.\n * The computed projectExtents will either include or exclude *outliers* depending on the `excludeOutliers` flag that defaults to `false`.\n * @see [[IModelImporter.autoExtendProjectExtents]]\n * @see [IModelImporter Options]($docs/learning/transformer/index.md#IModelImporter)\n */\n autoExtendProjectExtents?: boolean | { excludeOutliers: boolean };\n /** See [IModelTransformOptions]($transformer) */\n preserveElementIdsForFiltering?: boolean;\n /** If `true`, simplify the element geometry for visualization purposes. For example, convert b-reps into meshes.\n * @default false\n */\n simplifyElementGeometry?: boolean;\n /**\n * Skip propagating changes made to the root subject, dictionaryModel and IModelImporter._realityDataSourceLinkPartitionStaticId (0xe)\n * If it is set to false, changes to root elements are propagated, the root subject name gets changed and leads to the iModelDb.name property being updated in .initializeiModelDb\n * @default true\n */\n skipPropagateChangesToRootElements?: boolean;\n}\n\n/** Base class for importing data into an iModel.\n * @see [iModel Transformation and Data Exchange]($docs/learning/transformer/index.md)\n * @see [IModelExporter]($transformer)\n * @see [IModelTransformer]($transformer)\n * @beta\n */\nexport class IModelImporter {\n /** The read/write target iModel. */\n public readonly targetDb: IModelDb;\n\n /** The [[EditTxn]] used for write operations on the target iModel.\n * @beta\n */\n protected readonly _editTxn: EditTxn;\n\n /** The [[EditTxn]] used for write operations on the target iModel.\n * @beta\n */\n public get editTxn(): EditTxn {\n return this._editTxn;\n }\n\n private readonly _elementAspectCleanup: ElementAspectCleanup;\n\n /** Deletes replaceable ElementAspects through this importer's customized deletion callback.\n * @internal\n */\n public get elementAspectCleanup(): ElementAspectCleanup {\n return this._elementAspectCleanup;\n }\n\n /** resolved initialization options for the importer\n * @beta\n */\n public readonly options: Required<IModelImportOptions>;\n\n private static _realityDataSourceLinkPartitionStaticId: Id64String = \"0xe\";\n\n /**\n * A map of conflicting element code values.\n * In cases where updating an element's code value results in a codeValue conflict, the element's code value will instead be updated to a random guid.\n * The actual codeValue will be stored in this ElementId->CodeValue map.\n * This is needed in cases where the duplicate target element is set to be deleted in the future, or when elements are switching code values with one another and we need a temporary code value.\n * To resolve code values to their intended values call [[IModelImporter.resolveDuplicateCodeValues]].\n */\n private _duplicateCodeValueMap: Map<Id64String, string>;\n private readonly _entityExistenceCaches = new Set<EntityExistenceCache>();\n /**\n * A set of elementIds that the transformer adds to while exporting elements to indicate that the element already exists in the target.\n * Defaults to an empty set.\n * @note\n *\n * This is used as an optimization when `[[IModelTransformOptions.preserveElementIdsForFiltering]]` is set to `true`\n * In normal cases where this option set to `false`,\n * the importer determines whether to insert or update based off of whether the ID is defined on the `elementProps` passed to `importElement`.\n * However, with `preserveElementIdsForFiltering` set to `true`, IDs are always set, so we can't determine insert/update like the normal case.\n * The transformer already knows if an element exists or not by the time `importElement` is called and pushes to this set with `markElementToUpdateForPreserveId`.\n * @note This set should stay small, as right after the transformer pushes to it, the importer will remove from the set.\n */\n private _elementsToUpdateDuringPreserveIds = new Set<Id64String>([]);\n\n /** The set of target elements that this importer must not directly update or request for deletion.\n * Defaults to an empty set and is populated by consumers or custom transformers.\n * @note Adding an element to this set is typically necessary when remapping a source element to one that already exists in the target and already has the desired properties.\n * @note Deletion protection applies only when the exact element ID is passed to [[deleteElement]] or [[deleteElements]]. It does not protect the element from deletion through a parent, containing model, or other cascading dependency. Consumers that need to preserve such an element must also add every requested deletion root whose cascade would delete it.\n */\n public readonly doNotUpdateElementIds = new Set<Id64String>([]);\n\n /** This set is ONLY used for elements that are always present even in an \"empty\" iModel. We will use this set to filter out changes to root elements if [[IModelTransformOptions.skipPropagateChangesToRootElements]] is false. */\n private readonly _rootElementIds = new Set<Id64String>([\n IModel.rootSubjectId,\n IModel.dictionaryId,\n IModelImporter._realityDataSourceLinkPartitionStaticId,\n ]);\n\n /** The number of entity changes before incremental progress should be reported via the [[onProgress]] callback. */\n public progressInterval: number = 1000;\n /** Tracks the current total number of entity changes. */\n private _progressCounter: number = 0;\n /** */\n private _modelPropertiesToIgnore = new Set<string>([\n \"geometryGuid\", // cannot compare GeometricModel.GeometryGuid values across iModels\n ]);\n\n /** Construct a new IModelImporter\n * @param editTxn The [[EditTxn]] to use for write operations on the target iModel. The target db is derived from `editTxn.iModel`.\n * @param options The options that specify how the import should be done.\n */\n public constructor(editTxn: EditTxn, options?: IModelImportOptions) {\n this.targetDb = editTxn.iModel;\n this._editTxn = editTxn;\n this.options = {\n autoExtendProjectExtents: options?.autoExtendProjectExtents ?? true,\n preserveElementIdsForFiltering:\n options?.preserveElementIdsForFiltering ?? false,\n simplifyElementGeometry: options?.simplifyElementGeometry ?? false,\n skipPropagateChangesToRootElements:\n options?.skipPropagateChangesToRootElements ?? true,\n };\n this._duplicateCodeValueMap = new Map<Id64String, string>();\n this._elementAspectCleanup = new ElementAspectCleanup(\n this.targetDb,\n this._editTxn,\n async (aspect) => this.onDeleteElementAspect(aspect)\n );\n }\n\n /** Register a transformation-scoped existence cache for delete invalidation.\n * @internal\n */\n public registerEntityExistenceCache(cache: EntityExistenceCache): void {\n this._entityExistenceCaches.add(cache);\n }\n\n /** Stop invalidating a transformation-scoped existence cache.\n * @internal\n */\n public unregisterEntityExistenceCache(cache: EntityExistenceCache): void {\n this._entityExistenceCaches.delete(cache);\n }\n\n /**\n * Checks [[IModelImportOptions.skipPropagateChangesToRootElements]], [[IModelImporter.rootElementIds]], and [[IModelImporter.doNotUpdateElementIds]] and returns true for 'do not update', false for do 'update'.\n */\n private doNotUpdateElement(elementId: Id64String): boolean {\n if (\n this.options.skipPropagateChangesToRootElements &&\n this._rootElementIds.has(elementId)\n )\n return true;\n if (this.doNotUpdateElementIds.has(elementId)) return true;\n return false;\n }\n\n /**\n * Marks an element so that it can be updated during import when [[IModelTransformOptions.preserveElementIdsForFiltering]] is set to true.\n */\n public markElementToUpdateDuringPreserveIds(elementId: Id64String) {\n if (this._rootElementIds.has(elementId)) {\n return;\n }\n this._elementsToUpdateDuringPreserveIds.add(elementId);\n }\n\n /** Import the specified ModelProps (either as an insert or an update) into the target iModel. */\n public async importModel(modelProps: ModelProps): Promise<void> {\n if (undefined === modelProps.id || !Id64.isValidId64(modelProps.id))\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.InvalidModelId,\n },\n message:\n \"Model Id not provided, should be the same as the ModeledElementId\",\n });\n\n if (this.doNotUpdateElement(modelProps.id)) {\n Logger.logInfo(\n loggerCategory,\n `Do not update target model ${modelProps.id}`\n );\n return;\n }\n try {\n const model = this.targetDb.models.getModel(modelProps.id); // throws IModelError.NotFound if model does not exist\n if (hasEntityChanged(model, modelProps, this._modelPropertiesToIgnore)) {\n await this.onUpdateModel(modelProps);\n }\n } catch (error) {\n // catch NotFound error and insertModel\n if (\n error instanceof IModelError &&\n error.errorNumber === IModelStatus.NotFound\n ) {\n await this.onInsertModel(modelProps);\n return;\n }\n throw error;\n }\n }\n\n /** Create a new Model from the specified ModelProps and insert it into the target iModel.\n * @note A subclass may override this method to customize insert behavior but should call `super.onInsertModel`.\n */\n protected async onInsertModel(modelProps: ModelProps): Promise<Id64String> {\n try {\n const modelId: Id64String = this._editTxn.insertModel(modelProps);\n Logger.logInfo(\n loggerCategory,\n `Inserted ${this.formatModelForLogger(modelProps)}`\n );\n await this.trackProgress();\n return modelId;\n } catch (error) {\n if (!this.targetDb.containsClass(modelProps.classFullName)) {\n // Translate only confirmed missing-class failures; otherwise retain the backend error's identity.\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.TargetClassNotFound,\n },\n message: `Model class \"${modelProps.classFullName}\" not found in the target iModel. Was the latest version of the schema imported?`,\n cause: error,\n });\n }\n throw error;\n }\n }\n\n /** Update an existing Model in the target iModel from the specified ModelProps.\n * @note A subclass may override this method to customize update behavior but should call `super.onUpdateModel`.\n */\n protected async onUpdateModel(modelProps: ModelProps): Promise<void> {\n this._editTxn.updateModel(modelProps);\n Logger.logInfo(\n loggerCategory,\n `Updated ${this.formatModelForLogger(modelProps)}`\n );\n await this.trackProgress();\n }\n\n /** Format a Model for the Logger. */\n private formatModelForLogger(modelProps: ModelProps): string {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return `${modelProps.classFullName} [${modelProps.id!}]`;\n }\n\n /**\n * Tries to update an element with the specified element properties.\n * If a duplicate code error occurs, it assigns a new unique code value and retries the update\n */\n private async tryUpdateElement(elemProps: ElementProps) {\n try {\n await this.onUpdateElement(elemProps);\n } catch (err) {\n if ((err as IModelError).errorNumber === IModelStatus.DuplicateCode) {\n assert(\n elemProps.code.value !== undefined,\n \"NULL code values are always considered unique and cannot clash\"\n );\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._duplicateCodeValueMap.set(elemProps.id!, elemProps.code.value);\n // Using NULL code values as an alternative is not valid because definition elements cannot have NULL code values.\n elemProps.code.value = Guid.createValue();\n await this.onUpdateElement(elemProps);\n } else {\n throw err;\n }\n }\n }\n\n /** Import the specified ElementProps (either as an insert or an update) into the target iModel. */\n public async importElement(elementProps: ElementProps): Promise<Id64String> {\n if (\n undefined !== elementProps.id &&\n this.doNotUpdateElement(elementProps.id)\n ) {\n Logger.logInfo(\n loggerCategory,\n `Do not update target element ${elementProps.id}`\n );\n return elementProps.id;\n }\n\n if (this.options.preserveElementIdsForFiltering) {\n if (elementProps.id === undefined) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.ElementIdRequired,\n },\n message:\n \"elementProps.id must be defined during a preserveIds operation\",\n });\n }\n\n // Categories are the only element that onInserted will immediately insert a new element (their default subcategory)\n // since default subcategories always exist and always will be inserted after their categories, we treat them as an update\n // to prevent duplicate inserts.\n // Always present elements (0xe, 0x1, 0x10) also will be updated to prevent duplicate inserts.\n if (\n (isSubCategory(elementProps) && isDefaultSubCategory(elementProps)) ||\n this._rootElementIds.has(elementProps.id)\n ) {\n await this.onUpdateElement(elementProps);\n } else {\n if (this._elementsToUpdateDuringPreserveIds.has(elementProps.id)) {\n await this.tryUpdateElement(elementProps);\n this._elementsToUpdateDuringPreserveIds.delete(elementProps.id);\n } else {\n await this.onInsertElement(elementProps);\n }\n }\n } else {\n if (undefined !== elementProps.id) {\n await this.tryUpdateElement(elementProps);\n } else {\n elementProps.id = await this.onInsertElement(elementProps); // targetElementProps.id assigned by insertElement\n }\n }\n return elementProps.id;\n }\n\n /** Create a new Element from the specified ElementProps and insert it into the target iModel.\n * @returns The Id of the newly inserted Element.\n * @note A subclass may override this method to customize insert behavior but should call `super.onInsertElement`.\n */\n protected async onInsertElement(\n elementProps: ElementProps\n ): Promise<Id64String> {\n try {\n const elementId = this._editTxn.insertElement(elementProps, {\n forceUseId: this.options.preserveElementIdsForFiltering,\n });\n // set the id like [IModelDb.insertElement]($backend), does, the raw nativeDb method does not\n elementProps.id = elementId;\n Logger.logInfo(\n loggerCategory,\n `Inserted ${this.formatElementForLogger(elementProps)}`\n );\n await this.trackProgress();\n if (this.options.simplifyElementGeometry) {\n this.targetDb.simplifyElementGeometry({\n id: elementId,\n convertBReps: true,\n });\n Logger.logInfo(\n loggerCategory,\n `Simplified element geometry for ${this.formatElementForLogger(\n elementProps\n )}`\n );\n }\n return elementId;\n } catch (error) {\n if (!this.targetDb.containsClass(elementProps.classFullName)) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.TargetClassNotFound,\n },\n message: `Element class \"${elementProps.classFullName}\" not found in the target iModel. Was the latest version of the schema imported?`,\n cause: error,\n });\n }\n throw error;\n }\n }\n\n /** Update an existing Element in the target iModel from the specified ElementProps.\n * @note A subclass may override this method to customize update behavior but should call `super.onUpdateElement`.\n */\n protected async onUpdateElement(elementProps: ElementProps): Promise<void> {\n if (!elementProps.id) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.ElementIdRequired,\n },\n message: \"ElementId not provided\",\n });\n }\n this._editTxn.updateElement(elementProps);\n Logger.logInfo(\n loggerCategory,\n `Updated ${this.formatElementForLogger(elementProps)}`\n );\n await this.trackProgress();\n if (this.options.simplifyElementGeometry) {\n this.targetDb.simplifyElementGeometry({\n id: elementProps.id,\n convertBReps: true,\n });\n Logger.logInfo(\n loggerCategory,\n `Simplified element geometry for ${this.formatElementForLogger(\n elementProps\n )}`\n );\n }\n }\n\n /** Deletes one target element tree through [[deleteElements]]. */\n public async deleteElement(elementId: Id64String): Promise<void> {\n await this.deleteElements(new Set([elementId]));\n }\n\n /** Adds roots required by code-scope dependencies, then deletes the target element trees in as few native operations as their references allow.\n * Usually one native operation is enough. When a tree contains a definition, such as a category, that another deleted element uses, the elements that use it are deleted first.\n * Elements that something outside the deleted trees still references are kept, with a warning, and the rest are deleted.\n * @note An override must call `super.onDeleteElements` once to perform the deletion.\n */\n protected async onDeleteElements(\n elementIds: ReadonlySet<Id64String>\n ): Promise<void> {\n const plan = await planBulkDelete(this.targetDb, elementIds);\n if (plan.keptReferences.size > 0) {\n Logger.logWarning(\n loggerCategory,\n `Kept ${plan.keptReferences.size} elements that elements outside the deleted trees still reference, and the elements that contain them: ${formatKeptReferences(\n plan.keptReferences\n )}`\n );\n }\n if (plan.phases.length === 0) return;\n let rootCount = 0;\n for (const roots of plan.phases) {\n rootCount += roots.length;\n this.deleteElementRoots(roots);\n }\n\n Logger.logInfo(\n loggerCategory,\n `Deleted ${elementIds.size} requested element trees using ${rootCount} native deletion roots in ${plan.phases.length} native operations`\n );\n await this.trackProgress(elementIds.size);\n }\n\n private deleteElementRoots(roots: Id64String[]): void {\n const result = this._editTxn.deleteElements(roots);\n if (result.status !== BulkDeleteElementsStatus.Success) {\n ITwinError.throwError<ElementBulkDeleteError>({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.ElementBulkDeleteFailed,\n },\n message:\n `Bulk element deletion failed: status ${BulkDeleteElementsStatus[result.status]}, ` +\n `SQLite status ${result.sqlDeleteStatus}, failed element IDs: ${[\n ...result.failedIds,\n ].join(\", \")}`,\n status: result.status,\n sqlDeleteStatus: result.sqlDeleteStatus,\n failedIds: new Set(result.failedIds),\n });\n }\n }\n\n /** Deletes target element trees, using one native operation unless references between the trees require more.\n * Requested roots in [[doNotUpdateElementIds]] are skipped. This does not prevent an element in that set from being deleted as part of another root's cascade.\n * Elements that something outside the deleted trees still references are kept, along with their child elements and sub-models and the elements that contain them. A warning lists them.\n * @throws [[ElementBulkDeleteError]] if a native operation fails for any root, for example because geometry outside the deleted trees uses a geometry part in them, or because of a reference in a domain schema. The transformer does not check those references first. Deletions from that and earlier native operations stay pending in the caller-owned transaction. Abandon the transaction before retrying.\n */\n public async deleteElements(\n elementIds: ReadonlySet<Id64String>\n ): Promise<void> {\n const idsToDelete = new Set<Id64String>();\n for (const elementId of elementIds) {\n if (!this.doNotUpdateElement(elementId)) {\n idsToDelete.add(elementId);\n continue;\n }\n Logger.logInfo(\n loggerCategory,\n `Do not delete target element ${elementId}`\n );\n }\n if (idsToDelete.size === 0) return;\n await this.onDeleteElements(idsToDelete);\n // Element deletion cascades can remove descendants and their submodels.\n for (const cache of this._entityExistenceCaches)\n cache.clearDb(this.targetDb);\n }\n\n /** Delete the specified Model from the target iModel.\n * @note A subclass may override this method to customize delete behavior but should call `super.onDeleteModel`.\n */\n protected async onDeleteModel(modelId: Id64String): Promise<void> {\n this._editTxn.deleteModel(modelId);\n Logger.logInfo(loggerCategory, `Deleted model ${modelId}`);\n await this.trackProgress();\n }\n\n /** Delete the specified Model from the target iModel. */\n public async deleteModel(modelId: Id64String): Promise<void> {\n await this.onDeleteModel(modelId);\n const modelReference = EntityReferences.fromEntityType(\n modelId,\n ConcreteEntityTypes.Model\n );\n for (const cache of this._entityExistenceCaches)\n cache.invalidate(this.targetDb, modelReference);\n }\n\n /** Format an Element for the Logger. */\n private formatElementForLogger(elementProps: ElementProps): string {\n const namePiece: string = elementProps.code.value\n ? `${elementProps.code.value} `\n : elementProps.userLabel\n ? `${elementProps.userLabel} `\n : \"\";\n return `${elementProps.classFullName} ${namePiece}[${elementProps.id}]`;\n }\n\n /** Import an ElementUniqueAspect into the target iModel. */\n public async importElementUniqueAspect(\n aspectProps: ElementAspectProps\n ): Promise<Id64String> {\n const aspects: ElementAspect[] = this.targetDb.elements.getAspects(\n aspectProps.element.id,\n aspectProps.classFullName\n );\n if (aspects.length === 0) {\n return this.onInsertElementAspect(aspectProps);\n } else if (hasEntityChanged(aspects[0], aspectProps)) {\n aspectProps.id = aspects[0].id;\n await this.onUpdateElementAspect(aspectProps);\n }\n return aspects[0].id;\n }\n\n /** Import the collection of ElementMultiAspects into the target iModel.\n * @param aspectPropsArray The ElementMultiAspects to import\n * @param filterFunc Optional filter func that is used to exclude target ElementMultiAspects that were added during iModel transformation from the update detection logic.\n * @note For insert vs. update reasons, it is important to process all ElementMultiAspects owned by an Element at once since we don't have aspect-specific provenance.\n * @returns the array of ids of the resulting ElementMultiAspects, in the same order of the aspectPropsArray parameter\n */\n public async importElementMultiAspects(\n aspectPropsArray: ElementAspectProps[],\n /** caller must use this to enforce any aspects added by IModelTransformer are not considered for update */\n filterFunc: (a: ElementMultiAspect) => boolean = () => true\n ): Promise<Id64String[]> {\n const result = new Array<Id64String | undefined>(\n aspectPropsArray.length\n ).fill(undefined);\n\n if (aspectPropsArray.length === 0) {\n return result as Id64String[];\n }\n\n const elementId: Id64String = aspectPropsArray[0].element.id;\n const proposedAspectsByClass = new Map<\n string,\n Array<{ props: ElementAspectProps; index: number }>\n >();\n aspectPropsArray.forEach((props, index): void => {\n const proposedAspects =\n proposedAspectsByClass.get(props.classFullName) ?? [];\n proposedAspects.push({ props, index });\n proposedAspectsByClass.set(props.classFullName, proposedAspects);\n });\n\n // Handle ElementMultiAspects in groups by class\n for (const [\n aspectClassFullName,\n proposedAspects,\n ] of proposedAspectsByClass) {\n const currentAspects = this.targetDb.elements\n .getAspects(elementId, aspectClassFullName)\n .map((props, index) => ({ props, index }) as const)\n .filter(({ props }) => filterFunc(props));\n\n if (proposedAspects.length >= currentAspects.length) {\n for (let index = 0; index < proposedAspects.length; index++) {\n const { props, index: resultIndex } = proposedAspects[index];\n let id: Id64String;\n if (index < currentAspects.length) {\n id = currentAspects[index].props.id;\n props.id = id;\n if (hasEntityChanged(currentAspects[index].props, props)) {\n await this.onUpdateElementAspect(props);\n }\n id = props.id;\n } else {\n id = await this.onInsertElementAspect(props);\n }\n result[resultIndex] = id;\n }\n } else {\n for (let index = 0; index < currentAspects.length; index++) {\n const { props } = currentAspects[index];\n if (index < proposedAspects.length) {\n const { props: proposedProps, index: resultIndex } =\n proposedAspects[index];\n const id = props.id;\n proposedProps.id = id;\n if (hasEntityChanged(props, proposedProps)) {\n await this.onUpdateElementAspect(proposedProps);\n }\n result[resultIndex] = id;\n } else {\n await this.onDeleteElementAspect(props);\n }\n }\n }\n }\n\n assert(result.every((r) => r !== undefined));\n return result;\n }\n\n /** Insert the ElementAspect into the target iModel.\n * @note A subclass may override this method to customize insert behavior but should call `super.onInsertElementAspect`.\n */\n protected async onInsertElementAspect(\n aspectProps: ElementAspectProps\n ): Promise<Id64String> {\n try {\n const id = this._editTxn.insertAspect(aspectProps);\n Logger.logInfo(\n loggerCategory,\n `Inserted ${this.formatElementAspectForLogger(aspectProps)}`\n );\n await this.trackProgress();\n return id;\n } catch (error) {\n if (!this.targetDb.containsClass(aspectProps.classFullName)) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.TargetClassNotFound,\n },\n message: `ElementAspect class \"${aspectProps.classFullName}\" not found in the target iModel. Was the latest version of the schema imported?`,\n cause: error,\n });\n }\n throw error;\n }\n }\n\n /** Update the ElementAspect within the target iModel.\n * @note A subclass may override this method to customize update behavior but should call `super.onUpdateElementAspect`.\n */\n protected async onUpdateElementAspect(\n aspectProps: ElementAspectProps\n ): Promise<void> {\n this._editTxn.updateAspect(aspectProps);\n Logger.logInfo(\n loggerCategory,\n `Updated ${this.formatElementAspectForLogger(aspectProps)}`\n );\n await this.trackProgress();\n }\n\n /** Delete the specified ElementAspect from the target iModel.\n * @note A subclass may override this method to customize delete behavior but should call `super.onDeleteElementAspect`.\n */\n protected async onDeleteElementAspect(\n targetElementAspect: ElementAspect\n ): Promise<void> {\n this._editTxn.deleteAspect(targetElementAspect.id);\n Logger.logInfo(\n loggerCategory,\n `Deleted ${this.formatElementAspectForLogger(targetElementAspect)}`\n );\n await this.trackProgress();\n }\n\n /** Format an ElementAspect for the Logger. */\n private formatElementAspectForLogger(\n elementAspectProps: ElementAspectProps | ElementAspect\n ): string {\n return `${elementAspectProps.classFullName} elementId=[${elementAspectProps.element.id}]`;\n }\n\n /** Import the specified RelationshipProps (either as an insert or an update) into the target iModel.\n * @returns The instance Id of the inserted or updated Relationship.\n */\n public async importRelationship(\n relationshipProps: RelationshipProps\n ): Promise<Id64String> {\n if (\n undefined === relationshipProps.sourceId ||\n !Id64.isValidId64(relationshipProps.sourceId)\n ) {\n Logger.logInfo(\n loggerCategory,\n `Ignoring ${relationshipProps.classFullName} instance because of invalid RelationshipProps.sourceId`\n );\n return Id64.invalid;\n }\n if (\n undefined === relationshipProps.targetId ||\n !Id64.isValidId64(relationshipProps.targetId)\n ) {\n Logger.logInfo(\n loggerCategory,\n `Ignoring ${relationshipProps.classFullName} instance because of invalid RelationshipProps.targetId`\n );\n return Id64.invalid;\n }\n // check for an existing relationship\n const relSourceAndTarget: SourceAndTarget = {\n sourceId: relationshipProps.sourceId,\n targetId: relationshipProps.targetId,\n };\n const relationship: Relationship | undefined =\n this.targetDb.relationships.tryGetInstance(\n relationshipProps.classFullName,\n relSourceAndTarget\n );\n if (undefined !== relationship) {\n // if relationship found, update it\n relationshipProps.id = relationship.id;\n if (hasEntityChanged(relationship, relationshipProps)) {\n await this.onUpdateRelationship(relationshipProps);\n }\n return relationshipProps.id;\n } else {\n return this.onInsertRelationship(relationshipProps);\n }\n }\n\n /** Create a new Relationship from the specified RelationshipProps and insert it into the target iModel.\n * @returns The instance Id of the newly inserted relationship.\n * @note A subclass may override this method to customize insert behavior but should call `super.onInsertRelationship`.\n */\n protected async onInsertRelationship(\n relationshipProps: RelationshipProps\n ): Promise<Id64String> {\n try {\n const targetRelInstanceId: Id64String =\n this._editTxn.insertRelationship(relationshipProps);\n Logger.logInfo(\n loggerCategory,\n `Inserted ${this.formatRelationshipForLogger(relationshipProps)}`\n );\n await this.trackProgress();\n return targetRelInstanceId;\n } catch (error) {\n if (!this.targetDb.containsClass(relationshipProps.classFullName)) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.TargetClassNotFound,\n },\n message: `Relationship class \"${relationshipProps.classFullName}\" not found in the target iModel. Was the latest version of the schema imported?`,\n cause: error,\n });\n }\n throw error;\n }\n }\n\n /** Update an existing Relationship in the target iModel from the specified RelationshipProps.\n * @note A subclass may override this method to customize update behavior but should call `super.onUpdateRelationship`.\n */\n protected async onUpdateRelationship(\n relationshipProps: RelationshipProps\n ): Promise<void> {\n if (!relationshipProps.id) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.RelationshipIdRequired,\n },\n message: \"Relationship instance Id not provided\",\n });\n }\n this._editTxn.updateRelationship(relationshipProps);\n Logger.logInfo(\n loggerCategory,\n `Updated ${this.formatRelationshipForLogger(relationshipProps)}`\n );\n await this.trackProgress();\n }\n\n /** Delete the specified Relationship from the target iModel. */\n protected async onDeleteRelationship(\n relationshipProps: RelationshipPropsForDelete\n ): Promise<void> {\n // Only passing in what deleteInstance actually uses, full relationshipProps is not necessary.\n this._editTxn.deleteRelationship({\n id: relationshipProps.id,\n classFullName: relationshipProps.classFullName,\n } as RelationshipProps);\n Logger.logInfo(\n loggerCategory,\n `Deleted relationship ${relationshipProps.classFullName} id=${relationshipProps.id}`\n );\n await this.trackProgress();\n }\n\n /** Delete the specified Relationship from the target iModel. */\n public async deleteRelationship(\n relationshipProps: RelationshipPropsForDelete\n ): Promise<void> {\n await this.onDeleteRelationship(relationshipProps);\n }\n\n /** Format a Relationship for the Logger. */\n private formatRelationshipForLogger(relProps: RelationshipProps): string {\n return `${relProps.classFullName} sourceId=[${relProps.sourceId}] targetId=[${relProps.targetId}]`;\n }\n\n /** Tracks incremental progress */\n private async trackProgress(increment = 1): Promise<void> {\n const previousProgressCounter = this._progressCounter;\n this._progressCounter += increment;\n const progressCallbacks =\n Math.floor(this._progressCounter / this.progressInterval) -\n Math.floor(previousProgressCounter / this.progressInterval);\n for (let i = 0; i < progressCallbacks; ++i) await this.onProgress();\n }\n\n /** This method is called when IModelImporter has made incremental progress based on the [[progressInterval]] setting.\n * @note A subclass may override this method to report custom progress but should call `super.onProgress`.\n */\n protected async onProgress(): Promise<void> {}\n\n /** Optionally compute the projectExtents for the target iModel depending on the options for this IModelImporter.\n * @note This method is automatically called from [IModelTransformer.process]($transformer).\n * @see [IModelDb.computeProjectExtents]($backend), [[autoExtendProjectExtents]]\n */\n public computeProjectExtents(): void {\n const computedProjectExtents = this.targetDb.computeProjectExtents({\n reportExtentsWithOutliers: true,\n reportOutliers: true,\n });\n Logger.logInfo(\n loggerCategory,\n `Current projectExtents=${JSON.stringify(this.targetDb.projectExtents)}`\n );\n Logger.logInfo(\n loggerCategory,\n `Computed projectExtents without outliers=${JSON.stringify(\n computedProjectExtents.extents\n )}`\n );\n Logger.logInfo(\n loggerCategory,\n `Computed projectExtents with outliers=${JSON.stringify(\n computedProjectExtents.extentsWithOutliers\n )}`\n );\n if (this.options.autoExtendProjectExtents) {\n const excludeOutliers: boolean =\n typeof this.options.autoExtendProjectExtents === \"object\"\n ? this.options.autoExtendProjectExtents.excludeOutliers\n : false;\n // If excludeOutliers is true, use the extents without outliers.\n // Otherwise prefer extentsWithOutliers, but fall back to extents if it's undefined or a null range.\n const extentsWithOutliers = computedProjectExtents.extentsWithOutliers;\n const useExtentsWithOutliers =\n !excludeOutliers && extentsWithOutliers && !extentsWithOutliers.isNull;\n const newProjectExtents = useExtentsWithOutliers\n ? extentsWithOutliers\n : computedProjectExtents.extents;\n if (!newProjectExtents.isAlmostEqual(this.targetDb.projectExtents)) {\n this._editTxn.updateProjectExtents(newProjectExtents);\n Logger.logInfo(\n loggerCategory,\n `Updated projectExtents=${JSON.stringify(\n this.targetDb.projectExtents\n )}`\n );\n }\n if (\n !excludeOutliers &&\n computedProjectExtents.outliers &&\n computedProjectExtents.outliers.length > 0\n ) {\n Logger.logInfo(\n loggerCategory,\n `${computedProjectExtents.outliers.length} outliers detected within projectExtents`\n );\n }\n } else {\n if (\n !this.targetDb.projectExtents.containsRange(\n computedProjectExtents.extents\n )\n ) {\n Logger.logWarning(\n loggerCategory,\n \"Current project extents may be too small\"\n );\n }\n if (\n computedProjectExtents.outliers &&\n computedProjectExtents.outliers.length > 0\n ) {\n Logger.logInfo(\n loggerCategory,\n `${computedProjectExtents.outliers.length} outliers detected within projectExtents`\n );\n }\n }\n }\n\n /** Examine the geometry streams of every [GeometricElement3d]($backend) in the target iModel and apply the specified optimizations.\n * @note This method is automatically called from [[IModelTransformer.process]] if\n * [[IModelTransformOptions.optimizeGeometry]] is defined.\n */\n public optimizeGeometry(options: OptimizeGeometryOptions): void {\n if (options.inlineUniqueGeometryParts) {\n const result = this.targetDb.inlineGeometryParts();\n Logger.logInfo(\n loggerCategory,\n `Inlined ${result.numRefsInlined} references to ${result.numCandidateParts} geometry parts and deleted ${result.numPartsDeleted} parts.`\n );\n }\n }\n\n private resolveDuplicateCodeValues(): void {\n for (const [elementId, codeValue] of this._duplicateCodeValueMap) {\n const element = this.targetDb.elements.getElement(elementId);\n element.code.value = codeValue;\n this._editTxn.updateElement(element.toJSON());\n }\n this._duplicateCodeValueMap.clear();\n }\n\n /**\n * Needs to be called to perform necessary cleanup operations.\n * By not calling `finalize` there is a risk that data imported into targetDb will not be as expected.\n *\n * @note [[IModelTransformer.process]] invokes this method automatically. Call it explicitly after\n * composing the transformer's lower-level subset processing methods.\n */\n public finalize(): void {\n this.resolveDuplicateCodeValues();\n }\n}\n\n/** Returns true if a change within an Entity is detected.\n * @param entity The current persistent Entity.\n * @param entityProps The new EntityProps to compare against\n * @note This method should only be called if changeset information is not available.\n * @internal\n */\nexport function hasEntityChanged(\n entity: Entity,\n entityProps: EntityProps,\n namesToIgnore?: Set<string>\n): boolean {\n let changed: boolean = false;\n const entityClass = entity.iModel.schemaContext.getSchemaItemSync(\n entity.schemaItemKey\n );\n assert(\n EntityClass.isEntityClass(entityClass) ||\n RelationshipClass.isRelationshipClass(entityClass),\n `Cannot get metadata for ${entity.classFullName}.`\n );\n for (const property of entityClass.getPropertiesSync()) {\n const propertyName = property.name;\n if (!changed) {\n if (namesToIgnore && namesToIgnore.has(propertyName)) {\n // skip\n } else if (PropertyType.Binary === property.propertyType) {\n changed = hasBinaryValueChanged(\n entity.asAny[ECJsNames.toJsName(propertyName)],\n (entityProps as any)[ECJsNames.toJsName(propertyName)]\n );\n } else if (property.isNavigation()) {\n changed = hasNavigationValueChanged(\n entity.asAny[ECJsNames.toJsName(propertyName)],\n (entityProps as any)[ECJsNames.toJsName(propertyName)]\n );\n } else {\n changed = hasValueChanged(\n entity.asAny[ECJsNames.toJsName(propertyName)],\n (entityProps as any)[ECJsNames.toJsName(propertyName)]\n );\n }\n }\n }\n return changed;\n}\n\n/** Returns true if the specified binary values are different. */\nfunction hasBinaryValueChanged(\n binaryProperty1: any,\n binaryProperty2: any\n): boolean {\n const jsonString1 = JSON.stringify(\n binaryProperty1,\n Base64EncodedString.replacer\n );\n const jsonString2 = JSON.stringify(\n binaryProperty2,\n Base64EncodedString.replacer\n );\n return jsonString1 !== jsonString2;\n}\n\n/** Returns true if the specified navigation property values are different. */\nfunction hasNavigationValueChanged(\n navigationProperty1: any,\n navigationProperty2: any\n): boolean {\n const relatedElement1 = RelatedElement.fromJSON(navigationProperty1);\n const relatedElement2 = RelatedElement.fromJSON(navigationProperty2);\n const jsonString1 = JSON.stringify(relatedElement1);\n const jsonString2 = JSON.stringify(relatedElement2);\n return jsonString1 !== jsonString2;\n}\n\n/** Returns true if the specified navigation property values are different. */\nfunction hasValueChanged(property1: any, property2: any): boolean {\n return JSON.stringify(property1) !== JSON.stringify(property2);\n}\n\n/** check if element props are a subcategory */\nfunction isSubCategory(props: ElementProps): props is SubCategoryProps {\n return props.classFullName === SubCategory.classFullName;\n}\n\n/** check if element props are a subcategory without loading the element */\nfunction isDefaultSubCategory(props: SubCategoryProps): boolean {\n if (props.id === undefined) return false;\n\n if (!Id64.isId64(props.id))\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.InvalidSubCategory,\n },\n message: \"subcategory had invalid id\",\n });\n if (props.parent?.id === undefined)\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.InvalidSubCategory,\n },\n message: `subcategory with id ${props.id} had no parent`,\n });\n return props.id === IModelDb.getDefaultSubCategoryId(props.parent.id);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IModelImporter.js","sourceRoot":"","sources":["../src/IModelImporter.ts"],"names":[],"mappings":"AAAA;;;gGAGgG;AAChG;;GAEG;AACH,OAAO,EAEL,IAAI,EACJ,IAAI,EAEJ,YAA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a,CAAC;AAC3D,CAAC;AAED,2EAA2E;AAC3E,SAAS,oBAAoB,CAAC,KAAuB;IACnD,IAAI,KAAK,CAAC,EAAE,KAAK,SAAS;QAAE,OAAO,KAAK,CAAC;IAEzC,IAAI,CAAC,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,EAAE,CAAC;QACxB,UAAU,CAAC,UAAU,CAAC;YACpB,YAAY,EAAE;gBACZ,KAAK,EAAE,2BAA2B;gBAClC,GAAG,EAAE,sBAAsB,CAAC,kBAAkB;aAC/C;YACD,OAAO,EAAE,4BAA4B;SACtC,CAAC,CAAC;IACL,IAAI,KAAK,CAAC,MAAM,EAAE,EAAE,KAAK,SAAS;QAChC,UAAU,CAAC,UAAU,CAAC;YACpB,YAAY,EAAE;gBACZ,KAAK,EAAE,2BAA2B;gBAClC,GAAG,EAAE,sBAAsB,CAAC,kBAAkB;aAC/C;YACD,OAAO,EAAE,uBAAuB,KAAK,CAAC,EAAE,gBAAgB;SACzD,CAAC,CAAC;IACL,OAAO,KAAK,CAAC,EAAE,KAAK,QAAQ,CAAC,uBAAuB,CAAC,KAAK,CAAC,MAAM,CAAC,EAAE,CAAC,CAAC;AACxE,CAAC","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 iModels\n */\nimport {\n DbResult,\n Guid,\n Id64,\n Id64String,\n IModelStatus,\n ITwinError,\n Logger,\n} from \"@itwin/core-bentley\";\nimport {\n Base64EncodedString,\n ConcreteEntityTypes,\n ECJsNames,\n ElementAspectProps,\n ElementProps,\n EntityProps,\n IModel,\n IModelError,\n ModelProps,\n RelatedElement,\n SubCategoryProps,\n} from \"@itwin/core-common\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory.js\";\nimport {\n BulkDeleteElementsStatus,\n EditTxn,\n ElementAspect,\n ElementMultiAspect,\n Entity,\n EntityReferences,\n IModelDb,\n Relationship,\n RelationshipProps,\n SourceAndTarget,\n SubCategory,\n} from \"@itwin/core-backend\";\nimport type { RelationshipPropsForDelete } from \"./IModelTransformer.js\";\nimport { strict as assert } from \"node:assert\";\nimport { ElementAspectCleanup } from \"./ElementAspectCleanup.js\";\nimport {\n EntityClass,\n PropertyType,\n RelationshipClass,\n} from \"@itwin/ecschema-metadata\";\nimport {\n IModelTransformerError,\n IModelTransformerErrorScope,\n} from \"./IModelTransformerError.js\";\nimport { planBulkDelete } from \"./ElementBulkDelete.js\";\nimport { EntityExistenceCache } from \"./EntityExistenceCache.js\";\n\nconst loggerCategory: string = TransformerLoggerCategory.IModelImporter;\n\n/** Lists the first kept references for a log message. */\nfunction formatKeptReferences(\n keptReferences: ReadonlyMap<Id64String, Id64String>\n): string {\n const maxListed = 10;\n const listed = [...keptReferences]\n .slice(0, maxListed)\n .map(\n ([elementId, referencingId]) =>\n `${elementId} (referenced by ${referencingId})`\n )\n .join(\", \");\n const unlisted = keptReferences.size - maxListed;\n return unlisted > 0 ? `${listed}, and ${unlisted} more` : listed;\n}\n\n/** Error thrown when native bulk deletion fails to delete one or more requested element trees.\n * @beta\n */\nexport interface ElementBulkDeleteError extends ITwinError {\n /** Status returned by the native bulk-delete operation. */\n readonly status: BulkDeleteElementsStatus;\n /** SQLite status returned by the native delete statement. */\n readonly sqlDeleteStatus: DbResult;\n /** Target roots that the native operation did not delete. */\n readonly failedIds: ReadonlySet<Id64String>;\n}\n\n/** Options provided to [[IModelImporter.optimizeGeometry]] specifying post-processing optimizations to be applied to the iModel's geometry.\n * @beta\n */\nexport interface OptimizeGeometryOptions {\n /** If true, identify any [GeometryPart]($backend)s that are referenced exactly once. For each such part,\n * replace the reference in the element's geometry stream with the part's own geometry stream, then delete the part.\n */\n inlineUniqueGeometryParts?: boolean;\n}\n\n/** Options provided to the [[IModelImporter]] constructor.\n * @beta\n */\nexport interface IModelImportOptions {\n /** If `true` (the default), compute the projectExtents of the target iModel after elements are imported.\n * The computed projectExtents will either include or exclude *outliers* depending on the `excludeOutliers` flag that defaults to `false`.\n * @see [[IModelImporter.autoExtendProjectExtents]]\n * @see [IModelImporter Options]($docs/learning/transformer/index.md#IModelImporter)\n */\n autoExtendProjectExtents?: boolean | { excludeOutliers: boolean };\n /** See [IModelTransformOptions]($transformer) */\n preserveElementIdsForFiltering?: boolean;\n /** If `true`, simplify the element geometry for visualization purposes. For example, convert b-reps into meshes.\n * @default false\n */\n simplifyElementGeometry?: boolean;\n /**\n * Skip propagating changes made to the root subject, dictionaryModel and IModelImporter._realityDataSourceLinkPartitionStaticId (0xe)\n * If it is set to false, changes to root elements are propagated, the root subject name gets changed and leads to the iModelDb.name property being updated in .initializeiModelDb\n * @default true\n */\n skipPropagateChangesToRootElements?: boolean;\n}\n\n/** Base class for importing data into an iModel.\n * @see [iModel Transformation and Data Exchange]($docs/learning/transformer/index.md)\n * @see [IModelExporter]($transformer)\n * @see [IModelTransformer]($transformer)\n * @beta\n */\nexport class IModelImporter {\n /** The read/write target iModel. */\n public readonly targetDb: IModelDb;\n\n /** The [[EditTxn]] used for write operations on the target iModel.\n * @beta\n */\n protected readonly _editTxn: EditTxn;\n\n /** The [[EditTxn]] used for write operations on the target iModel.\n * @beta\n */\n public get editTxn(): EditTxn {\n return this._editTxn;\n }\n\n private readonly _elementAspectCleanup: ElementAspectCleanup;\n\n /** Deletes replaceable ElementAspects through this importer's customized deletion callback.\n * @internal\n */\n public get elementAspectCleanup(): ElementAspectCleanup {\n return this._elementAspectCleanup;\n }\n\n /** resolved initialization options for the importer\n * @beta\n */\n public readonly options: Required<IModelImportOptions>;\n\n private static _realityDataSourceLinkPartitionStaticId: Id64String = \"0xe\";\n\n /**\n * A map of conflicting element code values.\n * In cases where updating an element's code value results in a codeValue conflict, the element's code value will instead be updated to a random guid.\n * The actual codeValue will be stored in this ElementId->CodeValue map.\n * This is needed in cases where the duplicate target element is set to be deleted in the future, or when elements are switching code values with one another and we need a temporary code value.\n * To resolve code values to their intended values call [[IModelImporter.resolveDuplicateCodeValues]].\n */\n private _duplicateCodeValueMap: Map<Id64String, string>;\n private readonly _entityExistenceCaches = new Set<EntityExistenceCache>();\n /**\n * A set of elementIds that the transformer adds to while exporting elements to indicate that the element already exists in the target.\n * Defaults to an empty set.\n * @note\n *\n * This is used as an optimization when `[[IModelTransformOptions.preserveElementIdsForFiltering]]` is set to `true`\n * In normal cases where this option set to `false`,\n * the importer determines whether to insert or update based off of whether the ID is defined on the `elementProps` passed to `importElement`.\n * However, with `preserveElementIdsForFiltering` set to `true`, IDs are always set, so we can't determine insert/update like the normal case.\n * The transformer already knows if an element exists or not by the time `importElement` is called and pushes to this set with `markElementToUpdateForPreserveId`.\n * @note This set should stay small, as right after the transformer pushes to it, the importer will remove from the set.\n */\n private _elementsToUpdateDuringPreserveIds = new Set<Id64String>([]);\n\n /** The set of target elements that this importer must not directly update or request for deletion.\n * Defaults to an empty set and is populated by consumers or custom transformers.\n * @note Adding an element to this set is typically necessary when remapping a source element to one that already exists in the target and already has the desired properties.\n * @note Deletion protection applies only when the exact element ID is passed to [[deleteElement]] or [[deleteElements]]. It does not protect the element from deletion through a parent, containing model, or other cascading dependency. Consumers that need to preserve such an element must also add every requested deletion root whose cascade would delete it.\n */\n public readonly doNotUpdateElementIds = new Set<Id64String>([]);\n\n /** This set is ONLY used for elements that are always present even in an \"empty\" iModel. We will use this set to filter out changes to root elements if [[IModelTransformOptions.skipPropagateChangesToRootElements]] is false. */\n private readonly _rootElementIds = new Set<Id64String>([\n IModel.rootSubjectId,\n IModel.dictionaryId,\n IModelImporter._realityDataSourceLinkPartitionStaticId,\n ]);\n\n /** The number of entity changes before incremental progress should be reported via the [[onProgress]] callback. */\n public progressInterval: number = 1000;\n /** Tracks the current total number of entity changes. */\n private _progressCounter: number = 0;\n /** */\n private _modelPropertiesToIgnore = new Set<string>([\n \"geometryGuid\", // cannot compare GeometricModel.GeometryGuid values across iModels\n ]);\n\n /** Construct a new IModelImporter\n * @param editTxn The [[EditTxn]] to use for write operations on the target iModel. The target db is derived from `editTxn.iModel`.\n * @param options The options that specify how the import should be done.\n */\n public constructor(editTxn: EditTxn, options?: IModelImportOptions) {\n this.targetDb = editTxn.iModel;\n this._editTxn = editTxn;\n this.options = {\n autoExtendProjectExtents: options?.autoExtendProjectExtents ?? true,\n preserveElementIdsForFiltering:\n options?.preserveElementIdsForFiltering ?? false,\n simplifyElementGeometry: options?.simplifyElementGeometry ?? false,\n skipPropagateChangesToRootElements:\n options?.skipPropagateChangesToRootElements ?? true,\n };\n this._duplicateCodeValueMap = new Map<Id64String, string>();\n this._elementAspectCleanup = new ElementAspectCleanup(\n this.targetDb,\n this._editTxn,\n async (aspect) => this.onDeleteElementAspect(aspect)\n );\n }\n\n /** Register a transformation-scoped existence cache for delete invalidation.\n * @internal\n */\n public registerEntityExistenceCache(cache: EntityExistenceCache): void {\n this._entityExistenceCaches.add(cache);\n }\n\n /** Stop invalidating a transformation-scoped existence cache.\n * @internal\n */\n public unregisterEntityExistenceCache(cache: EntityExistenceCache): void {\n this._entityExistenceCaches.delete(cache);\n }\n\n /**\n * Checks [[IModelImportOptions.skipPropagateChangesToRootElements]], [[IModelImporter.rootElementIds]], and [[IModelImporter.doNotUpdateElementIds]] and returns true for 'do not update', false for do 'update'.\n */\n private doNotUpdateElement(elementId: Id64String): boolean {\n if (\n this.options.skipPropagateChangesToRootElements &&\n this._rootElementIds.has(elementId)\n )\n return true;\n if (this.doNotUpdateElementIds.has(elementId)) return true;\n return false;\n }\n\n /**\n * Marks an element so that it can be updated during import when [[IModelTransformOptions.preserveElementIdsForFiltering]] is set to true.\n */\n public markElementToUpdateDuringPreserveIds(elementId: Id64String) {\n if (this._rootElementIds.has(elementId)) {\n return;\n }\n this._elementsToUpdateDuringPreserveIds.add(elementId);\n }\n\n /** Import the specified ModelProps (either as an insert or an update) into the target iModel. */\n public async importModel(modelProps: ModelProps): Promise<void> {\n if (undefined === modelProps.id || !Id64.isValidId64(modelProps.id))\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.InvalidModelId,\n },\n message:\n \"Model Id not provided, should be the same as the ModeledElementId\",\n });\n\n if (this.doNotUpdateElement(modelProps.id)) {\n Logger.logInfo(\n loggerCategory,\n `Do not update target model ${modelProps.id}`\n );\n return;\n }\n try {\n const model = this.targetDb.models.getModel(modelProps.id); // throws IModelError.NotFound if model does not exist\n if (hasEntityChanged(model, modelProps, this._modelPropertiesToIgnore)) {\n await this.onUpdateModel(modelProps);\n }\n } catch (error) {\n // catch NotFound error and insertModel\n if (\n error instanceof IModelError &&\n error.errorNumber === IModelStatus.NotFound\n ) {\n await this.onInsertModel(modelProps);\n return;\n }\n throw error;\n }\n }\n\n /** Create a new Model from the specified ModelProps and insert it into the target iModel.\n * @note A subclass may override this method to customize insert behavior but should call `super.onInsertModel`.\n */\n protected async onInsertModel(modelProps: ModelProps): Promise<Id64String> {\n try {\n const modelId: Id64String = this._editTxn.insertModel(modelProps);\n Logger.logInfo(\n loggerCategory,\n `Inserted ${this.formatModelForLogger(modelProps)}`\n );\n await this.trackProgress();\n return modelId;\n } catch (error) {\n if (!this.targetDb.containsClass(modelProps.classFullName)) {\n // Translate only confirmed missing-class failures; otherwise retain the backend error's identity.\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.TargetClassNotFound,\n },\n message: `Model class \"${modelProps.classFullName}\" not found in the target iModel. Was the latest version of the schema imported?`,\n cause: error,\n });\n }\n throw error;\n }\n }\n\n /** Update an existing Model in the target iModel from the specified ModelProps.\n * @note A subclass may override this method to customize update behavior but should call `super.onUpdateModel`.\n */\n protected async onUpdateModel(modelProps: ModelProps): Promise<void> {\n this._editTxn.updateModel(modelProps);\n Logger.logInfo(\n loggerCategory,\n `Updated ${this.formatModelForLogger(modelProps)}`\n );\n await this.trackProgress();\n }\n\n /** Format a Model for the Logger. */\n private formatModelForLogger(modelProps: ModelProps): string {\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n return `${modelProps.classFullName} [${modelProps.id!}]`;\n }\n\n /**\n * Tries to update an element with the specified element properties.\n * If a duplicate code error occurs, it assigns a new unique code value and retries the update\n */\n private async tryUpdateElement(elemProps: ElementProps) {\n try {\n await this.onUpdateElement(elemProps);\n } catch (err) {\n if ((err as IModelError).errorNumber === IModelStatus.DuplicateCode) {\n assert(\n elemProps.code.value !== undefined,\n \"NULL code values are always considered unique and cannot clash\"\n );\n // eslint-disable-next-line @typescript-eslint/no-non-null-assertion\n this._duplicateCodeValueMap.set(elemProps.id!, elemProps.code.value);\n // Using NULL code values as an alternative is not valid because definition elements cannot have NULL code values.\n elemProps.code.value = Guid.createValue();\n await this.onUpdateElement(elemProps);\n } else {\n throw err;\n }\n }\n }\n\n /** Import the specified ElementProps (either as an insert or an update) into the target iModel. */\n public async importElement(elementProps: ElementProps): Promise<Id64String> {\n if (\n undefined !== elementProps.id &&\n this.doNotUpdateElement(elementProps.id)\n ) {\n Logger.logInfo(\n loggerCategory,\n `Do not update target element ${elementProps.id}`\n );\n return elementProps.id;\n }\n\n if (this.options.preserveElementIdsForFiltering) {\n if (elementProps.id === undefined) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.ElementIdRequired,\n },\n message:\n \"elementProps.id must be defined during a preserveIds operation\",\n });\n }\n\n // Categories are the only element that onInserted will immediately insert a new element (their default subcategory)\n // since default subcategories always exist and always will be inserted after their categories, we treat them as an update\n // to prevent duplicate inserts.\n // Always present elements (0xe, 0x1, 0x10) also will be updated to prevent duplicate inserts.\n if (\n (isSubCategory(elementProps) && isDefaultSubCategory(elementProps)) ||\n this._rootElementIds.has(elementProps.id)\n ) {\n await this.onUpdateElement(elementProps);\n } else {\n if (this._elementsToUpdateDuringPreserveIds.has(elementProps.id)) {\n await this.tryUpdateElement(elementProps);\n this._elementsToUpdateDuringPreserveIds.delete(elementProps.id);\n } else {\n await this.onInsertElement(elementProps);\n }\n }\n } else {\n if (undefined !== elementProps.id) {\n await this.tryUpdateElement(elementProps);\n } else {\n elementProps.id = await this.onInsertElement(elementProps); // targetElementProps.id assigned by insertElement\n }\n }\n return elementProps.id;\n }\n\n /** Create a new Element from the specified ElementProps and insert it into the target iModel.\n * @returns The Id of the newly inserted Element.\n * @note A subclass may override this method to customize insert behavior but should call `super.onInsertElement`.\n */\n protected async onInsertElement(\n elementProps: ElementProps\n ): Promise<Id64String> {\n try {\n const elementId = this._editTxn.insertElement(elementProps, {\n forceUseId: this.options.preserveElementIdsForFiltering,\n });\n // set the id like [IModelDb.insertElement]($backend), does, the raw nativeDb method does not\n elementProps.id = elementId;\n Logger.logInfo(\n loggerCategory,\n `Inserted ${this.formatElementForLogger(elementProps)}`\n );\n await this.trackProgress();\n if (this.options.simplifyElementGeometry) {\n this.targetDb.simplifyElementGeometry({\n id: elementId,\n convertBReps: true,\n });\n Logger.logInfo(\n loggerCategory,\n `Simplified element geometry for ${this.formatElementForLogger(\n elementProps\n )}`\n );\n }\n return elementId;\n } catch (error) {\n if (!this.targetDb.containsClass(elementProps.classFullName)) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.TargetClassNotFound,\n },\n message: `Element class \"${elementProps.classFullName}\" not found in the target iModel. Was the latest version of the schema imported?`,\n cause: error,\n });\n }\n throw error;\n }\n }\n\n /** Update an existing Element in the target iModel from the specified ElementProps.\n * @note A subclass may override this method to customize update behavior but should call `super.onUpdateElement`.\n */\n protected async onUpdateElement(elementProps: ElementProps): Promise<void> {\n if (!elementProps.id) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.ElementIdRequired,\n },\n message: \"ElementId not provided\",\n });\n }\n this._editTxn.updateElement(elementProps);\n Logger.logInfo(\n loggerCategory,\n `Updated ${this.formatElementForLogger(elementProps)}`\n );\n await this.trackProgress();\n if (this.options.simplifyElementGeometry) {\n this.targetDb.simplifyElementGeometry({\n id: elementProps.id,\n convertBReps: true,\n });\n Logger.logInfo(\n loggerCategory,\n `Simplified element geometry for ${this.formatElementForLogger(\n elementProps\n )}`\n );\n }\n }\n\n /** Deletes one target element tree through [[deleteElements]]. */\n public async deleteElement(elementId: Id64String): Promise<void> {\n await this.deleteElements(new Set([elementId]));\n }\n\n /** Adds roots required by code-scope dependencies, then deletes the target element trees in as few native operations as their references allow.\n * Usually one native operation is enough. When a tree contains a definition, such as a category, that another deleted element uses, the elements that use it are deleted first.\n * Elements that something outside the deleted trees still references are kept, with a warning, and the rest are deleted.\n * @note An override must call `super.onDeleteElements` once to perform the deletion.\n */\n protected async onDeleteElements(\n elementIds: ReadonlySet<Id64String>\n ): Promise<void> {\n const plan = await planBulkDelete(this.targetDb, elementIds);\n if (plan.keptReferences.size > 0) {\n Logger.logWarning(\n loggerCategory,\n `Kept ${plan.keptReferences.size} elements that elements outside the deleted trees still reference, and the elements that contain them: ${formatKeptReferences(\n plan.keptReferences\n )}`\n );\n }\n if (plan.phases.length === 0) return;\n let rootCount = 0;\n for (const roots of plan.phases) {\n rootCount += roots.length;\n this.deleteElementRoots(roots);\n }\n\n Logger.logInfo(\n loggerCategory,\n `Deleted ${elementIds.size} requested element trees using ${rootCount} native deletion roots in ${plan.phases.length} native operations`\n );\n await this.trackProgress(elementIds.size);\n }\n\n private deleteElementRoots(roots: Id64String[]): void {\n const result = this._editTxn.deleteElements(roots);\n if (result.status !== BulkDeleteElementsStatus.Success) {\n // Constraint violations list the blocking elements. Other failures leave every requested root undeleted.\n const failedIds =\n result.failures.length > 0\n ? new Set(result.failures.map((failure) => failure.elementId))\n : new Set(roots);\n ITwinError.throwError<ElementBulkDeleteError>({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.ElementBulkDeleteFailed,\n },\n message:\n `Bulk element deletion failed: status ${BulkDeleteElementsStatus[result.status]}, ` +\n `SQLite status ${result.sqlDeleteStatus}, failed element IDs: ${[\n ...failedIds,\n ].join(\", \")}`,\n status: result.status,\n sqlDeleteStatus: result.sqlDeleteStatus,\n failedIds,\n });\n }\n }\n\n /** Deletes target element trees, using one native operation unless references between the trees require more.\n * Requested roots in [[doNotUpdateElementIds]] are skipped. This does not prevent an element in that set from being deleted as part of another root's cascade.\n * Elements that something outside the deleted trees still references are kept, along with their child elements and sub-models and the elements that contain them. A warning lists them.\n * @throws [[ElementBulkDeleteError]] if a native operation fails for any root, for example because geometry outside the deleted trees uses a geometry part in them, or because of a reference in a domain schema. The transformer does not check those references first. Deletions from that and earlier native operations stay pending in the caller-owned transaction. Abandon the transaction before retrying.\n */\n public async deleteElements(\n elementIds: ReadonlySet<Id64String>\n ): Promise<void> {\n const idsToDelete = new Set<Id64String>();\n for (const elementId of elementIds) {\n if (!this.doNotUpdateElement(elementId)) {\n idsToDelete.add(elementId);\n continue;\n }\n Logger.logInfo(\n loggerCategory,\n `Do not delete target element ${elementId}`\n );\n }\n if (idsToDelete.size === 0) return;\n await this.onDeleteElements(idsToDelete);\n // Element deletion cascades can remove descendants and their submodels.\n for (const cache of this._entityExistenceCaches)\n cache.clearDb(this.targetDb);\n }\n\n /** Delete the specified Model from the target iModel.\n * @note A subclass may override this method to customize delete behavior but should call `super.onDeleteModel`.\n */\n protected async onDeleteModel(modelId: Id64String): Promise<void> {\n this._editTxn.deleteModel(modelId);\n Logger.logInfo(loggerCategory, `Deleted model ${modelId}`);\n await this.trackProgress();\n }\n\n /** Delete the specified Model from the target iModel. */\n public async deleteModel(modelId: Id64String): Promise<void> {\n await this.onDeleteModel(modelId);\n const modelReference = EntityReferences.fromEntityType(\n modelId,\n ConcreteEntityTypes.Model\n );\n for (const cache of this._entityExistenceCaches)\n cache.invalidate(this.targetDb, modelReference);\n }\n\n /** Format an Element for the Logger. */\n private formatElementForLogger(elementProps: ElementProps): string {\n const namePiece: string = elementProps.code.value\n ? `${elementProps.code.value} `\n : elementProps.userLabel\n ? `${elementProps.userLabel} `\n : \"\";\n return `${elementProps.classFullName} ${namePiece}[${elementProps.id}]`;\n }\n\n /** Import an ElementUniqueAspect into the target iModel. */\n public async importElementUniqueAspect(\n aspectProps: ElementAspectProps\n ): Promise<Id64String> {\n const aspects: ElementAspect[] = this.targetDb.elements.getAspects(\n aspectProps.element.id,\n aspectProps.classFullName\n );\n if (aspects.length === 0) {\n return this.onInsertElementAspect(aspectProps);\n } else if (hasEntityChanged(aspects[0], aspectProps)) {\n aspectProps.id = aspects[0].id;\n await this.onUpdateElementAspect(aspectProps);\n }\n return aspects[0].id;\n }\n\n /** Import the collection of ElementMultiAspects into the target iModel.\n * @param aspectPropsArray The ElementMultiAspects to import\n * @param filterFunc Optional filter func that is used to exclude target ElementMultiAspects that were added during iModel transformation from the update detection logic.\n * @note For insert vs. update reasons, it is important to process all ElementMultiAspects owned by an Element at once since we don't have aspect-specific provenance.\n * @returns the array of ids of the resulting ElementMultiAspects, in the same order of the aspectPropsArray parameter\n */\n public async importElementMultiAspects(\n aspectPropsArray: ElementAspectProps[],\n /** caller must use this to enforce any aspects added by IModelTransformer are not considered for update */\n filterFunc: (a: ElementMultiAspect) => boolean = () => true\n ): Promise<Id64String[]> {\n const result = new Array<Id64String | undefined>(\n aspectPropsArray.length\n ).fill(undefined);\n\n if (aspectPropsArray.length === 0) {\n return result as Id64String[];\n }\n\n const elementId: Id64String = aspectPropsArray[0].element.id;\n const proposedAspectsByClass = new Map<\n string,\n Array<{ props: ElementAspectProps; index: number }>\n >();\n aspectPropsArray.forEach((props, index): void => {\n const proposedAspects =\n proposedAspectsByClass.get(props.classFullName) ?? [];\n proposedAspects.push({ props, index });\n proposedAspectsByClass.set(props.classFullName, proposedAspects);\n });\n\n // Handle ElementMultiAspects in groups by class\n for (const [\n aspectClassFullName,\n proposedAspects,\n ] of proposedAspectsByClass) {\n const currentAspects = this.targetDb.elements\n .getAspects(elementId, aspectClassFullName)\n .map((props, index) => ({ props, index }) as const)\n .filter(({ props }) => filterFunc(props));\n\n if (proposedAspects.length >= currentAspects.length) {\n for (let index = 0; index < proposedAspects.length; index++) {\n const { props, index: resultIndex } = proposedAspects[index];\n let id: Id64String;\n if (index < currentAspects.length) {\n id = currentAspects[index].props.id;\n props.id = id;\n if (hasEntityChanged(currentAspects[index].props, props)) {\n await this.onUpdateElementAspect(props);\n }\n id = props.id;\n } else {\n id = await this.onInsertElementAspect(props);\n }\n result[resultIndex] = id;\n }\n } else {\n for (let index = 0; index < currentAspects.length; index++) {\n const { props } = currentAspects[index];\n if (index < proposedAspects.length) {\n const { props: proposedProps, index: resultIndex } =\n proposedAspects[index];\n const id = props.id;\n proposedProps.id = id;\n if (hasEntityChanged(props, proposedProps)) {\n await this.onUpdateElementAspect(proposedProps);\n }\n result[resultIndex] = id;\n } else {\n await this.onDeleteElementAspect(props);\n }\n }\n }\n }\n\n assert(result.every((r) => r !== undefined));\n return result;\n }\n\n /** Insert the ElementAspect into the target iModel.\n * @note A subclass may override this method to customize insert behavior but should call `super.onInsertElementAspect`.\n */\n protected async onInsertElementAspect(\n aspectProps: ElementAspectProps\n ): Promise<Id64String> {\n try {\n const id = this._editTxn.insertAspect(aspectProps);\n Logger.logInfo(\n loggerCategory,\n `Inserted ${this.formatElementAspectForLogger(aspectProps)}`\n );\n await this.trackProgress();\n return id;\n } catch (error) {\n if (!this.targetDb.containsClass(aspectProps.classFullName)) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.TargetClassNotFound,\n },\n message: `ElementAspect class \"${aspectProps.classFullName}\" not found in the target iModel. Was the latest version of the schema imported?`,\n cause: error,\n });\n }\n throw error;\n }\n }\n\n /** Update the ElementAspect within the target iModel.\n * @note A subclass may override this method to customize update behavior but should call `super.onUpdateElementAspect`.\n */\n protected async onUpdateElementAspect(\n aspectProps: ElementAspectProps\n ): Promise<void> {\n this._editTxn.updateAspect(aspectProps);\n Logger.logInfo(\n loggerCategory,\n `Updated ${this.formatElementAspectForLogger(aspectProps)}`\n );\n await this.trackProgress();\n }\n\n /** Delete the specified ElementAspect from the target iModel.\n * @note A subclass may override this method to customize delete behavior but should call `super.onDeleteElementAspect`.\n */\n protected async onDeleteElementAspect(\n targetElementAspect: ElementAspect\n ): Promise<void> {\n this._editTxn.deleteAspect(targetElementAspect.id);\n Logger.logInfo(\n loggerCategory,\n `Deleted ${this.formatElementAspectForLogger(targetElementAspect)}`\n );\n await this.trackProgress();\n }\n\n /** Format an ElementAspect for the Logger. */\n private formatElementAspectForLogger(\n elementAspectProps: ElementAspectProps | ElementAspect\n ): string {\n return `${elementAspectProps.classFullName} elementId=[${elementAspectProps.element.id}]`;\n }\n\n /** Import the specified RelationshipProps (either as an insert or an update) into the target iModel.\n * @returns The instance Id of the inserted or updated Relationship.\n */\n public async importRelationship(\n relationshipProps: RelationshipProps\n ): Promise<Id64String> {\n if (\n undefined === relationshipProps.sourceId ||\n !Id64.isValidId64(relationshipProps.sourceId)\n ) {\n Logger.logInfo(\n loggerCategory,\n `Ignoring ${relationshipProps.classFullName} instance because of invalid RelationshipProps.sourceId`\n );\n return Id64.invalid;\n }\n if (\n undefined === relationshipProps.targetId ||\n !Id64.isValidId64(relationshipProps.targetId)\n ) {\n Logger.logInfo(\n loggerCategory,\n `Ignoring ${relationshipProps.classFullName} instance because of invalid RelationshipProps.targetId`\n );\n return Id64.invalid;\n }\n // check for an existing relationship\n const relSourceAndTarget: SourceAndTarget = {\n sourceId: relationshipProps.sourceId,\n targetId: relationshipProps.targetId,\n };\n const relationship: Relationship | undefined =\n this.targetDb.relationships.tryGetInstance(\n relationshipProps.classFullName,\n relSourceAndTarget\n );\n if (undefined !== relationship) {\n // if relationship found, update it\n relationshipProps.id = relationship.id;\n if (hasEntityChanged(relationship, relationshipProps)) {\n await this.onUpdateRelationship(relationshipProps);\n }\n return relationshipProps.id;\n } else {\n return this.onInsertRelationship(relationshipProps);\n }\n }\n\n /** Create a new Relationship from the specified RelationshipProps and insert it into the target iModel.\n * @returns The instance Id of the newly inserted relationship.\n * @note A subclass may override this method to customize insert behavior but should call `super.onInsertRelationship`.\n */\n protected async onInsertRelationship(\n relationshipProps: RelationshipProps\n ): Promise<Id64String> {\n try {\n const targetRelInstanceId: Id64String =\n this._editTxn.insertRelationship(relationshipProps);\n Logger.logInfo(\n loggerCategory,\n `Inserted ${this.formatRelationshipForLogger(relationshipProps)}`\n );\n await this.trackProgress();\n return targetRelInstanceId;\n } catch (error) {\n if (!this.targetDb.containsClass(relationshipProps.classFullName)) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.TargetClassNotFound,\n },\n message: `Relationship class \"${relationshipProps.classFullName}\" not found in the target iModel. Was the latest version of the schema imported?`,\n cause: error,\n });\n }\n throw error;\n }\n }\n\n /** Update an existing Relationship in the target iModel from the specified RelationshipProps.\n * @note A subclass may override this method to customize update behavior but should call `super.onUpdateRelationship`.\n */\n protected async onUpdateRelationship(\n relationshipProps: RelationshipProps\n ): Promise<void> {\n if (!relationshipProps.id) {\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.RelationshipIdRequired,\n },\n message: \"Relationship instance Id not provided\",\n });\n }\n this._editTxn.updateRelationship(relationshipProps);\n Logger.logInfo(\n loggerCategory,\n `Updated ${this.formatRelationshipForLogger(relationshipProps)}`\n );\n await this.trackProgress();\n }\n\n /** Delete the specified Relationship from the target iModel. */\n protected async onDeleteRelationship(\n relationshipProps: RelationshipPropsForDelete\n ): Promise<void> {\n // Only passing in what deleteInstance actually uses, full relationshipProps is not necessary.\n this._editTxn.deleteRelationship({\n id: relationshipProps.id,\n classFullName: relationshipProps.classFullName,\n } as RelationshipProps);\n Logger.logInfo(\n loggerCategory,\n `Deleted relationship ${relationshipProps.classFullName} id=${relationshipProps.id}`\n );\n await this.trackProgress();\n }\n\n /** Delete the specified Relationship from the target iModel. */\n public async deleteRelationship(\n relationshipProps: RelationshipPropsForDelete\n ): Promise<void> {\n await this.onDeleteRelationship(relationshipProps);\n }\n\n /** Format a Relationship for the Logger. */\n private formatRelationshipForLogger(relProps: RelationshipProps): string {\n return `${relProps.classFullName} sourceId=[${relProps.sourceId}] targetId=[${relProps.targetId}]`;\n }\n\n /** Tracks incremental progress */\n private async trackProgress(increment = 1): Promise<void> {\n const previousProgressCounter = this._progressCounter;\n this._progressCounter += increment;\n const progressCallbacks =\n Math.floor(this._progressCounter / this.progressInterval) -\n Math.floor(previousProgressCounter / this.progressInterval);\n for (let i = 0; i < progressCallbacks; ++i) await this.onProgress();\n }\n\n /** This method is called when IModelImporter has made incremental progress based on the [[progressInterval]] setting.\n * @note A subclass may override this method to report custom progress but should call `super.onProgress`.\n */\n protected async onProgress(): Promise<void> {}\n\n /** Optionally compute the projectExtents for the target iModel depending on the options for this IModelImporter.\n * @note This method is automatically called from [IModelTransformer.process]($transformer).\n * @see [IModelDb.computeProjectExtents]($backend), [[autoExtendProjectExtents]]\n */\n public computeProjectExtents(): void {\n const computedProjectExtents = this.targetDb.computeProjectExtents({\n reportExtentsWithOutliers: true,\n reportOutliers: true,\n });\n Logger.logInfo(\n loggerCategory,\n `Current projectExtents=${JSON.stringify(this.targetDb.projectExtents)}`\n );\n Logger.logInfo(\n loggerCategory,\n `Computed projectExtents without outliers=${JSON.stringify(\n computedProjectExtents.extents\n )}`\n );\n Logger.logInfo(\n loggerCategory,\n `Computed projectExtents with outliers=${JSON.stringify(\n computedProjectExtents.extentsWithOutliers\n )}`\n );\n if (this.options.autoExtendProjectExtents) {\n const excludeOutliers: boolean =\n typeof this.options.autoExtendProjectExtents === \"object\"\n ? this.options.autoExtendProjectExtents.excludeOutliers\n : false;\n // If excludeOutliers is true, use the extents without outliers.\n // Otherwise prefer extentsWithOutliers, but fall back to extents if it's undefined or a null range.\n const extentsWithOutliers = computedProjectExtents.extentsWithOutliers;\n const useExtentsWithOutliers =\n !excludeOutliers && extentsWithOutliers && !extentsWithOutliers.isNull;\n const newProjectExtents = useExtentsWithOutliers\n ? extentsWithOutliers\n : computedProjectExtents.extents;\n if (!newProjectExtents.isAlmostEqual(this.targetDb.projectExtents)) {\n this._editTxn.updateProjectExtents(newProjectExtents);\n Logger.logInfo(\n loggerCategory,\n `Updated projectExtents=${JSON.stringify(\n this.targetDb.projectExtents\n )}`\n );\n }\n if (\n !excludeOutliers &&\n computedProjectExtents.outliers &&\n computedProjectExtents.outliers.length > 0\n ) {\n Logger.logInfo(\n loggerCategory,\n `${computedProjectExtents.outliers.length} outliers detected within projectExtents`\n );\n }\n } else {\n if (\n !this.targetDb.projectExtents.containsRange(\n computedProjectExtents.extents\n )\n ) {\n Logger.logWarning(\n loggerCategory,\n \"Current project extents may be too small\"\n );\n }\n if (\n computedProjectExtents.outliers &&\n computedProjectExtents.outliers.length > 0\n ) {\n Logger.logInfo(\n loggerCategory,\n `${computedProjectExtents.outliers.length} outliers detected within projectExtents`\n );\n }\n }\n }\n\n /** Examine the geometry streams of every [GeometricElement3d]($backend) in the target iModel and apply the specified optimizations.\n * @note This method is automatically called from [[IModelTransformer.process]] if\n * [[IModelTransformOptions.optimizeGeometry]] is defined.\n */\n public optimizeGeometry(options: OptimizeGeometryOptions): void {\n if (options.inlineUniqueGeometryParts) {\n const result = this.targetDb.inlineGeometryParts();\n Logger.logInfo(\n loggerCategory,\n `Inlined ${result.numRefsInlined} references to ${result.numCandidateParts} geometry parts and deleted ${result.numPartsDeleted} parts.`\n );\n }\n }\n\n private resolveDuplicateCodeValues(): void {\n for (const [elementId, codeValue] of this._duplicateCodeValueMap) {\n const element = this.targetDb.elements.getElement(elementId);\n element.code.value = codeValue;\n this._editTxn.updateElement(element.toJSON());\n }\n this._duplicateCodeValueMap.clear();\n }\n\n /**\n * Needs to be called to perform necessary cleanup operations.\n * By not calling `finalize` there is a risk that data imported into targetDb will not be as expected.\n *\n * @note [[IModelTransformer.process]] invokes this method automatically. Call it explicitly after\n * composing the transformer's lower-level subset processing methods.\n */\n public finalize(): void {\n this.resolveDuplicateCodeValues();\n }\n}\n\n/** Returns true if a change within an Entity is detected.\n * @param entity The current persistent Entity.\n * @param entityProps The new EntityProps to compare against\n * @note This method should only be called if changeset information is not available.\n * @internal\n */\nexport function hasEntityChanged(\n entity: Entity,\n entityProps: EntityProps,\n namesToIgnore?: Set<string>\n): boolean {\n let changed: boolean = false;\n const entityClass = entity.iModel.schemaContext.getSchemaItemSync(\n entity.schemaItemKey\n );\n assert(\n EntityClass.isEntityClass(entityClass) ||\n RelationshipClass.isRelationshipClass(entityClass),\n `Cannot get metadata for ${entity.classFullName}.`\n );\n for (const property of entityClass.getPropertiesSync()) {\n const propertyName = property.name;\n if (!changed) {\n if (namesToIgnore && namesToIgnore.has(propertyName)) {\n // skip\n } else if (PropertyType.Binary === property.propertyType) {\n changed = hasBinaryValueChanged(\n entity.asAny[ECJsNames.toJsName(propertyName)],\n (entityProps as any)[ECJsNames.toJsName(propertyName)]\n );\n } else if (property.isNavigation()) {\n changed = hasNavigationValueChanged(\n entity.asAny[ECJsNames.toJsName(propertyName)],\n (entityProps as any)[ECJsNames.toJsName(propertyName)]\n );\n } else {\n changed = hasValueChanged(\n entity.asAny[ECJsNames.toJsName(propertyName)],\n (entityProps as any)[ECJsNames.toJsName(propertyName)]\n );\n }\n }\n }\n return changed;\n}\n\n/** Returns true if the specified binary values are different. */\nfunction hasBinaryValueChanged(\n binaryProperty1: any,\n binaryProperty2: any\n): boolean {\n const jsonString1 = JSON.stringify(\n binaryProperty1,\n Base64EncodedString.replacer\n );\n const jsonString2 = JSON.stringify(\n binaryProperty2,\n Base64EncodedString.replacer\n );\n return jsonString1 !== jsonString2;\n}\n\n/** Returns true if the specified navigation property values are different. */\nfunction hasNavigationValueChanged(\n navigationProperty1: any,\n navigationProperty2: any\n): boolean {\n const relatedElement1 = RelatedElement.fromJSON(navigationProperty1);\n const relatedElement2 = RelatedElement.fromJSON(navigationProperty2);\n const jsonString1 = JSON.stringify(relatedElement1);\n const jsonString2 = JSON.stringify(relatedElement2);\n return jsonString1 !== jsonString2;\n}\n\n/** Returns true if the specified navigation property values are different. */\nfunction hasValueChanged(property1: any, property2: any): boolean {\n return JSON.stringify(property1) !== JSON.stringify(property2);\n}\n\n/** check if element props are a subcategory */\nfunction isSubCategory(props: ElementProps): props is SubCategoryProps {\n return props.classFullName === SubCategory.classFullName;\n}\n\n/** check if element props are a subcategory without loading the element */\nfunction isDefaultSubCategory(props: SubCategoryProps): boolean {\n if (props.id === undefined) return false;\n\n if (!Id64.isId64(props.id))\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.InvalidSubCategory,\n },\n message: \"subcategory had invalid id\",\n });\n if (props.parent?.id === undefined)\n ITwinError.throwError({\n iTwinErrorId: {\n scope: IModelTransformerErrorScope,\n key: IModelTransformerError.InvalidSubCategory,\n },\n message: `subcategory with id ${props.id} had no parent`,\n });\n return props.id === IModelDb.getDefaultSubCategoryId(props.parent.id);\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@itwin/imodel-transformer",
|
|
3
|
-
"version": "2.0.0-dev.
|
|
3
|
+
"version": "2.0.0-dev.78",
|
|
4
4
|
"description": "API for exporting an iModel's parts and also importing them into another iModel",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/imodel-transformer.js",
|
|
@@ -74,14 +74,14 @@
|
|
|
74
74
|
"Removing Dependencies on internal APIs is ongoing."
|
|
75
75
|
],
|
|
76
76
|
"peerDependencies": {
|
|
77
|
-
"@itwin/core-backend": "^5.
|
|
78
|
-
"@itwin/core-bentley": "^5.
|
|
79
|
-
"@itwin/core-common": "^5.
|
|
80
|
-
"@itwin/core-geometry": "^5.
|
|
81
|
-
"@itwin/core-quantity": "^5.
|
|
82
|
-
"@itwin/ecschema-editing": "^5.
|
|
83
|
-
"@itwin/ecschema-locaters": "^5.
|
|
84
|
-
"@itwin/ecschema-metadata": "^5.
|
|
77
|
+
"@itwin/core-backend": "^5.15.0",
|
|
78
|
+
"@itwin/core-bentley": "^5.15.0",
|
|
79
|
+
"@itwin/core-common": "^5.15.0",
|
|
80
|
+
"@itwin/core-geometry": "^5.15.0",
|
|
81
|
+
"@itwin/core-quantity": "^5.15.0",
|
|
82
|
+
"@itwin/ecschema-editing": "^5.15.0",
|
|
83
|
+
"@itwin/ecschema-locaters": "^5.15.0",
|
|
84
|
+
"@itwin/ecschema-metadata": "^5.15.0"
|
|
85
85
|
},
|
|
86
86
|
"peerDependenciesMeta": {
|
|
87
87
|
"@itwin/ecschema-editing": {
|
|
@@ -96,15 +96,15 @@
|
|
|
96
96
|
"NOTE: All tools used by scripts in this package must be listed as devDependencies, except ESLint and Prettier tooling, which the workspace root declares"
|
|
97
97
|
],
|
|
98
98
|
"devDependencies": {
|
|
99
|
-
"@itwin/build-tools": "^5.
|
|
100
|
-
"@itwin/core-backend": "^5.
|
|
101
|
-
"@itwin/core-bentley": "^5.
|
|
102
|
-
"@itwin/core-common": "^5.
|
|
103
|
-
"@itwin/core-geometry": "^5.
|
|
104
|
-
"@itwin/core-quantity": "^5.
|
|
105
|
-
"@itwin/ecschema-editing": "5.
|
|
106
|
-
"@itwin/ecschema-locaters": "5.
|
|
107
|
-
"@itwin/ecschema-metadata": "^5.
|
|
99
|
+
"@itwin/build-tools": "^5.15.0",
|
|
100
|
+
"@itwin/core-backend": "^5.15.0",
|
|
101
|
+
"@itwin/core-bentley": "^5.15.0",
|
|
102
|
+
"@itwin/core-common": "^5.15.0",
|
|
103
|
+
"@itwin/core-geometry": "^5.15.0",
|
|
104
|
+
"@itwin/core-quantity": "^5.15.0",
|
|
105
|
+
"@itwin/ecschema-editing": "5.15.0",
|
|
106
|
+
"@itwin/ecschema-locaters": "5.15.0",
|
|
107
|
+
"@itwin/ecschema-metadata": "^5.15.0",
|
|
108
108
|
"@itwin/imodel-transformer-test-utils": "0.0.0",
|
|
109
109
|
"@types/node": "^22.18.12",
|
|
110
110
|
"@types/semver": "^7.7.1",
|