// Copyright (C) Stichting Deltares 2018. All rights reserved. // // This file is part of Ringtoets. // // Ringtoets is free software: you can redistribute it and/or modify // it under the terms of the GNU General Public License as published by // the Free Software Foundation, either version 3 of the License, or // (at your option) any later version. // // This program is distributed in the hope that it will be useful, // but WITHOUT ANY WARRANTY; without even the implied warranty of // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the // GNU General Public License for more details. // // You should have received a copy of the GNU General Public License // along with this program. If not, see . // // All names, logos, and references to "Deltares" are registered trademarks of // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. using System; using System.Collections.Generic; using System.Linq; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Data.FailureMechanism; namespace Ringtoets.Integration.Data.Assembly { /// /// Factory that creates instances. /// internal static class CombinedFailureMechanismSectionAssemblyResultFactory { /// /// Creates a collection of based /// on the given and . /// /// The output to create the results for. /// The failure mechanisms to create the results for. /// The assessment section to use while creating the results. /// A collection of . /// Thrown when any parameter is null. public static IEnumerable Create(IEnumerable output, IDictionary failureMechanisms, AssessmentSection assessmentSection) { if (output == null) { throw new ArgumentNullException(nameof(output)); } if (failureMechanisms == null) { throw new ArgumentNullException(nameof(failureMechanisms)); } if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } return output.Select((assembly, sectionNumber) => new CombinedFailureMechanismSectionAssemblyResult( sectionNumber + 1, assembly.Section.SectionStart, assembly.Section.SectionEnd, assembly.Section.CategoryGroup, CreateFailureMechanismResults(assembly.FailureMechanismResults, failureMechanisms, assessmentSection))) .ToArray(); } private static CombinedFailureMechanismSectionAssemblyResult.ConstructionProperties CreateFailureMechanismResults( IEnumerable failureMechanismResults, IDictionary failureMechanisms, AssessmentSection assessmentSection) { var constructionProperties = new CombinedFailureMechanismSectionAssemblyResult.ConstructionProperties { Piping = GetCategoryGroup(assessmentSection.Piping, failureMechanisms, failureMechanismResults), GrassCoverErosionInwards = GetCategoryGroup(assessmentSection.GrassCoverErosionInwards, failureMechanisms, failureMechanismResults), MacroStabilityInwards = GetCategoryGroup(assessmentSection.MacroStabilityInwards, failureMechanisms, failureMechanismResults), MacroStabilityOutwards = GetCategoryGroup(assessmentSection.MacroStabilityOutwards, failureMechanisms, failureMechanismResults), Microstability = GetCategoryGroup(assessmentSection.Microstability, failureMechanisms, failureMechanismResults), StabilityStoneCover = GetCategoryGroup(assessmentSection.StabilityStoneCover, failureMechanisms, failureMechanismResults), WaveImpactAsphaltCover = GetCategoryGroup(assessmentSection.WaveImpactAsphaltCover, failureMechanisms, failureMechanismResults), WaterPressureAsphaltCover = GetCategoryGroup(assessmentSection.WaterPressureAsphaltCover, failureMechanisms, failureMechanismResults), GrassCoverErosionOutwards = GetCategoryGroup(assessmentSection.GrassCoverErosionOutwards, failureMechanisms, failureMechanismResults), GrassCoverSlipOffOutwards = GetCategoryGroup(assessmentSection.GrassCoverSlipOffOutwards, failureMechanisms, failureMechanismResults), GrassCoverSlipOffInwards = GetCategoryGroup(assessmentSection.GrassCoverSlipOffInwards, failureMechanisms, failureMechanismResults), HeightStructures = GetCategoryGroup(assessmentSection.HeightStructures, failureMechanisms, failureMechanismResults), ClosingStructures = GetCategoryGroup(assessmentSection.ClosingStructures, failureMechanisms, failureMechanismResults), PipingStructure = GetCategoryGroup(assessmentSection.PipingStructure, failureMechanisms, failureMechanismResults), StabilityPointStructures = GetCategoryGroup(assessmentSection.StabilityPointStructures, failureMechanisms, failureMechanismResults), StrengthStabilityLengthwiseConstruction = GetCategoryGroup(assessmentSection.StrengthStabilityLengthwiseConstruction, failureMechanisms, failureMechanismResults), DuneErosion = GetCategoryGroup(assessmentSection.DuneErosion, failureMechanisms, failureMechanismResults), TechnicalInnovation = GetCategoryGroup(assessmentSection.TechnicalInnovation, failureMechanisms, failureMechanismResults) }; return constructionProperties; } private static FailureMechanismSectionAssemblyCategoryGroup GetCategoryGroup(IFailureMechanism failureMechanism, IDictionary failureMechanisms, IEnumerable failureMechanismResults) { return failureMechanisms.ContainsKey(failureMechanism) ? failureMechanismResults.ElementAt(failureMechanisms[failureMechanism]) : FailureMechanismSectionAssemblyCategoryGroup.NotApplicable; } } }