@itwin/imodel-transformer 1.0.0-dev.1 → 1.0.0-dev.3
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/lib/cjs/IModelCloneContext.d.ts +1 -4
- package/lib/cjs/IModelCloneContext.d.ts.map +1 -1
- package/lib/cjs/IModelCloneContext.js +0 -30
- package/lib/cjs/IModelCloneContext.js.map +1 -1
- package/lib/cjs/IModelExporter.d.ts +5 -52
- package/lib/cjs/IModelExporter.d.ts.map +1 -1
- package/lib/cjs/IModelExporter.js +6 -60
- package/lib/cjs/IModelExporter.js.map +1 -1
- package/lib/cjs/IModelImporter.d.ts +4 -43
- package/lib/cjs/IModelImporter.d.ts.map +1 -1
- package/lib/cjs/IModelImporter.js +1 -49
- package/lib/cjs/IModelImporter.js.map +1 -1
- package/lib/cjs/IModelTransformer.d.ts +19 -57
- package/lib/cjs/IModelTransformer.d.ts.map +1 -1
- package/lib/cjs/IModelTransformer.js +119 -304
- package/lib/cjs/IModelTransformer.js.map +1 -1
- package/package.json +15 -14
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Id64String } from "@itwin/core-bentley";
|
|
2
2
|
import { ElementAspectProps, ElementProps, EntityReference } from "@itwin/core-common";
|
|
3
|
-
import { Element, ElementAspect, IModelElementCloneContext, IModelJsNative
|
|
3
|
+
import { Element, ElementAspect, IModelElementCloneContext, IModelJsNative } from "@itwin/core-backend";
|
|
4
4
|
/** The context for transforming a *source* Element to a *target* Element and remapping internal identifiers to the target iModel.
|
|
5
5
|
* @beta
|
|
6
6
|
*/
|
|
@@ -29,8 +29,5 @@ export declare class IModelCloneContext extends IModelElementCloneContext {
|
|
|
29
29
|
* @internal
|
|
30
30
|
*/
|
|
31
31
|
cloneElementAspect(sourceElementAspect: ElementAspect): ElementAspectProps;
|
|
32
|
-
private static aspectRemapTableName;
|
|
33
|
-
saveStateToDb(db: SQLiteDb): void;
|
|
34
|
-
loadStateFromDb(db: SQLiteDb): void;
|
|
35
32
|
}
|
|
36
33
|
//# sourceMappingURL=IModelCloneContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelCloneContext.d.ts","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkB,UAAU,EAAU,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAIL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EAOhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,OAAO,EACP,aAAa,EAEb,yBAAyB,EACzB,cAAc,
|
|
1
|
+
{"version":3,"file":"IModelCloneContext.d.ts","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":"AAQA,OAAO,EAAkB,UAAU,EAAU,MAAM,qBAAqB,CAAC;AACzE,OAAO,EAIL,kBAAkB,EAClB,YAAY,EACZ,eAAe,EAOhB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EACL,OAAO,EACP,aAAa,EAEb,yBAAyB,EACzB,cAAc,EAEf,MAAM,qBAAqB,CAAC;AAO7B;;GAEG;AACH,qBAAa,kBAAmB,SAAQ,yBAAyB;IAC/D,OAAO,CAAC,cAAc,CAA+B;IACrD,OAAO,CAAC,iBAAiB,CAAqC;IAE9D,0HAA0H;IACpG,UAAU;IAIhC;;OAEG;IACa,YAAY,CAC1B,aAAa,EAAE,OAAO,EACtB,YAAY,CAAC,EAAE,cAAc,CAAC,mBAAmB,GAChD,YAAY;IA+Cf,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;IACI,kBAAkB,CAAC,cAAc,EAAE,eAAe,GAAG,eAAe;IAkH3E;;OAEG;IACI,kBAAkB,CACvB,mBAAmB,EAAE,aAAa,GACjC,kBAAkB;CAsCtB"}
|
|
@@ -200,36 +200,6 @@ class IModelCloneContext extends core_backend_1.IModelElementCloneContext {
|
|
|
200
200
|
});
|
|
201
201
|
return targetElementAspectProps;
|
|
202
202
|
}
|
|
203
|
-
saveStateToDb(db) {
|
|
204
|
-
super.saveStateToDb(db);
|
|
205
|
-
if (core_bentley_1.DbResult.BE_SQLITE_DONE !==
|
|
206
|
-
db.executeSQL(`CREATE TABLE ${IModelCloneContext.aspectRemapTableName} (Source INTEGER, Target INTEGER)`))
|
|
207
|
-
throw Error("Failed to create the aspect remap table in the state database");
|
|
208
|
-
db.saveChanges();
|
|
209
|
-
db.withPreparedSqliteStatement(`INSERT INTO ${IModelCloneContext.aspectRemapTableName} (Source, Target) VALUES (?, ?)`, (stmt) => {
|
|
210
|
-
for (const [source, target] of this._aspectRemapTable) {
|
|
211
|
-
stmt.reset();
|
|
212
|
-
stmt.bindId(1, source);
|
|
213
|
-
stmt.bindId(2, target);
|
|
214
|
-
if (core_bentley_1.DbResult.BE_SQLITE_DONE !== stmt.step())
|
|
215
|
-
throw Error("Failed to insert aspect remapping into the state database");
|
|
216
|
-
}
|
|
217
|
-
});
|
|
218
|
-
}
|
|
219
|
-
loadStateFromDb(db) {
|
|
220
|
-
super.loadStateFromDb(db);
|
|
221
|
-
// FIXME: test this
|
|
222
|
-
db.withSqliteStatement(`SELECT Source, Target FROM ${IModelCloneContext.aspectRemapTableName}`, (stmt) => {
|
|
223
|
-
let status = core_bentley_1.DbResult.BE_SQLITE_ERROR;
|
|
224
|
-
while ((status = stmt.step()) === core_bentley_1.DbResult.BE_SQLITE_ROW) {
|
|
225
|
-
const source = stmt.getValue(0).getId();
|
|
226
|
-
const target = stmt.getValue(1).getId();
|
|
227
|
-
this._aspectRemapTable.set(source, target);
|
|
228
|
-
}
|
|
229
|
-
assert(status === core_bentley_1.DbResult.BE_SQLITE_DONE);
|
|
230
|
-
});
|
|
231
|
-
}
|
|
232
203
|
}
|
|
233
204
|
exports.IModelCloneContext = IModelCloneContext;
|
|
234
|
-
IModelCloneContext.aspectRemapTableName = "AspectIdRemaps";
|
|
235
205
|
//# sourceMappingURL=IModelCloneContext.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelCloneContext.js","sourceRoot":"","sources":["../../src/IModelCloneContext.ts"],"names":[],"mappings":";;;AAAA;;;gGAGgG;AAChG;;GAEG;AACH,iCAAiC;AACjC,sDAAyE;AACzE,oDAa4B;AAC5B,sDAO6B;AAC7B,mEAAgE;AAChE,mDAAgD;AAChD,2EAAwE;AAExE,MAAM,cAAc,GAAW,qDAAyB,CAAC,kBAAkB,CAAC;AAE5E;;GAEG;AACH,MAAa,kBAAmB,SAAQ,wCAAyB;IAAjE;;QACU,mBAAc,GAAG,IAAI,6CAAqB,EAAE,CAAC;QAC7C,sBAAiB,GAAG,IAAI,GAAG,EAA0B,CAAC;IA+RhE,CAAC;IA7RC,0HAA0H;IAC1G,KAAK,CAAC,UAAU;QAC9B,MAAM,IAAI,CAAC,cAAc,CAAC,sBAAsB,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC;IAClE,CAAC;IAED;;OAEG;IACa,YAAY,CAC1B,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,aAAa,CAAC,eAAe,CAC3B,CAAC,YAAoB,EAAE,IAAsB,EAAE,EAAE;YAC/C,IACE,IAAI,CAAC,YAAY;gBACjB,SAAS,KAAM,aAAqB,CAAC,YAAY,CAAC,EAClD;gBACC,kBAA0B,CAAC,YAAY,CAAC,GAAG,4BAAc,CAAC,IAAI,CAAC;aACjE;QACH,CAAC,EACD,KAAK,CACN,CAAC,CAAC,sDAAsD;QACzD,IAAI,IAAI,CAAC,gBAAgB,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B,AAAnB,CAAoB","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 * as assert from \"assert\";\nimport { DbResult, Id64, Id64String, Logger } from \"@itwin/core-bentley\";\nimport {\n Code,\n CodeScopeSpec,\n ConcreteEntityTypes,\n ElementAspectProps,\n ElementProps,\n EntityReference,\n IModel,\n IModelError,\n PrimitiveTypeCode,\n PropertyMetaData,\n RelatedElement,\n RelatedElementProps,\n} from \"@itwin/core-common\";\nimport {\n Element,\n ElementAspect,\n EntityReferences,\n IModelElementCloneContext,\n IModelJsNative,\n SQLiteDb,\n} from \"@itwin/core-backend\";\nimport { ECReferenceTypesCache } from \"./ECReferenceTypesCache\";\nimport { EntityUnifier } from \"./EntityUnifier\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\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 Map<Id64String, 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 cloneElement(\n sourceElement: Element,\n cloneOptions?: IModelJsNative.CloneElementOptions\n ): 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 sourceElement.forEachProperty(\n (propertyName: string, meta: PropertyMetaData) => {\n if (\n meta.isNavigation &&\n undefined === (sourceElement as any)[propertyName]\n ) {\n (targetElementProps as any)[propertyName] = RelatedElement.none;\n }\n },\n false\n ); // exclude custom because C++ has already handled them\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 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 findTargetEntityId(sourceEntityId: EntityReference): EntityReference {\n const [type, rawId] = EntityReferences.split(sourceEntityId);\n if (Id64.isValid(rawId)) {\n switch (type) {\n case ConcreteEntityTypes.Model: {\n const targetId = `m${this.findTargetElementId(rawId)}` as const;\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 EntityUnifier.exists(this.targetDb, { entityReference: targetId })\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 relInSource = this.sourceDb.withPreparedStatement(\n `\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 (stmt) => {\n stmt.bindId(1, rawId);\n let status: DbResult;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const sourceId = stmt.getValue(0).getId();\n const targetId = stmt.getValue(1).getId();\n const sourceType = stmt.getValue(2).getString() as\n | ConcreteEntityTypes\n | \"error\";\n const targetType = stmt.getValue(3).getString() 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 if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n return undefined;\n }\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: this.findTargetEntityId(relInSource.sourceId),\n targetId: 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 relInTargetId = this.targetDb.withPreparedStatement(\n `\n SELECT ECInstanceId\n FROM BisCore:ElementRefersToElements\n WHERE SourceECInstanceId=?\n AND TargetECInstanceId=?\n `,\n (stmt) => {\n stmt.bindId(1, EntityReferences.toId64(relInTarget.sourceId));\n stmt.bindId(2, EntityReferences.toId64(relInTarget.targetId));\n const status: DbResult = stmt.step();\n if (status === DbResult.BE_SQLITE_ROW)\n return stmt.getValue(0).getId();\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n return Id64.invalid;\n }\n );\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 cloneElementAspect(\n sourceElementAspect: ElementAspect\n ): ElementAspectProps {\n const targetElementAspectProps: ElementAspectProps =\n sourceElementAspect.toJSON();\n targetElementAspectProps.id = undefined;\n sourceElementAspect.forEachProperty((propertyName, propertyMetaData) => {\n if (propertyMetaData.isNavigation) {\n const sourceNavProp: RelatedElementProps | undefined =\n sourceElementAspect.asAny[propertyName];\n if (sourceNavProp?.id) {\n const navPropRefType = this._refTypesCache.getNavPropRefType(\n sourceElementAspect.schemaName,\n sourceElementAspect.className,\n propertyName\n );\n assert(\n navPropRefType !== undefined,\n `nav prop ref type for '${propertyName}' was not in the cache, this is a bug.`\n );\n const targetEntityReference = this.findTargetEntityId(\n EntityReferences.fromEntityType(sourceNavProp.id, navPropRefType)\n );\n const targetEntityId = EntityReferences.toId64(targetEntityReference);\n // spread the property in case toJSON did not deep-clone\n (targetElementAspectProps as any)[propertyName] = {\n ...(targetElementAspectProps as any)[propertyName],\n id: targetEntityId,\n };\n }\n } else if (\n PrimitiveTypeCode.Long === propertyMetaData.primitiveType &&\n \"Id\" === propertyMetaData.extendedType\n ) {\n (targetElementAspectProps as any)[propertyName] =\n this.findTargetElementId(sourceElementAspect.asAny[propertyName]);\n }\n });\n return targetElementAspectProps;\n }\n\n private static aspectRemapTableName = \"AspectIdRemaps\";\n\n public override saveStateToDb(db: SQLiteDb): void {\n super.saveStateToDb(db);\n if (\n DbResult.BE_SQLITE_DONE !==\n db.executeSQL(\n `CREATE TABLE ${IModelCloneContext.aspectRemapTableName} (Source INTEGER, Target INTEGER)`\n )\n )\n throw Error(\n \"Failed to create the aspect remap table in the state database\"\n );\n db.saveChanges();\n db.withPreparedSqliteStatement(\n `INSERT INTO ${IModelCloneContext.aspectRemapTableName} (Source, Target) VALUES (?, ?)`,\n (stmt) => {\n for (const [source, target] of this._aspectRemapTable) {\n stmt.reset();\n stmt.bindId(1, source);\n stmt.bindId(2, target);\n if (DbResult.BE_SQLITE_DONE !== stmt.step())\n throw Error(\n \"Failed to insert aspect remapping into the state database\"\n );\n }\n }\n );\n }\n\n public override loadStateFromDb(db: SQLiteDb): void {\n super.loadStateFromDb(db);\n // FIXME: test this\n db.withSqliteStatement(\n `SELECT Source, Target FROM ${IModelCloneContext.aspectRemapTableName}`,\n (stmt) => {\n let status = DbResult.BE_SQLITE_ERROR;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const source = stmt.getValue(0).getId();\n const target = stmt.getValue(1).getId();\n this._aspectRemapTable.set(source, target);\n }\n assert(status === DbResult.BE_SQLITE_DONE);\n }\n );\n }\n}\n"]}
|
|
1
|
+
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AAC,iBAAiB,CAC1D,mBAAmB,CAAC,UAAU,EAC9B,mBAAmB,CAAC,SAAS,EAC7B,YAAY,CACb,CAAC;oBACF,MAAM,CACJ,cAAc,KAAK,SAAS,EAC5B,0BAA0B,YAAY,wCAAwC,CAC/E,CAAC;oBACF,MAAM,qBAAqB,GAAG,IAAI,CAAC,kBAAkB,CACnD,+BAAgB,CAAC,cAAc,CAAC,aAAa,CAAC,EAAE,EAAE,cAAc,CAAC,CAClE,CAAC;oBACF,MAAM,cAAc,GAAG,+BAAgB,CAAC,MAAM,CAAC,qBAAqB,CAAC,CAAC;oBACtE,wDAAwD;oBACvD,wBAAgC,CAAC,YAAY,CAAC,GAAG;wBAChD,GAAI,wBAAgC,CAAC,YAAY,CAAC;wBAClD,EAAE,EAAE,cAAc;qBACnB,CAAC;iBACH;aACF;iBAAM,IACL,+BAAiB,CAAC,IAAI,KAAK,gBAAgB,CAAC,aAAa;gBACzD,IAAI,KAAK,gBAAgB,CAAC,YAAY,EACtC;gBACC,wBAAgC,CAAC,YAAY,CAAC;oBAC7C,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC;aACrE;QACH,CAAC,CAAC,CAAC;QACH,OAAO,wBAAwB,CAAC;IAClC,CAAC;CACF;AAlPD,gDAkPC","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 * as assert from \"assert\";\nimport { DbResult, Id64, Id64String, Logger } from \"@itwin/core-bentley\";\nimport {\n Code,\n CodeScopeSpec,\n ConcreteEntityTypes,\n ElementAspectProps,\n ElementProps,\n EntityReference,\n IModel,\n IModelError,\n PrimitiveTypeCode,\n PropertyMetaData,\n RelatedElement,\n RelatedElementProps,\n} from \"@itwin/core-common\";\nimport {\n Element,\n ElementAspect,\n EntityReferences,\n IModelElementCloneContext,\n IModelJsNative,\n SQLiteDb,\n} from \"@itwin/core-backend\";\nimport { ECReferenceTypesCache } from \"./ECReferenceTypesCache\";\nimport { EntityUnifier } from \"./EntityUnifier\";\nimport { TransformerLoggerCategory } from \"./TransformerLoggerCategory\";\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 Map<Id64String, 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 cloneElement(\n sourceElement: Element,\n cloneOptions?: IModelJsNative.CloneElementOptions\n ): 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 sourceElement.forEachProperty(\n (propertyName: string, meta: PropertyMetaData) => {\n if (\n meta.isNavigation &&\n undefined === (sourceElement as any)[propertyName]\n ) {\n (targetElementProps as any)[propertyName] = RelatedElement.none;\n }\n },\n false\n ); // exclude custom because C++ has already handled them\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 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 findTargetEntityId(sourceEntityId: EntityReference): EntityReference {\n const [type, rawId] = EntityReferences.split(sourceEntityId);\n if (Id64.isValid(rawId)) {\n switch (type) {\n case ConcreteEntityTypes.Model: {\n const targetId = `m${this.findTargetElementId(rawId)}` as const;\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 EntityUnifier.exists(this.targetDb, { entityReference: targetId })\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 relInSource = this.sourceDb.withPreparedStatement(\n `\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 (stmt) => {\n stmt.bindId(1, rawId);\n let status: DbResult;\n while ((status = stmt.step()) === DbResult.BE_SQLITE_ROW) {\n const sourceId = stmt.getValue(0).getId();\n const targetId = stmt.getValue(1).getId();\n const sourceType = stmt.getValue(2).getString() as\n | ConcreteEntityTypes\n | \"error\";\n const targetType = stmt.getValue(3).getString() 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 if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n return undefined;\n }\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: this.findTargetEntityId(relInSource.sourceId),\n targetId: 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 relInTargetId = this.targetDb.withPreparedStatement(\n `\n SELECT ECInstanceId\n FROM BisCore:ElementRefersToElements\n WHERE SourceECInstanceId=?\n AND TargetECInstanceId=?\n `,\n (stmt) => {\n stmt.bindId(1, EntityReferences.toId64(relInTarget.sourceId));\n stmt.bindId(2, EntityReferences.toId64(relInTarget.targetId));\n const status: DbResult = stmt.step();\n if (status === DbResult.BE_SQLITE_ROW)\n return stmt.getValue(0).getId();\n if (status !== DbResult.BE_SQLITE_DONE)\n throw new IModelError(status, \"unexpected query failure\");\n return Id64.invalid;\n }\n );\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 cloneElementAspect(\n sourceElementAspect: ElementAspect\n ): ElementAspectProps {\n const targetElementAspectProps: ElementAspectProps =\n sourceElementAspect.toJSON();\n targetElementAspectProps.id = undefined;\n sourceElementAspect.forEachProperty((propertyName, propertyMetaData) => {\n if (propertyMetaData.isNavigation) {\n const sourceNavProp: RelatedElementProps | undefined =\n sourceElementAspect.asAny[propertyName];\n if (sourceNavProp?.id) {\n const navPropRefType = this._refTypesCache.getNavPropRefType(\n sourceElementAspect.schemaName,\n sourceElementAspect.className,\n propertyName\n );\n assert(\n navPropRefType !== undefined,\n `nav prop ref type for '${propertyName}' was not in the cache, this is a bug.`\n );\n const targetEntityReference = this.findTargetEntityId(\n EntityReferences.fromEntityType(sourceNavProp.id, navPropRefType)\n );\n const targetEntityId = EntityReferences.toId64(targetEntityReference);\n // spread the property in case toJSON did not deep-clone\n (targetElementAspectProps as any)[propertyName] = {\n ...(targetElementAspectProps as any)[propertyName],\n id: targetEntityId,\n };\n }\n } else if (\n PrimitiveTypeCode.Long === propertyMetaData.primitiveType &&\n \"Id\" === propertyMetaData.extendedType\n ) {\n (targetElementAspectProps as any)[propertyName] =\n this.findTargetElementId(sourceElementAspect.asAny[propertyName]);\n }\n });\n return targetElementAspectProps;\n }\n}\n"]}
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @module iModels
|
|
3
3
|
*/
|
|
4
4
|
import { BriefcaseDb, ChangedECInstance, Element, ElementAspect, ElementMultiAspect, ElementUniqueAspect, IModelDb, IModelJsNative, Model, Relationship } from "@itwin/core-backend";
|
|
5
|
-
import { AccessToken,
|
|
5
|
+
import { AccessToken, Id64String } from "@itwin/core-bentley";
|
|
6
6
|
import { ChangesetFileProps, CodeSpec, FontProps } from "@itwin/core-common";
|
|
7
7
|
import { Schema, SchemaKey } from "@itwin/ecschema-metadata";
|
|
8
8
|
import type { InitOptions } from "./IModelTransformer";
|
|
@@ -27,10 +27,10 @@ export type ExporterInitOptions = ExportChangesOptions;
|
|
|
27
27
|
*/
|
|
28
28
|
export type ExportChangesOptions = Omit<InitOptions, "startChangeset"> & {
|
|
29
29
|
skipPropagateChangesToRootElements?: boolean;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
30
|
+
} /**
|
|
31
|
+
* an array of ChangesetFileProps which are used to read the changesets and populate the ChangedInstanceIds using [[ChangedInstanceIds.initialize]] in [[IModelExporter.exportChanges]]
|
|
32
|
+
* @note mutually exclusive with @see changesetRanges, @see startChangeset and @see changedInstanceIds, so define one of the four, never more
|
|
33
|
+
*/ & ({
|
|
34
34
|
csFileProps: ChangesetFileProps[];
|
|
35
35
|
}
|
|
36
36
|
/**
|
|
@@ -330,53 +330,6 @@ export declare class IModelExporter {
|
|
|
330
330
|
exportRelationship(relClassFullName: string, relInstanceId: Id64String): Promise<void>;
|
|
331
331
|
/** Tracks incremental progress */
|
|
332
332
|
private trackProgress;
|
|
333
|
-
/**
|
|
334
|
-
* You may override this to store arbitrary json state in a exporter state dump, useful for some resumptions
|
|
335
|
-
* @see [[IModelTransformer.saveStateToFile]]
|
|
336
|
-
*/
|
|
337
|
-
protected getAdditionalStateJson(): any;
|
|
338
|
-
/**
|
|
339
|
-
* You may override this to load arbitrary json state in a transformer state dump, useful for some resumptions
|
|
340
|
-
* @see [[IModelTransformer.loadStateFromFile]]
|
|
341
|
-
*/
|
|
342
|
-
protected loadAdditionalStateJson(_additionalState: any): void;
|
|
343
|
-
/**
|
|
344
|
-
* Reload our state from a JSON object
|
|
345
|
-
* Intended for [[IModelTransformer.resumeTransformation]]
|
|
346
|
-
* @internal
|
|
347
|
-
* You can load custom json from the exporter save state for custom exporters by overriding [[IModelExporter.loadAdditionalStateJson]]
|
|
348
|
-
*/
|
|
349
|
-
loadStateFromJson(state: IModelExporterState): void;
|
|
350
|
-
/**
|
|
351
|
-
* Serialize state to a JSON object
|
|
352
|
-
* Intended for [[IModelTransformer.resumeTransformation]]
|
|
353
|
-
* @internal
|
|
354
|
-
* You can add custom json to the exporter save state for custom exporters by overriding [[IModelExporter.getAdditionalStateJson]]
|
|
355
|
-
*/
|
|
356
|
-
saveStateToJson(): IModelExporterState;
|
|
357
|
-
}
|
|
358
|
-
/**
|
|
359
|
-
* The JSON format of a serialized IModelExporter instance
|
|
360
|
-
* Used for starting an exporter in the middle of an export operation,
|
|
361
|
-
* such as resuming a crashed transformation
|
|
362
|
-
*
|
|
363
|
-
* @note Must be kept synchronized with IModelExporter
|
|
364
|
-
* @internal
|
|
365
|
-
*/
|
|
366
|
-
export interface IModelExporterState {
|
|
367
|
-
exporterClass: string;
|
|
368
|
-
wantGeometry: boolean;
|
|
369
|
-
wantTemplateModels: boolean;
|
|
370
|
-
wantSystemSchemas: boolean;
|
|
371
|
-
visitElements: boolean;
|
|
372
|
-
visitRelationships: boolean;
|
|
373
|
-
excludedCodeSpecNames: string[];
|
|
374
|
-
excludedElementIds: CompressedId64Set;
|
|
375
|
-
excludedElementCategoryIds: CompressedId64Set;
|
|
376
|
-
excludedElementClassNames: string[];
|
|
377
|
-
excludedElementAspectClassFullNames: string[];
|
|
378
|
-
excludedRelationshipClassNames: string[];
|
|
379
|
-
additionalState?: any;
|
|
380
333
|
}
|
|
381
334
|
/**
|
|
382
335
|
* Arguments for [[ChangedInstanceIds.initialize]]
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"IModelExporter.d.ts","sourceRoot":"","sources":["../../src/IModelExporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,WAAW,EAEX,iBAAiB,EAIjB,OAAO,EACP,aAAa,EACb,kBAAkB,EAElB,mBAAmB,EAEnB,QAAQ,EAER,cAAc,EACd,KAAK,EAGL,YAAY,EAGb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"IModelExporter.d.ts","sourceRoot":"","sources":["../../src/IModelExporter.ts"],"names":[],"mappings":"AAIA;;GAEG;AAEH,OAAO,EACL,WAAW,EAEX,iBAAiB,EAIjB,OAAO,EACP,aAAa,EACb,kBAAkB,EAElB,mBAAmB,EAEnB,QAAQ,EAER,cAAc,EACd,KAAK,EAGL,YAAY,EAGb,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,WAAW,EAIX,UAAU,EAIX,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EACL,kBAAkB,EAClB,QAAQ,EACR,SAAS,EAGV,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAEL,MAAM,EACN,SAAS,EAEV,MAAM,0BAA0B,CAAC;AAGlC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EACL,qBAAqB,EACrB,4BAA4B,EAC7B,MAAM,gCAAgC,CAAC;AAKxC;;;GAGG;AACH,MAAM,WAAW,kBAAkB;IACjC,uFAAuF;IACvF,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED;;;;GAIG;AACH,MAAM,MAAM,mBAAmB,GAAG,oBAAoB,CAAC;AAEvD;;;GAGG;AACH,MAAM,MAAM,oBAAoB,GAAG,IAAI,CAAC,WAAW,EAAE,gBAAgB,CAAC,GAAG;IACvE,kCAAkC,CAAC,EAAE,OAAO,CAAC;CAC9C,CAAC;;;GAGC,GAAG,CACA;IAAE,WAAW,EAAE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AAG,OAAO,CAAC,IAAI,CAAC;IAyBhE,OAAO,CAAC,YAAY;IAyBpB;;OAEG;WACiB,UAAU,CAC5B,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,kBAAkB,GAAG,SAAS,CAAC;CAwF3C"}
|
|
@@ -592,6 +592,12 @@ class IModelExporter {
|
|
|
592
592
|
core_bentley_1.Logger.logTrace(loggerCategory, `visitElements=false, skipping exportElement(${elementId})`);
|
|
593
593
|
return;
|
|
594
594
|
}
|
|
595
|
+
// Return early if the elementId is already in the excludedElementIds, that way we don't need to load the element from the db.
|
|
596
|
+
if (this._excludedElementIds.has(elementId)) {
|
|
597
|
+
core_bentley_1.Logger.logInfo(loggerCategory, `Excluded element ${elementId} by Id`);
|
|
598
|
+
this.handler.onSkipElement(elementId);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
595
601
|
// are we processing changes?
|
|
596
602
|
const isUpdate = this._sourceDbChanges?.element.insertIds.has(elementId)
|
|
597
603
|
? false
|
|
@@ -702,66 +708,6 @@ class IModelExporter {
|
|
|
702
708
|
return this.handler.onProgress();
|
|
703
709
|
}
|
|
704
710
|
}
|
|
705
|
-
/**
|
|
706
|
-
* You may override this to store arbitrary json state in a exporter state dump, useful for some resumptions
|
|
707
|
-
* @see [[IModelTransformer.saveStateToFile]]
|
|
708
|
-
*/
|
|
709
|
-
getAdditionalStateJson() {
|
|
710
|
-
return {};
|
|
711
|
-
}
|
|
712
|
-
/**
|
|
713
|
-
* You may override this to load arbitrary json state in a transformer state dump, useful for some resumptions
|
|
714
|
-
* @see [[IModelTransformer.loadStateFromFile]]
|
|
715
|
-
*/
|
|
716
|
-
loadAdditionalStateJson(_additionalState) { }
|
|
717
|
-
/**
|
|
718
|
-
* Reload our state from a JSON object
|
|
719
|
-
* Intended for [[IModelTransformer.resumeTransformation]]
|
|
720
|
-
* @internal
|
|
721
|
-
* You can load custom json from the exporter save state for custom exporters by overriding [[IModelExporter.loadAdditionalStateJson]]
|
|
722
|
-
*/
|
|
723
|
-
loadStateFromJson(state) {
|
|
724
|
-
if (state.exporterClass !== this.constructor.name)
|
|
725
|
-
throw Error("resuming from a differently named exporter class, it is not necessarily valid to resume with a different exporter class");
|
|
726
|
-
this.wantGeometry = state.wantGeometry;
|
|
727
|
-
this.wantTemplateModels = state.wantTemplateModels;
|
|
728
|
-
this.wantSystemSchemas = state.wantSystemSchemas;
|
|
729
|
-
this.visitElements = state.visitElements;
|
|
730
|
-
this.visitRelationships = state.visitRelationships;
|
|
731
|
-
this._excludedCodeSpecNames = new Set(state.excludedCodeSpecNames);
|
|
732
|
-
(this._excludedElementIds = core_bentley_1.CompressedId64Set.decompressSet(state.excludedElementIds)),
|
|
733
|
-
(this._excludedElementCategoryIds = core_bentley_1.CompressedId64Set.decompressSet(state.excludedElementCategoryIds)),
|
|
734
|
-
(this._excludedElementClasses = new Set(state.excludedElementClassNames.map((c) => this.sourceDb.getJsClass(c))));
|
|
735
|
-
this._exportElementAspectsStrategy.loadExcludedElementAspectClasses(state.excludedElementAspectClassFullNames);
|
|
736
|
-
this._excludedRelationshipClasses = new Set(state.excludedRelationshipClassNames.map((c) => this.sourceDb.getJsClass(c)));
|
|
737
|
-
this.loadAdditionalStateJson(state.additionalState);
|
|
738
|
-
}
|
|
739
|
-
/**
|
|
740
|
-
* Serialize state to a JSON object
|
|
741
|
-
* Intended for [[IModelTransformer.resumeTransformation]]
|
|
742
|
-
* @internal
|
|
743
|
-
* You can add custom json to the exporter save state for custom exporters by overriding [[IModelExporter.getAdditionalStateJson]]
|
|
744
|
-
*/
|
|
745
|
-
saveStateToJson() {
|
|
746
|
-
return {
|
|
747
|
-
exporterClass: this.constructor.name,
|
|
748
|
-
wantGeometry: this.wantGeometry,
|
|
749
|
-
wantTemplateModels: this.wantTemplateModels,
|
|
750
|
-
wantSystemSchemas: this.wantSystemSchemas,
|
|
751
|
-
visitElements: this.visitElements,
|
|
752
|
-
visitRelationships: this.visitRelationships,
|
|
753
|
-
excludedCodeSpecNames: [...this._excludedCodeSpecNames],
|
|
754
|
-
excludedElementIds: core_bentley_1.CompressedId64Set.compressSet(this._excludedElementIds),
|
|
755
|
-
excludedElementCategoryIds: core_bentley_1.CompressedId64Set.compressSet(this._excludedElementCategoryIds),
|
|
756
|
-
excludedElementClassNames: Array.from(this._excludedElementClasses, (cls) => cls.classFullName),
|
|
757
|
-
excludedElementAspectClassFullNames: [
|
|
758
|
-
...this._exportElementAspectsStrategy
|
|
759
|
-
.excludedElementAspectClassFullNames,
|
|
760
|
-
],
|
|
761
|
-
excludedRelationshipClassNames: Array.from(this._excludedRelationshipClasses, (cls) => cls.classFullName),
|
|
762
|
-
additionalState: this.getAdditionalStateJson(),
|
|
763
|
-
};
|
|
764
|
-
}
|
|
765
711
|
}
|
|
766
712
|
exports.IModelExporter = IModelExporter;
|
|
767
713
|
/** Class for holding change information.
|