@itwin/imodel-transformer 2.0.0-dev.35 → 2.0.0-dev.36
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/README.md +10 -0
- package/lib/cjs/IModelCloneContext.d.ts +3 -2
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +1 -1
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelTransformContext.d.ts +54 -0
- package/lib/cjs/IModelTransformContext.d.ts.map +1 -0
- package/lib/cjs/IModelTransformContext.js +3 -0
- package/lib/cjs/IModelTransformContext.js.map +1 -0
- package/lib/cjs/IModelTransformer.d.ts +5 -3
- package/lib/cjs/IModelTransformer.d.ts.map +1 -1
- package/lib/cjs/IModelTransformer.js +17 -11
- package/lib/cjs/IModelTransformer.js.map +1 -1
- package/lib/cjs/ProvenanceManager.d.ts +8 -3
- package/lib/cjs/ProvenanceManager.d.ts.map +1 -1
- package/lib/cjs/ProvenanceManager.js +23 -23
- package/lib/cjs/ProvenanceManager.js.map +1 -1
- package/lib/cjs/SyncTypeResolver.d.ts +3 -3
- package/lib/cjs/SyncTypeResolver.d.ts.map +1 -1
- package/lib/cjs/SyncTypeResolver.js +6 -4
- package/lib/cjs/SyncTypeResolver.js.map +1 -1
- package/lib/cjs/TransformerLoggerCategory.d.ts +1 -1
- package/lib/cjs/TransformerLoggerCategory.js +1 -1
- package/lib/cjs/TransformerLoggerCategory.js.map +1 -1
- package/lib/cjs/imodel-transformer.d.ts +1 -0
- package/lib/cjs/imodel-transformer.d.ts.map +1 -1
- package/lib/cjs/imodel-transformer.js +1 -0
- package/lib/cjs/imodel-transformer.js.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -10,6 +10,16 @@ The __@itwin/imodel-transformer__ package contains classes that handle traversin
|
|
|
10
10
|
|
|
11
11
|
See the [iTwin.js](https://www.itwinjs.org) documentation for more information.
|
|
12
12
|
|
|
13
|
+
### Transformation context
|
|
14
|
+
|
|
15
|
+
Retrieve the supported transformation context from an `IModelTransformer`. Depend on `IModelTransformContext` when passing the context to helpers or creating test doubles; `IModelCloneContext` is an implementation detail.
|
|
16
|
+
|
|
17
|
+
```ts
|
|
18
|
+
import type { IModelTransformContext } from "@itwin/imodel-transformer";
|
|
19
|
+
|
|
20
|
+
const context: IModelTransformContext = transformer.context;
|
|
21
|
+
```
|
|
22
|
+
|
|
13
23
|
## Versioning
|
|
14
24
|
|
|
15
25
|
This package, for the time being, relies on @internal APIs in iTwin.js, and therefore has very strict peerDependencies versions.
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import { Id64String } from "@itwin/core-bentley";
|
|
2
2
|
import { ElementAspectProps, ElementProps, EntityReference } from "@itwin/core-common";
|
|
3
3
|
import { Element, ElementAspect, IModelElementCloneContext, IModelJsNative } from "@itwin/core-backend";
|
|
4
|
+
import type { IModelTransformContext } from "./IModelTransformContext";
|
|
4
5
|
/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.
|
|
5
|
-
* @
|
|
6
|
+
* @internal
|
|
6
7
|
*/
|
|
7
|
-
export declare class IModelCloneContext extends IModelElementCloneContext {
|
|
8
|
+
export declare class IModelCloneContext extends IModelElementCloneContext implements IModelTransformContext {
|
|
8
9
|
private _refTypesCache;
|
|
9
10
|
private _aspectRemapTable;
|
|
10
11
|
/** perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelCloneContext.d.ts","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":"AAQA,OAAO,EAAQ,UAAU,EAAU,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAKL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EAKhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,OAAO,EACP,aAAa,EAEb,yBAAyB,EACzB,cAAc,EACf,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"IModelCloneContext.d.ts","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":"AAQA,OAAO,EAAQ,UAAU,EAAU,MAAM,qBAAqB,CAAC;AAC/D,OAAO,EAKL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EAKhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,OAAO,EACP,aAAa,EAEb,yBAAyB,EACzB,cAAc,EACf,MAAM,qBAAqB,CAAC;AAM7B,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,0BAA0B,CAAC;AAIvE;;GAEG;AACH,qBAAa,kBACX,SAAQ,yBACR,YAAW,sBAAsB;IAEjC,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,iBAAiB,CAA4B;IAErD,0HAA0H;IACpG,UAAU;IAIhC;;OAEG;IACmB,YAAY,CAChC,aAAa,EAAE,OAAO,EACtB,YAAY,CAAC,EAAE,cAAc,CAAC,mBAAmB,GAChD,OAAO,CAAC,YAAY,CAAC;IA2DxB,uGAAuG;IAChG,kBAAkB,CACvB,cAAc,EAAE,UAAU,EAC1B,cAAc,EAAE,UAAU,GACzB,IAAI;IAIP,mEAAmE;IAC5D,mBAAmB,CAAC,cAAc,EAAE,UAAU,GAAG,IAAI;IAI5D;;OAEG;IACI,kBAAkB,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU;IAIjE;;OAEG;IACU,kBAAkB,CAC7B,cAAc,EAAE,eAAe,GAC9B,OAAO,CAAC,eAAe,CAAC;IAqI3B;;OAEG;IACU,kBAAkB,CAC7B,mBAAmB,EAAE,aAAa,GACjC,OAAO,CAAC,kBAAkB,CAAC;CAsD/B"}
|
|
@@ -19,7 +19,7 @@ const TransformerLoggerCategory_1 = require("./TransformerLoggerCategory");
|
|
|
19
19
|
const BigMap_1 = require("./BigMap");
|
|
20
20
|
const loggerCategory = TransformerLoggerCategory_1.TransformerLoggerCategory.IModelCloneContext;
|
|
21
21
|
/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.
|
|
22
|
-
* @
|
|
22
|
+
* @internal
|
|
23
23
|
*/
|
|
24
24
|
class IModelCloneContext extends core_backend_1.IModelElementCloneContext {
|
|
25
25
|
_refTypesCache = new ECReferenceTypesCache_1.ECReferenceTypesCache();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelCloneContext.js","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG;;GAEG;AACH,6CAA+C;AAC/C,sDAA+D;AAC/D,oDAY4B;AAC5B,sDAO6B;AAC7B,gEAAuD;AACvD,mEAAgE;AAChE,mDAAgD;AAChD,2EAAwE;AACxE,qCAAkC;AAElC,MAAM,cAAc,GAAW,qDAAyB,CAAC,kBAAkB,CAAC;AAE5E;;GAEG;AACH,MAAa,kBAAmB,SAAQ,wCAAyB;IACvD,cAAc,GAAG,IAAI,6CAAqB,EAAE,CAAC;IAC7C,iBAAiB,GAAG,IAAI,eAAM,EAAc,CAAC;IAErD,0HAA0H;IAC1G,KAAK,CAAC,UAAU;QAC9B,MAAM,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACa,KAAK,CAAC,YAAY,CAChC,aAAsB,EACtB,YAAiD;QAEjD,MAAM,kBAAkB,GAAiB,IAAI,CAC3C,gBAAgB,CACjB,CAAC,YAAY,CAAC,aAAa,CAAC,EAAE,EAAE,YAAY,CAAC,CAAC;QAC/C,iJAAiJ;QACjJ,MAAM,kBAAkB,GACtB,aAAa,CAAC,MAAM,CAAC,aAAa,CAAC,iBAAiB,CAClD,aAAa,CAAC,aAAa,EAC3B,+BAAW,CACZ,CAAC;QACJ,IAAA,oBAAM,EACJ,kBAAkB,KAAK,SAAS,EAChC,2BAA2B,aAAa,CAAC,aAAa,GAAG,CAC1D,CAAC;QACF,KAA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AC;oBACtB,MAAM,cAAc,GAAG,IAAI,CAAC,cAAc,CAAC,iBAAiB,CAC1D,mBAAmB,CAAC,UAAU,EAC9B,mBAAmB,CAAC,SAAS,EAC7B,IAAI,CACL,CAAC;oBACF,IAAA,oBAAM,EACJ,cAAc,KAAK,SAAS,EAC5B,0BAA0B,IAAI,wCAAwC,CACvE,CAAC;oBACF,eAAe,CAAC,IAAI,CAClB,IAAI,CAAC,kBAAkB,CACrB,+BAAgB,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,cAAc,CAAC,CAClE,CAAC,IAAI,CAAC,CAAC,qBAAqB,EAAE,EAAE;wBAC/B,MAAM,cAAc,GAAG,+BAAgB,CAAC,MAAM,CAC5C,qBAAqB,CACtB,CAAC;wBACF,wDAAwD;wBACvD,wBAAgC,CAAC,IAAI,CAAC,GAAG;4BACxC,GAAI,wBAAgC,CAAC,IAAI,CAAC;4BAC1C,EAAE,EAAE,cAAc;yBACnB,CAAC;oBACJ,CAAC,CAAC,CACH,CAAC;gBACJ,CAAC;YACH,CAAC;iBAAM,IAAI,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,KAAK,QAAQ,CAAC,gBAAgB,EAAE,CAAC;gBACvE,wBAAgC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAChE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAChC,CAAC;YACJ,CAAC;QACH,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF;AAnSD,gDAmSC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\nimport { strict as assert } from \"node:assert\";\nimport { Id64, Id64String, Logger } from \"@itwin/core-bentley\";\nimport {\n Code,\n CodeScopeSpec,\n ConcreteEntityTypes,\n ECJsNames,\n ElementAspectProps,\n ElementProps,\n EntityReference,\n IModel,\n QueryBinder,\n RelatedElement,\n RelatedElementProps,\n} from \"@itwin/core-common\";\nimport {\n // eslint-disable-next-line @typescript-eslint/no-redeclare\n Element,\n ElementAspect,\n EntityReferences,\n IModelElementCloneContext,\n IModelJsNative,\n} from \"@itwin/core-backend\";\nimport { EntityClass } from \"@itwin/ecschema-metadata\";\nimport { ECReferenceTypesCache } from \"./ECReferenceTypesCache\";\nimport { EntityUnifier } from \"./EntityUnifier\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\nimport { BigMap } from \"./BigMap\";\n\nconst loggerCategory: string = TransformerLoggerCategory.IModelCloneContext;\n\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\n * @beta\n */\nexport class IModelCloneContext extends IModelElementCloneContext {\n private _refTypesCache = new ECReferenceTypesCache();\n private _aspectRemapTable = new BigMap<Id64String>();\n\n /** perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */\n public override async initialize() {\n await this._refTypesCache.initAllSchemasInIModel(this.sourceDb);\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public override async cloneElement(\n sourceElement: Element,\n cloneOptions?: IModelJsNative.CloneElementOptions\n ): Promise<ElementProps> {\n const targetElementProps: ElementProps = this[\n \"_nativeContext\"\n ].cloneElement(sourceElement.id, cloneOptions);\n // Ensure that all NavigationProperties in targetElementProps have a defined value so \"clearing\" changes will be part of the JSON used for update\n const sourceElementClass =\n sourceElement.iModel.schemaContext.getSchemaItemSync(\n sourceElement.schemaItemKey,\n EntityClass\n );\n assert(\n sourceElementClass !== undefined,\n `Cannot get metadata for ${sourceElement.classFullName}.`\n );\n for (const property of sourceElementClass.getPropertiesSync()) {\n // Exclude custom properties because C++ has already handled them.\n if (property.customAttributes?.has(\"BisCore.CustomHandledProperty\"))\n continue;\n\n const name = property.name;\n if (\n property.isNavigation() &&\n undefined === (sourceElement as any)[ECJsNames.toJsName(name)]\n ) {\n (targetElementProps as any)[ECJsNames.toJsName(name)] =\n RelatedElement.none;\n }\n }\n if (this.isBetweenIModels) {\n // The native C++ cloneElement strips off federationGuid, want to put it back if transformation is between iModels\n targetElementProps.federationGuid = sourceElement.federationGuid;\n const targetElementCodeScopeType = this.targetDb.codeSpecs.getById(\n targetElementProps.code.spec\n ).scopeType;\n if (\n CodeScopeSpec.Type.Repository === targetElementCodeScopeType &&\n targetElementProps.code.scope !== IModel.rootSubjectId\n ) {\n Logger.logWarning(\n loggerCategory,\n `Incorrect CodeScope '${targetElementCodeScopeType}' is set for target element ${targetElementProps.id}`\n );\n }\n }\n // unlike other references, code cannot be null. If it is null, use an empty code instead\n // this will be updated back later as the transformer resolves references\n if (\n targetElementProps.code.scope === Id64.invalid ||\n targetElementProps.code.spec === Id64.invalid\n ) {\n targetElementProps.code = Code.createEmpty();\n }\n const jsClass = this.sourceDb.getJsClass<typeof Element>(\n sourceElement.classFullName\n );\n await jsClass[\"onCloned\"](this, sourceElement.toJSON(), targetElementProps);\n return targetElementProps;\n }\n\n /** Add a rule that remaps the specified source ElementAspect to the specified target ElementAspect. */\n public remapElementAspect(\n aspectSourceId: Id64String,\n aspectTargetId: Id64String\n ): void {\n this._aspectRemapTable.set(aspectSourceId, aspectTargetId);\n }\n\n /** Remove a rule that remaps the specified source ElementAspect */\n public removeElementAspect(aspectSourceId: Id64String): void {\n this._aspectRemapTable.delete(aspectSourceId);\n }\n\n /** Look up a target AspectId from the source AspectId.\n * @returns the target AspectId or [Id64.invalid]($bentley) if a mapping not found.\n */\n public findTargetAspectId(sourceAspectId: Id64String): Id64String {\n return this._aspectRemapTable.get(sourceAspectId) ?? Id64.invalid;\n }\n\n /** Look up a target [EntityReference]($bentley) from a source [EntityReference]($bentley)\n * @returns the target CodeSpecId or a [EntityReference]($bentley) containing [Id64.invalid]($bentley) if a mapping is not found.\n */\n public async findTargetEntityId(\n sourceEntityId: EntityReference\n ): Promise<EntityReference> {\n const [type, rawId] = EntityReferences.split(sourceEntityId);\n if (Id64.isValid(rawId)) {\n switch (type) {\n case ConcreteEntityTypes.Model: {\n let targetId;\n /**\n * The repository model is a singleton container which exists in all iModels which has a modelId of 0x1.\n * It is possible to remap the root subject (id 0x1) to some other non root subject, but this is not possible for the repository model.\n * The RepositoryModel only contains bis:Subject elements and bis:InformationpartitionElement instances (https://www.itwinjs.org/bis/domains/biscore.ecschema/#repositorymodel)\n * The system handler for both bis:InformationPartitionElement and bis:Subject will only permit instances to be inserted into the RepositoryModel.\n * https://www.itwinjs.org/bis/domains/biscore.ecschema/#informationpartitionelement\n * https://www.itwinjs.org/bis/domains/biscore.ecschema/#subject\n * Since there is a chance that the root subject is remapped to some other subject which has the same id as the repositoryModel, we need to ignore the remapping for the repository model.\n */\n if (rawId === IModel.repositoryModelId) {\n targetId = `m${IModel.repositoryModelId}` as const;\n } else {\n targetId = `m${this.findTargetElementId(rawId)}` as const;\n }\n // Check if the model exists, `findTargetElementId` may have worked because the element exists when the model doesn't.\n // That can occur in the transformer since a submodeled element is imported before its submodel.\n if (\n await EntityUnifier.exists(this.targetDb, {\n entityReference: targetId,\n })\n )\n return targetId;\n break;\n }\n case ConcreteEntityTypes.Element:\n return `e${this.findTargetElementId(rawId)}`;\n case ConcreteEntityTypes.ElementAspect:\n return `a${this.findTargetAspectId(rawId)}`;\n case ConcreteEntityTypes.Relationship: {\n const makeGetConcreteEntityTypeSql = (property: string) => `\n CASE\n WHEN [${property}] IS (BisCore.ElementUniqueAspect) OR [${property}] IS (BisCore.ElementMultiAspect)\n THEN 'a'\n WHEN [${property}] IS (BisCore.Element)\n THEN 'e'\n WHEN [${property}] IS (BisCore.Model)\n THEN 'm'\n WHEN [${property}] IS (BisCore.CodeSpec)\n THEN 'c'\n WHEN [${property}] IS (BisCore.ElementRefersToElements) -- TODO: ElementDrivesElement still not handled by the transformer\n THEN 'r'\n ELSE 'error'\n END\n `;\n const sql = `\n SELECT\n SourceECInstanceId,\n TargetECInstanceId,\n (${makeGetConcreteEntityTypeSql(\n \"SourceECClassId\"\n )}) AS SourceType,\n (${makeGetConcreteEntityTypeSql(\"TargetECClassId\")}) AS TargetType\n FROM BisCore:ElementRefersToElements\n WHERE ECInstanceId=?\n `;\n const params = new QueryBinder().bindId(1, rawId);\n const reader = this.sourceDb.createQueryReader(sql, params, {\n usePrimaryConn: true,\n });\n const relInSource = await (async () => {\n if (await reader.step()) {\n const sourceId = reader.current[0];\n const targetId = reader.current[1];\n const sourceType = reader.current[2] as\n | ConcreteEntityTypes\n | \"error\";\n const targetType = reader.current[3] as\n | ConcreteEntityTypes\n | \"error\";\n if (sourceType === \"error\" || targetType === \"error\")\n throw Error(\"relationship end had unknown root class\");\n return {\n sourceId: `${sourceType}${sourceId}`,\n targetId: `${targetType}${targetId}`,\n } as const;\n }\n return undefined;\n })();\n if (relInSource === undefined) break;\n // just in case prevent recursion\n if (\n relInSource.sourceId === sourceEntityId ||\n relInSource.targetId === sourceEntityId\n )\n throw Error(\n \"link table relationship end was resolved to itself. This should be impossible\"\n );\n const relInTarget = {\n sourceId: await this.findTargetEntityId(relInSource.sourceId),\n targetId: await this.findTargetEntityId(relInSource.targetId),\n };\n // return a null\n if (\n !EntityReferences.isValid(relInTarget.sourceId) ||\n !EntityReferences.isValid(relInTarget.targetId)\n )\n break;\n const relInTargetSql = `\n SELECT ECInstanceId\n FROM BisCore:ElementRefersToElements\n WHERE SourceECInstanceId=?\n AND TargetECInstanceId=?\n `;\n const relInTargetParams = new QueryBinder();\n relInTargetParams.bindId(\n 1,\n EntityReferences.toId64(relInTarget.sourceId)\n );\n relInTargetParams.bindId(\n 2,\n EntityReferences.toId64(relInTarget.targetId)\n );\n const relInTargetResult = await this.targetDb\n .createQueryReader(relInTargetSql, relInTargetParams, {\n usePrimaryConn: true,\n })\n .next();\n const relInTargetId = relInTargetResult.done\n ? Id64.invalid\n : relInTargetResult.value.id;\n return `r${relInTargetId}`;\n }\n }\n }\n return `${type}${Id64.invalid}`;\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public async cloneElementAspect(\n sourceElementAspect: ElementAspect\n ): Promise<ElementAspectProps> {\n const targetElementAspectProps: ElementAspectProps =\n sourceElementAspect.toJSON();\n targetElementAspectProps.id = undefined;\n const targetEntityIds: Promise<void>[] = [];\n const sourceElementAspectClass =\n sourceElementAspect.iModel.schemaContext.getSchemaItemSync(\n sourceElementAspect.schemaItemKey,\n EntityClass\n );\n assert(\n sourceElementAspectClass !== undefined,\n `Cannot get metadata for ${sourceElementAspect.classFullName}.`\n );\n for (const property of sourceElementAspectClass.getPropertiesSync()) {\n const ecName = property.name;\n const name = ECJsNames.toJsName(ecName);\n if (property.isNavigation()) {\n const sourceNavProp: RelatedElementProps | undefined =\n sourceElementAspect.asAny[name];\n if (sourceNavProp?.id) {\n const navPropRefType = this._refTypesCache.getNavPropRefType(\n sourceElementAspect.schemaName,\n sourceElementAspect.className,\n name\n );\n assert(\n navPropRefType !== undefined,\n `nav prop ref type for '${name}' was not in the cache, this is a bug.`\n );\n targetEntityIds.push(\n this.findTargetEntityId(\n EntityReferences.fromEntityType(sourceNavProp.id, navPropRefType)\n ).then((targetEntityReference) => {\n const targetEntityId = EntityReferences.toId64(\n targetEntityReference\n );\n // spread the property in case toJSON did not deep-clone\n (targetElementAspectProps as any)[name] = {\n ...(targetElementAspectProps as any)[name],\n id: targetEntityId,\n };\n })\n );\n }\n } else if (property.isPrimitive() && \"Id\" === property.extendedTypeName) {\n (targetElementAspectProps as any)[name] = this.findTargetElementId(\n sourceElementAspect.asAny[name]\n );\n }\n }\n await Promise.all(targetEntityIds);\n return targetElementAspectProps;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"IModelCloneContext.js","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG;;GAEG;AACH,6CAA+C;AAC/C,sDAA+D;AAC/D,oDAY4B;AAC5B,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C/B,MAAM,cAAc,GAAG,+BAAgB,CAAC,MAAM,CAC5C,qBAAqB,CACtB,CAAC;wBACF,wDAAwD;wBACvD,wBAAgC,CAAC,IAAI,CAAC,GAAG;4BACxC,GAAI,wBAAgC,CAAC,IAAI,CAAC;4BAC1C,EAAE,EAAE,cAAc;yBACnB,CAAC;oBACJ,CAAC,CAAC,CACH,CAAC;gBACJ,CAAC;YACH,CAAC;iBAAM,IAAI,QAAQ,CAAC,WAAW,EAAE,IAAI,IAAI,KAAK,QAAQ,CAAC,gBAAgB,EAAE,CAAC;gBACvE,wBAAgC,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,mBAAmB,CAChE,mBAAmB,CAAC,KAAK,CAAC,IAAI,CAAC,CAChC,CAAC;YACJ,CAAC;QACH,CAAC;QACD,MAAM,OAAO,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC;QACnC,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF;AAtSD,gDAsSC","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\nimport { strict as assert } from \"node:assert\";\nimport { Id64, Id64String, Logger } from \"@itwin/core-bentley\";\nimport {\n Code,\n CodeScopeSpec,\n ConcreteEntityTypes,\n ECJsNames,\n ElementAspectProps,\n ElementProps,\n EntityReference,\n IModel,\n QueryBinder,\n RelatedElement,\n RelatedElementProps,\n} from \"@itwin/core-common\";\nimport {\n // eslint-disable-next-line @typescript-eslint/no-redeclare\n Element,\n ElementAspect,\n EntityReferences,\n IModelElementCloneContext,\n IModelJsNative,\n} from \"@itwin/core-backend\";\nimport { EntityClass } from \"@itwin/ecschema-metadata\";\nimport { ECReferenceTypesCache } from \"./ECReferenceTypesCache\";\nimport { EntityUnifier } from \"./EntityUnifier\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\nimport { BigMap } from \"./BigMap\";\nimport type { IModelTransformContext } from \"./IModelTransformContext\";\n\nconst loggerCategory: string = TransformerLoggerCategory.IModelCloneContext;\n\n/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.\n * @internal\n */\nexport class IModelCloneContext\n extends IModelElementCloneContext\n implements IModelTransformContext\n{\n private _refTypesCache = new ECReferenceTypesCache();\n private _aspectRemapTable = new BigMap<Id64String>();\n\n /** perform necessary initialization to use a clone context, namely caching the reference types in the source's schemas */\n public override async initialize() {\n await this._refTypesCache.initAllSchemasInIModel(this.sourceDb);\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public override async cloneElement(\n sourceElement: Element,\n cloneOptions?: IModelJsNative.CloneElementOptions\n ): Promise<ElementProps> {\n const targetElementProps: ElementProps = this[\n \"_nativeContext\"\n ].cloneElement(sourceElement.id, cloneOptions);\n // Ensure that all NavigationProperties in targetElementProps have a defined value so \"clearing\" changes will be part of the JSON used for update\n const sourceElementClass =\n sourceElement.iModel.schemaContext.getSchemaItemSync(\n sourceElement.schemaItemKey,\n EntityClass\n );\n assert(\n sourceElementClass !== undefined,\n `Cannot get metadata for ${sourceElement.classFullName}.`\n );\n for (const property of sourceElementClass.getPropertiesSync()) {\n // Exclude custom properties because C++ has already handled them.\n if (property.customAttributes?.has(\"BisCore.CustomHandledProperty\"))\n continue;\n\n const name = property.name;\n if (\n property.isNavigation() &&\n undefined === (sourceElement as any)[ECJsNames.toJsName(name)]\n ) {\n (targetElementProps as any)[ECJsNames.toJsName(name)] =\n RelatedElement.none;\n }\n }\n if (this.isBetweenIModels) {\n // The native C++ cloneElement strips off federationGuid, want to put it back if transformation is between iModels\n targetElementProps.federationGuid = sourceElement.federationGuid;\n const targetElementCodeScopeType = this.targetDb.codeSpecs.getById(\n targetElementProps.code.spec\n ).scopeType;\n if (\n CodeScopeSpec.Type.Repository === targetElementCodeScopeType &&\n targetElementProps.code.scope !== IModel.rootSubjectId\n ) {\n Logger.logWarning(\n loggerCategory,\n `Incorrect CodeScope '${targetElementCodeScopeType}' is set for target element ${targetElementProps.id}`\n );\n }\n }\n // unlike other references, code cannot be null. If it is null, use an empty code instead\n // this will be updated back later as the transformer resolves references\n if (\n targetElementProps.code.scope === Id64.invalid ||\n targetElementProps.code.spec === Id64.invalid\n ) {\n targetElementProps.code = Code.createEmpty();\n }\n const jsClass = this.sourceDb.getJsClass<typeof Element>(\n sourceElement.classFullName\n );\n await jsClass[\"onCloned\"](this, sourceElement.toJSON(), targetElementProps);\n return targetElementProps;\n }\n\n /** Add a rule that remaps the specified source ElementAspect to the specified target ElementAspect. */\n public remapElementAspect(\n aspectSourceId: Id64String,\n aspectTargetId: Id64String\n ): void {\n this._aspectRemapTable.set(aspectSourceId, aspectTargetId);\n }\n\n /** Remove a rule that remaps the specified source ElementAspect */\n public removeElementAspect(aspectSourceId: Id64String): void {\n this._aspectRemapTable.delete(aspectSourceId);\n }\n\n /** Look up a target AspectId from the source AspectId.\n * @returns the target AspectId or [Id64.invalid]($bentley) if a mapping not found.\n */\n public findTargetAspectId(sourceAspectId: Id64String): Id64String {\n return this._aspectRemapTable.get(sourceAspectId) ?? Id64.invalid;\n }\n\n /** Look up a target [EntityReference]($bentley) from a source [EntityReference]($bentley)\n * @returns the target CodeSpecId or a [EntityReference]($bentley) containing [Id64.invalid]($bentley) if a mapping is not found.\n */\n public async findTargetEntityId(\n sourceEntityId: EntityReference\n ): Promise<EntityReference> {\n const [type, rawId] = EntityReferences.split(sourceEntityId);\n if (Id64.isValid(rawId)) {\n switch (type) {\n case ConcreteEntityTypes.Model: {\n let targetId;\n /**\n * The repository model is a singleton container which exists in all iModels which has a modelId of 0x1.\n * It is possible to remap the root subject (id 0x1) to some other non root subject, but this is not possible for the repository model.\n * The RepositoryModel only contains bis:Subject elements and bis:InformationpartitionElement instances (https://www.itwinjs.org/bis/domains/biscore.ecschema/#repositorymodel)\n * The system handler for both bis:InformationPartitionElement and bis:Subject will only permit instances to be inserted into the RepositoryModel.\n * https://www.itwinjs.org/bis/domains/biscore.ecschema/#informationpartitionelement\n * https://www.itwinjs.org/bis/domains/biscore.ecschema/#subject\n * Since there is a chance that the root subject is remapped to some other subject which has the same id as the repositoryModel, we need to ignore the remapping for the repository model.\n */\n if (rawId === IModel.repositoryModelId) {\n targetId = `m${IModel.repositoryModelId}` as const;\n } else {\n targetId = `m${this.findTargetElementId(rawId)}` as const;\n }\n // Check if the model exists, `findTargetElementId` may have worked because the element exists when the model doesn't.\n // That can occur in the transformer since a submodeled element is imported before its submodel.\n if (\n await EntityUnifier.exists(this.targetDb, {\n entityReference: targetId,\n })\n )\n return targetId;\n break;\n }\n case ConcreteEntityTypes.Element:\n return `e${this.findTargetElementId(rawId)}`;\n case ConcreteEntityTypes.ElementAspect:\n return `a${this.findTargetAspectId(rawId)}`;\n case ConcreteEntityTypes.Relationship: {\n const makeGetConcreteEntityTypeSql = (property: string) => `\n CASE\n WHEN [${property}] IS (BisCore.ElementUniqueAspect) OR [${property}] IS (BisCore.ElementMultiAspect)\n THEN 'a'\n WHEN [${property}] IS (BisCore.Element)\n THEN 'e'\n WHEN [${property}] IS (BisCore.Model)\n THEN 'm'\n WHEN [${property}] IS (BisCore.CodeSpec)\n THEN 'c'\n WHEN [${property}] IS (BisCore.ElementRefersToElements) -- TODO: ElementDrivesElement still not handled by the transformer\n THEN 'r'\n ELSE 'error'\n END\n `;\n const sql = `\n SELECT\n SourceECInstanceId,\n TargetECInstanceId,\n (${makeGetConcreteEntityTypeSql(\n \"SourceECClassId\"\n )}) AS SourceType,\n (${makeGetConcreteEntityTypeSql(\"TargetECClassId\")}) AS TargetType\n FROM BisCore:ElementRefersToElements\n WHERE ECInstanceId=?\n `;\n const params = new QueryBinder().bindId(1, rawId);\n const reader = this.sourceDb.createQueryReader(sql, params, {\n usePrimaryConn: true,\n });\n const relInSource = await (async () => {\n if (await reader.step()) {\n const sourceId = reader.current[0];\n const targetId = reader.current[1];\n const sourceType = reader.current[2] as\n | ConcreteEntityTypes\n | \"error\";\n const targetType = reader.current[3] as\n | ConcreteEntityTypes\n | \"error\";\n if (sourceType === \"error\" || targetType === \"error\")\n throw Error(\"relationship end had unknown root class\");\n return {\n sourceId: `${sourceType}${sourceId}`,\n targetId: `${targetType}${targetId}`,\n } as const;\n }\n return undefined;\n })();\n if (relInSource === undefined) break;\n // just in case prevent recursion\n if (\n relInSource.sourceId === sourceEntityId ||\n relInSource.targetId === sourceEntityId\n )\n throw Error(\n \"link table relationship end was resolved to itself. This should be impossible\"\n );\n const relInTarget = {\n sourceId: await this.findTargetEntityId(relInSource.sourceId),\n targetId: await this.findTargetEntityId(relInSource.targetId),\n };\n // return a null\n if (\n !EntityReferences.isValid(relInTarget.sourceId) ||\n !EntityReferences.isValid(relInTarget.targetId)\n )\n break;\n const relInTargetSql = `\n SELECT ECInstanceId\n FROM BisCore:ElementRefersToElements\n WHERE SourceECInstanceId=?\n AND TargetECInstanceId=?\n `;\n const relInTargetParams = new QueryBinder();\n relInTargetParams.bindId(\n 1,\n EntityReferences.toId64(relInTarget.sourceId)\n );\n relInTargetParams.bindId(\n 2,\n EntityReferences.toId64(relInTarget.targetId)\n );\n const relInTargetResult = await this.targetDb\n .createQueryReader(relInTargetSql, relInTargetParams, {\n usePrimaryConn: true,\n })\n .next();\n const relInTargetId = relInTargetResult.done\n ? Id64.invalid\n : relInTargetResult.value.id;\n return `r${relInTargetId}`;\n }\n }\n }\n return `${type}${Id64.invalid}`;\n }\n\n /** Clone the specified source Element into ElementProps for the target iModel.\n * @internal\n */\n public async cloneElementAspect(\n sourceElementAspect: ElementAspect\n ): Promise<ElementAspectProps> {\n const targetElementAspectProps: ElementAspectProps =\n sourceElementAspect.toJSON();\n targetElementAspectProps.id = undefined;\n const targetEntityIds: Promise<void>[] = [];\n const sourceElementAspectClass =\n sourceElementAspect.iModel.schemaContext.getSchemaItemSync(\n sourceElementAspect.schemaItemKey,\n EntityClass\n );\n assert(\n sourceElementAspectClass !== undefined,\n `Cannot get metadata for ${sourceElementAspect.classFullName}.`\n );\n for (const property of sourceElementAspectClass.getPropertiesSync()) {\n const ecName = property.name;\n const name = ECJsNames.toJsName(ecName);\n if (property.isNavigation()) {\n const sourceNavProp: RelatedElementProps | undefined =\n sourceElementAspect.asAny[name];\n if (sourceNavProp?.id) {\n const navPropRefType = this._refTypesCache.getNavPropRefType(\n sourceElementAspect.schemaName,\n sourceElementAspect.className,\n name\n );\n assert(\n navPropRefType !== undefined,\n `nav prop ref type for '${name}' was not in the cache, this is a bug.`\n );\n targetEntityIds.push(\n this.findTargetEntityId(\n EntityReferences.fromEntityType(sourceNavProp.id, navPropRefType)\n ).then((targetEntityReference) => {\n const targetEntityId = EntityReferences.toId64(\n targetEntityReference\n );\n // spread the property in case toJSON did not deep-clone\n (targetElementAspectProps as any)[name] = {\n ...(targetElementAspectProps as any)[name],\n id: targetEntityId,\n };\n })\n );\n }\n } else if (property.isPrimitive() && \"Id\" === property.extendedTypeName) {\n (targetElementAspectProps as any)[name] = this.findTargetElementId(\n sourceElementAspect.asAny[name]\n );\n }\n }\n await Promise.all(targetEntityIds);\n return targetElementAspectProps;\n }\n}\n"]}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/** @packageDocumentation
|
|
2
|
+
* @module iModels
|
|
3
|
+
*/
|
|
4
|
+
import type { Id64String } from "@itwin/core-bentley";
|
|
5
|
+
import type { EntityReference } from "@itwin/core-common";
|
|
6
|
+
/** The supported transformation context exposed by an [[IModelTransformer]].
|
|
7
|
+
*
|
|
8
|
+
* Use [[IModelTransformer.context]] to obtain this context. It records source-to-target mappings,
|
|
9
|
+
* accepts explicit mapping and geometry-filtering rules, and resolves transformed entities.
|
|
10
|
+
* Element cloning, database access, native resource management, and context persistence remain
|
|
11
|
+
* implementation details of the transformer.
|
|
12
|
+
* @beta
|
|
13
|
+
*/
|
|
14
|
+
export interface IModelTransformContext {
|
|
15
|
+
/** Whether this context maps entities between two different iModels. */
|
|
16
|
+
readonly isBetweenIModels: boolean;
|
|
17
|
+
/** Find the target element corresponding to a source element.
|
|
18
|
+
* @returns The target element ID, or [Id64.invalid]($bentley) if no mapping exists.
|
|
19
|
+
*/
|
|
20
|
+
findTargetElementId(sourceElementId: Id64String): Id64String;
|
|
21
|
+
/** Find the target element aspect corresponding to a source element aspect.
|
|
22
|
+
* @returns The target aspect ID, or [Id64.invalid]($bentley) if no mapping exists.
|
|
23
|
+
*/
|
|
24
|
+
findTargetAspectId(sourceAspectId: Id64String): Id64String;
|
|
25
|
+
/** Find the target CodeSpec corresponding to a source CodeSpec.
|
|
26
|
+
* @returns The target CodeSpec ID, or [Id64.invalid]($bentley) if no mapping exists.
|
|
27
|
+
*/
|
|
28
|
+
findTargetCodeSpecId(sourceCodeSpecId: Id64String): Id64String;
|
|
29
|
+
/** Find the target entity corresponding to a typed source entity reference.
|
|
30
|
+
* @returns The typed target entity reference, containing [Id64.invalid]($bentley) if no mapping exists.
|
|
31
|
+
*/
|
|
32
|
+
findTargetEntityId(sourceEntityId: EntityReference): Promise<EntityReference>;
|
|
33
|
+
/** Add or replace a mapping from a source element to a target element. */
|
|
34
|
+
remapElement(sourceElementId: Id64String, targetElementId: Id64String): void;
|
|
35
|
+
/** Remove the mapping for a source element. */
|
|
36
|
+
removeElement(sourceElementId: Id64String): void;
|
|
37
|
+
/** Add or replace a mapping from a source element aspect to a target element aspect. */
|
|
38
|
+
remapElementAspect(sourceAspectId: Id64String, targetAspectId: Id64String): void;
|
|
39
|
+
/** Remove the mapping for a source element aspect. */
|
|
40
|
+
removeElementAspect(sourceAspectId: Id64String): void;
|
|
41
|
+
/** Add or replace a mapping from a source element class to a target element class. */
|
|
42
|
+
remapElementClass(sourceClassFullName: string, targetClassFullName: string): void;
|
|
43
|
+
/** Add or replace a mapping from a source CodeSpec to a target CodeSpec. */
|
|
44
|
+
remapCodeSpec(sourceCodeSpecName: string, targetCodeSpecName: string): void;
|
|
45
|
+
/** Exclude geometry belonging to a source SubCategory from cloned geometry streams.
|
|
46
|
+
* Requests to filter a default SubCategory are ignored.
|
|
47
|
+
*/
|
|
48
|
+
filterSubCategory(sourceSubCategoryId: Id64String): void;
|
|
49
|
+
/** Whether any SubCategories are currently filtered. */
|
|
50
|
+
readonly hasSubCategoryFilter: boolean;
|
|
51
|
+
/** Determine whether a source SubCategory is currently filtered. */
|
|
52
|
+
isSubCategoryFiltered(sourceSubCategoryId: Id64String): boolean;
|
|
53
|
+
}
|
|
54
|
+
//# sourceMappingURL=IModelTransformContext.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelTransformContext.d.ts","sourceRoot":"","sources":["../../src/IModelTransformContext.ts"],"names":[],"mappings":"AAIA;;GAEG;AACH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAE1D;;;;;;;GAOG;AACH,MAAM,WAAW,sBAAsB;IACrC,wEAAwE;IACxE,QAAQ,CAAC,gBAAgB,EAAE,OAAO,CAAC;IAEnC;;OAEG;IACH,mBAAmB,CAAC,eAAe,EAAE,UAAU,GAAG,UAAU,CAAC;IAE7D;;OAEG;IACH,kBAAkB,CAAC,cAAc,EAAE,UAAU,GAAG,UAAU,CAAC;IAE3D;;OAEG;IACH,oBAAoB,CAAC,gBAAgB,EAAE,UAAU,GAAG,UAAU,CAAC;IAE/D;;OAEG;IACH,kBAAkB,CAAC,cAAc,EAAE,eAAe,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC;IAE9E,0EAA0E;IAC1E,YAAY,CAAC,eAAe,EAAE,UAAU,EAAE,eAAe,EAAE,UAAU,GAAG,IAAI,CAAC;IAE7E,+CAA+C;IAC/C,aAAa,CAAC,eAAe,EAAE,UAAU,GAAG,IAAI,CAAC;IAEjD,wFAAwF;IACxF,kBAAkB,CAChB,cAAc,EAAE,UAAU,EAC1B,cAAc,EAAE,UAAU,GACzB,IAAI,CAAC;IAER,sDAAsD;IACtD,mBAAmB,CAAC,cAAc,EAAE,UAAU,GAAG,IAAI,CAAC;IAEtD,sFAAsF;IACtF,iBAAiB,CACf,mBAAmB,EAAE,MAAM,EAC3B,mBAAmB,EAAE,MAAM,GAC1B,IAAI,CAAC;IAER,4EAA4E;IAC5E,aAAa,CAAC,kBAAkB,EAAE,MAAM,EAAE,kBAAkB,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5E;;OAEG;IACH,iBAAiB,CAAC,mBAAmB,EAAE,UAAU,GAAG,IAAI,CAAC;IAEzD,wDAAwD;IACxD,QAAQ,CAAC,oBAAoB,EAAE,OAAO,CAAC;IAEvC,oEAAoE;IACpE,qBAAqB,CAAC,mBAAmB,EAAE,UAAU,GAAG,OAAO,CAAC;CACjE"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IModelTransformContext.js","sourceRoot":"","sources":["../../src/IModelTransformContext.ts"],"names":[],"mappings":"","sourcesContent":["/*---------------------------------------------------------------------------------------------\n * Copyright (c) Bentley Systems, Incorporated. All rights reserved.\n * See LICENSE.md in the project root for license terms and full copyright notice.\n *--------------------------------------------------------------------------------------------*/\n/** @packageDocumentation\n * @module iModels\n */\nimport type { Id64String } from \"@itwin/core-bentley\";\nimport type { EntityReference } from \"@itwin/core-common\";\n\n/** The supported transformation context exposed by an [[IModelTransformer]].\n *\n * Use [[IModelTransformer.context]] to obtain this context. It records source-to-target mappings,\n * accepts explicit mapping and geometry-filtering rules, and resolves transformed entities.\n * Element cloning, database access, native resource management, and context persistence remain\n * implementation details of the transformer.\n * @beta\n */\nexport interface IModelTransformContext {\n /** Whether this context maps entities between two different iModels. */\n readonly isBetweenIModels: boolean;\n\n /** Find the target element corresponding to a source element.\n * @returns The target element ID, or [Id64.invalid]($bentley) if no mapping exists.\n */\n findTargetElementId(sourceElementId: Id64String): Id64String;\n\n /** Find the target element aspect corresponding to a source element aspect.\n * @returns The target aspect ID, or [Id64.invalid]($bentley) if no mapping exists.\n */\n findTargetAspectId(sourceAspectId: Id64String): Id64String;\n\n /** Find the target CodeSpec corresponding to a source CodeSpec.\n * @returns The target CodeSpec ID, or [Id64.invalid]($bentley) if no mapping exists.\n */\n findTargetCodeSpecId(sourceCodeSpecId: Id64String): Id64String;\n\n /** Find the target entity corresponding to a typed source entity reference.\n * @returns The typed target entity reference, containing [Id64.invalid]($bentley) if no mapping exists.\n */\n findTargetEntityId(sourceEntityId: EntityReference): Promise<EntityReference>;\n\n /** Add or replace a mapping from a source element to a target element. */\n remapElement(sourceElementId: Id64String, targetElementId: Id64String): void;\n\n /** Remove the mapping for a source element. */\n removeElement(sourceElementId: Id64String): void;\n\n /** Add or replace a mapping from a source element aspect to a target element aspect. */\n remapElementAspect(\n sourceAspectId: Id64String,\n targetAspectId: Id64String\n ): void;\n\n /** Remove the mapping for a source element aspect. */\n removeElementAspect(sourceAspectId: Id64String): void;\n\n /** Add or replace a mapping from a source element class to a target element class. */\n remapElementClass(\n sourceClassFullName: string,\n targetClassFullName: string\n ): void;\n\n /** Add or replace a mapping from a source CodeSpec to a target CodeSpec. */\n remapCodeSpec(sourceCodeSpecName: string, targetCodeSpecName: string): void;\n\n /** Exclude geometry belonging to a source SubCategory from cloned geometry streams.\n * Requests to filter a default SubCategory are ignored.\n */\n filterSubCategory(sourceSubCategoryId: Id64String): void;\n\n /** Whether any SubCategories are currently filtered. */\n readonly hasSubCategoryFilter: boolean;\n\n /** Determine whether a source SubCategory is currently filtered. */\n isSubCategoryFiltered(sourceSubCategoryId: Id64String): boolean;\n}\n"]}
|
|
@@ -5,7 +5,7 @@ import { EditTxn, Element, ElementAspect, ElementMultiAspect, ElementUniqueAspec
|
|
|
5
5
|
import { ChangesetIndexAndId, CodeSpec, ElementAspectProps, ElementProps, ExternalSourceAspectProps, FontProps, Helmert2DWithZOffset, ModelProps, Placement2d, Placement3d } from "@itwin/core-common";
|
|
6
6
|
import { ChangedInstanceIds, ExportChangesOptions, ExportSchemaResult, IModelExporter, IModelExportHandler } from "./IModelExporter";
|
|
7
7
|
import { IModelImporter, OptimizeGeometryOptions } from "./IModelImporter";
|
|
8
|
-
import {
|
|
8
|
+
import type { IModelTransformContext } from "./IModelTransformContext";
|
|
9
9
|
import { ProvenanceManager } from "./ProvenanceManager";
|
|
10
10
|
/** Required arguments for the [[IModelTransformer]] constructor.
|
|
11
11
|
* @beta
|
|
@@ -227,8 +227,10 @@ export declare class IModelTransformer extends IModelExportHandler {
|
|
|
227
227
|
readonly sourceDb: IModelDb;
|
|
228
228
|
/** The read/write target iModel. */
|
|
229
229
|
readonly targetDb: IModelDb;
|
|
230
|
-
/** The
|
|
231
|
-
|
|
230
|
+
/** The supported transformation context for this transformer. */
|
|
231
|
+
get context(): IModelTransformContext;
|
|
232
|
+
/** The clone context used by the transformer implementation. */
|
|
233
|
+
private readonly _cloneContext;
|
|
232
234
|
/** The transform to be applied to the placement of spatial elements
|
|
233
235
|
* This transform should be applied when:
|
|
234
236
|
* - source and target db have different ECEF locations
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelTransformer.d.ts","sourceRoot":"","sources":["../../src/IModelTransformer.ts"],"names":[],"mappings":"AAUA,OAAO,EAIL,SAAS,EACT,OAAO,EACP,UAAU,EAMX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,gBAAgB,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAKL,SAAS,EAEV,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAUL,OAAO,EAEP,OAAO,EACP,aAAa,EACb,kBAAkB,EAElB,mBAAmB,EACnB,MAAM,EAEN,oBAAoB,EAGpB,QAAQ,EAKR,KAAK,EAEL,YAAY,EACZ,iBAAiB,EAGlB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAEL,mBAAmB,EAGnB,QAAQ,EAGR,kBAAkB,EAClB,YAAY,EAEZ,yBAAyB,EACzB,SAAS,EAGT,oBAAoB,EAGpB,UAAU,EACV,WAAW,EACX,WAAW,EAIZ,MAAM,oBAAo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@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
80
80
|
sourceDb;
|
|
81
81
|
/** The read/write target iModel. */
|
|
82
82
|
targetDb;
|
|
83
|
-
/** The
|
|
84
|
-
context
|
|
83
|
+
/** The supported transformation context for this transformer. */
|
|
84
|
+
get context() {
|
|
85
|
+
return this._cloneContext;
|
|
86
|
+
}
|
|
87
|
+
/** The clone context used by the transformer implementation. */
|
|
88
|
+
_cloneContext;
|
|
85
89
|
/** The transform to be applied to the placement of spatial elements
|
|
86
90
|
* This transform should be applied when:
|
|
87
91
|
* - source and target db have different ECEF locations
|
|
@@ -198,7 +202,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
198
202
|
this._sourceEditTxn = options?.sourceEditTxn;
|
|
199
203
|
this.exporter.elementAspectExportCoordinator.setPreparation(async (excludedClasses, elementIds) => this.prepareElementAspects(excludedClasses, elementIds));
|
|
200
204
|
// create the IModelCloneContext, it must be initialized later
|
|
201
|
-
this.
|
|
205
|
+
this._cloneContext = new IModelCloneContext_1.IModelCloneContext(this.sourceDb, this.targetDb);
|
|
202
206
|
// this internal is guaranteed stable for just transformer usage
|
|
203
207
|
/* eslint-disable @itwin/no-internal */
|
|
204
208
|
if (("codeValueBehavior" in this.sourceDb)) {
|
|
@@ -206,8 +210,8 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
206
210
|
this.targetDb.codeValueBehavior = "exact";
|
|
207
211
|
}
|
|
208
212
|
/* eslint-enable @itwin/no-internal */
|
|
209
|
-
this._syncTypeResolver = new SyncTypeResolver_1.SyncTypeResolver(this.
|
|
210
|
-
this._provenanceManager = new ProvenanceManager_1.ProvenanceManager(this._options.targetScopeElementId, this._options, this._syncTypeResolver, this._targetEditTxn, this._sourceEditTxn);
|
|
213
|
+
this._syncTypeResolver = new SyncTypeResolver_1.SyncTypeResolver(this.sourceDb, this.targetDb, this._options.targetScopeElementId, !!this._isProvenanceInitTransform, !!this._options.argsForProcessChanges);
|
|
214
|
+
this._provenanceManager = new ProvenanceManager_1.ProvenanceManager(this._options.targetScopeElementId, this._options, this._cloneContext, this._syncTypeResolver, this._targetEditTxn, this._sourceEditTxn);
|
|
211
215
|
if (this._options.tryAlignGeolocation) {
|
|
212
216
|
if (this.sourceDb.geographicCoordinateSystem ||
|
|
213
217
|
this.targetDb.geographicCoordinateSystem) {
|
|
@@ -251,7 +255,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
251
255
|
/** Dispose any native resources associated with this IModelTransformer. */
|
|
252
256
|
dispose() {
|
|
253
257
|
core_bentley_1.Logger.logTrace(loggerCategory, "dispose()");
|
|
254
|
-
this.
|
|
258
|
+
this._cloneContext[Symbol.dispose]();
|
|
255
259
|
}
|
|
256
260
|
/** Log current settings that affect IModelTransformer's behavior. */
|
|
257
261
|
logSettings() {
|
|
@@ -348,7 +352,9 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
348
352
|
*/
|
|
349
353
|
async onTransformElement(sourceElement) {
|
|
350
354
|
core_bentley_1.Logger.logTrace(loggerCategory, `onTransformElement(${sourceElement.id}) "${sourceElement.getDisplayLabel()}"`);
|
|
351
|
-
const targetElementProps = await this.
|
|
355
|
+
const targetElementProps = await this._cloneContext.cloneElement(sourceElement, {
|
|
356
|
+
binaryGeometry: this._options.cloneUsingBinaryGeometry,
|
|
357
|
+
});
|
|
352
358
|
// Special case: source element is the root subject
|
|
353
359
|
if (sourceElement.id === core_common_1.IModel.rootSubjectId) {
|
|
354
360
|
const targetElementId = this.context.findTargetElementId(sourceElement.id);
|
|
@@ -1169,7 +1175,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
1169
1175
|
* @note A subclass can override this method to provide custom transform behavior.
|
|
1170
1176
|
*/
|
|
1171
1177
|
async onTransformElementAspect(sourceElementAspect) {
|
|
1172
|
-
const targetElementAspectProps = await this.
|
|
1178
|
+
const targetElementAspectProps = await this._cloneContext.cloneElementAspect(sourceElementAspect);
|
|
1173
1179
|
return targetElementAspectProps;
|
|
1174
1180
|
}
|
|
1175
1181
|
/** The directory where schemas will be exported, a random temporary directory */
|
|
@@ -1264,7 +1270,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
1264
1270
|
}
|
|
1265
1271
|
/** Override of [IModelExportHandler.onExportFont]($transformer) that imports a font into the target iModel when it is exported from the source iModel. */
|
|
1266
1272
|
async onExportFont(font, _isUpdate) {
|
|
1267
|
-
this.
|
|
1273
|
+
this._cloneContext.importFont(font.id);
|
|
1268
1274
|
}
|
|
1269
1275
|
/** Cause all CodeSpecs to be exported from the source iModel and imported into the target iModel.
|
|
1270
1276
|
* @note This method is called from [[process]], so it only needs to be called directly when processing a subset of an iModel.
|
|
@@ -1288,7 +1294,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
1288
1294
|
}
|
|
1289
1295
|
/** Override of [IModelExportHandler.onExportCodeSpec]($transformer) that imports a CodeSpec into the target iModel when it is exported from the source iModel. */
|
|
1290
1296
|
async onExportCodeSpec(sourceCodeSpec) {
|
|
1291
|
-
this.
|
|
1297
|
+
this._cloneContext.importCodeSpec(sourceCodeSpec.id);
|
|
1292
1298
|
}
|
|
1293
1299
|
/** Recursively import all Elements and sub-Models that descend from the specified Subject */
|
|
1294
1300
|
async processSubject(sourceSubjectId, targetSubjectId) {
|
|
@@ -1321,7 +1327,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
1321
1327
|
this.assertEditTxnActive();
|
|
1322
1328
|
await this.initScopeProvenance();
|
|
1323
1329
|
await this._tryInitChangesetData(this._options.argsForProcessChanges);
|
|
1324
|
-
await this.
|
|
1330
|
+
await this._cloneContext.initialize();
|
|
1325
1331
|
const exporterInitOptions = await this.getExportInitOpts(this._options.argsForProcessChanges ?? {});
|
|
1326
1332
|
await this.initializeChangesetScanAndExporter(exporterInitOptions);
|
|
1327
1333
|
// Exporter must be initialized prior to processing changesets in order to properly handle entity recreations (an entity delete followed by an insert of that same entity).
|