// 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.Integration.Data.StandAlone; using Ringtoets.Integration.Data.StandAlone.AssemblyFactories; using Ringtoets.Integration.Data.StandAlone.SectionResults; 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 slip off inwards. /// public static class ExportableGrassCoverSlipOffInwardsFailureMechanismFactory { private const ExportableFailureMechanismType failureMechanismCode = ExportableFailureMechanismType.GABI; private const ExportableFailureMechanismGroup failureMechanismGroup = ExportableFailureMechanismGroup.Group4; 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( GrassCoverSlipOffInwardsFailureMechanism 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 = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.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) { GrassCoverSlipOffInwardsFailureMechanismSectionResult failureMechanismSectionResult = failureMechanismSectionPair.Key; FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(failureMechanismSectionResult); FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(failureMechanismSectionResult); FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(failureMechanismSectionResult); FailureMechanismSectionAssemblyCategoryGroup combinedAssembly = GrassCoverSlipOffInwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(failureMechanismSectionResult); exportableResults.Add( new ExportableAggregatedFailureMechanismSectionAssemblyResult( failureMechanismSectionPair.Value, ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(simpleAssembly, ExportableAssemblyMethod.WBI0E1), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(detailedAssembly, ExportableAssemblyMethod.WBI0G1), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(tailorMadeAssembly, ExportableAssemblyMethod.WBI0T1), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(combinedAssembly, ExportableAssemblyMethod.WBI0A1))); } return exportableResults; } } }