Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Util/ClosingStructuresHelper.cs
===================================================================
diff -u -r7e3ea9fdd77f4efe3cd50c9adebbfcf369253bfd -r540898bb1046a0815eb45d17bf6bf74264ae84c3
--- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Util/ClosingStructuresHelper.cs (.../ClosingStructuresHelper.cs) (revision 7e3ea9fdd77f4efe3cd50c9adebbfcf369253bfd)
+++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Util/ClosingStructuresHelper.cs (.../ClosingStructuresHelper.cs) (revision 540898bb1046a0815eb45d17bf6bf74264ae84c3)
@@ -22,6 +22,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
+using Core.Common.Base;
using Ringtoets.ClosingStructures.Data;
using Ringtoets.Common.Data.Structures;
using Ringtoets.Common.Util;
@@ -36,82 +37,44 @@
{
///
/// Updates the for each element
- /// of if required due to a change.
+ /// of if required due to a change.
///
- /// The of
- /// to possibly reassign a calculation to.
- /// The of to try
- /// and match with the .
+ /// The failure mechanism which contains the
+ /// and calculations to update with.
/// All affected objects by the update.
- /// Thrown when any input parameter is null or when an element
- /// in is null.
- /// Thrown when element in is
- /// null.
- public static IEnumerable UpdateCalculationToSectionResultAssignments(
- IEnumerable sectionResults,
- IEnumerable> calculations)
+ /// Thrown when is null.
+ public static IEnumerable UpdateCalculationToSectionResultAssignments(ClosingStructuresFailureMechanism failureMechanism)
{
- ValidateSectionResults(sectionResults);
+ if (failureMechanism == null)
+ {
+ throw new ArgumentNullException(nameof(failureMechanism));
+ }
+ IObservableEnumerable sectionResults = failureMechanism.SectionResults2;
+ IEnumerable> calculations = failureMechanism.Calculations
+ .Cast>();
return AssignUnassignCalculations.Update(sectionResults.Select(AsCalculationAssignment),
AsCalculationsWithLocations(calculations))
.Cast()
.ToArray();
}
- ///
- /// Transforms the into and filter out the calculations
- /// for which a could not be made.
- ///
- /// The collection to transform.
- /// A collection of .
- /// Thrown when is null or when
- /// an element in is null.
private static IEnumerable AsCalculationsWithLocations(
IEnumerable> calculations)
{
- if (calculations == null)
+ var calculationsWithLocation = new List();
+ foreach (StructuresCalculation calculation in calculations)
{
- throw new ArgumentNullException(nameof(calculations));
+ if (calculation.InputParameters.Structure != null)
+ {
+ calculationsWithLocation.Add(new CalculationWithLocation(calculation,
+ calculation.InputParameters.Structure.Location));
+ }
}
- return calculations.Select(AsCalculationWithLocation).Where(c => c != null);
+ return calculationsWithLocation;
}
- ///
- /// Validates the section results.
- ///
- /// The to validate.
- /// Thrown when is null.
- /// Thrown when contains null items.
- private static void ValidateSectionResults(IEnumerable sectionResults)
- {
- if (sectionResults == null)
- {
- throw new ArgumentNullException(nameof(sectionResults));
- }
-
- if (sectionResults.Any(sr => sr == null))
- {
- throw new ArgumentException(@"SectionResults contains an entry without value.", nameof(sectionResults));
- }
- }
-
- private static CalculationWithLocation AsCalculationWithLocation(StructuresCalculation calculation)
- {
- if (calculation == null)
- {
- throw new ArgumentNullException(nameof(calculation));
- }
-
- if (calculation.InputParameters.Structure == null)
- {
- return null;
- }
-
- return new CalculationWithLocation(calculation, calculation.InputParameters.Structure.Location);
- }
-
private static SectionResultWithCalculationAssignment AsCalculationAssignment(
ClosingStructuresFailureMechanismSectionResult failureMechanismSectionResult)
{