fix(transport): template Overwrite clears compositions and cascades removed slots' derived templates (TRN-4, TRN-5, WP2 task 2.6)
TRN-4: the composition rewire skipped any bundle template with zero compositions before the clear ran, so an Overwrite never removed the target's slots although the preview reported the removals. It now skips only an Add/Rename (nothing to clear). TRN-5: a slot the bundle removes is deleted through TemplateService.DeleteCompositionAsync, which cascades the slot-owned derived template (no DB relationship on OwnerCompositionId, so the row-only delete orphaned it and blocked deleting its base). A slot the bundle re-composes keeps the row-only delete so a pre-#118 bundle that re-composes the slot onto its derived template by name still resolves. Tests run the real importer against an EF context and fail on the previous importer.
This commit is contained in:
@@ -315,6 +315,8 @@ Site identifiers and connection names are environment-specific, so a bundle expo
|
||||
- `InstanceConnectionBinding.DataConnectionId` is resolved via the connection map, with a **Pass-2** that also binds connections which already exist in the target but were not carried in the bundle.
|
||||
- `InstanceNativeAlarmSourceOverride.ConnectionNameOverride` is rewritten to the **mapped target** connection name.
|
||||
|
||||
**Composition Overwrite (2026-12-03, TRN-4/TRN-5).** An Overwrite of a template whose bundle copy has **no** compositions still runs the composition clear — it used to skip the template entirely, so the target's slots survived an Overwrite the preview said would remove them. A slot the bundle **removes** (its instance name is not among the bundle owner's compositions, and no bundle composition names its composed template) is deleted through `TemplateService.DeleteCompositionAsync`, which also deletes its slot-owned derived template (and that template's nested slots); before, only the row was deleted, leaving a derived template with a dangling `OwnerCompositionId` and a live `ParentTemplateId` that then blocked deleting its base. A slot the bundle re-composes keeps the plain row delete-and-re-add, so a pre-#118 bundle that re-composes a slot onto its derived template by name still resolves.
|
||||
|
||||
### Derived (composition-slot) templates (ScadaBridge#118)
|
||||
|
||||
Composing a template into a slot creates a slot-owned **derived** template (`IsDerived`, `ParentTemplateId` = the base, `OwnerCompositionId` = the slot) named after the slot. Before #118 the bundle did not say so, and the importer re-created every such template as a **base** template named after its slot. Owner decision (2026-11-10): carry the relationship and rebuild the slot through the normal compose flow.
|
||||
|
||||
Reference in New Issue
Block a user