// 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 macro stability outwards. /// public static class ExportableMacroStabilityOutwardsFailureMechanismFactory { private const ExportableFailureMechanismGroup failureMechanismGroup = ExportableFailureMechanismGroup.Group4; private const ExportableFailureMechanismType failureMechanismCode = ExportableFailureMechanismType.STBU; 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( MacroStabilityOutwardsFailureMechanism 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 = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleFailureMechanism(failureMechanism, assessmentSection, false); return new ExportableFailureMechanism( new ExportableFailureMechanismAssemblyResult(failureMechanismAssemblyMethod, failureMechanismAssembly), CreateExportableFailureMechanismSectionResults(failureMechanism, assessmentSection), failureMechanismCode, failureMechanismGroup); } /// /// Creates a collection of /// with assembly results based on . /// /// The to create a collection of /// for. /// The assessment section the failure mechanism belongs to. /// A collection of . /// Thrown when assembly results cannot be created. private static IEnumerable CreateExportableFailureMechanismSectionResults( MacroStabilityOutwardsFailureMechanism failureMechanism, IAssessmentSection assessmentSection) { IDictionary failureMechanismSectionsLookup = ExportableFailureMechanismSectionHelper.CreateFailureMechanismSectionResultLookup(failureMechanism.SectionResults); var exportableResults = new List(); foreach (KeyValuePair failureMechanismSectionPair in failureMechanismSectionsLookup) { MacroStabilityOutwardsFailureMechanismSectionResult failureMechanismSectionResult = failureMechanismSectionPair.Key; FailureMechanismSectionAssemblyCategoryGroup simpleAssembly = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleSimpleAssessment(failureMechanismSectionResult); FailureMechanismSectionAssemblyCategoryGroup detailedAssembly = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleDetailedAssessment(failureMechanismSectionResult, failureMechanism, assessmentSection); FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssembly = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleTailorMadeAssessment(failureMechanismSectionResult, failureMechanism, assessmentSection); FailureMechanismSectionAssemblyCategoryGroup combinedAssembly = MacroStabilityOutwardsFailureMechanismAssemblyFactory.AssembleCombinedAssessment(failureMechanismSectionResult, failureMechanism, assessmentSection); exportableResults.Add( new ExportableAggregatedFailureMechanismSectionAssemblyResult( failureMechanismSectionPair.Value, ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(simpleAssembly, ExportableAssemblyMethod.WBI0E1), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(detailedAssembly, ExportableAssemblyMethod.WBI0G3), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(tailorMadeAssembly, ExportableAssemblyMethod.WBI0T7), ExportableSectionAssemblyResultFactory.CreateExportableSectionAssemblyResult(combinedAssembly, ExportableAssemblyMethod.WBI0A1))); } return exportableResults; } } }