Index: Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs
===================================================================
diff -u -rd9e5e7ea1e028347a738fc8e3d9c158a9b53ce15 -rf7b5ed585321bbc2249ec9c8ecd8af7f9eb1808a
--- Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs (.../RingtoetsDataSynchronizationService.cs) (revision d9e5e7ea1e028347a738fc8e3d9c158a9b53ce15)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Service/RingtoetsDataSynchronizationService.cs (.../RingtoetsDataSynchronizationService.cs) (revision f7b5ed585321bbc2249ec9c8ecd8af7f9eb1808a)
@@ -20,10 +20,7 @@
// All rights reserved.
using System;
-using System.Collections;
using System.Collections.Generic;
-using System.Linq;
-using Core.Common.Utils.Extensions;
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.GrassCoverErosionInwards.Data;
@@ -45,8 +42,8 @@
/// Clears all the output data within the .
///
/// The to clear the data for.
- /// Thrown when is null.
/// An of calculations which are affected by clearing the output.
+ /// Thrown when is null.
public static IEnumerable ClearAssessmentSectionData(IAssessmentSection assessmentSection)
{
if (assessmentSection == null)
@@ -59,60 +56,79 @@
}
///
- /// Clears the output of all calculations in the .
+ /// Clears all the output data and hydraulic boundary locations within the .
///
- /// The which contains the calculations.
+ /// The to clear the data for.
/// An of calculations which are affected by clearing the output.
- public static IEnumerable ClearFailureMechanismCalculationOutputs(IAssessmentSection assessmentSection)
+ /// /// Thrown when is null.
+ public static IEnumerable ClearAllCalculationOutputAndHydraulicBoundaryLocations(IAssessmentSection assessmentSection)
{
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException("assessmentSection");
+ }
+
List affectedItems = new List();
- var failureMechanisms = assessmentSection.GetFailureMechanisms().ToArray();
- failureMechanisms.OfType().ForEachElementDo(fm => affectedItems.AddRange(PipingDataSynchronizationService.ClearAllCalculationOutput(fm)));
- failureMechanisms.OfType().ForEachElementDo(fm => affectedItems.AddRange(GrassCoverErosionInwardsDataSynchronizationService.ClearAllCalculationOutput(fm)));
- failureMechanisms.OfType().ForEachElementDo(fm => affectedItems.AddRange(HeightStructuresDataSynchronizationService.ClearAllCalculationOutput(fm)));
+ foreach (var failureMechanism in assessmentSection.GetFailureMechanisms())
+ {
+ var pipingFailureMechanism = failureMechanism as PipingFailureMechanism;
+ var grassCoverErosionInwardsFailureMechanism = failureMechanism as GrassCoverErosionInwardsFailureMechanism;
+ var heightStructuresFailureMechanism = failureMechanism as HeightStructuresFailureMechanism;
+ if (pipingFailureMechanism != null)
+ {
+ affectedItems.AddRange(PipingDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(pipingFailureMechanism));
+ }
+ if (grassCoverErosionInwardsFailureMechanism != null)
+ {
+ affectedItems.AddRange(GrassCoverErosionInwardsDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(grassCoverErosionInwardsFailureMechanism));
+ }
+ if (heightStructuresFailureMechanism != null)
+ {
+ affectedItems.AddRange(HeightStructuresDataSynchronizationService.ClearAllCalculationOutputAndHydraulicBoundaryLocations(heightStructuresFailureMechanism));
+ }
+ }
+
return affectedItems;
}
///
- /// Clears the for all calculations in the .
+ /// Clears the output of all calculations in the .
///
/// The which contains the calculations.
/// An of calculations which are affected by clearing the output.
- public static IEnumerable ClearHydraulicBoundaryLocationFromCalculations(IAssessmentSection assessmentSection)
+ /// Thrown when is null.
+ public static IEnumerable ClearFailureMechanismCalculationOutputs(IAssessmentSection assessmentSection)
{
+ if (assessmentSection == null)
+ {
+ throw new ArgumentNullException("assessmentSection");
+ }
+
List affectedItems = new List();
- var failureMechanisms = assessmentSection.GetFailureMechanisms().ToArray();
- failureMechanisms.OfType().ForEachElementDo(fm => affectedItems.AddRange(PipingDataSynchronizationService.ClearHydraulicBoundaryLocations(fm)));
- failureMechanisms.OfType().ForEachElementDo(fm => affectedItems.AddRange(GrassCoverErosionInwardsDataSynchronizationService.ClearHydraulicBoundaryLocations(fm)));
- failureMechanisms.OfType().ForEachElementDo(fm => affectedItems.AddRange(HeightStructuresDataSynchronizationService.ClearHydraulicBoundaryLocations(fm)));
-
- return affectedItems;
- }
-
- ///
- /// Notifies the observers of the calculation in the .
- ///
- /// The which contains the calculations.
- public static void NotifyCalculationObservers(IAssessmentSection assessmentSection)
- {
- var failureMechanisms = assessmentSection.GetFailureMechanisms().ToArray();
-
- foreach (ICalculation calc in failureMechanisms.SelectMany(fm => fm.Calculations))
+ foreach (var failureMechanism in assessmentSection.GetFailureMechanisms())
{
- calc.NotifyObservers();
+ var pipingFailureMechanism = failureMechanism as PipingFailureMechanism;
+ var grassCoverErosionInwardsFailureMechanism = failureMechanism as GrassCoverErosionInwardsFailureMechanism;
+ var heightStructuresFailureMechanism = failureMechanism as HeightStructuresFailureMechanism;
+
+ if (pipingFailureMechanism != null)
+ {
+ affectedItems.AddRange(PipingDataSynchronizationService.ClearAllCalculationOutput(pipingFailureMechanism));
+ }
+ if (grassCoverErosionInwardsFailureMechanism != null)
+ {
+ affectedItems.AddRange(GrassCoverErosionInwardsDataSynchronizationService.ClearAllCalculationOutput(grassCoverErosionInwardsFailureMechanism));
+ }
+ if (heightStructuresFailureMechanism != null)
+ {
+ affectedItems.AddRange(HeightStructuresDataSynchronizationService.ClearAllCalculationOutput(heightStructuresFailureMechanism));
+ }
}
- }
- ///
- /// Notifies the observers of the .
- ///
- /// An containing the calculations to notify.
- public static void NotifyCalculationObservers(IEnumerable affectedCalculations)
- {
- affectedCalculations.ForEachElementDo(c => c.NotifyObservers());
+ return affectedItems;
}
private static void ClearHydraulicBoundaryLocationOutput(HydraulicBoundaryDatabase hydraulicBoundaryDatabase)