Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresDataSynchronizationService.cs
===================================================================
diff -u -rd9e5e7ea1e028347a738fc8e3d9c158a9b53ce15 -rf7b5ed585321bbc2249ec9c8ecd8af7f9eb1808a
--- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresDataSynchronizationService.cs (.../HeightStructuresDataSynchronizationService.cs) (revision d9e5e7ea1e028347a738fc8e3d9c158a9b53ce15)
+++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Service/HeightStructuresDataSynchronizationService.cs (.../HeightStructuresDataSynchronizationService.cs) (revision f7b5ed585321bbc2249ec9c8ecd8af7f9eb1808a)
@@ -21,6 +21,7 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Linq;
using Core.Common.Utils.Extensions;
using Ringtoets.HeightStructures.Data;
@@ -38,8 +39,14 @@
///
/// The which contains the calculations.
/// An of calculations which are affected by clearing the output.
+ /// Thrown when is null.
public static IEnumerable ClearAllCalculationOutput(HeightStructuresFailureMechanism failureMechanism)
{
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+
var affectedItems = failureMechanism.Calculations
.Cast()
.Where(c => c.HasOutput)
@@ -70,8 +77,14 @@
///
/// The which contains the calculations.
/// An of calculations which are affected by clearing the output.
+ /// Thrown when is null.
public static IEnumerable ClearHydraulicBoundaryLocations(HeightStructuresFailureMechanism failureMechanism)
{
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+
var affectedItems = failureMechanism.Calculations
.Cast()
.Where(c => c.InputParameters.HydraulicBoundaryLocation != null)
@@ -82,6 +95,46 @@
return affectedItems;
}
+ ///
+ /// Clears the and output for all the calculations in the .
+ ///
+ /// The which contains the calculations.
+ /// An of calculations which are affected by clearing the output.
+ /// Thrown when is null.
+ public static IEnumerable ClearAllCalculationOutputAndHydraulicBoundaryLocations(HeightStructuresFailureMechanism failureMechanism)
+ {
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException("failureMechanism");
+ }
+
+ Collection affectedItems = new Collection();
+
+ foreach (var calculation in failureMechanism.Calculations.Cast())
+ {
+ var calculationChanged = false;
+
+ if (calculation.HasOutput)
+ {
+ ClearCalculationOutput(calculation);
+ calculationChanged = true;
+ }
+
+ if (calculation.InputParameters.HydraulicBoundaryLocation != null)
+ {
+ ClearHydraulicBoundaryLocation(calculation);
+ calculationChanged = true;
+ }
+
+ if (calculationChanged)
+ {
+ affectedItems.Add(calculation);
+ }
+ }
+
+ return affectedItems;
+ }
+
private static void ClearHydraulicBoundaryLocation(HeightStructuresCalculation calculation)
{
calculation.InputParameters.HydraulicBoundaryLocation = null;