Index: Ringtoets/Common/src/Ringtoets.Common.Service/RingtoetsCommonDataSynchronizationService.cs
===================================================================
diff -u -r41a37c93cb0b3e36ff7023c9f42b4e6225598b55 -r7618e47c7ff0d09102d56e2c25545f57a4269352
--- Ringtoets/Common/src/Ringtoets.Common.Service/RingtoetsCommonDataSynchronizationService.cs (.../RingtoetsCommonDataSynchronizationService.cs) (revision 41a37c93cb0b3e36ff7023c9f42b4e6225598b55)
+++ Ringtoets/Common/src/Ringtoets.Common.Service/RingtoetsCommonDataSynchronizationService.cs (.../RingtoetsCommonDataSynchronizationService.cs) (revision 7618e47c7ff0d09102d56e2c25545f57a4269352)
@@ -20,7 +20,12 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
+using System.Linq;
+using Core.Common.Base;
using Core.Common.Base.Data;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.Data.Structures;
using Ringtoets.HydraRing.Data;
namespace Ringtoets.Common.Service
@@ -31,39 +36,62 @@
public static class RingtoetsCommonDataSynchronizationService
{
///
- /// Clears the output design water level
- /// of the .
+ /// Clears the output of the hydraulic boundary locations within the collection.
///
- /// The
- /// to clear the output for.
- /// Thrown when
- /// is null.
- public static void ClearDesignWaterLevel(HydraulicBoundaryLocation location)
+ /// The locations for which the output needs to be cleared.
+ /// All objects changed during the clear.
+ /// Thrown when is null.
+ public static IEnumerable ClearHydraulicBoundaryLocationOutput(IEnumerable locations)
{
- if (location == null)
+ if (locations == null)
{
- throw new ArgumentNullException("location");
+ throw new ArgumentNullException("locations");
}
- location.DesignWaterLevel = RoundedDouble.NaN;
+ return locations.SelectMany(ClearHydraulicBoundaryLocationOutput)
+ .ToArray();
}
///
- /// Clears the output WaveHeight
- /// of the .
+ /// Clears the output of the given .
///
- /// The
- /// to clear the output for.
- /// Thrown when
- /// is null.
- public static void ClearWaveHeight(HydraulicBoundaryLocation location)
+ /// The to clear the output for.
+ /// Thrown when is null.
+ /// All objects that have been changed.
+ public static IEnumerable ClearCalculationOutput(StructuresCalculation calculation) where T : ICalculationInput, new()
{
- if (location == null)
+ if (calculation == null)
{
- throw new ArgumentNullException("location");
+ throw new ArgumentNullException("calculation");
}
- location.WaveHeight = RoundedDouble.NaN;
+ if (calculation.HasOutput)
+ {
+ calculation.ClearOutput();
+ return new[]
+ {
+ calculation
+ };
+ }
+ return Enumerable.Empty();
}
+
+ private static IEnumerable ClearHydraulicBoundaryLocationOutput(HydraulicBoundaryLocation location)
+ {
+ if (!double.IsNaN(location.DesignWaterLevel) ||
+ !double.IsNaN(location.WaveHeight))
+ {
+ location.DesignWaterLevel = RoundedDouble.NaN;
+ location.WaveHeight = RoundedDouble.NaN;
+ location.DesignWaterLevelCalculationConvergence = CalculationConvergence.NotCalculated;
+ location.WaveHeightCalculationConvergence = CalculationConvergence.NotCalculated;
+
+ return new[]
+ {
+ location
+ };
+ }
+ return Enumerable.Empty();
+ }
}
}
\ No newline at end of file