@itwin/imodel-transformer 2.0.0-dev.50 → 2.0.0-dev.51

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.
@@ -889,18 +889,17 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
889
889
  }
890
890
  }
891
891
  }
892
- /** Override of [IModelExportHandler.onDeleteElement]($transformer) that is called when [IModelExporter]($transformer) detects that an Element has been deleted from the source iModel.
893
- * This override propagates the delete to the target iModel via [IModelImporter.deleteElement]($transformer).
894
- */
895
- async onDeleteElement(sourceElementId) {
896
- const targetElementId = this.context.findTargetElementId(sourceElementId);
897
- if (core_bentley_1.Id64.isValidId64(targetElementId)) {
898
- // Skip deletion if new / updated source element was remapped to it by Code during
899
- // this transformation pass.
900
- if (!this._targetElementIdsRemappedByCode.has(targetElementId)) {
901
- await this.importer.deleteElement(targetElementId);
892
+ /** Maps the deleted source element IDs and passes the target IDs to the importer as one set. */
893
+ async onDeleteElements(sourceElementIds) {
894
+ const targetElementIds = new Set();
895
+ for (const sourceElementId of sourceElementIds) {
896
+ const targetElementId = this.context.findTargetElementId(sourceElementId);
897
+ if (core_bentley_1.Id64.isValidId64(targetElementId) &&
898
+ !this._targetElementIdsRemappedByCode.has(targetElementId)) {
899
+ targetElementIds.add(targetElementId);
902
900
  }
903
901
  }
902
+ await this.importer.deleteElements(targetElementIds);
904
903
  }
905
904
  /** Override of [IModelExportHandler.onExportModel]($transformer) that is called when a Model should be exported from the source iModel.
906
905
  * This override calls [[onTransformModel]] and then [IModelImporter.importModel]($transformer) to update the target iModel.
@@ -969,9 +968,8 @@ class IModelTransformer extends IModelExporter_1.IModelExportHandler {
969
968
  error.errorNumber === core_bentley_1.IModelStatus.ForeignKeyConstraint);
970
969
  if (!isDeletionProhibitedErr)
971
970
  throw error;
972
- // Transformer tries to delete models before it deletes elements. Definition models cannot be deleted unless all of their modeled elements are deleted first.
973
- // In case a definition model needs to be deleted we need to skip it for now and register its modeled partition for deletion.
974
- // The `OnDeleteElement` calls `DeleteElementTree` Which deletes the model together with its partition after deleting all of the modeled elements.
971
+ // Models are processed before elements, but a definition model cannot be deleted while it contains elements.
972
+ // Add its partition to the element deletion set. Bulk cascade deletion will remove the contents, model, and partition together.
975
973
  this.scheduleModeledPartitionDeletion(sourceModelId);
976
974
  }
977
975
  }