// 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 Ringtoets.AssemblyTool.Data; using Ringtoets.AssemblyTool.Forms; using Ringtoets.Common.Data.Exceptions; using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.Views; using Ringtoets.Common.Primitives; using Ringtoets.GrassCoverErosionOutwards.Data; namespace Ringtoets.GrassCoverErosionOutwards.Forms.Views { /// /// Class for displaying as a row in a grid view. /// public class GrassCoverErosionOutwardsFailureMechanismSectionResultRow : FailureMechanismSectionResultRow { private FailureMechanismSectionAssemblyCategoryGroup simpleAssemblyCategoryGroup; private FailureMechanismSectionAssemblyCategoryGroup detailedAssemblyCategoryGroup; private FailureMechanismSectionAssemblyCategoryGroup tailorMadeAssemblyCategoryGroup; private FailureMechanismSectionAssemblyCategoryGroup combinedAssemblyCategoryGroup; /// /// Creates a new instance of . /// /// The to wrap /// so that it can be displayed as a row. /// Thrown when is null. internal GrassCoverErosionOutwardsFailureMechanismSectionResultRow(GrassCoverErosionOutwardsFailureMechanismSectionResult sectionResult) : base(sectionResult) { Update(); } /// /// Gets or sets the value representing the simple assessment result. /// public SimpleAssessmentResultType SimpleAssessmentResult { get { return SectionResult.SimpleAssessmentResult; } set { SectionResult.SimpleAssessmentResult = value; UpdateInternalData(); } } /// /// Gets or sets the value of the detailed assessment of safety per failure mechanism section /// for the factorized signaling norm (Cat Iv - IIv). /// /// Thrown when /// is a valid value, but unsupported. public DetailedAssessmentResultType DetailedAssessmentResultForFactorizedSignalingNorm { get { return SectionResult.DetailedAssessmentResultForFactorizedSignalingNorm; } set { SectionResult.DetailedAssessmentResultForFactorizedSignalingNorm = value; UpdateInternalData(); } } /// /// Gets or sets the value of the detailed assessment of safety per failure mechanism section /// for the signaling norm (Cat IIv - IIIv). /// /// Thrown when /// is a valid value, but unsupported. public DetailedAssessmentResultType DetailedAssessmentResultForSignalingNorm { get { return SectionResult.DetailedAssessmentResultForSignalingNorm; } set { SectionResult.DetailedAssessmentResultForSignalingNorm = value; UpdateInternalData(); } } /// /// Gets or sets the value of the detailed assessment of safety per failure mechanism section /// for the failure mechanism specific lower limit norm (Cat IIIv - IVv). /// /// Thrown when /// is a valid value, but unsupported. public DetailedAssessmentResultType DetailedAssessmentResultForMechanismSpecificLowerLimitNorm { get { return SectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm; } set { SectionResult.DetailedAssessmentResultForMechanismSpecificLowerLimitNorm = value; UpdateInternalData(); } } /// /// Gets or sets the value of the detailed assessment of safety per failure mechanism section /// for the lower limit norm (Cat IVv - Vv). /// /// Thrown when /// is a valid value, but unsupported. public DetailedAssessmentResultType DetailedAssessmentResultForLowerLimitNorm { get { return SectionResult.DetailedAssessmentResultForLowerLimitNorm; } set { SectionResult.DetailedAssessmentResultForLowerLimitNorm = value; UpdateInternalData(); } } /// /// Gets or sets the value of the detailed assessment of safety per failure mechanism section /// for the factorized lower limit norm (Cat Vv - VIv). /// /// Thrown when /// is a valid value, but unsupported. public DetailedAssessmentResultType DetailedAssessmentResultForFactorizedLowerLimitNorm { get { return SectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm; } set { SectionResult.DetailedAssessmentResultForFactorizedLowerLimitNorm = value; UpdateInternalData(); } } /// /// Gets or sets the tailor made assessment result. /// /// Thrown when /// is a valid value, but unsupported. public SelectableFailureMechanismSectionAssemblyCategoryGroup TailorMadeAssessmentResult { get { return SelectableFailureMechanismSectionAssemblyCategoryGroupConverter.ConvertTo(SectionResult.TailorMadeAssessmentResult); } set { SectionResult.TailorMadeAssessmentResult = SelectableFailureMechanismSectionAssemblyCategoryGroupConverter.ConvertFrom(value); UpdateInternalData(); } } /// /// Gets the simple assembly category group. /// public string SimpleAssemblyCategoryGroup { get { return FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(simpleAssemblyCategoryGroup); } } /// /// Gets the detailed assembly category group. /// public string DetailedAssemblyCategoryGroup { get { return FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(detailedAssemblyCategoryGroup); } } /// /// Gets the tailor made assembly category group. /// public string TailorMadeAssemblyCategoryGroup { get { return FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(tailorMadeAssemblyCategoryGroup); } } /// /// Gets the combined assembly category group. /// public string CombinedAssemblyCategoryGroup { get { return FailureMechanismSectionResultRowHelper.GetCategoryGroupDisplayname(combinedAssemblyCategoryGroup); } } /// /// Gets or sets the indicator whether the combined assembly should be overwritten by . /// /// Thrown when /// is a valid value, but unsupported. public bool UseManualAssemblyCategoryGroup { get { return SectionResult.UseManualAssemblyCategoryGroup; } set { SectionResult.UseManualAssemblyCategoryGroup = value; UpdateInternalData(); } } /// /// Gets or sets the manually selected assembly category group. /// /// Thrown when /// is a valid value, but unsupported. public SelectableFailureMechanismSectionAssemblyCategoryGroup ManualAssemblyCategoryGroup { get { return SelectableFailureMechanismSectionAssemblyCategoryGroupConverter.ConvertTo(SectionResult.ManualAssemblyCategoryGroup); } set { SectionResult.ManualAssemblyCategoryGroup = SelectableFailureMechanismSectionAssemblyCategoryGroupConverter.ConvertFrom(value); UpdateInternalData(); } } public override void Update() { UpdateDerivedData(); } private void UpdateDerivedData() { TryGetSimpleAssemblyCategoryGroup(); TryGetDetailedAssemblyCategoryGroup(); TryGetTailorMadeAssemblyCategoryGroup(); TryGetCombinedAssemblyCategoryGroup(); } private void TryGetSimpleAssemblyCategoryGroup() { try { simpleAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleSimpleAssessment(SectionResult); } catch (AssemblyException e) { simpleAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.None; } } private void TryGetDetailedAssemblyCategoryGroup() { try { detailedAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleDetailedAssessment(SectionResult); } catch (AssemblyException e) { detailedAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.None; } } private void TryGetTailorMadeAssemblyCategoryGroup() { try { tailorMadeAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleTailorMadeAssessment(SectionResult); } catch (AssemblyException e) { tailorMadeAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.None; } } private void TryGetCombinedAssemblyCategoryGroup() { try { combinedAssemblyCategoryGroup = GrassCoverErosionOutwardsFailureMechanismSectionResultAssemblyFactory.AssembleCombinedAssessment( SectionResult); } catch (AssemblyException e) { combinedAssemblyCategoryGroup = FailureMechanismSectionAssemblyCategoryGroup.None; } } } }