Index: Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingDataSynchronizationService.cs =================================================================== diff -u -rc964c048005d93b097a1e6a817dace95b293040f -r52cdf6d3134a95bad594aa61c9ef062a97b1a2ab --- Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingDataSynchronizationService.cs (.../PipingDataSynchronizationService.cs) (revision c964c048005d93b097a1e6a817dace95b293040f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Service/PipingDataSynchronizationService.cs (.../PipingDataSynchronizationService.cs) (revision 52cdf6d3134a95bad594aa61c9ef062a97b1a2ab) @@ -27,6 +27,7 @@ using Core.Common.Utils.Extensions; using Ringtoets.HydraRing.Data; using Ringtoets.Piping.Data; +using Ringtoets.Piping.Primitives; namespace Ringtoets.Piping.Service { @@ -145,6 +146,81 @@ return observables; } + /// + /// Removes a given from the + /// and clears all data that depends on it, either directly or indirectly. + /// + /// The failure mechanism containing at least one surfaceline. + /// The surfaceline residing in + /// that should be removed. + /// All observable objects affected by this method. + /// Thrown when + /// or is null. + public static IEnumerable RemoveSurfaceLine(PipingFailureMechanism failureMechanism, RingtoetsPipingSurfaceLine surfaceLine) + { + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + if (surfaceLine == null) + { + throw new ArgumentNullException("surfaceLine"); + } + + var changedObservables = new List(); + foreach (PipingCalculation pipingCalculationScenario in failureMechanism.Calculations) + { + if (ReferenceEquals(pipingCalculationScenario.InputParameters.SurfaceLine, surfaceLine)) + { + pipingCalculationScenario.InputParameters.SurfaceLine = null; + changedObservables.Add(pipingCalculationScenario.InputParameters); + } + } + + failureMechanism.SurfaceLines.Remove(surfaceLine); + changedObservables.Add(failureMechanism.SurfaceLines); + + return changedObservables; + } + + /// + /// Removes a given from the + /// and clears all data that depends on it, either directly or indirectly. + /// + /// The failure mechanism containing at least one stochastic soil model. + /// The soil model residing in + /// that should be removed. + /// All observable objects affected by this method. + /// Thrown when + /// or is null. + public static IEnumerable RemoveStochasticSoilModel(PipingFailureMechanism failureMechanism, StochasticSoilModel soilModel) + { + if (failureMechanism == null) + { + throw new ArgumentNullException("failureMechanism"); + } + if (soilModel == null) + { + throw new ArgumentNullException("soilModel"); + } + + var changedObservables = new List(); + foreach (PipingCalculation pipingCalculationScenario in failureMechanism.Calculations) + { + if (ReferenceEquals(pipingCalculationScenario.InputParameters.StochasticSoilModel, soilModel)) + { + pipingCalculationScenario.InputParameters.StochasticSoilModel = null; + pipingCalculationScenario.InputParameters.StochasticSoilProfile = null; + changedObservables.Add(pipingCalculationScenario.InputParameters); + } + } + + failureMechanism.StochasticSoilModels.Remove(soilModel); + changedObservables.Add(failureMechanism.StochasticSoilModels); + + return changedObservables; + } + private static void ClearHydraulicBoundaryLocation(PipingCalculation calculation) { calculation.InputParameters.HydraulicBoundaryLocation = null;