// Copyright (C) Stichting Deltares 2017. 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 Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.Exceptions; using Ringtoets.GrassCoverErosionOutwards.Data; using Ringtoets.Integration.IO.Assembly; using Ringtoets.Integration.IO.Helpers; namespace Ringtoets.Integration.IO.Factories { /// /// Factory to create instances of /// with assembly results for grass cover erosion outwards. /// public static class ExportableGrassCoverErosionOutwardsFailureMechanismFactory { private const ExportableFailureMechanismType failureMechanismCode = ExportableFailureMechanismType.GEBU; private const ExportableFailureMechanismGroup failureMechanismGroup = ExportableFailureMechanismGroup.Group3; private const ExportableAssemblyMethod failureMechanismAssemblyMethod = ExportableAssemblyMethod.WBI1A1; /// /// Creates an /// with assembly results based on the input parameters. /// /// The to create an /// for. /// The assessment section this failure mechanism belongs to. /// An with assembly results. /// Thrown when any parameter is null. /// Thrown when assembly results cannot be created. public static ExportableFailureMechanism CreateExportableFailureMechanism( GrassCoverErosionOutwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { if (failureMechanism == null) { throw new ArgumentNullException(nameof(failureMechanism)); } if (assessmentSection == null) { throw new ArgumentNullException(nameof(assessmentSection)); } if (!failureMechanism.IsRelevant) { return ExportableFailureMechanismFactory.CreateDefaultExportableFailureMechanismWithoutProbability(assessmentSection, failureMechanismCode, failureMechanismGroup, failureMechanismAssemblyMethod); } FailureMechanismAssemblyCategoryGroup failureMechanismAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism, false); return new ExportableFailureMechanism( new ExportableFailureMechanismAssemblyResult(failureMechanismAssemblyMethod, failureMechanismAssembly), CreateFailureMechanismSectionResults(failureMechanism.SectionResults), failureMechanismCode, failureMechanismGroup); } /// /// Creates a collection of /// with assembly results based on . /// /// The collection of /// to create a collection of for. /// A collection of . /// Thrown when assembly results cannot be created. private static IEnumerable CreateFailureMechanismSectionResults( IEnumerable failureMechanismSectionResults) { IDictionary failureMechanismSectionsLookup = ExportableFailureMechanismSectionHelper.CreateFailureMechanismSectionResultLookup(failureMechanismSectionResults); var exportableResults = new List(); foreach (KeyValuePair failureMechanismSectionPair in failureMechanismSectionsLookup) { GrassCoverErosionOutwardsFailureMechanismSectionResult failureMechanismSectionResult = failureMechanismSectionPair.Key; FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(failureMechanismSectionResult); FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(failureMechanismSectionResult); FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(failureMechanismSectionResult); FailureMechanismSectionAssemblyCategoryGroup combinedAssembly = GrassCoverErosionOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(failureMechanismSectionResult); exportableResults.Add( new ExportableAggregatedFailureMechanismSectionAssemblyResult( failureMechanismSectionPair.Value, ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(simpleAssembly, ExportableAssemblyMethod.WBI0E1), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(detailedAssembly, ExportableAssemblyMethod.WBI0G6), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(tailorMadeAssembly, ExportableAssemblyMethod.WBI0T4), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(combinedAssembly, ExportableAssemblyMethod.WBI0A1))); } return exportableResults; } } }