Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresDataSynchronizationService.cs
===================================================================
diff -u -r7618e47c7ff0d09102d56e2c25545f57a4269352 -r6f46ce9a263e50bca4ff0cb32973f330defd6f3b
--- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresDataSynchronizationService.cs (.../StabilityPointStructuresDataSynchronizationService.cs) (revision 7618e47c7ff0d09102d56e2c25545f57a4269352)
+++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/StabilityPointStructuresDataSynchronizationService.cs (.../StabilityPointStructuresDataSynchronizationService.cs) (revision 6f46ce9a263e50bca4ff0cb32973f330defd6f3b)
@@ -26,6 +26,7 @@
using Core.Common.Base;
using Ringtoets.Common.Data.Structures;
using Ringtoets.Common.Service;
+using Ringtoets.Common.Utils;
using Ringtoets.HydraRing.Data;
using Ringtoets.StabilityPointStructures.Data;
@@ -122,6 +123,42 @@
return observables;
}
+ ///
+ /// Removes the given stability point structure and all dependent data, either
+ /// directly or indirectly, from the failure mechanism.
+ ///
+ /// The failure mechanism with at least 1 structure.
+ /// The structure to be removed.
+ /// All objects affected by the removal.
+ public static IEnumerable RemoveStructure(StabilityPointStructuresFailureMechanism failureMechanism,
+ StabilityPointStructure structure)
+ {
+ var changedObservables = new HashSet();
+ StructuresCalculation[] heightStructureCalculations = failureMechanism.Calculations
+ .Cast>()
+ .ToArray();
+ StructuresCalculation[] calculationWithRemovedStabilityPointStructure = heightStructureCalculations
+ .Where(c => ReferenceEquals(c.InputParameters.Structure, structure))
+ .ToArray();
+ foreach (StructuresCalculation calculation in calculationWithRemovedStabilityPointStructure)
+ {
+ calculation.InputParameters.Structure = null;
+
+ IEnumerable> affectedSectionResults =
+ StructuresHelper.Delete(failureMechanism.SectionResults, calculation, heightStructureCalculations);
+ foreach (StructuresFailureMechanismSectionResult result in affectedSectionResults)
+ {
+ changedObservables.Add(result);
+ }
+ changedObservables.Add(calculation.InputParameters);
+ }
+
+ failureMechanism.StabilityPointStructures.Remove(structure);
+ changedObservables.Add(failureMechanism.StabilityPointStructures);
+
+ return changedObservables;
+ }
+
private static IEnumerable ClearHydraulicBoundaryLocation(StabilityPointStructuresInput input)
{
if (input.HydraulicBoundaryLocation != null)