@itwin/imodel-transformer 0.1.13 → 0.1.14-fedguidopt.1
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 +9 -1
- package/lib/cjs/Algo.d.ts +7 -0
- package/lib/cjs/Algo.d.ts.map +1 -0
- package/lib/cjs/Algo.js +50 -0
- package/lib/cjs/Algo.js.map +1 -0
- package/lib/cjs/IModelExporter.d.ts +31 -9
- package/lib/cjs/IModelExporter.d.ts.map +1 -1
- package/lib/cjs/IModelExporter.js +44 -24
- package/lib/cjs/IModelExporter.js.map +1 -1
- package/lib/cjs/IModelTransformer.d.ts +138 -28
- package/lib/cjs/IModelTransformer.d.ts.map +1 -1
- package/lib/cjs/IModelTransformer.js +828 -208
- package/lib/cjs/IModelTransformer.js.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelExporter.js","sourceRoot":"","sources":["../../src/IModelExporter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;GAEG;;;AAEH,sDAI6B;AAC7B,sDAA6I;AAC7I,oDAA8E;AAC9E,gEAAsF;AACtF,2EAAwE;AAExE,MAAM,cAAc,GAAG,qDAAyB,CAAC,cAAc,CAAC;AAWhE;;;;;GAKG;AACH,MAAsB,mBAAmB;IACvC;;OAEG;IACI,oBAAoB,CAAC,SAAmB,IAAa,OAAO,IAAI,CAAC,CAAC,CAAC;IAE1E;;;;OAIG;IACI,gBAAgB,CAAC,SAAmB,EAAE,SAA8B,IAAU,CAAC;IAEtF;;;;OAIG;IACI,YAAY,CAAC,KAAgB,EAAE,SAA8B,IAAU,CAAC;IAE/E;;;;OAIG;IACI,aAAa,CAAC,MAAa,EAAE,SAA8B,IAAU,CAAC;IAE7E,6CAA6C;IACtC,aAAa,CAAC,QAAoB,IAAU,CAAC;IAEpD;;OAEG;IACI,mBAAmB,CAAC,QAAiB,IAAa,OAAO,IAAI,CAAC,CAA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AM,cAAc,GAAG,MAAM,CAAC,QAAQ,CAAC,uCAAuC,CAAC,cAAc,CAAC,CAAC;QAC/F,IAAI,cAAc,CAAC,KAAK,EAAE;YACxB,MAAM,IAAI,yBAAW,CAAC,cAAc,CAAC,KAAK,CAAC,MAAM,EAAE,4BAA4B,CAAC,CAAC;SAClF;QACD,MAAM,MAAM,GAAG,cAAc,CAAC,MAAM,CAAC;QACrC,IAAA,qBAAM,EAAC,MAAM,KAAK,SAAS,CAAC,CAAC;QAC7B,kBAAkB,CAAC,QAAQ,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACzD,kBAAkB,CAAC,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QACnD,kBAAkB,CAAC,OAAO,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC;QACvD,kBAAkB,CAAC,MAAM,CAAC,WAAW,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC;QACrD,kBAAkB,CAAC,YAAY,CAAC,WAAW,CAAC,MAAM,CAAC,YAAY,CAAC,CAAC;QACjE,kBAAkB,CAAC,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QACjD,OAAO,kBAAkB,CAAC;IAC5B,CAAC;CACF;AAtCD,gDAsCC","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 */\n\nimport {\n BriefcaseDb, BriefcaseManager, DefinitionModel, ECSqlStatement, Element, ElementAspect,\n ElementMultiAspect, ElementRefersToElements, ElementUniqueAspect, GeometricElement, IModelDb,\n IModelHost, IModelJsNative, Model, RecipeDefinitionElement, Relationship,\n} from \"@itwin/core-backend\";\nimport { AccessToken, assert, CompressedId64Set, DbResult, Id64, Id64String, IModelStatus, Logger, YieldManager } from \"@itwin/core-bentley\";\nimport { CodeSpec, FontProps, IModel, IModelError } from \"@itwin/core-common\";\nimport { ECVersion, Schema, SchemaKey, SchemaLoader } from \"@itwin/ecschema-metadata\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\n\nconst loggerCategory = TransformerLoggerCategory.IModelExporter;\n\n/**\n * @beta\n * The (optional) result of [[IModelExportHandler.onExportSchema]]\n */\nexport interface ExportSchemaResult {\n /** set this property to notify subclasses where you wrote a schema for later import */\n schemaPath?: string;\n}\n\n/** Handles the events generated by IModelExporter.\n * @note Change information is available when `IModelExportHandler` methods are invoked via [IModelExporter.exportChanges]($transformer), but not available when invoked via [IModelExporter.exportAll]($transformer).\n * @note The handler is intended to be owned by (registered with) and called from the IModelExporter exclusively\n * @see [iModel Transformation and Data Exchange]($docs/learning/transformer/index.md), [IModelExporter]($transformer)\n * @beta\n */\nexport abstract class IModelExportHandler {\n /** If `true` is returned, then the CodeSpec will be exported.\n * @note This method can optionally be overridden to exclude an individual CodeSpec from the export. The base implementation always returns `true`.\n */\n public shouldExportCodeSpec(_codeSpec: CodeSpec): boolean { return true; }\n\n /** Called when a CodeSpec should be exported.\n * @param codeSpec The CodeSpec to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportCodeSpec(_codeSpec: CodeSpec, _isUpdate: boolean | undefined): void { }\n\n /** Called when a font should be exported.\n * @param font The font to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportFont(_font: FontProps, _isUpdate: boolean | undefined): void { }\n\n /** Called when a model should be exported.\n * @param model The model to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportModel(_model: Model, _isUpdate: boolean | undefined): void { }\n\n /** Called when a model should be deleted. */\n public onDeleteModel(_modelId: Id64String): void { }\n\n /** If `true` is returned, then the element will be exported.\n * @note This method can optionally be overridden to exclude an individual Element (and its children and ElementAspects) from the export. The base implementation always returns `true`.\n */\n public shouldExportElement(_element: Element): boolean { return true; }\n\n /** Called when an element should be exported.\n * @param element The element to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportElement(_element: Element, _isUpdate: boolean | undefined): void { }\n\n /**\n * Do any asynchronous actions before exporting an element\n * @note Do not implement this handler manually, it is internal, it will be removed.\n * This will become a part of onExportElement once that becomes async\n * @internal\n */\n public async preExportElement(_element: Element): Promise<void> {}\n\n /** Called when an element should be deleted. */\n public onDeleteElement(_elementId: Id64String): void { }\n\n /** If `true` is returned, then the ElementAspect will be exported.\n * @note This method can optionally be overridden to exclude an individual ElementAspect from the export. The base implementation always returns `true`.\n */\n public shouldExportElementAspect(_aspect: ElementAspect): boolean { return true; }\n\n /** Called when an ElementUniqueAspect should be exported.\n * @param aspect The ElementUniqueAspect to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportElementUniqueAspect(_aspect: ElementUniqueAspect, _isUpdate: boolean | undefined): void { }\n\n /** Called when ElementMultiAspects should be exported.\n * @note This should be overridden to actually do the export.\n */\n public onExportElementMultiAspects(_aspects: ElementMultiAspect[]): void { }\n\n /** If `true` is returned, then the relationship will be exported.\n * @note This method can optionally be overridden to exclude an individual CodeSpec from the export. The base implementation always returns `true`.\n */\n public shouldExportRelationship(_relationship: Relationship): boolean { return true; }\n\n /** Called when a Relationship should be exported.\n * @param relationship The Relationship to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportRelationship(_relationship: Relationship, _isUpdate: boolean | undefined): void { }\n\n /** Called when a relationship should be deleted. */\n public onDeleteRelationship(_relInstanceId: Id64String): void { }\n\n /** If `true` is returned, then the schema will be exported.\n * @note This method can optionally be overridden to exclude an individual schema from the export. The base implementation always returns `true`.\n */\n public shouldExportSchema(_schemaKey: SchemaKey): boolean { return true; }\n\n /** Called when a schema should be exported.\n * @param schema The schema to export\n * @note This should be overridden to actually do the export.\n * @note return an [[ExportSchemaResult]] with a `schemaPath` property to notify overrides that call `super`\n * where a schema was written for import.\n */\n public async onExportSchema(_schema: Schema): Promise<void | ExportSchemaResult> { }\n\n /** This method is called when IModelExporter has made incremental progress based on the [[IModelExporter.progressInterval]] setting.\n * This method is `async` to make it easier to integrate with asynchronous status and health reporting services.\n * @note A subclass may override this method to report custom progress. The base implementation does nothing.\n */\n public async onProgress(): Promise<void> { }\n}\n\n/** Base class for exporting data from an iModel.\n * @note Most uses cases will not require a custom subclass of `IModelExporter`. Instead, it is more typical to subclass/customize [IModelExportHandler]($transformer).\n * @see [iModel Transformation and Data Exchange]($docs/learning/transformer/index.md), [[registerHandler]], [IModelTransformer]($transformer), [IModelImporter]($transformer)\n * @beta\n */\nexport class IModelExporter {\n /** The read-only source iModel. */\n public readonly sourceDb: IModelDb;\n /** A flag that indicates whether element GeometryStreams are loaded or not.\n * @note As an optimization, exporters that don't need geometry can set this flag to `false`. The default is `true`.\n * @note The transformer by default sets this to `false` as an optimization.\n * @note This implies the `wantBRepData` option when loading elements.\n * @see [ElementLoadProps.wantGeometry]($common)\n */\n public wantGeometry: boolean = true;\n /** A flag that indicates whether template models should be exported or not. The default is `true`.\n * @note If only exporting *instances* then template models can be skipped since they are just definitions that are cloned to create new instances.\n * @see [Model.isTemplate]($backend)\n */\n public wantTemplateModels: boolean = true;\n /** A flag that indicates whether *system* schemas should be exported or not. The default is `true` (previously false).\n * This can be set to false for the legacy default behavior, but it may cause errors during schema processing in some cases.\n * @see [[exportSchemas]]\n */\n public wantSystemSchemas: boolean = true;\n /** A flag that determines whether this IModelExporter should visit Elements or not. The default is `true`.\n * @note This flag is available as an optimization when the exporter doesn't need to visit elements, so can skip loading them.\n */\n public visitElements: boolean = true;\n /** A flag that determines whether this IModelExporter should visit Relationships or not. The default is `true`.\n * @note This flag is available as an optimization when the exporter doesn't need to visit relationships, so can skip loading them.\n */\n public visitRelationships: boolean = true;\n /** The number of entities exported before incremental progress should be reported via the [[onProgress]] callback. */\n public progressInterval: number = 1000;\n /** Tracks the current total number of entities exported. */\n private _progressCounter: number = 0;\n /** Optionally cached entity change information */\n private _sourceDbChanges?: ChangedInstanceIds;\n /**\n * Retrieve the cached entity change information.\n * @note This will only be initialized after [IModelExporter.exportChanges] is invoked.\n */\n public get sourceDbChanges(): ChangedInstanceIds | undefined {\n return this._sourceDbChanges;\n }\n /** The handler called by this IModelExporter. */\n private _handler: IModelExportHandler | undefined;\n /** The handler called by this IModelExporter. */\n protected get handler(): IModelExportHandler {\n if (undefined === this._handler) {\n throw new Error(\"IModelExportHandler not registered\");\n }\n\n return this._handler;\n }\n\n /** The set of CodeSpecs to exclude from the export. */\n private _excludedCodeSpecNames = new Set<string>();\n /** The set of specific Elements to exclude from the export. */\n private _excludedElementIds = new Set<Id64String>();\n /** The set of Categories where Elements in that Category will be excluded from transformation to the target iModel. */\n private _excludedElementCategoryIds = new Set<Id64String>();\n /** The set of classes of Elements that will be excluded (polymorphically) from transformation to the target iModel. */\n private _excludedElementClasses = new Set<typeof Element>();\n /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */\n private _excludedElementAspectClasses = new Set<typeof ElementAspect>();\n /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */\n private _excludedElementAspectClassFullNames = new Set<string>();\n /** The set of classes of Relationships that will be excluded (polymorphically) from transformation to the target iModel. */\n private _excludedRelationshipClasses = new Set<typeof Relationship>();\n\n /** Construct a new IModelExporter\n * @param sourceDb The source IModelDb\n * @see registerHandler\n */\n public constructor(sourceDb: IModelDb) {\n this.sourceDb = sourceDb;\n }\n\n /** Register the handler that will be called by IModelExporter. */\n public registerHandler(handler: IModelExportHandler): void {\n this._handler = handler;\n }\n\n /** Add a rule to exclude a CodeSpec */\n public excludeCodeSpec(codeSpecName: string): void {\n this._excludedCodeSpecNames.add(codeSpecName);\n }\n\n /** Add a rule to exclude a specific Element. */\n public excludeElement(elementId: Id64String): void {\n this._excludedElementIds.add(elementId);\n }\n\n /** Add a rule to exclude all Elements in a specified Category. */\n public excludeElementsInCategory(categoryId: Id64String): void {\n this._excludedElementCategoryIds.add(categoryId);\n }\n\n /** Add a rule to exclude all Elements of a specified class. */\n public excludeElementClass(classFullName: string): void {\n this._excludedElementClasses.add(this.sourceDb.getJsClass<typeof Element>(classFullName));\n }\n\n /** Add a rule to exclude all ElementAspects of a specified class. */\n public excludeElementAspectClass(classFullName: string): void {\n this._excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query\n this._excludedElementAspectClasses.add(this.sourceDb.getJsClass<typeof ElementAspect>(classFullName)); // allows polymorphic exclusion after query/load\n }\n\n /** Add a rule to exclude all Relationships of a specified class. */\n public excludeRelationshipClass(classFullName: string): void {\n this._excludedRelationshipClasses.add(this.sourceDb.getJsClass<typeof Relationship>(classFullName));\n }\n\n /** Export all entity instance types from the source iModel.\n * @note [[exportSchemas]] must be called separately.\n */\n public async exportAll(): Promise<void> {\n await this.exportCodeSpecs();\n await this.exportFonts();\n await this.exportModel(IModel.repositoryModelId);\n await this.exportRelationships(ElementRefersToElements.classFullName);\n }\n\n /** Export changes from the source iModel.\n * @param user The user\n * @param startChangesetId Include changes from this changeset up through and including the current changeset.\n * If this parameter is not provided, then just the current changeset will be exported.\n * @note To form a range of versions to export, set `startChangesetId` for the start (inclusive) of the desired range and open the source iModel as of the end (inclusive) of the desired range.\n */\n public async exportChanges(user?: AccessToken, startChangesetId?: string): Promise<void> {\n if (!this.sourceDb.isBriefcaseDb()) {\n throw new IModelError(IModelStatus.BadRequest, \"Must be a briefcase to export changes\");\n }\n if (\"\" === this.sourceDb.changeset.id) {\n await this.exportAll(); // no changesets, so revert to exportAll\n return;\n }\n if (undefined === startChangesetId) {\n startChangesetId = this.sourceDb.changeset.id;\n }\n this._sourceDbChanges = await ChangedInstanceIds.initialize(user, this.sourceDb, startChangesetId);\n await this.exportCodeSpecs();\n await this.exportFonts();\n await this.exportModelContents(IModel.repositoryModelId);\n await this.exportSubModels(IModel.repositoryModelId);\n await this.exportRelationships(ElementRefersToElements.classFullName);\n // handle deletes\n if (this.visitElements) {\n // must delete models first since they have a constraint on the submodeling element which may also be deleted\n for (const modelId of this._sourceDbChanges.model.deleteIds) {\n this.handler.onDeleteModel(modelId);\n }\n for (const elementId of this._sourceDbChanges.element.deleteIds) {\n // We don't know how the handler wants to handle deletions, and we don't have enough information\n // to know if deleted entities were related, so when processing changes, ignore errors from deletion.\n // Technically, to keep the ignored error scope small, we ignore only the error of looking up a missing element,\n // that approach works at least for the IModelTransformer.\n // In the future, the handler may be responsible for doing the work of finding out which elements were cascade deleted,\n // and returning them for the exporter to use to avoid double-deleting with error ignoring\n try {\n this.handler.onDeleteElement(elementId);\n } catch (err: unknown) {\n const isMissingErr = err instanceof IModelError && err.errorNumber === IModelStatus.NotFound;\n if (!isMissingErr)\n throw err;\n }\n }\n }\n if (this.visitRelationships) {\n for (const relInstanceId of this._sourceDbChanges.relationship.deleteIds) {\n this.handler.onDeleteRelationship(relInstanceId);\n }\n }\n }\n\n /** Export schemas from the source iModel.\n * @note This must be called separately from [[exportAll]] or [[exportChanges]].\n */\n public async exportSchemas(): Promise<void> {\n /* eslint-disable @typescript-eslint/indent */\n const sql = `\n SELECT s.Name, s.VersionMajor, s.VersionWrite, s.VersionMinor\n FROM ECDbMeta.ECSchemaDef s\n ${this.wantSystemSchemas ? \"\" : `\n WHERE ECInstanceId >= (SELECT ECInstanceId FROM ECDbMeta.ECSchemaDef WHERE Name='BisCore')\n `}\n ORDER BY ECInstanceId\n `;\n /* eslint-enable @typescript-eslint/indent */\n const schemaNamesToExport: string[] = [];\n this.sourceDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n const schemaName = statement.getValue(0).getString();\n const versionMajor = statement.getValue(1).getInteger();\n const versionWrite = statement.getValue(2).getInteger();\n const versionMinor = statement.getValue(3).getInteger();\n const schemaKey = new SchemaKey(schemaName, new ECVersion(versionMajor, versionWrite, versionMinor));\n if (this.handler.shouldExportSchema(schemaKey)) {\n schemaNamesToExport.push(schemaName);\n }\n }\n });\n\n if (schemaNamesToExport.length === 0)\n return;\n\n const schemaLoader = new SchemaLoader((name: string) => this.sourceDb.getSchemaProps(name));\n await Promise.all(schemaNamesToExport.map(async (schemaName) => {\n const schema = schemaLoader.getSchema(schemaName);\n Logger.logTrace(loggerCategory, `exportSchema(${schemaName})`);\n return this.handler.onExportSchema(schema);\n }));\n }\n\n /** For logging, indicate the change type if known. */\n private getChangeOpSuffix(isUpdate: boolean | undefined): string {\n return isUpdate ? \" UPDATE\" : undefined === isUpdate ? \"\" : \" INSERT\";\n }\n\n /** Export all CodeSpecs from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportCodeSpecs(): Promise<void> {\n Logger.logTrace(loggerCategory, `exportCodeSpecs()`);\n const sql = `SELECT Name FROM BisCore:CodeSpec ORDER BY ECInstanceId`;\n await this.sourceDb.withPreparedStatement(sql, async (statement: ECSqlStatement): Promise<void> => {\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n const codeSpecName: string = statement.getValue(0).getString();\n await this.exportCodeSpecByName(codeSpecName);\n }\n });\n }\n\n /** Export a single CodeSpec from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportCodeSpecByName(codeSpecName: string): Promise<void> {\n const codeSpec: CodeSpec = this.sourceDb.codeSpecs.getByName(codeSpecName);\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (this._sourceDbChanges.codeSpec.insertIds.has(codeSpec.id)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.codeSpec.updateIds.has(codeSpec.id)) {\n isUpdate = true;\n } else {\n return; // not in changeset, don't export\n }\n }\n // passed changeset test, now apply standard exclusion rules\n if (this._excludedCodeSpecNames.has(codeSpec.name)) {\n Logger.logInfo(loggerCategory, `Excluding CodeSpec: ${codeSpec.name}`);\n return;\n }\n // CodeSpec has passed standard exclusion rules, now give handler a chance to accept/reject export\n if (this.handler.shouldExportCodeSpec(codeSpec)) {\n Logger.logTrace(loggerCategory, `exportCodeSpec(${codeSpecName})${this.getChangeOpSuffix(isUpdate)}`);\n this.handler.onExportCodeSpec(codeSpec, isUpdate);\n return this.trackProgress();\n }\n }\n\n /** Export a single CodeSpec from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportCodeSpecById(codeSpecId: Id64String): Promise<void> {\n const codeSpec: CodeSpec = this.sourceDb.codeSpecs.getById(codeSpecId);\n return this.exportCodeSpecByName(codeSpec.name);\n }\n\n /** Export all fonts from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportFonts(): Promise<void> {\n Logger.logTrace(loggerCategory, `exportFonts()`);\n for (const font of this.sourceDb.fontMap.fonts.values()) {\n await this.exportFontByNumber(font.id);\n }\n }\n\n /** Export a single font from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportFontByName(fontName: string): Promise<void> {\n Logger.logTrace(loggerCategory, `exportFontByName(${fontName})`);\n const font: FontProps | undefined = this.sourceDb.fontMap.getFont(fontName);\n if (undefined !== font) {\n await this.exportFontByNumber(font.id);\n }\n }\n\n /** Export a single font from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportFontByNumber(fontNumber: number): Promise<void> {\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n const fontId: Id64String = Id64.fromUint32Pair(fontNumber, 0); // changeset information uses Id64String, not number\n if (this._sourceDbChanges.font.insertIds.has(fontId)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.font.updateIds.has(fontId)) {\n isUpdate = true;\n } else {\n return; // not in changeset, don't export\n }\n }\n Logger.logTrace(loggerCategory, `exportFontById(${fontNumber})`);\n const font: FontProps | undefined = this.sourceDb.fontMap.getFont(fontNumber);\n if (undefined !== font) {\n this.handler.onExportFont(font, isUpdate);\n return this.trackProgress();\n }\n }\n\n /** Export the model container, contents, and sub-models from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportModel(modeledElementId: Id64String): Promise<void> {\n const model: Model = this.sourceDb.models.getModel(modeledElementId);\n if (model.isTemplate && !this.wantTemplateModels) {\n return;\n }\n const modeledElement: Element = this.sourceDb.elements.getElement({ id: modeledElementId, wantGeometry: this.wantGeometry, wantBRepData: this.wantGeometry });\n Logger.logTrace(loggerCategory, `exportModel(${modeledElementId})`);\n if (this.shouldExportElement(modeledElement)) {\n await this.exportModelContainer(model);\n if (this.visitElements) {\n await this.exportModelContents(modeledElementId);\n }\n await this.exportSubModels(modeledElementId);\n }\n }\n\n /** Export the model (the container only) from the source iModel. */\n private async exportModelContainer(model: Model): Promise<void> {\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (this._sourceDbChanges.model.insertIds.has(model.id)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.model.updateIds.has(model.id)) {\n isUpdate = true;\n } else {\n return; // not in changeset, don't export\n }\n }\n this.handler.onExportModel(model, isUpdate);\n return this.trackProgress();\n }\n\n private _yieldManager = new YieldManager();\n\n /** Export the model contents.\n * @param modelId The only required parameter\n * @param elementClassFullName Can be optionally specified if the goal is to export a subset of the model contents\n * @param skipRootSubject Decides whether or not to export the root Subject. It is normally left undefined except for internal implementation purposes.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportModelContents(modelId: Id64String, elementClassFullName: string = Element.classFullName, skipRootSubject?: boolean): Promise<void> {\n if (skipRootSubject) {\n // NOTE: IModelTransformer.processAll should skip the root Subject since it is specific to the individual iModel and is not part of the changes that need to be synchronized\n // NOTE: IModelExporter.exportAll should not skip the root Subject since the goal is to export everything\n assert(modelId === IModel.repositoryModelId); // flag is only relevant when processing the RepositoryModel\n }\n if (!this.visitElements) {\n Logger.logTrace(loggerCategory, `visitElements=false, skipping exportModelContents(${modelId})`);\n return;\n }\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (!this._sourceDbChanges.model.insertIds.has(modelId) && !this._sourceDbChanges.model.updateIds.has(modelId)) {\n return; // this optimization assumes that the Model changes (LastMod) any time an Element in the Model changes\n }\n }\n Logger.logTrace(loggerCategory, `exportModelContents(${modelId})`);\n let sql: string;\n if (skipRootSubject) {\n sql = `SELECT ECInstanceId FROM ${elementClassFullName} WHERE Parent.Id IS NULL AND Model.Id=:modelId AND ECInstanceId!=:rootSubjectId ORDER BY ECInstanceId`;\n } else {\n sql = `SELECT ECInstanceId FROM ${elementClassFullName} WHERE Parent.Id IS NULL AND Model.Id=:modelId ORDER BY ECInstanceId`;\n }\n await this.sourceDb.withPreparedStatement(sql, async (statement: ECSqlStatement): Promise<void> => {\n statement.bindId(\"modelId\", modelId);\n if (skipRootSubject) {\n statement.bindId(\"rootSubjectId\", IModel.rootSubjectId);\n }\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n await this.exportElement(statement.getValue(0).getId());\n await this._yieldManager.allowYield();\n }\n });\n }\n\n /** Export the sub-models directly below the specified model.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportSubModels(parentModelId: Id64String): Promise<void> {\n Logger.logTrace(loggerCategory, `exportSubModels(${parentModelId})`);\n const definitionModelIds: Id64String[] = [];\n const otherModelIds: Id64String[] = [];\n const sql = `SELECT ECInstanceId FROM ${Model.classFullName} WHERE ParentModel.Id=:parentModelId ORDER BY ECInstanceId`;\n this.sourceDb.withPreparedStatement(sql, (statement: ECSqlStatement): void => {\n statement.bindId(\"parentModelId\", parentModelId);\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n const modelId: Id64String = statement.getValue(0).getId();\n const model: Model = this.sourceDb.models.getModel(modelId);\n if (model instanceof DefinitionModel) {\n definitionModelIds.push(modelId);\n } else {\n otherModelIds.push(modelId);\n }\n }\n });\n // export DefinitionModels before other types of Models\n for (const definitionModelId of definitionModelIds) {\n await this.exportModel(definitionModelId);\n }\n for (const otherModelId of otherModelIds) {\n await this.exportModel(otherModelId);\n }\n }\n\n /** Returns true if the specified element should be exported.\n * This considers the standard IModelExporter exclusion rules plus calls [IModelExportHandler.shouldExportElement]($transformer) for any custom exclusion rules.\n * @note This method is called from within [[exportChanges]] and [[exportAll]], so usually does not need to be called directly.\n */\n public shouldExportElement(element: Element): boolean {\n if (this._excludedElementIds.has(element.id)) {\n Logger.logInfo(loggerCategory, `Excluded element ${element.id} by Id`);\n return false;\n }\n if (element instanceof GeometricElement) {\n if (this._excludedElementCategoryIds.has(element.category)) {\n Logger.logInfo(loggerCategory, `Excluded element ${element.id} by Category`);\n return false;\n }\n }\n if (!this.wantTemplateModels && (element instanceof RecipeDefinitionElement)) {\n Logger.logInfo(loggerCategory, `Excluded RecipeDefinitionElement ${element.id} because wantTemplate=false`);\n return false;\n }\n for (const excludedElementClass of this._excludedElementClasses) {\n if (element instanceof excludedElementClass) {\n Logger.logInfo(loggerCategory, `Excluded element ${element.id} by class: ${excludedElementClass.classFullName}`);\n return false;\n }\n }\n // element has passed standard exclusion rules, now give handler a chance to accept/reject\n return this.handler.shouldExportElement(element);\n }\n\n /** Export the specified element, its child elements (if applicable), and any owned ElementAspects.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportElement(elementId: Id64String): Promise<void> {\n if (!this.visitElements) {\n Logger.logTrace(loggerCategory, `visitElements=false, skipping exportElement(${elementId})`);\n return;\n }\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (this._sourceDbChanges.element.insertIds.has(elementId)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.element.updateIds.has(elementId)) {\n isUpdate = true;\n } else {\n // NOTE: This optimization assumes that the Element will change (LastMod) if an owned ElementAspect changes\n // NOTE: However, child elements may have changed without the parent changing\n return this.exportChildElements(elementId);\n }\n }\n const element: Element = this.sourceDb.elements.getElement({ id: elementId, wantGeometry: this.wantGeometry, wantBRepData: this.wantGeometry });\n Logger.logTrace(loggerCategory, `exportElement(${element.id}, \"${element.getDisplayLabel()}\")${this.getChangeOpSuffix(isUpdate)}`);\n // the order and `await`ing of calls beyond here is depended upon by the IModelTransformer for a current bug workaround\n if (this.shouldExportElement(element)) {\n await this.handler.preExportElement(element);\n this.handler.onExportElement(element, isUpdate);\n await this.trackProgress();\n await this.exportElementAspects(elementId);\n return this.exportChildElements(elementId);\n }\n }\n\n /** Export the child elements of the specified element from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportChildElements(elementId: Id64String): Promise<void> {\n if (!this.visitElements) {\n Logger.logTrace(loggerCategory, `visitElements=false, skipping exportChildElements(${elementId})`);\n return;\n }\n const childElementIds: Id64String[] = this.sourceDb.elements.queryChildren(elementId);\n if (childElementIds.length > 0) {\n Logger.logTrace(loggerCategory, `exportChildElements(${elementId})`);\n for (const childElementId of childElementIds) {\n await this.exportElement(childElementId);\n }\n }\n }\n\n /** Returns `true` if the specified ElementAspect should be exported or `false` if if should be excluded. */\n private shouldExportElementAspect(aspect: ElementAspect): boolean {\n for (const excludedElementAspectClass of this._excludedElementAspectClasses) {\n if (aspect instanceof excludedElementAspectClass) {\n Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);\n return false;\n }\n }\n // ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject\n return this.handler.shouldExportElementAspect(aspect);\n }\n\n /** Export ElementAspects from the specified element from the source iModel. */\n private async exportElementAspects(elementId: Id64String): Promise<void> {\n const _uniqueAspects = await Promise.all(this.sourceDb.elements\n ._queryAspects(elementId, ElementUniqueAspect.classFullName, this._excludedElementAspectClassFullNames)\n .filter((a) => this.shouldExportElementAspect(a))\n .map(async (uniqueAspect: ElementUniqueAspect) => {\n const isInsertChange = this._sourceDbChanges?.aspect.insertIds.has(uniqueAspect.id) ?? false;\n const isUpdateChange = this._sourceDbChanges?.aspect.updateIds.has(uniqueAspect.id) ?? false;\n const doExport = this._sourceDbChanges === undefined || isInsertChange || isUpdateChange;\n if (doExport) {\n const isKnownUpdate = this._sourceDbChanges ? isUpdateChange : undefined;\n this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);\n await this.trackProgress();\n }\n }));\n\n const multiAspects = this.sourceDb.elements\n ._queryAspects(elementId, ElementMultiAspect.classFullName, this._excludedElementAspectClassFullNames)\n .filter((a) => this.shouldExportElementAspect(a));\n\n if (multiAspects.length > 0) {\n this.handler.onExportElementMultiAspects(multiAspects);\n return this.trackProgress();\n }\n }\n\n /** Exports all relationships that subclass from the specified base class.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportRelationships(baseRelClassFullName: string): Promise<void> {\n if (!this.visitRelationships) {\n Logger.logTrace(loggerCategory, `visitRelationships=false, skipping exportRelationships()`);\n return;\n }\n Logger.logTrace(loggerCategory, `exportRelationships(${baseRelClassFullName})`);\n const sql = `SELECT r.ECInstanceId, r.ECClassId FROM ${baseRelClassFullName} r\n JOIN bis.Element s ON s.ECInstanceId = r.SourceECInstanceId\n JOIN bis.Element t ON t.ECInstanceId = r.TargetECInstanceId\n WHERE s.ECInstanceId IS NOT NULL AND t.ECInstanceId IS NOT NULL`;\n await this.sourceDb.withPreparedStatement(sql, async (statement: ECSqlStatement): Promise<void> => {\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n const relationshipId = statement.getValue(0).getId();\n const relationshipClass = statement.getValue(1).getClassNameForClassId();\n await this.exportRelationship(relationshipClass, relationshipId); // must call exportRelationship using the actual classFullName, not baseRelClassFullName\n await this._yieldManager.allowYield();\n }\n });\n }\n\n /** Export a relationship from the source iModel. */\n public async exportRelationship(relClassFullName: string, relInstanceId: Id64String): Promise<void> {\n if (!this.visitRelationships) {\n Logger.logTrace(loggerCategory, `visitRelationships=false, skipping exportRelationship(${relClassFullName}, ${relInstanceId})`);\n return;\n }\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (this._sourceDbChanges.relationship.insertIds.has(relInstanceId)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.relationship.updateIds.has(relInstanceId)) {\n isUpdate = true;\n } else {\n return; // not in changeset, don't export\n }\n }\n // passed changeset test, now apply standard exclusion rules\n Logger.logTrace(loggerCategory, `exportRelationship(${relClassFullName}, ${relInstanceId})`);\n const relationship: Relationship = this.sourceDb.relationships.getInstance(relClassFullName, relInstanceId);\n for (const excludedRelationshipClass of this._excludedRelationshipClasses) {\n if (relationship instanceof excludedRelationshipClass) {\n Logger.logInfo(loggerCategory, `Excluded relationship by class: ${excludedRelationshipClass.classFullName}`);\n return;\n }\n }\n // relationship has passed standard exclusion rules, now give handler a chance to accept/reject export\n if (this.handler.shouldExportRelationship(relationship)) {\n this.handler.onExportRelationship(relationship, isUpdate);\n await this.trackProgress();\n }\n }\n\n /** Tracks incremental progress */\n private async trackProgress(): Promise<void> {\n this._progressCounter++;\n if (0 === (this._progressCounter % this.progressInterval)) {\n return this.handler.onProgress();\n }\n }\n\n /**\n * You may override this to store arbitrary json state in a exporter state dump, useful for some resumptions\n * @see [[IModelTransformer.saveStateToFile]]\n */\n protected getAdditionalStateJson(): any {\n return {};\n }\n\n /**\n * You may override this to load arbitrary json state in a transformer state dump, useful for some resumptions\n * @see [[IModelTransformer.loadStateFromFile]]\n */\n protected loadAdditionalStateJson(_additionalState: any): void {}\n\n /**\n * Reload our state from a JSON object\n * Intended for [[IModelTransformer.resumeTransformation]]\n * @internal\n * You can load custom json from the exporter save state for custom exporters by overriding [[IModelExporter.loadAdditionalStateJson]]\n */\n public loadStateFromJson(state: IModelExporterState): void {\n if (state.exporterClass !== this.constructor.name)\n throw Error(\"resuming from a differently named exporter class, it is not necessarily valid to resume with a different exporter class\");\n this.wantGeometry = state.wantGeometry;\n this.wantTemplateModels = state.wantTemplateModels;\n this.wantSystemSchemas = state.wantSystemSchemas;\n this.visitElements = state.visitElements;\n this.visitRelationships = state.visitRelationships;\n this._excludedCodeSpecNames = new Set(state.excludedCodeSpecNames);\n this._excludedElementIds = CompressedId64Set.decompressSet(state.excludedElementIds),\n this._excludedElementCategoryIds = CompressedId64Set.decompressSet(state.excludedElementCategoryIds),\n this._excludedElementClasses = new Set(state.excludedElementClassNames.map((c) => this.sourceDb.getJsClass(c)));\n this._excludedElementAspectClassFullNames = new Set(state.excludedElementAspectClassFullNames);\n this._excludedElementAspectClasses = new Set(state.excludedElementAspectClassFullNames.map((c) => this.sourceDb.getJsClass(c)));\n this._excludedRelationshipClasses = new Set(state.excludedRelationshipClassNames.map((c) => this.sourceDb.getJsClass(c)));\n this.loadAdditionalStateJson(state.additionalState);\n }\n\n /**\n * Serialize state to a JSON object\n * Intended for [[IModelTransformer.resumeTransformation]]\n * @internal\n * You can add custom json to the exporter save state for custom exporters by overriding [[IModelExporter.getAdditionalStateJson]]\n */\n public saveStateToJson(): IModelExporterState {\n return {\n exporterClass: this.constructor.name,\n wantGeometry: this.wantGeometry,\n wantTemplateModels: this.wantTemplateModels,\n wantSystemSchemas: this.wantSystemSchemas,\n visitElements: this.visitElements,\n visitRelationships: this.visitRelationships,\n excludedCodeSpecNames: [...this._excludedCodeSpecNames],\n excludedElementIds: CompressedId64Set.compressSet(this._excludedElementIds),\n excludedElementCategoryIds: CompressedId64Set.compressSet(this._excludedElementCategoryIds),\n excludedElementClassNames: Array.from(this._excludedElementClasses, (cls) => cls.classFullName),\n excludedElementAspectClassFullNames: [...this._excludedElementAspectClassFullNames],\n excludedRelationshipClassNames: Array.from(this._excludedRelationshipClasses, (cls) => cls.classFullName),\n additionalState: this.getAdditionalStateJson(),\n };\n }\n}\n\n/**\n * The JSON format of a serialized IModelExporter instance\n * Used for starting an exporter in the middle of an export operation,\n * such as resuming a crashed transformation\n *\n * @note Must be kept synchronized with IModelExporter\n * @internal\n */\nexport interface IModelExporterState {\n exporterClass: string;\n wantGeometry: boolean;\n wantTemplateModels: boolean;\n wantSystemSchemas: boolean;\n visitElements: boolean;\n visitRelationships: boolean;\n excludedCodeSpecNames: string[];\n excludedElementIds: CompressedId64Set;\n excludedElementCategoryIds: CompressedId64Set;\n excludedElementClassNames: string[];\n excludedElementAspectClassFullNames: string[];\n excludedRelationshipClassNames: string[];\n additionalState?: any;\n}\n\n/** Class for holding change information.\n * @beta\n*/\nexport class ChangedInstanceOps {\n public insertIds = new Set<Id64String>();\n public updateIds = new Set<Id64String>();\n public deleteIds = new Set<Id64String>();\n\n /** Initializes the object from IModelJsNative.ChangedInstanceOpsProps. */\n public addFromJson(val: IModelJsNative.ChangedInstanceOpsProps | undefined): void {\n if (undefined !== val) {\n if ((undefined !== val.insert) && (Array.isArray(val.insert)))\n val.insert.forEach((id: Id64String) => this.insertIds.add(id));\n\n if ((undefined !== val.update) && (Array.isArray(val.update)))\n val.update.forEach((id: Id64String) => this.updateIds.add(id));\n\n if ((undefined !== val.delete) && (Array.isArray(val.delete)))\n val.delete.forEach((id: Id64String) => this.deleteIds.add(id));\n }\n }\n}\n\n/**\n * Class for discovering modified elements between 2 versions of an iModel.\n * @beta\n */\nexport class ChangedInstanceIds {\n public codeSpec = new ChangedInstanceOps();\n public model = new ChangedInstanceOps();\n public element = new ChangedInstanceOps();\n public aspect = new ChangedInstanceOps();\n public relationship = new ChangedInstanceOps();\n public font = new ChangedInstanceOps();\n private constructor() { }\n\n /**\n * Initializes a new ChangedInstanceIds object with information taken from a range of changesets.\n * @param accessToken Access token.\n * @param iModel IModel briefcase whose changesets will be queried.\n * @param firstChangesetId Changeset id.\n * @note Modified element information will be taken from a range of changesets. First changeset in a range will be the 'firstChangesetId', the last will be whichever changeset the 'iModel' briefcase is currently opened on.\n */\n public static async initialize(accessToken: AccessToken | undefined, iModel: BriefcaseDb, firstChangesetId: string): Promise<ChangedInstanceIds> {\n const iModelId = iModel.iModelId;\n const first = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: firstChangesetId }, accessToken })).index;\n const end = (await IModelHost.hubAccess.queryChangeset({ iModelId, changeset: { id: iModel.changeset.id }, accessToken })).index;\n const changesets = await IModelHost.hubAccess.downloadChangesets({ accessToken, iModelId, range: { first, end }, targetDir: BriefcaseManager.getChangeSetsPath(iModelId) });\n\n const changedInstanceIds = new ChangedInstanceIds();\n const changesetFiles = changesets.map((c) => c.pathname);\n const statusOrResult = iModel.nativeDb.extractChangedInstanceIdsFromChangeSets(changesetFiles);\n if (statusOrResult.error) {\n throw new IModelError(statusOrResult.error.status, \"Error processing changeset\");\n }\n const result = statusOrResult.result;\n assert(result !== undefined);\n changedInstanceIds.codeSpec.addFromJson(result.codeSpec);\n changedInstanceIds.model.addFromJson(result.model);\n changedInstanceIds.element.addFromJson(result.element);\n changedInstanceIds.aspect.addFromJson(result.aspect);\n changedInstanceIds.relationship.addFromJson(result.relationship);\n changedInstanceIds.font.addFromJson(result.font);\n return changedInstanceIds;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IModelExporter.js","sourceRoot":"","sources":["../../src/IModelExporter.ts"],"names":[],"mappings":";AAAA;;;+FAG+F;AAC/F;;G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,gDAiFC","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 */\n\nimport {\n BriefcaseDb, BriefcaseManager, DefinitionModel, ECSqlStatement, Element, ElementAspect,\n ElementMultiAspect, ElementRefersToElements, ElementUniqueAspect, GeometricElement, IModelDb,\n IModelHost, IModelJsNative, Model, RecipeDefinitionElement, Relationship,\n} from \"@itwin/core-backend\";\nimport { AccessToken, assert, CompressedId64Set, DbResult, Id64, Id64String, IModelStatus, Logger, YieldManager } from \"@itwin/core-bentley\";\nimport { ChangesetIndexOrId, CodeSpec, FontProps, IModel, IModelError } from \"@itwin/core-common\";\nimport { ECVersion, Schema, SchemaKey, SchemaLoader } from \"@itwin/ecschema-metadata\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\nimport type { InitArgs } from \"./IModelTransformer\";\nimport * as nodeAssert from \"assert\";\n\nconst loggerCategory = TransformerLoggerCategory.IModelExporter;\n\nexport interface ExportChangesArgs extends InitArgs {\n accessToken?: AccessToken;\n /**\n * A changeset id or index signifiying the inclusive start of changes\n * to include. The end is implicitly the changeset of the source iModel\n * @note mutually exclusive with @see changesetRanges\n */\n startChangeset?: ChangesetIndexOrId;\n /**\n * An array of changeset index ranges, e.g. [[2,2], [4,5]] is [2,4,5]\n * @note mutually exclusive with @see startChangeset\n */\n changesetRanges?: [number, number][];\n}\n\nexport interface ChangedInstanceIdsInitOptions extends ExportChangesArgs {\n iModel: BriefcaseDb;\n}\n\n/**\n * @beta\n * The (optional) result of [[IModelExportHandler.onExportSchema]]\n */\nexport interface ExportSchemaResult {\n /** set this property to notify subclasses where you wrote a schema for later import */\n schemaPath?: string;\n}\n\n/** Handles the events generated by IModelExporter.\n * @note Change information is available when `IModelExportHandler` methods are invoked via [IModelExporter.exportChanges]($transformer), but not available when invoked via [IModelExporter.exportAll]($transformer).\n * @note The handler is intended to be owned by (registered with) and called from the IModelExporter exclusively\n * @see [iModel Transformation and Data Exchange]($docs/learning/transformer/index.md), [IModelExporter]($transformer)\n * @beta\n */\nexport abstract class IModelExportHandler {\n /** If `true` is returned, then the CodeSpec will be exported.\n * @note This method can optionally be overridden to exclude an individual CodeSpec from the export. The base implementation always returns `true`.\n */\n public shouldExportCodeSpec(_codeSpec: CodeSpec): boolean { return true; }\n\n /** Called when a CodeSpec should be exported.\n * @param codeSpec The CodeSpec to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportCodeSpec(_codeSpec: CodeSpec, _isUpdate: boolean | undefined): void { }\n\n /** Called when a font should be exported.\n * @param font The font to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportFont(_font: FontProps, _isUpdate: boolean | undefined): void { }\n\n /** Called when a model should be exported.\n * @param model The model to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportModel(_model: Model, _isUpdate: boolean | undefined): void { }\n\n /** Called when a model should be deleted. */\n public onDeleteModel(_modelId: Id64String): void { }\n\n /** If `true` is returned, then the element will be exported.\n * @note This method can optionally be overridden to exclude an individual Element (and its children and ElementAspects) from the export. The base implementation always returns `true`.\n */\n public shouldExportElement(_element: Element): boolean { return true; }\n\n /** Called when an element should be exported.\n * @param element The element to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportElement(_element: Element, _isUpdate: boolean | undefined): void { }\n\n /**\n * Do any asynchronous actions before exporting an element\n * @note Do not implement this handler manually, it is internal, it will be removed.\n * This will become a part of onExportElement once that becomes async\n * @internal\n */\n public async preExportElement(_element: Element): Promise<void> {}\n\n /** Called when an element should be deleted. */\n public onDeleteElement(_elementId: Id64String): void { }\n\n /** If `true` is returned, then the ElementAspect will be exported.\n * @note This method can optionally be overridden to exclude an individual ElementAspect from the export. The base implementation always returns `true`.\n */\n public shouldExportElementAspect(_aspect: ElementAspect): boolean { return true; }\n\n /** Called when an ElementUniqueAspect should be exported.\n * @param aspect The ElementUniqueAspect to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportElementUniqueAspect(_aspect: ElementUniqueAspect, _isUpdate: boolean | undefined): void { }\n\n /** Called when ElementMultiAspects should be exported.\n * @note This should be overridden to actually do the export.\n */\n public onExportElementMultiAspects(_aspects: ElementMultiAspect[]): void { }\n\n /** If `true` is returned, then the relationship will be exported.\n * @note This method can optionally be overridden to exclude an individual CodeSpec from the export. The base implementation always returns `true`.\n */\n public shouldExportRelationship(_relationship: Relationship): boolean { return true; }\n\n /** Called when a Relationship should be exported.\n * @param relationship The Relationship to export\n * @param isUpdate If defined, then `true` indicates an UPDATE operation while `false` indicates an INSERT operation. If not defined, then INSERT vs. UPDATE is not known.\n * @note This should be overridden to actually do the export.\n */\n public onExportRelationship(_relationship: Relationship, _isUpdate: boolean | undefined): void { }\n\n /** Called when a relationship should be deleted. */\n public onDeleteRelationship(_relInstanceId: Id64String): void { }\n\n /** If `true` is returned, then the schema will be exported.\n * @note This method can optionally be overridden to exclude an individual schema from the export. The base implementation always returns `true`.\n */\n public shouldExportSchema(_schemaKey: SchemaKey): boolean { return true; }\n\n /** Called when a schema should be exported.\n * @param schema The schema to export\n * @note This should be overridden to actually do the export.\n * @note return an [[ExportSchemaResult]] with a `schemaPath` property to notify overrides that call `super`\n * where a schema was written for import.\n */\n public async onExportSchema(_schema: Schema): Promise<void | ExportSchemaResult> { }\n\n /** This method is called when IModelExporter has made incremental progress based on the [[IModelExporter.progressInterval]] setting.\n * This method is `async` to make it easier to integrate with asynchronous status and health reporting services.\n * @note A subclass may override this method to report custom progress. The base implementation does nothing.\n */\n public async onProgress(): Promise<void> { }\n}\n\n/** Base class for exporting data from an iModel.\n * @note Most uses cases will not require a custom subclass of `IModelExporter`. Instead, it is more typical to subclass/customize [IModelExportHandler]($transformer).\n * @see [iModel Transformation and Data Exchange]($docs/learning/transformer/index.md), [[registerHandler]], [IModelTransformer]($transformer), [IModelImporter]($transformer)\n * @beta\n */\nexport class IModelExporter {\n /** The read-only source iModel. */\n public readonly sourceDb: IModelDb;\n /** A flag that indicates whether element GeometryStreams are loaded or not.\n * @note As an optimization, exporters that don't need geometry can set this flag to `false`. The default is `true`.\n * @note The transformer by default sets this to `false` as an optimization.\n * @note This implies the `wantBRepData` option when loading elements.\n * @see [ElementLoadProps.wantGeometry]($common)\n */\n public wantGeometry: boolean = true;\n /** A flag that indicates whether template models should be exported or not. The default is `true`.\n * @note If only exporting *instances* then template models can be skipped since they are just definitions that are cloned to create new instances.\n * @see [Model.isTemplate]($backend)\n */\n public wantTemplateModels: boolean = true;\n /** A flag that indicates whether *system* schemas should be exported or not. The default is `true` (previously false).\n * This can be set to false for the legacy default behavior, but it may cause errors during schema processing in some cases.\n * @see [[exportSchemas]]\n */\n public wantSystemSchemas: boolean = true;\n /** A flag that determines whether this IModelExporter should visit Elements or not. The default is `true`.\n * @note This flag is available as an optimization when the exporter doesn't need to visit elements, so can skip loading them.\n */\n public visitElements: boolean = true;\n /** A flag that determines whether this IModelExporter should visit Relationships or not. The default is `true`.\n * @note This flag is available as an optimization when the exporter doesn't need to visit relationships, so can skip loading them.\n */\n public visitRelationships: boolean = true;\n /** The number of entities exported before incremental progress should be reported via the [[onProgress]] callback. */\n public progressInterval: number = 1000;\n /** Tracks the current total number of entities exported. */\n private _progressCounter: number = 0;\n /** Optionally cached entity change information */\n private _sourceDbChanges?: ChangedInstanceIds;\n /**\n * Retrieve the cached entity change information.\n * @note This will only be initialized after [IModelExporter.exportChanges] is invoked.\n */\n public get sourceDbChanges(): ChangedInstanceIds | undefined {\n return this._sourceDbChanges;\n }\n /** The handler called by this IModelExporter. */\n private _handler: IModelExportHandler | undefined;\n /** The handler called by this IModelExporter. */\n protected get handler(): IModelExportHandler {\n if (undefined === this._handler) {\n throw new Error(\"IModelExportHandler not registered\");\n }\n\n return this._handler;\n }\n\n /** The set of CodeSpecs to exclude from the export. */\n private _excludedCodeSpecNames = new Set<string>();\n /** The set of specific Elements to exclude from the export. */\n private _excludedElementIds = new Set<Id64String>();\n /** The set of Categories where Elements in that Category will be excluded from transformation to the target iModel. */\n private _excludedElementCategoryIds = new Set<Id64String>();\n /** The set of classes of Elements that will be excluded (polymorphically) from transformation to the target iModel. */\n private _excludedElementClasses = new Set<typeof Element>();\n /** The set of classes of ElementAspects that will be excluded (polymorphically) from transformation to the target iModel. */\n private _excludedElementAspectClasses = new Set<typeof ElementAspect>();\n /** The set of classFullNames for ElementAspects that will be excluded from transformation to the target iModel. */\n private _excludedElementAspectClassFullNames = new Set<string>();\n /** The set of classes of Relationships that will be excluded (polymorphically) from transformation to the target iModel. */\n private _excludedRelationshipClasses = new Set<typeof Relationship>();\n\n /** Construct a new IModelExporter\n * @param sourceDb The source IModelDb\n * @see registerHandler\n */\n public constructor(sourceDb: IModelDb) {\n this.sourceDb = sourceDb;\n }\n\n /** Register the handler that will be called by IModelExporter. */\n public registerHandler(handler: IModelExportHandler): void {\n this._handler = handler;\n }\n\n /** Add a rule to exclude a CodeSpec */\n public excludeCodeSpec(codeSpecName: string): void {\n this._excludedCodeSpecNames.add(codeSpecName);\n }\n\n /** Add a rule to exclude a specific Element. */\n public excludeElement(elementId: Id64String): void {\n this._excludedElementIds.add(elementId);\n }\n\n /** Add a rule to exclude all Elements in a specified Category. */\n public excludeElementsInCategory(categoryId: Id64String): void {\n this._excludedElementCategoryIds.add(categoryId);\n }\n\n /** Add a rule to exclude all Elements of a specified class. */\n public excludeElementClass(classFullName: string): void {\n this._excludedElementClasses.add(this.sourceDb.getJsClass<typeof Element>(classFullName));\n }\n\n /** Add a rule to exclude all ElementAspects of a specified class. */\n public excludeElementAspectClass(classFullName: string): void {\n this._excludedElementAspectClassFullNames.add(classFullName); // allows non-polymorphic exclusion before query\n this._excludedElementAspectClasses.add(this.sourceDb.getJsClass<typeof ElementAspect>(classFullName)); // allows polymorphic exclusion after query/load\n }\n\n /** Add a rule to exclude all Relationships of a specified class. */\n public excludeRelationshipClass(classFullName: string): void {\n this._excludedRelationshipClasses.add(this.sourceDb.getJsClass<typeof Relationship>(classFullName));\n }\n\n /** Export all entity instance types from the source iModel.\n * @note [[exportSchemas]] must be called separately.\n */\n public async exportAll(): Promise<void> {\n await this.exportCodeSpecs();\n await this.exportFonts();\n await this.exportModel(IModel.repositoryModelId);\n await this.exportRelationships(ElementRefersToElements.classFullName);\n }\n\n /** Export changes from the source iModel.\n * Inserts, updates, and deletes are determined by inspecting the changeset(s).\n * @param accessToken A valid access token string\n * @param startChangesetId Include changes from this changeset up through and including the current changeset.\n * If this parameter is not provided, then just the current changeset will be exported.\n * @note To form a range of versions to process, set `startChangesetId` for the start (inclusive) of the desired\n * range and open the source iModel as of the end (inclusive) of the desired range.\n */\n public async exportChanges(options: ExportChangesArgs): Promise<void>;\n /**\n * @deprecated in 0.1.x.\n */\n public async exportChanges(accessToken: AccessToken, startChangesetId?: string): Promise<void>;\n public async exportChanges(optionsOrAccessToken: AccessToken | ExportChangesArgs, startChangesetId?: string): Promise<void> {\n const args: ExportChangesArgs\n = typeof optionsOrAccessToken === \"string\"\n ? {\n accessToken: optionsOrAccessToken,\n startChangeset: startChangesetId\n ? { id: startChangesetId }\n : this.sourceDb.changeset,\n }\n : optionsOrAccessToken;\n\n if (!this.sourceDb.isBriefcaseDb()) {\n throw new IModelError(IModelStatus.BadRequest, \"Must be a briefcase to export changes\");\n }\n\n if (\"\" === this.sourceDb.changeset.id) {\n await this.exportAll(); // no changesets, so revert to exportAll\n return;\n }\n\n this._sourceDbChanges = await ChangedInstanceIds.initialize({ ...args, iModel: this.sourceDb });\n await this.exportCodeSpecs();\n await this.exportFonts();\n await this.exportModelContents(IModel.repositoryModelId);\n await this.exportSubModels(IModel.repositoryModelId);\n await this.exportRelationships(ElementRefersToElements.classFullName);\n\n // handle deletes\n if (this.visitElements) {\n // must delete models first since they have a constraint on the submodeling element which may also be deleted\n for (const modelId of this._sourceDbChanges.model.deleteIds) {\n this.handler.onDeleteModel(modelId);\n }\n for (const elementId of this._sourceDbChanges.element.deleteIds) {\n // We don't know how the handler wants to handle deletions, and we don't have enough information\n // to know if deleted entities were related, so when processing changes, ignore errors from deletion.\n // Technically, to keep the ignored error scope small, we ignore only the error of looking up a missing element,\n // that approach works at least for the IModelTransformer.\n // In the future, the handler may be responsible for doing the work of finding out which elements were cascade deleted,\n // and returning them for the exporter to use to avoid double-deleting with error ignoring\n try {\n this.handler.onDeleteElement(elementId);\n } catch (err: unknown) {\n const isMissingErr = err instanceof IModelError && err.errorNumber === IModelStatus.NotFound;\n if (!isMissingErr)\n throw err;\n }\n }\n }\n\n if (this.visitRelationships) {\n for (const relInstanceId of this._sourceDbChanges.relationship.deleteIds) {\n this.handler.onDeleteRelationship(relInstanceId);\n }\n }\n }\n\n /** Export schemas from the source iModel.\n * @note This must be called separately from [[exportAll]] or [[exportChanges]].\n */\n public async exportSchemas(): Promise<void> {\n /* eslint-disable @typescript-eslint/indent */\n const sql = `\n SELECT s.Name, s.VersionMajor, s.VersionWrite, s.VersionMinor\n FROM ECDbMeta.ECSchemaDef s\n ${this.wantSystemSchemas ? \"\" : `\n WHERE ECInstanceId >= (SELECT ECInstanceId FROM ECDbMeta.ECSchemaDef WHERE Name='BisCore')\n `}\n ORDER BY ECInstanceId\n `;\n /* eslint-enable @typescript-eslint/indent */\n const schemaNamesToExport: string[] = [];\n this.sourceDb.withPreparedStatement(sql, (statement: ECSqlStatement) => {\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n const schemaName = statement.getValue(0).getString();\n const versionMajor = statement.getValue(1).getInteger();\n const versionWrite = statement.getValue(2).getInteger();\n const versionMinor = statement.getValue(3).getInteger();\n const schemaKey = new SchemaKey(schemaName, new ECVersion(versionMajor, versionWrite, versionMinor));\n if (this.handler.shouldExportSchema(schemaKey)) {\n schemaNamesToExport.push(schemaName);\n }\n }\n });\n\n if (schemaNamesToExport.length === 0)\n return;\n\n const schemaLoader = new SchemaLoader((name: string) => this.sourceDb.getSchemaProps(name));\n await Promise.all(schemaNamesToExport.map(async (schemaName) => {\n const schema = schemaLoader.getSchema(schemaName);\n Logger.logTrace(loggerCategory, `exportSchema(${schemaName})`);\n return this.handler.onExportSchema(schema);\n }));\n }\n\n /** For logging, indicate the change type if known. */\n private getChangeOpSuffix(isUpdate: boolean | undefined): string {\n return isUpdate ? \" UPDATE\" : undefined === isUpdate ? \"\" : \" INSERT\";\n }\n\n /** Export all CodeSpecs from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportCodeSpecs(): Promise<void> {\n Logger.logTrace(loggerCategory, `exportCodeSpecs()`);\n const sql = `SELECT Name FROM BisCore:CodeSpec ORDER BY ECInstanceId`;\n await this.sourceDb.withPreparedStatement(sql, async (statement: ECSqlStatement): Promise<void> => {\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n const codeSpecName: string = statement.getValue(0).getString();\n await this.exportCodeSpecByName(codeSpecName);\n }\n });\n }\n\n /** Export a single CodeSpec from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportCodeSpecByName(codeSpecName: string): Promise<void> {\n const codeSpec: CodeSpec = this.sourceDb.codeSpecs.getByName(codeSpecName);\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (this._sourceDbChanges.codeSpec.insertIds.has(codeSpec.id)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.codeSpec.updateIds.has(codeSpec.id)) {\n isUpdate = true;\n } else {\n return; // not in changeset, don't export\n }\n }\n // passed changeset test, now apply standard exclusion rules\n if (this._excludedCodeSpecNames.has(codeSpec.name)) {\n Logger.logInfo(loggerCategory, `Excluding CodeSpec: ${codeSpec.name}`);\n return;\n }\n // CodeSpec has passed standard exclusion rules, now give handler a chance to accept/reject export\n if (this.handler.shouldExportCodeSpec(codeSpec)) {\n Logger.logTrace(loggerCategory, `exportCodeSpec(${codeSpecName})${this.getChangeOpSuffix(isUpdate)}`);\n this.handler.onExportCodeSpec(codeSpec, isUpdate);\n return this.trackProgress();\n }\n }\n\n /** Export a single CodeSpec from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportCodeSpecById(codeSpecId: Id64String): Promise<void> {\n const codeSpec: CodeSpec = this.sourceDb.codeSpecs.getById(codeSpecId);\n return this.exportCodeSpecByName(codeSpec.name);\n }\n\n /** Export all fonts from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportFonts(): Promise<void> {\n Logger.logTrace(loggerCategory, `exportFonts()`);\n for (const font of this.sourceDb.fontMap.fonts.values()) {\n await this.exportFontByNumber(font.id);\n }\n }\n\n /** Export a single font from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportFontByName(fontName: string): Promise<void> {\n Logger.logTrace(loggerCategory, `exportFontByName(${fontName})`);\n const font: FontProps | undefined = this.sourceDb.fontMap.getFont(fontName);\n if (undefined !== font) {\n await this.exportFontByNumber(font.id);\n }\n }\n\n /** Export a single font from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportFontByNumber(fontNumber: number): Promise<void> {\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n const fontId: Id64String = Id64.fromUint32Pair(fontNumber, 0); // changeset information uses Id64String, not number\n if (this._sourceDbChanges.font.insertIds.has(fontId)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.font.updateIds.has(fontId)) {\n isUpdate = true;\n } else {\n return; // not in changeset, don't export\n }\n }\n Logger.logTrace(loggerCategory, `exportFontById(${fontNumber})`);\n const font: FontProps | undefined = this.sourceDb.fontMap.getFont(fontNumber);\n if (undefined !== font) {\n this.handler.onExportFont(font, isUpdate);\n return this.trackProgress();\n }\n }\n\n /** Export the model container, contents, and sub-models from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportModel(modeledElementId: Id64String): Promise<void> {\n const model: Model = this.sourceDb.models.getModel(modeledElementId);\n if (model.isTemplate && !this.wantTemplateModels) {\n return;\n }\n const modeledElement: Element = this.sourceDb.elements.getElement({ id: modeledElementId, wantGeometry: this.wantGeometry, wantBRepData: this.wantGeometry });\n Logger.logTrace(loggerCategory, `exportModel(${modeledElementId})`);\n if (this.shouldExportElement(modeledElement)) {\n await this.exportModelContainer(model);\n if (this.visitElements) {\n await this.exportModelContents(modeledElementId);\n }\n await this.exportSubModels(modeledElementId);\n }\n }\n\n /** Export the model (the container only) from the source iModel. */\n private async exportModelContainer(model: Model): Promise<void> {\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (this._sourceDbChanges.model.insertIds.has(model.id)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.model.updateIds.has(model.id)) {\n isUpdate = true;\n } else {\n return; // not in changeset, don't export\n }\n }\n this.handler.onExportModel(model, isUpdate);\n return this.trackProgress();\n }\n\n private _yieldManager = new YieldManager();\n\n /** Export the model contents.\n * @param modelId The only required parameter\n * @param elementClassFullName Can be optionally specified if the goal is to export a subset of the model contents\n * @param skipRootSubject Decides whether or not to export the root Subject. It is normally left undefined except for internal implementation purposes.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportModelContents(modelId: Id64String, elementClassFullName: string = Element.classFullName, skipRootSubject?: boolean): Promise<void> {\n if (skipRootSubject) {\n // NOTE: IModelTransformer.processAll should skip the root Subject since it is specific to the individual iModel and is not part of the changes that need to be synchronized\n // NOTE: IModelExporter.exportAll should not skip the root Subject since the goal is to export everything\n assert(modelId === IModel.repositoryModelId); // flag is only relevant when processing the RepositoryModel\n }\n if (!this.visitElements) {\n Logger.logTrace(loggerCategory, `visitElements=false, skipping exportModelContents(${modelId})`);\n return;\n }\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (!this._sourceDbChanges.model.insertIds.has(modelId) && !this._sourceDbChanges.model.updateIds.has(modelId)) {\n return; // this optimization assumes that the Model changes (LastMod) any time an Element in the Model changes\n }\n }\n Logger.logTrace(loggerCategory, `exportModelContents(${modelId})`);\n let sql: string;\n if (skipRootSubject) {\n sql = `SELECT ECInstanceId FROM ${elementClassFullName} WHERE Parent.Id IS NULL AND Model.Id=:modelId AND ECInstanceId!=:rootSubjectId ORDER BY ECInstanceId`;\n } else {\n sql = `SELECT ECInstanceId FROM ${elementClassFullName} WHERE Parent.Id IS NULL AND Model.Id=:modelId ORDER BY ECInstanceId`;\n }\n await this.sourceDb.withPreparedStatement(sql, async (statement: ECSqlStatement): Promise<void> => {\n statement.bindId(\"modelId\", modelId);\n if (skipRootSubject) {\n statement.bindId(\"rootSubjectId\", IModel.rootSubjectId);\n }\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n await this.exportElement(statement.getValue(0).getId());\n await this._yieldManager.allowYield();\n }\n });\n }\n\n /** Export the sub-models directly below the specified model.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportSubModels(parentModelId: Id64String): Promise<void> {\n Logger.logTrace(loggerCategory, `exportSubModels(${parentModelId})`);\n const definitionModelIds: Id64String[] = [];\n const otherModelIds: Id64String[] = [];\n const sql = `SELECT ECInstanceId FROM ${Model.classFullName} WHERE ParentModel.Id=:parentModelId ORDER BY ECInstanceId`;\n this.sourceDb.withPreparedStatement(sql, (statement: ECSqlStatement): void => {\n statement.bindId(\"parentModelId\", parentModelId);\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n const modelId: Id64String = statement.getValue(0).getId();\n const model: Model = this.sourceDb.models.getModel(modelId);\n if (model instanceof DefinitionModel) {\n definitionModelIds.push(modelId);\n } else {\n otherModelIds.push(modelId);\n }\n }\n });\n // export DefinitionModels before other types of Models\n for (const definitionModelId of definitionModelIds) {\n await this.exportModel(definitionModelId);\n }\n for (const otherModelId of otherModelIds) {\n await this.exportModel(otherModelId);\n }\n }\n\n /** Returns true if the specified element should be exported.\n * This considers the standard IModelExporter exclusion rules plus calls [IModelExportHandler.shouldExportElement]($transformer) for any custom exclusion rules.\n * @note This method is called from within [[exportChanges]] and [[exportAll]], so usually does not need to be called directly.\n */\n public shouldExportElement(element: Element): boolean {\n if (this._excludedElementIds.has(element.id)) {\n Logger.logInfo(loggerCategory, `Excluded element ${element.id} by Id`);\n return false;\n }\n if (element instanceof GeometricElement) {\n if (this._excludedElementCategoryIds.has(element.category)) {\n Logger.logInfo(loggerCategory, `Excluded element ${element.id} by Category`);\n return false;\n }\n }\n if (!this.wantTemplateModels && (element instanceof RecipeDefinitionElement)) {\n Logger.logInfo(loggerCategory, `Excluded RecipeDefinitionElement ${element.id} because wantTemplate=false`);\n return false;\n }\n for (const excludedElementClass of this._excludedElementClasses) {\n if (element instanceof excludedElementClass) {\n Logger.logInfo(loggerCategory, `Excluded element ${element.id} by class: ${excludedElementClass.classFullName}`);\n return false;\n }\n }\n // element has passed standard exclusion rules, now give handler a chance to accept/reject\n return this.handler.shouldExportElement(element);\n }\n\n /** Export the specified element, its child elements (if applicable), and any owned ElementAspects.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportElement(elementId: Id64String): Promise<void> {\n if (!this.visitElements) {\n Logger.logTrace(loggerCategory, `visitElements=false, skipping exportElement(${elementId})`);\n return;\n }\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (this._sourceDbChanges.element.insertIds.has(elementId)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.element.updateIds.has(elementId)) {\n isUpdate = true;\n } else {\n // NOTE: This optimization assumes that the Element will change (LastMod) if an owned ElementAspect changes\n // NOTE: However, child elements may have changed without the parent changing\n return this.exportChildElements(elementId);\n }\n }\n const element: Element = this.sourceDb.elements.getElement({ id: elementId, wantGeometry: this.wantGeometry, wantBRepData: this.wantGeometry });\n Logger.logTrace(loggerCategory, `exportElement(${element.id}, \"${element.getDisplayLabel()}\")${this.getChangeOpSuffix(isUpdate)}`);\n // the order and `await`ing of calls beyond here is depended upon by the IModelTransformer for a current bug workaround\n if (this.shouldExportElement(element)) {\n await this.handler.preExportElement(element);\n this.handler.onExportElement(element, isUpdate);\n await this.trackProgress();\n await this.exportElementAspects(elementId);\n return this.exportChildElements(elementId);\n }\n }\n\n /** Export the child elements of the specified element from the source iModel.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportChildElements(elementId: Id64String): Promise<void> {\n if (!this.visitElements) {\n Logger.logTrace(loggerCategory, `visitElements=false, skipping exportChildElements(${elementId})`);\n return;\n }\n const childElementIds: Id64String[] = this.sourceDb.elements.queryChildren(elementId);\n if (childElementIds.length > 0) {\n Logger.logTrace(loggerCategory, `exportChildElements(${elementId})`);\n for (const childElementId of childElementIds) {\n await this.exportElement(childElementId);\n }\n }\n }\n\n /** Returns `true` if the specified ElementAspect should be exported or `false` if if should be excluded. */\n private shouldExportElementAspect(aspect: ElementAspect): boolean {\n for (const excludedElementAspectClass of this._excludedElementAspectClasses) {\n if (aspect instanceof excludedElementAspectClass) {\n Logger.logInfo(loggerCategory, `Excluded ElementAspect by class: ${aspect.classFullName}`);\n return false;\n }\n }\n // ElementAspect has passed standard exclusion rules, now give handler a chance to accept/reject\n return this.handler.shouldExportElementAspect(aspect);\n }\n\n /** Export ElementAspects from the specified element from the source iModel. */\n private async exportElementAspects(elementId: Id64String): Promise<void> {\n const _uniqueAspects = await Promise.all(this.sourceDb.elements\n ._queryAspects(elementId, ElementUniqueAspect.classFullName, this._excludedElementAspectClassFullNames)\n .filter((a) => this.shouldExportElementAspect(a))\n .map(async (uniqueAspect: ElementUniqueAspect) => {\n const isInsertChange = this._sourceDbChanges?.aspect.insertIds.has(uniqueAspect.id) ?? false;\n const isUpdateChange = this._sourceDbChanges?.aspect.updateIds.has(uniqueAspect.id) ?? false;\n const doExport = this._sourceDbChanges === undefined || isInsertChange || isUpdateChange;\n if (doExport) {\n const isKnownUpdate = this._sourceDbChanges ? isUpdateChange : undefined;\n this.handler.onExportElementUniqueAspect(uniqueAspect, isKnownUpdate);\n await this.trackProgress();\n }\n }));\n\n const multiAspects = this.sourceDb.elements\n ._queryAspects(elementId, ElementMultiAspect.classFullName, this._excludedElementAspectClassFullNames)\n .filter((a) => this.shouldExportElementAspect(a));\n\n if (multiAspects.length > 0) {\n this.handler.onExportElementMultiAspects(multiAspects);\n return this.trackProgress();\n }\n }\n\n /** Exports all relationships that subclass from the specified base class.\n * @note This method is called from [[exportChanges]] and [[exportAll]], so it only needs to be called directly when exporting a subset of an iModel.\n */\n public async exportRelationships(baseRelClassFullName: string): Promise<void> {\n if (!this.visitRelationships) {\n Logger.logTrace(loggerCategory, `visitRelationships=false, skipping exportRelationships()`);\n return;\n }\n Logger.logTrace(loggerCategory, `exportRelationships(${baseRelClassFullName})`);\n const sql = `SELECT r.ECInstanceId, r.ECClassId FROM ${baseRelClassFullName} r\n JOIN bis.Element s ON s.ECInstanceId = r.SourceECInstanceId\n JOIN bis.Element t ON t.ECInstanceId = r.TargetECInstanceId\n WHERE s.ECInstanceId IS NOT NULL AND t.ECInstanceId IS NOT NULL`;\n await this.sourceDb.withPreparedStatement(sql, async (statement: ECSqlStatement): Promise<void> => {\n while (DbResult.BE_SQLITE_ROW === statement.step()) {\n const relationshipId = statement.getValue(0).getId();\n const relationshipClass = statement.getValue(1).getClassNameForClassId();\n await this.exportRelationship(relationshipClass, relationshipId); // must call exportRelationship using the actual classFullName, not baseRelClassFullName\n await this._yieldManager.allowYield();\n }\n });\n }\n\n /** Export a relationship from the source iModel. */\n public async exportRelationship(relClassFullName: string, relInstanceId: Id64String): Promise<void> {\n if (!this.visitRelationships) {\n Logger.logTrace(loggerCategory, `visitRelationships=false, skipping exportRelationship(${relClassFullName}, ${relInstanceId})`);\n return;\n }\n let isUpdate: boolean | undefined;\n if (undefined !== this._sourceDbChanges) { // is changeset information available?\n if (this._sourceDbChanges.relationship.insertIds.has(relInstanceId)) {\n isUpdate = false;\n } else if (this._sourceDbChanges.relationship.updateIds.has(relInstanceId)) {\n isUpdate = true;\n } else {\n return; // not in changeset, don't export\n }\n }\n // passed changeset test, now apply standard exclusion rules\n Logger.logTrace(loggerCategory, `exportRelationship(${relClassFullName}, ${relInstanceId})`);\n const relationship: Relationship = this.sourceDb.relationships.getInstance(relClassFullName, relInstanceId);\n for (const excludedRelationshipClass of this._excludedRelationshipClasses) {\n if (relationship instanceof excludedRelationshipClass) {\n Logger.logInfo(loggerCategory, `Excluded relationship by class: ${excludedRelationshipClass.classFullName}`);\n return;\n }\n }\n // relationship has passed standard exclusion rules, now give handler a chance to accept/reject export\n if (this.handler.shouldExportRelationship(relationship)) {\n this.handler.onExportRelationship(relationship, isUpdate);\n await this.trackProgress();\n }\n }\n\n /** Tracks incremental progress */\n private async trackProgress(): Promise<void> {\n this._progressCounter++;\n if (0 === (this._progressCounter % this.progressInterval)) {\n return this.handler.onProgress();\n }\n }\n\n /**\n * You may override this to store arbitrary json state in a exporter state dump, useful for some resumptions\n * @see [[IModelTransformer.saveStateToFile]]\n */\n protected getAdditionalStateJson(): any {\n return {};\n }\n\n /**\n * You may override this to load arbitrary json state in a transformer state dump, useful for some resumptions\n * @see [[IModelTransformer.loadStateFromFile]]\n */\n protected loadAdditionalStateJson(_additionalState: any): void {}\n\n /**\n * Reload our state from a JSON object\n * Intended for [[IModelTransformer.resumeTransformation]]\n * @internal\n * You can load custom json from the exporter save state for custom exporters by overriding [[IModelExporter.loadAdditionalStateJson]]\n */\n public loadStateFromJson(state: IModelExporterState): void {\n if (state.exporterClass !== this.constructor.name)\n throw Error(\"resuming from a differently named exporter class, it is not necessarily valid to resume with a different exporter class\");\n this.wantGeometry = state.wantGeometry;\n this.wantTemplateModels = state.wantTemplateModels;\n this.wantSystemSchemas = state.wantSystemSchemas;\n this.visitElements = state.visitElements;\n this.visitRelationships = state.visitRelationships;\n this._excludedCodeSpecNames = new Set(state.excludedCodeSpecNames);\n this._excludedElementIds = CompressedId64Set.decompressSet(state.excludedElementIds),\n this._excludedElementCategoryIds = CompressedId64Set.decompressSet(state.excludedElementCategoryIds),\n this._excludedElementClasses = new Set(state.excludedElementClassNames.map((c) => this.sourceDb.getJsClass(c)));\n this._excludedElementAspectClassFullNames = new Set(state.excludedElementAspectClassFullNames);\n this._excludedElementAspectClasses = new Set(state.excludedElementAspectClassFullNames.map((c) => this.sourceDb.getJsClass(c)));\n this._excludedRelationshipClasses = new Set(state.excludedRelationshipClassNames.map((c) => this.sourceDb.getJsClass(c)));\n this.loadAdditionalStateJson(state.additionalState);\n }\n\n /**\n * Serialize state to a JSON object\n * Intended for [[IModelTransformer.resumeTransformation]]\n * @internal\n * You can add custom json to the exporter save state for custom exporters by overriding [[IModelExporter.getAdditionalStateJson]]\n */\n public saveStateToJson(): IModelExporterState {\n return {\n exporterClass: this.constructor.name,\n wantGeometry: this.wantGeometry,\n wantTemplateModels: this.wantTemplateModels,\n wantSystemSchemas: this.wantSystemSchemas,\n visitElements: this.visitElements,\n visitRelationships: this.visitRelationships,\n excludedCodeSpecNames: [...this._excludedCodeSpecNames],\n excludedElementIds: CompressedId64Set.compressSet(this._excludedElementIds),\n excludedElementCategoryIds: CompressedId64Set.compressSet(this._excludedElementCategoryIds),\n excludedElementClassNames: Array.from(this._excludedElementClasses, (cls) => cls.classFullName),\n excludedElementAspectClassFullNames: [...this._excludedElementAspectClassFullNames],\n excludedRelationshipClassNames: Array.from(this._excludedRelationshipClasses, (cls) => cls.classFullName),\n additionalState: this.getAdditionalStateJson(),\n };\n }\n}\n\n/**\n * The JSON format of a serialized IModelExporter instance\n * Used for starting an exporter in the middle of an export operation,\n * such as resuming a crashed transformation\n *\n * @note Must be kept synchronized with IModelExporter\n * @internal\n */\nexport interface IModelExporterState {\n exporterClass: string;\n wantGeometry: boolean;\n wantTemplateModels: boolean;\n wantSystemSchemas: boolean;\n visitElements: boolean;\n visitRelationships: boolean;\n excludedCodeSpecNames: string[];\n excludedElementIds: CompressedId64Set;\n excludedElementCategoryIds: CompressedId64Set;\n excludedElementClassNames: string[];\n excludedElementAspectClassFullNames: string[];\n excludedRelationshipClassNames: string[];\n additionalState?: any;\n}\n\n/** Class for holding change information.\n * @beta\n*/\nexport class ChangedInstanceOps {\n public insertIds = new Set<Id64String>();\n public updateIds = new Set<Id64String>();\n public deleteIds = new Set<Id64String>();\n\n /** Initializes the object from IModelJsNative.ChangedInstanceOpsProps. */\n public addFromJson(val: IModelJsNative.ChangedInstanceOpsProps | undefined): void {\n if (undefined !== val) {\n if ((undefined !== val.insert) && (Array.isArray(val.insert)))\n val.insert.forEach((id: Id64String) => this.insertIds.add(id));\n\n if ((undefined !== val.update) && (Array.isArray(val.update)))\n val.update.forEach((id: Id64String) => this.updateIds.add(id));\n\n if ((undefined !== val.delete) && (Array.isArray(val.delete)))\n val.delete.forEach((id: Id64String) => this.deleteIds.add(id));\n }\n }\n}\n\n/**\n * Class for discovering modified elements between 2 versions of an iModel.\n * @beta\n */\nexport class ChangedInstanceIds {\n public codeSpec = new ChangedInstanceOps();\n public model = new ChangedInstanceOps();\n public element = new ChangedInstanceOps();\n public aspect = new ChangedInstanceOps();\n public relationship = new ChangedInstanceOps();\n public font = new ChangedInstanceOps();\n private constructor() { }\n\n /**\n * Initializes a new ChangedInstanceIds object with information taken from a range of changesets.\n */\n public static async initialize(opts: ChangedInstanceIdsInitOptions): Promise<ChangedInstanceIds>;\n /** @deprecated in 0.1.x. Pass a [[ChangedInstanceIdsInitOptions]] object instead of a changeset id */\n public static async initialize(accessToken: AccessToken | undefined, iModel: BriefcaseDb, startChangesetId: string): Promise<ChangedInstanceIds>;\n public static async initialize(\n accessTokenOrOpts: AccessToken | ChangedInstanceIdsInitOptions | undefined,\n iModel?: BriefcaseDb,\n startChangesetId?: string,\n ): Promise<ChangedInstanceIds> {\n const opts: ChangedInstanceIdsInitOptions\n = typeof accessTokenOrOpts === \"object\"\n ? accessTokenOrOpts\n : {\n accessToken: accessTokenOrOpts,\n iModel: iModel!,\n startChangeset: { id: startChangesetId! },\n };\n\n nodeAssert(\n ((opts.startChangeset ? 1 : 0) + (opts.changesetRanges ? 1 : 0)) === 1,\n \"exactly one of options.startChangeset XOR opts.changesetRanges may be used\",\n );\n\n const iModelId = opts.iModel.iModelId;\n const accessToken = opts.accessToken;\n\n const changesetRanges = opts.changesetRanges\n ?? [[\n opts.startChangeset!.index\n ?? (await IModelHost.hubAccess.queryChangeset({\n iModelId,\n changeset: { id: opts.startChangeset!.id },\n accessToken,\n })).index,\n opts.iModel.changeset.index\n ?? (await IModelHost.hubAccess.queryChangeset({\n iModelId,\n changeset: { id: opts.iModel.changeset.id },\n accessToken,\n })).index,\n ]];\n\n Logger.logTrace(loggerCategory, `ChangedInstanceIds.initialize ranges: ${changesetRanges.join(\"|\")}`);\n\n const changesets = (await Promise.all(\n changesetRanges.map(async ([first, end]) =>\n IModelHost.hubAccess.downloadChangesets({\n accessToken,\n iModelId, range: { first, end },\n targetDir: BriefcaseManager.getChangeSetsPath(iModelId),\n })\n )\n )).flat();\n\n const changedInstanceIds = new ChangedInstanceIds();\n const changesetFiles = changesets.map((c) => c.pathname);\n const statusOrResult = opts.iModel.nativeDb.extractChangedInstanceIdsFromChangeSets(changesetFiles);\n if (statusOrResult.error) {\n throw new IModelError(statusOrResult.error.status, \"Error processing changeset\");\n }\n const result = statusOrResult.result;\n assert(result !== undefined);\n changedInstanceIds.codeSpec.addFromJson(result.codeSpec);\n changedInstanceIds.model.addFromJson(result.model);\n changedInstanceIds.element.addFromJson(result.element);\n changedInstanceIds.aspect.addFromJson(result.aspect);\n changedInstanceIds.relationship.addFromJson(result.relationship);\n changedInstanceIds.font.addFromJson(result.font);\n return changedInstanceIds;\n }\n}\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { AccessToken, Id64String } from "@itwin/core-bentley";
|
|
2
2
|
import * as ECSchemaMetaData from "@itwin/ecschema-metadata";
|
|
3
3
|
import { Element, ElementAspect, ElementMultiAspect, ElementUniqueAspect, Entity, IModelDb, Model, Relationship, RelationshipProps, SQLiteDb } from "@itwin/core-backend";
|
|
4
|
-
import { CodeSpec, ElementAspectProps, ElementProps, EntityReference, EntityReferenceSet, FontProps, ModelProps, Placement2d, Placement3d } from "@itwin/core-common";
|
|
4
|
+
import { ChangesetIndexOrId, CodeSpec, ElementAspectProps, ElementProps, EntityReference, EntityReferenceSet, FontProps, ModelProps, Placement2d, Placement3d } from "@itwin/core-common";
|
|
5
5
|
import { ExportSchemaResult, IModelExporter, IModelExportHandler } from "./IModelExporter";
|
|
6
6
|
import { IModelImporter, OptimizeGeometryOptions } from "./IModelImporter";
|
|
7
7
|
import { PendingReferenceMap } from "./PendingReferenceMap";
|
|
@@ -13,7 +13,8 @@ import { IModelCloneContext } from "./IModelCloneContext";
|
|
|
13
13
|
*/
|
|
14
14
|
export interface IModelTransformOptions {
|
|
15
15
|
/** The Id of the Element in the **target** iModel that represents the **source** repository as a whole and scopes its [ExternalSourceAspect]($backend) instances.
|
|
16
|
-
*
|
|
16
|
+
* It is always a good idea to define this, although particularly necessary in any multi-source scenario such as multiple branches that reverse synchronize
|
|
17
|
+
* or physical consolidation.
|
|
17
18
|
*/
|
|
18
19
|
targetScopeElementId?: Id64String;
|
|
19
20
|
/** Set to `true` if IModelTransformer should not record its provenance.
|
|
@@ -100,6 +101,28 @@ export interface IModelTransformOptions {
|
|
|
100
101
|
* @beta
|
|
101
102
|
*/
|
|
102
103
|
optimizeGeometry?: OptimizeGeometryOptions;
|
|
104
|
+
/**
|
|
105
|
+
* force the insertion of external source aspects to provide provenance, even if there are federation guids
|
|
106
|
+
* in the source that we can use. This can make some operations (like transforming new elements or initializing forks)
|
|
107
|
+
* much slower due to needing to insert aspects, but prevents requiring change information for future merges.
|
|
108
|
+
* @default false
|
|
109
|
+
*/
|
|
110
|
+
forceExternalSourceAspectProvenance?: boolean;
|
|
111
|
+
/**
|
|
112
|
+
* Do not detach the change cache that we build. Use this if you want to do multiple transformations to
|
|
113
|
+
* the same iModels, to avoid the performance cost of reinitializing the change cache which can be
|
|
114
|
+
* expensive. You should only use this if you know the cache will be reused.
|
|
115
|
+
* @note You must detach the change cache yourself.
|
|
116
|
+
* @default false
|
|
117
|
+
*/
|
|
118
|
+
noDetachChangeCache?: boolean;
|
|
119
|
+
/**
|
|
120
|
+
* Do not check that processChanges is called from the next changeset index.
|
|
121
|
+
* This is an unsafe option (e.g. it can cause data loss in future branch operations)
|
|
122
|
+
* and you should not use it.
|
|
123
|
+
* @default false
|
|
124
|
+
*/
|
|
125
|
+
ignoreMissingChangesetsInSynchronizations?: boolean;
|
|
103
126
|
}
|
|
104
127
|
/**
|
|
105
128
|
* A container for tracking the state of a partially committed entity and finalizing it when it's ready to be fully committed
|
|
@@ -123,13 +146,25 @@ declare class PartiallyCommittedEntity {
|
|
|
123
146
|
resolveReference(id: EntityReference): void;
|
|
124
147
|
forceComplete(): void;
|
|
125
148
|
}
|
|
126
|
-
/** Arguments you can pass to [[IModelTransformer.
|
|
149
|
+
/** Arguments you can pass to [[IModelTransformer.initialize]]
|
|
127
150
|
* @beta
|
|
128
151
|
*/
|
|
129
|
-
export interface
|
|
152
|
+
export interface InitArgs {
|
|
130
153
|
accessToken?: AccessToken;
|
|
154
|
+
/**
|
|
155
|
+
* @deprecated in 0.1.x. Use startChangeset instead
|
|
156
|
+
*/
|
|
131
157
|
startChangesetId?: string;
|
|
158
|
+
/**
|
|
159
|
+
* The starting changeset of the source, inclusive, from which to apply changes
|
|
160
|
+
* @default (if undefined) should mean the last synchronized changeset in a branch relationship
|
|
161
|
+
*/
|
|
162
|
+
startChangeset?: ChangesetIndexOrId;
|
|
132
163
|
}
|
|
164
|
+
/** Arguments you can pass to [[IModelTransformer.initExternalSourceAspects]]
|
|
165
|
+
* @deprecated in 0.1.0. Use [[InitArgs]] (and [[IModelTransformer.initialize]]) instead.
|
|
166
|
+
*/
|
|
167
|
+
export type InitFromExternalSourceAspectsArgs = InitArgs;
|
|
133
168
|
/** Base class used to transform a source iModel into a different target iModel.
|
|
134
169
|
* @see [iModel Transformation and Data Exchange]($docs/learning/transformer/index.md), [IModelExporter]($transformer), [IModelImporter]($transformer)
|
|
135
170
|
* @beta
|
|
@@ -156,6 +191,10 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
156
191
|
protected _partiallyCommittedEntities: EntityMap<PartiallyCommittedEntity>;
|
|
157
192
|
/** the options that were used to initialize this transformer */
|
|
158
193
|
private readonly _options;
|
|
194
|
+
private _isSynchronization;
|
|
195
|
+
private get _isReverseSynchronization();
|
|
196
|
+
private get _isForwardSynchronization();
|
|
197
|
+
private _changesetRanges;
|
|
159
198
|
/** Set if it can be determined whether this is the first source --> target synchronization. */
|
|
160
199
|
private _isFirstSynchronization?;
|
|
161
200
|
/** The element classes that are considered to define provenance in the iModel */
|
|
@@ -176,17 +215,54 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
176
215
|
* @note This will be [[targetDb]] except when it is a reverse synchronization. In that case it be [[sourceDb]].
|
|
177
216
|
*/
|
|
178
217
|
get provenanceDb(): IModelDb;
|
|
179
|
-
/**
|
|
218
|
+
/** Return the IModelDb where IModelTransformer will NOT store its provenance.
|
|
219
|
+
* @note This will be [[sourceDb]] except when it is a reverse synchronization. In that case it be [[targetDb]].
|
|
220
|
+
*/
|
|
221
|
+
get provenanceSourceDb(): IModelDb;
|
|
180
222
|
private initElementProvenance;
|
|
223
|
+
/**
|
|
224
|
+
* Previously the transformer would insert provenance always pointing to the "target" relationship.
|
|
225
|
+
* It should (and now by default does) instead insert provenance pointing to the provenanceSource
|
|
226
|
+
* SEE: https://github.com/iTwin/imodel-transformer/issues/54
|
|
227
|
+
* This exists only to facilitate testing that the transformer can handle the older, flawed method
|
|
228
|
+
*/
|
|
229
|
+
private _forceOldRelationshipProvenanceMethod;
|
|
181
230
|
/** Create an ExternalSourceAspectProps in a standard way for a Relationship in an iModel --> iModel transformations.
|
|
182
231
|
* The ExternalSourceAspect is meant to be owned by the Element in the target iModel that is the `sourceId` of transformed relationship.
|
|
183
232
|
* The `identifier` property of the ExternalSourceAspect will be the ECInstanceId of the relationship in the source iModel.
|
|
184
233
|
* The ECInstanceId of the relationship in the target iModel will be stored in the JsonProperties of the ExternalSourceAspect.
|
|
185
234
|
*/
|
|
186
235
|
private initRelationshipProvenance;
|
|
187
|
-
|
|
188
|
-
private
|
|
189
|
-
/**
|
|
236
|
+
/** NOTE: the json properties must be converted to string before insertion */
|
|
237
|
+
private _targetScopeProvenanceProps;
|
|
238
|
+
/**
|
|
239
|
+
* Index of the changeset that the transformer was at when the transformation begins (was constructed).
|
|
240
|
+
* Used to determine at the end which changesets were part of a synchronization.
|
|
241
|
+
*/
|
|
242
|
+
private _startingTargetChangesetIndex;
|
|
243
|
+
private _cachedSynchronizationVersion;
|
|
244
|
+
/** the changeset in the scoping element's source version found for this transformation
|
|
245
|
+
* @note: the version depends on whether this is a reverse synchronization or not, as
|
|
246
|
+
* it is stored separately for both synchronization directions
|
|
247
|
+
* @note: empty string and -1 for changeset and index if it has never been transformed
|
|
248
|
+
*/
|
|
249
|
+
private get _synchronizationVersion();
|
|
250
|
+
/**
|
|
251
|
+
* Make sure there are no conflicting other scope-type external source aspects on the *target scope element*,
|
|
252
|
+
* If there are none at all, insert one, then this must be a first synchronization.
|
|
253
|
+
* @returns the last synced version (changesetId) on the target scope's external source aspect,
|
|
254
|
+
* if this was a [BriefcaseDb]($backend)
|
|
255
|
+
*/
|
|
256
|
+
private initScopeProvenance;
|
|
257
|
+
/**
|
|
258
|
+
* @returns the id and version of an aspect with the given element, scope, kind, and identifier
|
|
259
|
+
* May also return a reverseSyncVersion from json properties if requested
|
|
260
|
+
*/
|
|
261
|
+
private queryScopeExternalSource;
|
|
262
|
+
/**
|
|
263
|
+
* Iterate all matching ExternalSourceAspects in the provenance iModel (target unless reverse sync) and call a function for each one.
|
|
264
|
+
* @note provenance is done by federation guids where possible
|
|
265
|
+
*/
|
|
190
266
|
private forEachTrackedElement;
|
|
191
267
|
/** Initialize the source to target Element mapping from ExternalSourceAspects in the target iModel.
|
|
192
268
|
* @note This method is called from all `process*` functions and should never need to be called directly.
|
|
@@ -194,19 +270,30 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
194
270
|
* @note Passing an [[InitFromExternalSourceAspectsArgs]] is required when processing changes, to remap any elements that may have been deleted.
|
|
195
271
|
* You must await the returned promise as well in this case. The synchronous behavior has not changed but is deprecated and won't process everything.
|
|
196
272
|
*/
|
|
197
|
-
initFromExternalSourceAspects(args?:
|
|
198
|
-
/**
|
|
199
|
-
*
|
|
200
|
-
*
|
|
201
|
-
*/
|
|
202
|
-
private
|
|
273
|
+
initFromExternalSourceAspects(args?: InitArgs): void | Promise<void>;
|
|
274
|
+
/**
|
|
275
|
+
* Scan changesets for deleted entities, if in a reverse synchronization, provenance has
|
|
276
|
+
* already been deleted, so we must scan for that as well.
|
|
277
|
+
*/
|
|
278
|
+
private remapDeletedSourceEntities;
|
|
279
|
+
private _queryProvenanceForElement;
|
|
280
|
+
private _queryProvenanceForRelationship;
|
|
281
|
+
private _queryTargetRelId;
|
|
282
|
+
private _targetClassNameToClassIdCache;
|
|
283
|
+
private _targetClassNameToClassId;
|
|
284
|
+
private _getRelClassId;
|
|
285
|
+
private _queryElemIdByFedGuid;
|
|
203
286
|
/** Returns `true` if *brute force* delete detections should be run.
|
|
204
287
|
* @note Not relevant for processChanges when change history is known.
|
|
205
288
|
*/
|
|
206
289
|
private shouldDetectDeletes;
|
|
207
|
-
/**
|
|
208
|
-
*
|
|
209
|
-
*
|
|
290
|
+
/**
|
|
291
|
+
* Detect Element deletes using ExternalSourceAspects in the target iModel and a *brute force* comparison against Elements
|
|
292
|
+
* in the source iModel.
|
|
293
|
+
* @deprecated in 0.1.x. This method is only called during [[processAll]] when the option
|
|
294
|
+
* [[IModelTransformerOptions.forceExternalSourceAspectProvenance]] is enabled. It is not
|
|
295
|
+
* necessary when using [[processChanges]] since changeset information is sufficient.
|
|
296
|
+
* @note you do not need to call this directly unless processing a subset of an iModel.
|
|
210
297
|
* @throws [[IModelError]] If the required provenance information is not available to detect deletes.
|
|
211
298
|
*/
|
|
212
299
|
detectElementDeletes(): Promise<void>;
|
|
@@ -221,12 +308,15 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
221
308
|
* @note This can be called more than once for an element in arbitrary order, so it should not have side-effects.
|
|
222
309
|
*/
|
|
223
310
|
onTransformElement(sourceElement: Element): ElementProps;
|
|
311
|
+
private _hasElementChangedCache?;
|
|
312
|
+
private _deletedSourceRelationshipData?;
|
|
313
|
+
private _cacheSourceChanges;
|
|
224
314
|
/** Returns true if a change within sourceElement is detected.
|
|
225
315
|
* @param sourceElement The Element from the source iModel
|
|
226
316
|
* @param targetElementId The Element from the target iModel to compare against.
|
|
227
317
|
* @note A subclass can override this method to provide custom change detection behavior.
|
|
228
318
|
*/
|
|
229
|
-
protected hasElementChanged(sourceElement: Element,
|
|
319
|
+
protected hasElementChanged(sourceElement: Element, _targetElementId: Id64String): boolean;
|
|
230
320
|
private static transformCallbackFor;
|
|
231
321
|
/** callback to perform when a partial element says it's ready to be completed
|
|
232
322
|
* transforms the source element with all references now valid, then updates the partial element with the results
|
|
@@ -296,6 +386,11 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
296
386
|
* @deprecated in 3.x. This method is no longer necessary since the transformer no longer needs to defer elements
|
|
297
387
|
*/
|
|
298
388
|
processDeferredElements(_numRetries?: number): Promise<void>;
|
|
389
|
+
/** called at the end ([[finalizeTransformation]]) of a transformation,
|
|
390
|
+
* updates the target scope element to say that transformation up through the
|
|
391
|
+
* source's changeset has been performed.
|
|
392
|
+
*/
|
|
393
|
+
private _updateSynchronizationVersion;
|
|
299
394
|
private finalizeTransformation;
|
|
300
395
|
/** Imports all relationships that subclass from the specified base class.
|
|
301
396
|
* @param baseRelClassFullName The specified base relationship class.
|
|
@@ -316,6 +411,7 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
316
411
|
onDeleteRelationship(sourceRelInstanceId: Id64String): void;
|
|
317
412
|
private _yieldManager;
|
|
318
413
|
/** Detect Relationship deletes using ExternalSourceAspects in the target iModel and a *brute force* comparison against relationships in the source iModel.
|
|
414
|
+
* @deprecated
|
|
319
415
|
* @see processChanges
|
|
320
416
|
* @note This method is called from [[processAll]] and is not needed by [[processChanges]], so it only needs to be called directly when processing a subset of an iModel.
|
|
321
417
|
* @throws [[IModelError]] If the required provenance information is not available to detect deletes.
|
|
@@ -389,17 +485,22 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
389
485
|
processSubject(sourceSubjectId: Id64String, targetSubjectId: Id64String): Promise<void>;
|
|
390
486
|
/** state to prevent reinitialization, @see [[initialize]] */
|
|
391
487
|
private _initialized;
|
|
488
|
+
/** length === 0 when _changeDataState = "no-change", length > 0 means "has-changes", otherwise undefined */
|
|
489
|
+
private _changeSummaryIds?;
|
|
490
|
+
private _sourceChangeDataState;
|
|
392
491
|
/**
|
|
393
|
-
* Initialize prerequisites of processing, you must initialize with an [[
|
|
394
|
-
* are intending process changes, but prefer using [[processChanges]]
|
|
395
|
-
* Called by all `process*` functions implicitly.
|
|
492
|
+
* Initialize prerequisites of processing, you must initialize with an [[InitArgs]] if you
|
|
493
|
+
* are intending to process changes, but prefer using [[processChanges]] explicitly since it calls this.
|
|
494
|
+
* @note Called by all `process*` functions implicitly.
|
|
396
495
|
* Overriders must call `super.initialize()` first
|
|
397
496
|
*/
|
|
398
|
-
initialize(args?:
|
|
497
|
+
initialize(args?: InitArgs): Promise<void>;
|
|
498
|
+
private _tryInitChangesetData;
|
|
399
499
|
/** Export everything from the source iModel and import the transformed entities into the target iModel.
|
|
400
500
|
* @note [[processSchemas]] is not called automatically since the target iModel may want a different collection of schemas.
|
|
401
501
|
*/
|
|
402
502
|
processAll(): Promise<void>;
|
|
503
|
+
/** previous provenance, either a federation guid, a `${sourceFedGuid}/${targetFedGuid}` pair, or required aspect props */
|
|
403
504
|
private _lastProvenanceEntityInfo;
|
|
404
505
|
private markLastProvenance;
|
|
405
506
|
/** @internal the name of the table where javascript state of the transformer is serialized in transformer state dumps */
|
|
@@ -453,12 +554,21 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
453
554
|
*/
|
|
454
555
|
saveStateToFile(nativeStatePath: string): void;
|
|
455
556
|
/** Export changes from the source iModel and import the transformed entities into the target iModel.
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
557
|
+
* Inserts, updates, and deletes are determined by inspecting the changeset(s).
|
|
558
|
+
* @note the transformer assumes that you saveChanges after processing changes. You should not
|
|
559
|
+
* modify the iModel after processChanges until saveChanges, failure to do so may result in corrupted
|
|
560
|
+
* data loss in future branch operations
|
|
561
|
+
* @param accessToken A valid access token string
|
|
562
|
+
* @param startChangesetId Include changes from this changeset up through and including the current changeset.
|
|
563
|
+
* If this parameter is not provided, then just the current changeset will be exported.
|
|
564
|
+
* @note To form a range of versions to process, set `startChangesetId` for the start (inclusive) of the desired range and open the source iModel as of the end (inclusive) of the desired range.
|
|
565
|
+
*/
|
|
566
|
+
processChanges(options: InitArgs): Promise<void>;
|
|
567
|
+
/**
|
|
568
|
+
* @deprecated in 0.1.x.
|
|
569
|
+
* This overload follows the older behavior of defaulting an undefined startChangesetId to the
|
|
570
|
+
* current changeset.
|
|
571
|
+
*/
|
|
462
572
|
processChanges(accessToken: AccessToken, startChangesetId?: string): Promise<void>;
|
|
463
573
|
}
|
|
464
574
|
/** IModelTransformer that clones the contents of a template model.
|