@itwin/imodel-transformer 2.0.0-dev.27 → 2.0.0-dev.28
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/ECReferenceTypesCache.d.ts.map +1 -1
- package/lib/cjs/ECReferenceTypesCache.js +8 -1
- package/lib/cjs/ECReferenceTypesCache.js.map +1 -1
- package/lib/cjs/IModelExporter.d.ts +1 -1
- package/lib/cjs/IModelExporter.d.ts.map +1 -1
- package/lib/cjs/IModelExporter.js +39 -8
- package/lib/cjs/IModelExporter.js.map +1 -1
- package/lib/cjs/IModelImporter.d.ts.map +1 -1
- package/lib/cjs/IModelImporter.js +80 -22
- package/lib/cjs/IModelImporter.js.map +1 -1
- package/lib/cjs/IModelTransformer.d.ts.map +1 -1
- package/lib/cjs/IModelTransformer.js +186 -43
- package/lib/cjs/IModelTransformer.js.map +1 -1
- package/lib/cjs/IModelTransformerError.d.ts +74 -0
- package/lib/cjs/IModelTransformerError.d.ts.map +1 -0
- package/lib/cjs/IModelTransformerError.js +83 -0
- package/lib/cjs/IModelTransformerError.js.map +1 -0
- package/lib/cjs/ProvenanceManager.d.ts.map +1 -1
- package/lib/cjs/ProvenanceManager.js +52 -9
- package/lib/cjs/ProvenanceManager.js.map +1 -1
- package/lib/cjs/SyncTypeResolver.d.ts.map +1 -1
- package/lib/cjs/SyncTypeResolver.js +13 -1
- package/lib/cjs/SyncTypeResolver.js.map +1 -1
- package/lib/cjs/imodel-transformer.d.ts +5 -0
- package/lib/cjs/imodel-transformer.d.ts.map +1 -1
- package/lib/cjs/imodel-transformer.js +26 -7
- package/lib/cjs/imodel-transformer.js.map +1 -1
- package/package.json +1 -1
|
@@ -24,6 +24,7 @@ const EntityUnifier_1 = require("./EntityUnifier");
|
|
|
24
24
|
const Algo_1 = require("./Algo");
|
|
25
25
|
const SyncTypeResolver_1 = require("./SyncTypeResolver");
|
|
26
26
|
const ProvenanceManager_1 = require("./ProvenanceManager");
|
|
27
|
+
const IModelTransformerError_1 = require("./IModelTransformerError");
|
|
27
28
|
const loggerCategory = TransformerLoggerCategory_1.TransformerLoggerCategory.IModelTransformer;
|
|
28
29
|
/**
|
|
29
30
|
* Apply a function to each Id64 in a supported container type of Id64s.
|
|
@@ -50,10 +51,16 @@ function mapId64(idContainer, func) {
|
|
|
50
51
|
results.push(func(idContainer.id));
|
|
51
52
|
}
|
|
52
53
|
else {
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
54
|
+
core_bentley_1.ITwinError.throwError({
|
|
55
|
+
iTwinErrorId: {
|
|
56
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
57
|
+
key: IModelTransformerError_1.IModelTransformerError.InvalidEntityReference,
|
|
58
|
+
},
|
|
59
|
+
message: [
|
|
60
|
+
`Id64 container '${JSON.stringify(idContainer)}' is unsupported.`,
|
|
61
|
+
"Currently only singular Id64 strings or prop-like objects containing an 'id' property are supported.",
|
|
62
|
+
].join("\n"),
|
|
63
|
+
});
|
|
57
64
|
}
|
|
58
65
|
return results;
|
|
59
66
|
}
|
|
@@ -220,13 +227,23 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
220
227
|
validateSharedOptionsMatch() {
|
|
221
228
|
if (Boolean(this._options.preserveElementIdsForFiltering) !==
|
|
222
229
|
this.importer.options.preserveElementIdsForFiltering) {
|
|
223
|
-
|
|
224
|
-
|
|
230
|
+
core_bentley_1.ITwinError.throwError({
|
|
231
|
+
iTwinErrorId: {
|
|
232
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
233
|
+
key: IModelTransformerError_1.IModelTransformerError.ImporterOptionMismatch,
|
|
234
|
+
},
|
|
235
|
+
message: "A custom importer was passed as a target but its 'preserveElementIdsForFiltering' option is out of sync with the transformer's option.",
|
|
236
|
+
});
|
|
225
237
|
}
|
|
226
238
|
if (Boolean(this._options.skipPropagateChangesToRootElements) !==
|
|
227
239
|
this.importer.options.skipPropagateChangesToRootElements) {
|
|
228
|
-
|
|
229
|
-
|
|
240
|
+
core_bentley_1.ITwinError.throwError({
|
|
241
|
+
iTwinErrorId: {
|
|
242
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
243
|
+
key: IModelTransformerError_1.IModelTransformerError.ImporterOptionMismatch,
|
|
244
|
+
},
|
|
245
|
+
message: "A custom importer was passed as a target but its 'skipPropagateChangesToRootElements' option is out of sync with the transformer's option.",
|
|
246
|
+
});
|
|
230
247
|
}
|
|
231
248
|
}
|
|
232
249
|
/** Dispose any native resources associated with this IModelTransformer. */
|
|
@@ -372,7 +389,13 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
372
389
|
const srcEcefLoc = this.sourceDb.ecefLocation;
|
|
373
390
|
const targetEcefLoc = this.targetDb.ecefLocation;
|
|
374
391
|
if (srcEcefLoc === undefined || targetEcefLoc === undefined) {
|
|
375
|
-
|
|
392
|
+
core_bentley_1.ITwinError.throwError({
|
|
393
|
+
iTwinErrorId: {
|
|
394
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
395
|
+
key: IModelTransformerError_1.IModelTransformerError.GeolocationUnavailable,
|
|
396
|
+
},
|
|
397
|
+
message: "Both source and target ECEF locations must be defined to calculate the transform.",
|
|
398
|
+
});
|
|
376
399
|
}
|
|
377
400
|
if (srcEcefLoc.getTransform().isAlmostEqual(targetEcefLoc.getTransform())) {
|
|
378
401
|
core_bentley_1.Logger.logTrace(loggerCategory, "ECEF data is already aligned. No spatial transforms needed.");
|
|
@@ -381,7 +404,13 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
381
404
|
const srcSpatialToECEF = srcEcefLoc.getTransform(); // converts relative to ECEF in relation to source
|
|
382
405
|
const targetECEFToSpatial = targetEcefLoc.getTransform().inverse(); // converts ECEF to relative in relation to target
|
|
383
406
|
if (!targetECEFToSpatial) {
|
|
384
|
-
|
|
407
|
+
core_bentley_1.ITwinError.throwError({
|
|
408
|
+
iTwinErrorId: {
|
|
409
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
410
|
+
key: IModelTransformerError_1.IModelTransformerError.GeolocationUnavailable,
|
|
411
|
+
},
|
|
412
|
+
message: "Failed to invert target ECEF transform.",
|
|
413
|
+
});
|
|
385
414
|
}
|
|
386
415
|
const ecefTransform = targetECEFToSpatial.multiplyTransformTransform(srcSpatialToECEF); // chain both transforms
|
|
387
416
|
return ecefTransform;
|
|
@@ -399,15 +428,33 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
399
428
|
calculateTransformFromHelmertTransforms() {
|
|
400
429
|
if (this.sourceDb.geographicCoordinateSystem?.horizontalCRS === undefined ||
|
|
401
430
|
this.sourceDb.geographicCoordinateSystem?.verticalCRS === undefined) {
|
|
402
|
-
|
|
431
|
+
core_bentley_1.ITwinError.throwError({
|
|
432
|
+
iTwinErrorId: {
|
|
433
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
434
|
+
key: IModelTransformerError_1.IModelTransformerError.GeographicCoordinateSystemUnavailable,
|
|
435
|
+
},
|
|
436
|
+
message: "Source iModel does not have a geographic coordinate system defined.",
|
|
437
|
+
});
|
|
403
438
|
}
|
|
404
439
|
if (this.targetDb.geographicCoordinateSystem?.horizontalCRS === undefined ||
|
|
405
440
|
this.targetDb.geographicCoordinateSystem.verticalCRS === undefined) {
|
|
406
|
-
|
|
441
|
+
core_bentley_1.ITwinError.throwError({
|
|
442
|
+
iTwinErrorId: {
|
|
443
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
444
|
+
key: IModelTransformerError_1.IModelTransformerError.GeographicCoordinateSystemUnavailable,
|
|
445
|
+
},
|
|
446
|
+
message: "Target iModel does not have a geographic coordinate system defined.",
|
|
447
|
+
});
|
|
407
448
|
}
|
|
408
449
|
if (!this.sourceDb.geographicCoordinateSystem.horizontalCRS.equals(this.targetDb.geographicCoordinateSystem.horizontalCRS) ||
|
|
409
450
|
!this.sourceDb.geographicCoordinateSystem.verticalCRS.equals(this.targetDb.geographicCoordinateSystem.verticalCRS)) {
|
|
410
|
-
|
|
451
|
+
core_bentley_1.ITwinError.throwError({
|
|
452
|
+
iTwinErrorId: {
|
|
453
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
454
|
+
key: IModelTransformerError_1.IModelTransformerError.GeographicCoordinateSystemMismatch,
|
|
455
|
+
},
|
|
456
|
+
message: "Source and target geographic coordinate systems must match to calculate the spatial transform.",
|
|
457
|
+
});
|
|
411
458
|
}
|
|
412
459
|
if (this.sourceDb.geographicCoordinateSystem.additionalTransform ===
|
|
413
460
|
this.targetDb.geographicCoordinateSystem.additionalTransform) {
|
|
@@ -419,14 +466,26 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
419
466
|
const targetScale = this.targetDb.geographicCoordinateSystem.additionalTransform
|
|
420
467
|
?.helmert2DWithZOffset?.scale ?? 1;
|
|
421
468
|
if (srcScale !== targetScale) {
|
|
422
|
-
|
|
469
|
+
core_bentley_1.ITwinError.throwError({
|
|
470
|
+
iTwinErrorId: {
|
|
471
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
472
|
+
key: IModelTransformerError_1.IModelTransformerError.GeographicCoordinateSystemMismatch,
|
|
473
|
+
},
|
|
474
|
+
message: "Spatial transform is non rigid. Source and target Helmert transforms must have the same scale to calculate a rigid spatial transform.",
|
|
475
|
+
});
|
|
423
476
|
}
|
|
424
477
|
const srcTransform = IModelTransformer.convertHelmertToTransform(this.sourceDb.geographicCoordinateSystem.additionalTransform
|
|
425
478
|
?.helmert2DWithZOffset); // moves elements to where src helmert transform would move them at render time
|
|
426
479
|
const targetTransformInv = IModelTransformer.convertHelmertToTransform(this.targetDb.geographicCoordinateSystem.additionalTransform
|
|
427
480
|
?.helmert2DWithZOffset).inverse(); // negates target helmert transform that is applied at render time
|
|
428
481
|
if (!targetTransformInv) {
|
|
429
|
-
|
|
482
|
+
core_bentley_1.ITwinError.throwError({
|
|
483
|
+
iTwinErrorId: {
|
|
484
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
485
|
+
key: IModelTransformerError_1.IModelTransformerError.GeolocationUnavailable,
|
|
486
|
+
},
|
|
487
|
+
message: "Failed to invert target Helmert transform.",
|
|
488
|
+
});
|
|
430
489
|
}
|
|
431
490
|
const combinedTransform = targetTransformInv.multiplyTransformTransform(srcTransform);
|
|
432
491
|
return combinedTransform;
|
|
@@ -503,12 +562,18 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
503
562
|
entityReference: referenceId,
|
|
504
563
|
});
|
|
505
564
|
if (!referencedExistsInSource) {
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
565
|
+
core_bentley_1.ITwinError.throwError({
|
|
566
|
+
iTwinErrorId: {
|
|
567
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
568
|
+
key: IModelTransformerError_1.IModelTransformerError.DanglingReference,
|
|
569
|
+
},
|
|
570
|
+
message: [
|
|
571
|
+
`Found a reference to an element "${referenceId}" that doesn't exist while looking for references of "${entity.id}".`,
|
|
572
|
+
"This must have been caused by an upstream application that changed the iModel.",
|
|
573
|
+
"You can set the IModelTransformOptions.danglingReferencesBehavior option to 'ignore' to ignore this,",
|
|
574
|
+
`and the referenceId found on "${entity.id}" will not be carried over to corresponding target element.`,
|
|
575
|
+
].join("\n"),
|
|
576
|
+
});
|
|
512
577
|
}
|
|
513
578
|
}
|
|
514
579
|
/** Cause the specified Element and its child Elements (if applicable) to be exported from the source iModel and imported into the target iModel.
|
|
@@ -518,7 +583,13 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
518
583
|
async processElement(sourceElementId) {
|
|
519
584
|
await this.initialize();
|
|
520
585
|
if (sourceElementId === core_common_1.IModel.rootSubjectId) {
|
|
521
|
-
|
|
586
|
+
core_bentley_1.ITwinError.throwError({
|
|
587
|
+
iTwinErrorId: {
|
|
588
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
589
|
+
key: IModelTransformerError_1.IModelTransformerError.RootSubjectNotProcessable,
|
|
590
|
+
},
|
|
591
|
+
message: "The root Subject should not be directly imported",
|
|
592
|
+
});
|
|
522
593
|
}
|
|
523
594
|
return this.exporter.exportElement(sourceElementId);
|
|
524
595
|
}
|
|
@@ -607,9 +678,21 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
607
678
|
// It mimicks 4.x implementation: https://github.com/iTwin/itwinjs-core/blob/9c8b394ec3878a39764be81f928fd8b0b9115d31/core/backend/src/IModelDb.ts#L1882
|
|
608
679
|
async queryElementIdByCode(iModel, code) {
|
|
609
680
|
if (core_bentley_1.Id64.isInvalid(code.spec))
|
|
610
|
-
|
|
681
|
+
core_bentley_1.ITwinError.throwError({
|
|
682
|
+
iTwinErrorId: {
|
|
683
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
684
|
+
key: IModelTransformerError_1.IModelTransformerError.InvalidCode,
|
|
685
|
+
},
|
|
686
|
+
message: "Invalid CodeSpec",
|
|
687
|
+
});
|
|
611
688
|
if (code.value === undefined)
|
|
612
|
-
|
|
689
|
+
core_bentley_1.ITwinError.throwError({
|
|
690
|
+
iTwinErrorId: {
|
|
691
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
692
|
+
key: IModelTransformerError_1.IModelTransformerError.InvalidCode,
|
|
693
|
+
},
|
|
694
|
+
message: "Invalid Code",
|
|
695
|
+
});
|
|
613
696
|
const query = "SELECT ECInstanceId FROM BisCore:Element WHERE CodeSpec.Id=? AND CodeScope.Id=? AND CodeValue=?";
|
|
614
697
|
const queryBinder = new core_common_1.QueryBinder()
|
|
615
698
|
.bindId(1, code.spec)
|
|
@@ -679,7 +762,13 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
679
762
|
const isValid = core_bentley_1.Id64.isValid(targetElementId);
|
|
680
763
|
if (isValid && targetElementId !== sourceElement.id) {
|
|
681
764
|
// Element found with different id
|
|
682
|
-
|
|
765
|
+
core_bentley_1.ITwinError.throwError({
|
|
766
|
+
iTwinErrorId: {
|
|
767
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
768
|
+
key: IModelTransformerError_1.IModelTransformerError.ElementIdNotPreservable,
|
|
769
|
+
},
|
|
770
|
+
message: `Element id(${sourceElement.id}) cannot be preserved. Found a different mapping(${targetElementId}) from source element`,
|
|
771
|
+
});
|
|
683
772
|
}
|
|
684
773
|
else if (isValid && targetElementId === sourceElement.id) {
|
|
685
774
|
// targetElementId is valid (indicating update)
|
|
@@ -690,7 +779,13 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
690
779
|
// if we don't find mapping for source element in target(invalid) but another element with source id exists in target
|
|
691
780
|
if (sourceInTargetElemProps) {
|
|
692
781
|
// Element id is already taken by another element
|
|
693
|
-
|
|
782
|
+
core_bentley_1.ITwinError.throwError({
|
|
783
|
+
iTwinErrorId: {
|
|
784
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
785
|
+
key: IModelTransformerError_1.IModelTransformerError.ElementIdNotPreservable,
|
|
786
|
+
},
|
|
787
|
+
message: `Element id(${sourceElement.id}) cannot be preserved. An unrelated element in the target already uses id: ${sourceElement.id}`,
|
|
788
|
+
});
|
|
694
789
|
}
|
|
695
790
|
else {
|
|
696
791
|
// Element id in target is available to be remapped
|
|
@@ -702,7 +797,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
702
797
|
await this.importer.importElement(targetElementProps); // don't need to import if iModel was copied
|
|
703
798
|
}
|
|
704
799
|
if (targetElementProps.id === undefined) {
|
|
705
|
-
throw new
|
|
800
|
+
throw new Error("targetElementProps.id should be assigned by importElement");
|
|
706
801
|
}
|
|
707
802
|
this.context.remapElement(sourceElement.id, targetElementProps.id);
|
|
708
803
|
// the transformer does not currently 'split' or 'join' any elements, therefore, it does not
|
|
@@ -761,7 +856,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
761
856
|
const targetModelProps = this.onTransformModel(sourceModel, targetModeledElementId);
|
|
762
857
|
await this.importer.importModel(targetModelProps);
|
|
763
858
|
if (targetModelProps.id === undefined) {
|
|
764
|
-
throw new
|
|
859
|
+
throw new Error("targetModelProps.id should be assigned by now");
|
|
765
860
|
}
|
|
766
861
|
this._targetModelsImportedInCurrentTransform.add(targetModelProps.id);
|
|
767
862
|
}
|
|
@@ -884,7 +979,13 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
884
979
|
};
|
|
885
980
|
targetModelProps.id = targetModeledElementId;
|
|
886
981
|
if (targetModelProps.parentModel === undefined) {
|
|
887
|
-
|
|
982
|
+
core_bentley_1.ITwinError.throwError({
|
|
983
|
+
iTwinErrorId: {
|
|
984
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
985
|
+
key: IModelTransformerError_1.IModelTransformerError.ParentModelRequired,
|
|
986
|
+
},
|
|
987
|
+
message: "targetElementProps must have a defined parentModel",
|
|
988
|
+
});
|
|
888
989
|
}
|
|
889
990
|
targetModelProps.parentModel = this.context.findTargetElementId(targetModelProps.parentModel);
|
|
890
991
|
return targetModelProps;
|
|
@@ -1283,9 +1384,21 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
1283
1384
|
const changeType = change.$meta?.op;
|
|
1284
1385
|
const ecClassId = change.ECClassId ?? change.$meta?.fallbackClassId;
|
|
1285
1386
|
if (ecClassId === undefined)
|
|
1286
|
-
|
|
1387
|
+
core_bentley_1.ITwinError.throwError({
|
|
1388
|
+
iTwinErrorId: {
|
|
1389
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1390
|
+
key: IModelTransformerError_1.IModelTransformerError.ChangedInstanceMetadataMissing,
|
|
1391
|
+
},
|
|
1392
|
+
message: `ECClassId was not found for id: ${change.ECInstanceId}! Table is : ${change?.$meta?.tables}`,
|
|
1393
|
+
});
|
|
1287
1394
|
if (changeType === undefined)
|
|
1288
|
-
|
|
1395
|
+
core_bentley_1.ITwinError.throwError({
|
|
1396
|
+
iTwinErrorId: {
|
|
1397
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1398
|
+
key: IModelTransformerError_1.IModelTransformerError.ChangedInstanceMetadataMissing,
|
|
1399
|
+
},
|
|
1400
|
+
message: `ChangeType was undefined for id: ${change.ECInstanceId}.`,
|
|
1401
|
+
});
|
|
1289
1402
|
if (changeType !== "Deleted" ||
|
|
1290
1403
|
relationshipECClassIdsToSkip.has(ecClassId))
|
|
1291
1404
|
continue;
|
|
@@ -1408,7 +1521,7 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
1408
1521
|
if (deletionNotInTarget)
|
|
1409
1522
|
return;
|
|
1410
1523
|
if (targetId === undefined) {
|
|
1411
|
-
throw new
|
|
1524
|
+
throw new Error("targetId should be acquired from source id or element provenance");
|
|
1412
1525
|
}
|
|
1413
1526
|
this.context.remapElement(changedInstanceId, targetId);
|
|
1414
1527
|
// If an entity insert and an entity delete both point to the same entity in target iModel, that means that entity was recreated.
|
|
@@ -1451,13 +1564,19 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
1451
1564
|
?.ignoreMissingChangesetsInSynchronizations &&
|
|
1452
1565
|
startChangesetIndex !== syncVersion.index + 1 &&
|
|
1453
1566
|
syncVersion.index !== -1) {
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
`
|
|
1460
|
-
|
|
1567
|
+
core_bentley_1.ITwinError.throwError({
|
|
1568
|
+
iTwinErrorId: {
|
|
1569
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1570
|
+
key: IModelTransformerError_1.IModelTransformerError.SynchronizationRangeInvalid,
|
|
1571
|
+
},
|
|
1572
|
+
message: `synchronization is ${missingChangesets ? "missing changesets" : ""},` +
|
|
1573
|
+
" startChangesetId should be" +
|
|
1574
|
+
" exactly the first changeset *after* the previous synchronization to not miss data." +
|
|
1575
|
+
` You specified '${startChangesetIndexOrId}' which is changeset #${startChangesetIndex}` +
|
|
1576
|
+
` but the previous synchronization for this targetScopeElem ${syncVersion.id}'` +
|
|
1577
|
+
` which is changeset #${syncVersion.index}. The transformer expected` +
|
|
1578
|
+
` #${syncVersion.index + 1}.`,
|
|
1579
|
+
});
|
|
1461
1580
|
}
|
|
1462
1581
|
const changesetsToSkip = await this._provenanceManager.getChangesetsToSkip();
|
|
1463
1582
|
core_bentley_1.Logger.logTrace(loggerCategory, `changesets to skip: ${changesetsToSkip}`);
|
|
@@ -1481,10 +1600,22 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
|
|
|
1481
1600
|
/** Asserts that the EditTxn is active before any write operations. */
|
|
1482
1601
|
assertEditTxnActive() {
|
|
1483
1602
|
if (!this._targetEditTxn.isActive) {
|
|
1484
|
-
|
|
1603
|
+
core_bentley_1.ITwinError.throwError({
|
|
1604
|
+
iTwinErrorId: {
|
|
1605
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1606
|
+
key: IModelTransformerError_1.IModelTransformerError.EditTxnNotActive,
|
|
1607
|
+
},
|
|
1608
|
+
message: "The target EditTxn must be started before calling process(). Call targetEditTxn.start() before invoking the transformer.",
|
|
1609
|
+
});
|
|
1485
1610
|
}
|
|
1486
1611
|
if (this._sourceEditTxn && !this._sourceEditTxn.isActive) {
|
|
1487
|
-
|
|
1612
|
+
core_bentley_1.ITwinError.throwError({
|
|
1613
|
+
iTwinErrorId: {
|
|
1614
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1615
|
+
key: IModelTransformerError_1.IModelTransformerError.EditTxnNotActive,
|
|
1616
|
+
},
|
|
1617
|
+
message: "The source EditTxn was provided but is not active. Call sourceEditTxn.start() before invoking the transformer.",
|
|
1618
|
+
});
|
|
1488
1619
|
}
|
|
1489
1620
|
}
|
|
1490
1621
|
/**
|
|
@@ -1676,7 +1807,13 @@ class TemplateModelCloner extends IModelTransformer {
|
|
|
1676
1807
|
// TODO: consider going through all definition elements at once and remapping them to themselves
|
|
1677
1808
|
if (!core_backend_1.EntityReferences.isValid(await this.context.findTargetEntityId(referenceId))) {
|
|
1678
1809
|
if (this.context.isBetweenIModels) {
|
|
1679
|
-
|
|
1810
|
+
core_bentley_1.ITwinError.throwError({
|
|
1811
|
+
iTwinErrorId: {
|
|
1812
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1813
|
+
key: IModelTransformerError_1.IModelTransformerError.DependencyMappingMissing,
|
|
1814
|
+
},
|
|
1815
|
+
message: `Remapping for source dependency ${referenceId} not found for target iModel`,
|
|
1816
|
+
});
|
|
1680
1817
|
}
|
|
1681
1818
|
else {
|
|
1682
1819
|
const definitionElement = this.sourceDb.elements.tryGetElement(referenceId, core_backend_1.DefinitionElement);
|
|
@@ -1685,7 +1822,13 @@ class TemplateModelCloner extends IModelTransformer {
|
|
|
1685
1822
|
this.context.remapElement(referenceId, referenceId); // when in the same iModel, can use existing DefinitionElements without remapping
|
|
1686
1823
|
}
|
|
1687
1824
|
else {
|
|
1688
|
-
|
|
1825
|
+
core_bentley_1.ITwinError.throwError({
|
|
1826
|
+
iTwinErrorId: {
|
|
1827
|
+
scope: IModelTransformerError_1.IModelTransformerErrorScope,
|
|
1828
|
+
key: IModelTransformerError_1.IModelTransformerError.DependencyMappingMissing,
|
|
1829
|
+
},
|
|
1830
|
+
message: `Remapping for dependency ${referenceId} not found`,
|
|
1831
|
+
});
|
|
1689
1832
|
}
|
|
1690
1833
|
}
|
|
1691
1834
|
}
|