Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs =================================================================== diff -u -r28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1 -rff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs (.../StabilityPointStructuresCalculationConfigurationImporter.cs) (revision 28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Configurations/StabilityPointStructuresCalculationConfigurationImporter.cs (.../StabilityPointStructuresCalculationConfigurationImporter.cs) (revision ff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493) @@ -103,10 +103,12 @@ && TrySetHydraulicBoundaryLocation(readCalculation.HydraulicBoundaryLocationName, calculation) && TrySetForeshoreProfile(readCalculation.ForeshoreProfileName, calculation) && TryReadFailureProbabilityRepairClosure(readCalculation, calculation) + && TryReadEvaluationLevel(readCalculation, calculation) && TryReadStochasts(readCalculation, calculation) && TryReadOrientation(readCalculation, calculation) && TryReadFailureProbabilityStructureWithErosion(readCalculation, calculation) && TryReadInflowModelType(readCalculation, calculation) + && TryReadLoadSchematizationType(readCalculation, calculation) && readCalculation.WaveReduction.ValidateWaveReduction(calculation.InputParameters.ForeshoreProfile, calculation.Name, Log)) { ReadFactorStormDurationOpenStructure(readCalculation, calculation); @@ -116,9 +118,35 @@ return null; } - private bool TryReadStochasts(StabilityPointStructuresCalculationConfiguration readCalculation, - StructuresCalculation calculation) + /// + /// Reads the evaluation level. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when the evaluation level is invalid or when there is an + /// evaluation level but no structure defined, true otherwise. + private bool TryReadEvaluationLevel(StabilityPointStructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) { + if (readCalculation.EvaluationLevel.HasValue) + { + if (calculation.InputParameters.Structure == null) + { + Log.LogCalculationConversionError(string.Format(RingtoetsCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_, + Resources.CalculationConfigurationImporter_EvaluationLevel_DisplayName), + calculation.Name); + + return false; + } + + calculation.InputParameters.EvaluationLevel = (RoundedDouble) readCalculation.EvaluationLevel.Value; + } + + return true; + } + + private bool TryReadStochasts(StabilityPointStructuresCalculationConfiguration readCalculation, + StructuresCalculation calculation) + { if (!readCalculation.ValidateStructureBaseStochasts(Log)) { return false; @@ -177,6 +205,18 @@ readCalculation.ModelFactorSuperCriticalFlow, i => i.ModelFactorSuperCriticalFlow, (i, d) => i.ModelFactorSuperCriticalFlow = d) && TryReadVariationCoefficientStochast( + StabilityPointStructuresConfigurationSchemaIdentifiers.ConstructiveStrengthLinearLoadModelStochastName, + calculation.Name, + calculation.InputParameters, + readCalculation.ConstructiveStrengthLinearLoadModel, + i => i.ConstructiveStrengthLinearLoadModel, (i, d) => i.ConstructiveStrengthLinearLoadModel = d) + && TryReadVariationCoefficientStochast( + StabilityPointStructuresConfigurationSchemaIdentifiers.ConstructiveStrengthQuadraticLoadModelStochastName, + calculation.Name, + calculation.InputParameters, + readCalculation.ConstructiveStrengthQuadraticLoadModel, + i => i.ConstructiveStrengthQuadraticLoadModel, (i, d) => i.ConstructiveStrengthQuadraticLoadModel = d) + && TryReadVariationCoefficientStochast( ConfigurationSchemaIdentifiers.StorageStructureAreaStochastName, calculation.Name, calculation.InputParameters, @@ -365,6 +405,34 @@ return true; } + /// + /// Reads the load schematization type. + /// + /// The calculation read from the imported file. + /// The calculation to configure. + /// false when the load schematization type is invalid or when there is a + /// load schematization type but no structure defined, true otherwise. + private bool TryReadLoadSchematizationType(StabilityPointStructuresCalculationConfiguration readCalculation, StructuresCalculation calculation) + { + if (readCalculation.LoadSchematizationType.HasValue) + { + if (calculation.InputParameters.Structure == null) + { + Log.LogCalculationConversionError(string.Format(RingtoetsCommonIOResources.CalculationConfigurationImporter_TryParameter_No_Structure_to_assign_Parameter_0_, + RingtoetsCommonIOResources.CalculationConfigurationImporter_InflowModelType_DisplayName), + calculation.Name); + + return false; + } + + calculation.InputParameters.LoadSchematizationType = (LoadSchematizationType) + new ConfigurationStabilityPointStructuresLoadSchematizationTypeConverter() + .ConvertTo(readCalculation.LoadSchematizationType.Value, typeof(LoadSchematizationType)); + } + + return true; + } + private bool TrySetHydraulicBoundaryLocation(string locationName, StructuresCalculation calculation) { HydraulicBoundaryLocation location; Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r3ca074d78bf75ff67c19539c04be91196a0659b0 -rff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 3ca074d78bf75ff67c19539c04be91196a0659b0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493) @@ -82,6 +82,15 @@ } /// + /// Looks up a localized string similar to analysehoogte. + /// + internal static string CalculationConfigurationImporter_EvaluationLevel_DisplayName { + get { + return ResourceManager.GetString("CalculationConfigurationImporter_EvaluationLevel_DisplayName", resourceCulture); + } + } + + /// /// Looks up a localized string similar to faalkans herstel van gefaalde situatie. /// internal static string CalculationConfigurationImporter_FailureProbabilityRepairClosure_DisplayName { Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Properties/Resources.resx =================================================================== diff -u -r3ca074d78bf75ff67c19539c04be91196a0659b0 -rff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Properties/Resources.resx (.../Resources.resx) (revision 3ca074d78bf75ff67c19539c04be91196a0659b0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.IO/Properties/Resources.resx (.../Resources.resx) (revision ff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493) @@ -117,6 +117,9 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + analysehoogte + faalkans herstel van gefaalde situatie Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs =================================================================== diff -u -r28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1 -rff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs (.../StabilityPointStructuresCalculationConfigurationImporterTest.cs) (revision 28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/Configurations/StabilityPointStructuresCalculationConfigurationImporterTest.cs (.../StabilityPointStructuresCalculationConfigurationImporterTest.cs) (revision ff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493) @@ -61,6 +61,10 @@ "Er kan geen spreiding voor stochast 'afvoercoefficient' opgegeven worden."); yield return new TestCaseData( + "validConfigurationEvaluationLevelWithoutStructure.xml", + "Er is geen kunstwerk opgegeven om analysehoogte aan toe te voegen."); + + yield return new TestCaseData( "validConfigurationInvalidFailureProbabilityStructureErosion.xml", "Een waarde van '1,1' als faalkans gegeven erosie bodem is ongeldig. De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen."); @@ -74,6 +78,9 @@ yield return new TestCaseData( "validConfigurationInflowModelTypeWithoutStructure.xml", "Er is geen kunstwerk opgegeven om instroommodel aan toe te voegen."); + yield return new TestCaseData( + "validConfigurationLoadSchematizationTypeWithoutStructure.xml", + "Er is geen kunstwerk opgegeven om instroommodel aan toe te voegen."); yield return new TestCaseData( "validConfigurationStructureNormalOrientationWithoutStructure.xml", @@ -215,36 +222,6 @@ AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); } - [TestCase("validConfigurationUnknownForeshoreProfile.xml", - "Het voorlandprofiel 'unknown' bestaat niet.")] - [TestCase("validConfigurationUnknownHydraulicBoundaryLocation.xml", - "De locatie met hydraulische randvoorwaarden 'unknown' bestaat niet.")] - [TestCase("validConfigurationUnknownStructure.xml", - "Het kunstwerk 'unknown' bestaat niet.")] - public void Import_ValidConfigurationUnknownData_LogMessageAndContinueImport(string file, string expectedErrorMessage) - { - // Setup - string filePath = Path.Combine(importerPath, file); - - var calculationGroup = new CalculationGroup(); - - var importer = new StabilityPointStructuresCalculationConfigurationImporter(filePath, - calculationGroup, - Enumerable.Empty(), - Enumerable.Empty(), - Enumerable.Empty()); - var successful = false; - - // Call - Action call = () => successful = importer.Import(); - - // Assert - string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; - TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 1); - Assert.IsTrue(successful); - CollectionAssert.IsEmpty(calculationGroup.Children); - } - [Test] public void Import_FullCalculationConfiguration_DataAddedToModel() { @@ -288,6 +265,16 @@ Structure = structure, ForeshoreProfile = foreshoreProfile, + AllowedLevelIncreaseStorage = + { + Mean = (RoundedDouble) 0.2, + StandardDeviation = (RoundedDouble) 0.01 + }, + AreaFlowApertures = + { + Mean = (RoundedDouble) 80.5, + StandardDeviation = (RoundedDouble) 1 + }, BankWidth = { Mean = (RoundedDouble) 1.2, @@ -298,101 +285,104 @@ Height = (RoundedDouble) 1.23, Type = BreakWaterType.Dam }, - - FactorStormDurationOpenStructure = (RoundedDouble) 0.002, - FailureProbabilityRepairClosure = 0.001, - FailureProbabilityStructureWithErosion = 0.0001, - - - - - InflowModelType = StabilityPointStructureInflowModelType.FloodedCulvert, - - - - - - - - - - - - - StructureNormalOrientation = (RoundedDouble) 7, - - - - UseBreakWater = true, - UseForeshore = false, - - - - - - - - - StormDuration = + ConstructiveStrengthLinearLoadModel = { - Mean = (RoundedDouble) 6.0 + Mean = (RoundedDouble) 2, + CoefficientOfVariation = (RoundedDouble) 0.1 }, - ModelFactorSuperCriticalFlow = + ConstructiveStrengthQuadraticLoadModel = { - Mean = (RoundedDouble) 1.10 + Mean = (RoundedDouble) 2, + CoefficientOfVariation = (RoundedDouble) 0.1 }, + CriticalOvertoppingDischarge = + { + Mean = (RoundedDouble) 2, + CoefficientOfVariation = (RoundedDouble) 0.1 + }, + DrainCoefficient = + { + Mean = (RoundedDouble) 0.1 + }, + EvaluationLevel = (RoundedDouble) 0.1, + FactorStormDurationOpenStructure = (RoundedDouble) 0.002, + FailureProbabilityRepairClosure = 0.001, + FailureProbabilityStructureWithErosion = 0.0001, FlowWidthAtBottomProtection = { Mean = (RoundedDouble) 15.2, StandardDeviation = (RoundedDouble) 0.1 }, - WidthFlowApertures = + InflowModelType = StabilityPointStructureInflowModelType.FloodedCulvert, + InsideWaterLevel = { - Mean = (RoundedDouble) 15.2, + Mean = (RoundedDouble) 0.5, StandardDeviation = (RoundedDouble) 0.1 }, - StorageStructureArea = + LoadSchematizationType = LoadSchematizationType.Quadratic, + ModelFactorSuperCriticalFlow = { - Mean = (RoundedDouble) 15000, - CoefficientOfVariation = (RoundedDouble) 0.01 + Mean = (RoundedDouble) 1.10 }, - AllowedLevelIncreaseStorage = + StormDuration = { - Mean = (RoundedDouble) 0.2, - StandardDeviation = (RoundedDouble) 0.01 + Mean = (RoundedDouble) 6.0 }, - CriticalOvertoppingDischarge = + StructureNormalOrientation = (RoundedDouble) 7, + UseBreakWater = true, + UseForeshore = false, + StorageStructureArea = { - Mean = (RoundedDouble) 2, - CoefficientOfVariation = (RoundedDouble) 0.1 + Mean = (RoundedDouble) 15000, + CoefficientOfVariation = (RoundedDouble) 0.01 }, - - AreaFlowApertures = + ThresholdHeightOpenWeir = { - Mean = (RoundedDouble) 80.5, - StandardDeviation = (RoundedDouble) 1 - }, - DrainCoefficient = - { - Mean = (RoundedDouble) 0.1 - }, - InsideWaterLevel = - { - Mean = (RoundedDouble) 0.5, + Mean = (RoundedDouble) 1.2, StandardDeviation = (RoundedDouble) 0.1 }, - ThresholdHeightOpenWeir = + WidthFlowApertures = { - Mean = (RoundedDouble) 1.2, + Mean = (RoundedDouble) 15.2, StandardDeviation = (RoundedDouble) 0.1 } } }; Assert.AreEqual(1, calculationGroup.Children.Count); - AssertCalculation(expectedCalculation, (StructuresCalculation)calculationGroup.Children[0]); + AssertCalculation(expectedCalculation, (StructuresCalculation) calculationGroup.Children[0]); } + [TestCase("validConfigurationUnknownForeshoreProfile.xml", + "Het voorlandprofiel 'unknown' bestaat niet.")] + [TestCase("validConfigurationUnknownHydraulicBoundaryLocation.xml", + "De locatie met hydraulische randvoorwaarden 'unknown' bestaat niet.")] + [TestCase("validConfigurationUnknownStructure.xml", + "Het kunstwerk 'unknown' bestaat niet.")] + public void Import_ValidConfigurationUnknownData_LogMessageAndContinueImport(string file, string expectedErrorMessage) + { + // Setup + string filePath = Path.Combine(importerPath, file); + + var calculationGroup = new CalculationGroup(); + + var importer = new StabilityPointStructuresCalculationConfigurationImporter(filePath, + calculationGroup, + Enumerable.Empty(), + Enumerable.Empty(), + Enumerable.Empty()); + var successful = false; + + // Call + Action call = () => successful = importer.Import(); + + // Assert + string expectedMessage = $"{expectedErrorMessage} Berekening 'Berekening 1' is overgeslagen."; + TestHelper.AssertLogMessageWithLevelIsGenerated(call, Tuple.Create(expectedMessage, LogLevelConstant.Error), 1); + Assert.IsTrue(successful); + CollectionAssert.IsEmpty(calculationGroup.Children); + } + private static void AssertCalculation(StructuresCalculation expectedCalculation, StructuresCalculation actualCalculation) { Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationEvaluationLevelWithoutStructure.xml =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationEvaluationLevelWithoutStructure.xml (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationEvaluationLevelWithoutStructure.xml (revision ff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493) @@ -0,0 +1,6 @@ + + + + 0.1 + + Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationLoadSchematizationTypeWithoutStructure.xml =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationLoadSchematizationTypeWithoutStructure.xml (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validConfigurationLoadSchematizationTypeWithoutStructure.xml (revision ff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493) @@ -0,0 +1,6 @@ + + + + kwadratisch + + Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validFullConfiguration.xml =================================================================== diff -u -r28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1 -rff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validFullConfiguration.xml (.../validFullConfiguration.xml) (revision 28bf5f4129f5d170ec9dfd9ab12f258a0193d7b1) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.IO.Test/test-data/StabilityPointStructuresCalculationConfigurationImporter/validFullConfiguration.xml (.../validFullConfiguration.xml) (revision ff6bb6b2bd6eb8bbd7c7c954dcde6fa6770dc493) @@ -7,7 +7,7 @@ kunstwerk1 7 verdronkenkoker - lineair + kwadratisch 0.1 2 0.001