@@ -247,6 +247,23 @@ export interface IModelTransformOptions {
247
247
* @default "reject"
248
248
*/
249
249
branchRelationshipDataBehavior ?: "unsafe-migrate" | "reject" ;
250
+
251
+ /**
252
+ * The forward sync 'version' to set on the scoping ESA @see ExternalSourceAspectProps upon startup, if the version property on the scoping ESA is undefined or empty string.
253
+ * @note This option is not without risk! You must also set @see branchRelationshipDataBehavior to "unsafe-migrate".
254
+ * @note This value is ignored if the version property on the scoping ESA is NOT undefined or empty string.
255
+ * @default ""
256
+ */
257
+ unsafeSyncVersion ?: string ;
258
+
259
+ /**
260
+ * The reverse sync version to set on the scoping ESA @see TargetScopeProvenanceJsonProps upon startup, if the reverseSync property on the scoping ESA is undefined or empty string.
261
+ * @note This option is not without risk! You must also set @see branchRelationshipDataBehavior to "unsafe-migrate".
262
+ * @note This value is ignored if the reverseSyncVersion property on the scoping ESA is NOT undefined or empty string.
263
+ * @default ""
264
+ */
265
+ unsafeReverseSyncVersion ?: string ;
266
+
250
267
/**
251
268
* Skip propagating changes made to the root subject, dictionaryModel and IModelImporter._realityDataSourceLinkPartitionStaticId (0xe)
252
269
* @default false
@@ -779,7 +796,9 @@ export class IModelTransformer extends IModelExportHandler {
779
796
) ;
780
797
Logger . logInfo (
781
798
TransformerLoggerCategory . IModelImporter ,
782
- `this.importer.autoExtendProjectExtents=${ JSON . stringify ( this . importer . options . autoExtendProjectExtents ) } `
799
+ `this.importer.autoExtendProjectExtents=${ JSON . stringify (
800
+ this . importer . options . autoExtendProjectExtents
801
+ ) } `
783
802
) ;
784
803
Logger . logInfo (
785
804
TransformerLoggerCategory . IModelImporter ,
@@ -1119,6 +1138,52 @@ export class IModelTransformer extends IModelExportHandler {
1119
1138
reverseSyncVersion : "" ,
1120
1139
}
1121
1140
: undefined ;
1141
+
1142
+ if ( this . _options . branchRelationshipDataBehavior === "unsafe-migrate" ) {
1143
+ // Only propagate the unsafeSyncVersion and unsafeReverseSyncVersion if the currently stored versions are empty string.
1144
+ // Note that in the unsafe-migrate case these may have just been set to empty string, if they were previously undefined.
1145
+ aspectProps . version =
1146
+ aspectProps . version === ""
1147
+ ? this . _options . unsafeSyncVersion ?? ""
1148
+ : aspectProps . version ;
1149
+ aspectProps . jsonProperties ! . reverseSyncVersion =
1150
+ aspectProps . jsonProperties ! . reverseSyncVersion === ""
1151
+ ? this . _options . unsafeReverseSyncVersion ?? ""
1152
+ : aspectProps . jsonProperties ! . reverseSyncVersion ;
1153
+ }
1154
+
1155
+ /**
1156
+ * This case will only be hit when:
1157
+ * - first transformation was performed on pre-fedguid transformer.
1158
+ * - a second processAll transformation was performed on the same target-source iModels post-fedguid transformer.
1159
+ * - change processing was invoked on for the second 'initial' transformation.
1160
+ * NOTE: This case likely does not exist anymore, but we will keep it just to be sure.
1161
+ */
1162
+
1163
+ if (
1164
+ aspectProps . jsonProperties !== undefined &&
1165
+ this . _options . branchRelationshipDataBehavior === "unsafe-migrate"
1166
+ ) {
1167
+ if (
1168
+ aspectProps . jsonProperties . pendingReverseSyncChangesetIndices ===
1169
+ undefined
1170
+ ) {
1171
+ Logger . logWarning (
1172
+ loggerCategory ,
1173
+ "Property pendingReverseSyncChangesetIndices missing on the jsonProperties of the scoping ESA. Setting to []."
1174
+ ) ;
1175
+ aspectProps . jsonProperties . pendingReverseSyncChangesetIndices = [ ] ;
1176
+ }
1177
+ if (
1178
+ aspectProps . jsonProperties . pendingSyncChangesetIndices === undefined
1179
+ ) {
1180
+ Logger . logWarning (
1181
+ loggerCategory ,
1182
+ "Property pendingSyncChangesetIndices missing on the jsonProperties of the scoping ESA. Setting to []."
1183
+ ) ;
1184
+ aspectProps . jsonProperties . pendingSyncChangesetIndices = [ ] ;
1185
+ }
1186
+ }
1122
1187
}
1123
1188
1124
1189
this . _targetScopeProvenanceProps =
@@ -1550,13 +1615,9 @@ export class IModelTransformer extends IModelExportHandler {
1550
1615
1551
1616
/** Returns true if a change within sourceElement is detected.
1552
1617
* @param sourceElement The Element from the source iModel
1553
- * @param targetElementId The Element from the target iModel to compare against.
1554
1618
* @note A subclass can override this method to provide custom change detection behavior.
1555
1619
*/
1556
- protected hasElementChanged (
1557
- sourceElement : Element ,
1558
- _targetElementId : Id64String
1559
- ) : boolean {
1620
+ protected hasElementChanged ( sourceElement : Element ) : boolean {
1560
1621
if ( this . _sourceChangeDataState === "no-changes" ) return false ;
1561
1622
if ( this . _sourceChangeDataState === "unconnected" ) return true ;
1562
1623
nodeAssert (
@@ -1882,11 +1943,7 @@ export class IModelTransformer extends IModelExportHandler {
1882
1943
}
1883
1944
}
1884
1945
1885
- if (
1886
- Id64 . isValid ( targetElementId ) &&
1887
- ! this . hasElementChanged ( sourceElement , targetElementId )
1888
- )
1889
- return ;
1946
+ if ( ! this . hasElementChanged ( sourceElement ) ) return ;
1890
1947
1891
1948
this . collectUnmappedReferences ( sourceElement ) ;
1892
1949
@@ -2848,6 +2905,12 @@ export class IModelTransformer extends IModelExportHandler {
2848
2905
) ) {
2849
2906
relationshipECClassIds . add ( row . ECInstanceId ) ;
2850
2907
}
2908
+ const elementECClassIds = new Set < string > ( ) ;
2909
+ for await ( const row of this . sourceDb . createQueryReader (
2910
+ "SELECT ECInstanceId FROM ECDbMeta.ECClassDef where ECInstanceId IS (BisCore.Element)"
2911
+ ) ) {
2912
+ elementECClassIds . add ( row . ECInstanceId ) ;
2913
+ }
2851
2914
2852
2915
// For later use when processing deletes.
2853
2916
const alreadyImportedElementInserts = new Set < Id64String > ( ) ;
@@ -2900,7 +2963,12 @@ export class IModelTransformer extends IModelExportHandler {
2900
2963
change . Scope . Id === this . targetScopeElementId
2901
2964
) {
2902
2965
elemIdToScopeEsa . set ( change . Element . Id , change ) ;
2903
- } else if ( changeType === "Inserted" || changeType === "Updated" )
2966
+ } else if (
2967
+ changeType === "Inserted" ||
2968
+ ( changeType === "Updated" &&
2969
+ change . ECClassId !== undefined &&
2970
+ elementECClassIds . has ( change . ECClassId ) )
2971
+ )
2904
2972
hasElementChangedCache . add ( change . ECInstanceId ) ;
2905
2973
}
2906
2974
0 commit comments