Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs =================================================================== diff -u -rd1da05ec938b495861737b25df84127a399e70a5 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (.../CalculationConfigurationImporter.cs) (revision d1da05ec938b495861737b25df84127a399e70a5) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (.../CalculationConfigurationImporter.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -122,7 +122,8 @@ protected void LogReadCalculationConversionError(string message, string calculationName) { - log.ErrorFormat(Resources.CalculationConfigurationImporter_ValidateCalculation_Error_message_0_calculation_1_skipped, message, calculationName); + log.ErrorFormat(Resources.CalculationConfigurationImporter_ValidateCalculation_ErrorMessage_0_Calculation_1_skipped, + message, calculationName); } private ReadResult ReadConfiguration() Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r5d7d6070e020dcc02fefb624d582c958d9bd9890 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5d7d6070e020dcc02fefb624d582c958d9bd9890) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -121,10 +121,10 @@ /// /// Looks up a localized string similar to {0} Berekening '{1}' is overgeslagen.. /// - public static string CalculationConfigurationImporter_ValidateCalculation_Error_message_0_calculation_1_skipped { + public static string CalculationConfigurationImporter_ValidateCalculation_ErrorMessage_0_Calculation_1_skipped { get { - return ResourceManager.GetString("CalculationConfigurationImporter_ValidateCalculation_Error_message_0_calculation_" + - "1_skipped", resourceCulture); + return ResourceManager.GetString("CalculationConfigurationImporter_ValidateCalculation_ErrorMessage_0_Calculation_1" + + "_skipped", resourceCulture); } } Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r5d7d6070e020dcc02fefb624d582c958d9bd9890 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 5d7d6070e020dcc02fefb624d582c958d9bd9890) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -538,7 +538,7 @@ {0} Er is geen berekeningenconfiguratie geïmporteerd. - + {0} Berekening '{1}' is overgeslagen. Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs =================================================================== diff -u -r60b9c5761bd42da110cf85a03e3e2db34109325e -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision 60b9c5761bd42da110cf85a03e3e2db34109325e) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Importers/GrassCoverErosionInwardsCalculationConfigurationImporter.cs (.../GrassCoverErosionInwardsCalculationConfigurationImporter.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -83,32 +83,16 @@ }; ReadDikeHeightCalculationType(readCalculation, calculation); - if(!ReadCriticalWaveReduction(readCalculation, calculation)) + if (TryReadCriticalWaveReduction(readCalculation, calculation) + && TryReadHydraulicBoundaryLocation(readCalculation, calculation) + && TryReadDikeProfile(readCalculation, calculation) + && TryReadOrientation(readCalculation, calculation) + && TryReadWaveReduction(readCalculation, calculation) + && TryReadDikeHeight(readCalculation, calculation)) { - return null; + return calculation; } - if (!ReadHydraulicBoundaryLocation(readCalculation, calculation)) - { - return null; - } - if (!ReadDikeProfile(readCalculation, calculation)) - { - return null; - } - if (!ReadOrientation(readCalculation, calculation)) - { - return null; - } - if (!ReadWaveReduction(readCalculation, calculation)) - { - return null; - } - if (!ReadDikeHeight(readCalculation, calculation)) - { - return null; - } - - return calculation; + return null; } /// @@ -118,7 +102,7 @@ /// The calculation to configure. /// false when the has a /// set which is not available in , true otherwise. - private bool ReadHydraulicBoundaryLocation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadHydraulicBoundaryLocation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) { if (readCalculation.HydraulicBoundaryLocation != null) { @@ -149,7 +133,7 @@ /// The calculation to configure. /// false when the has a /// set which is not available in , true otherwise. - private bool ReadDikeProfile(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadDikeProfile(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) { if (readCalculation.DikeProfile != null) { @@ -179,21 +163,19 @@ /// The calculation to configure. /// false when the orientation is invalid or when there is an orientation but /// no dike profile defined, true otherwise. - private bool ReadOrientation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadOrientation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) { - if (calculation.InputParameters.DikeProfile == null) + if (readCalculation.Orientation.HasValue) { - if (readCalculation.Orientation.HasValue) + if (calculation.InputParameters.DikeProfile == null) { LogReadCalculationConversionError( Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_Orientation, calculation.Name); return false; } - } - if (readCalculation.Orientation.HasValue) - { + double orientation = readCalculation.Orientation.Value; try @@ -220,7 +202,7 @@ /// The calculation read from the imported file. /// The calculation to configure. /// false when there is an invalid wave reduction parameter defined, true otherwise. - private bool ReadWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) { if (!ValidateWaveReduction(readCalculation, calculation)) { @@ -256,21 +238,18 @@ /// The calculation read from the imported file. /// The calculation to configure. /// false when there is a dike height but no dike profile defined, true otherwise. - private bool ReadDikeHeight(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadDikeHeight(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) { - if (calculation.InputParameters.DikeProfile == null) + if (readCalculation.DikeHeight.HasValue) { - if (readCalculation.DikeHeight.HasValue) + if (calculation.InputParameters.DikeProfile == null) { LogReadCalculationConversionError( Resources.GrassCoverErosionInwardsCalculationConfigurationImporter_ValidateWaveReduction_No_DikeProfile_provided_for_DikeHeight, calculation.Name); return false; } - } - else if (readCalculation.DikeHeight.HasValue) - { calculation.InputParameters.DikeHeight = (RoundedDouble) readCalculation.DikeHeight.Value; } return true; @@ -294,12 +273,14 @@ /// /// The calculation read from the imported file. /// The calculation to configure. - private bool ReadCriticalWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + /// true if reading all required wave reduction parameters was successful, + /// false otherwise. + private bool TryReadCriticalWaveReduction(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) { - return ReadCriticalFlowRateMean(readCalculation, calculation) && ReadCriticalFlowRateStandardDeviation(readCalculation, calculation); + return TryReadCriticalFlowRateMean(readCalculation, calculation) && TryReadCriticalFlowRateStandardDeviation(readCalculation, calculation); } - private bool ReadCriticalFlowRateMean(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadCriticalFlowRateMean(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) { if (!readCalculation.CriticalFlowRateMean.HasValue) { @@ -310,7 +291,7 @@ try { - calculation.InputParameters.CriticalFlowRate.Mean = (RoundedDouble)criticalFlowRateMean; + calculation.InputParameters.CriticalFlowRate.Mean = (RoundedDouble) criticalFlowRateMean; } catch (ArgumentOutOfRangeException e) { @@ -328,7 +309,7 @@ return true; } - private bool ReadCriticalFlowRateStandardDeviation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) + private bool TryReadCriticalFlowRateStandardDeviation(ReadGrassCoverErosionInwardsCalculation readCalculation, GrassCoverErosionInwardsCalculation calculation) { if (!readCalculation.CriticalFlowRateStandardDeviation.HasValue) { Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs =================================================================== diff -u -rae6ef0985e7b64acca060b6782e21a3446548366 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs (.../PipingCalculationConfigurationImporter.cs) (revision ae6ef0985e7b64acca060b6782e21a3446548366) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingCalculationConfigurationImporter.cs (.../PipingCalculationConfigurationImporter.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -57,9 +57,9 @@ /// Thrown when any parameter is /// null. public PipingCalculationConfigurationImporter(string xmlFilePath, - CalculationGroup importTarget, - IEnumerable availableHydraulicBoundaryLocations, - PipingFailureMechanism failureMechanism) + CalculationGroup importTarget, + IEnumerable availableHydraulicBoundaryLocations, + PipingFailureMechanism failureMechanism) : base(xmlFilePath, importTarget) { if (availableHydraulicBoundaryLocations == null) @@ -86,32 +86,16 @@ Name = readCalculation.Name }; - if (!ReadHydraulicBoundaryData(readCalculation, pipingCalculation)) + if (TryReadHydraulicBoundaryData(readCalculation, pipingCalculation) + && TryReadSurfaceLine(readCalculation, pipingCalculation) + && TryReadEntryExitPoint(readCalculation, pipingCalculation) + && TryReadStochasticSoilModel(readCalculation, pipingCalculation) + && TryReadStochasticSoilProfile(readCalculation, pipingCalculation) + && TryReadStochasts(readCalculation, pipingCalculation)) { - return null; + return pipingCalculation; } - if (!ReadSurfaceLine(readCalculation, pipingCalculation)) - { - return null; - } - if (!ReadEntryExitPoint(readCalculation, pipingCalculation)) - { - return null; - } - if (!ReadStochasticSoilModel(readCalculation, pipingCalculation)) - { - return null; - } - if (!ReadStochasticSoilProfile(readCalculation, pipingCalculation)) - { - return null; - } - if (!ReadStochasts(readCalculation, pipingCalculation)) - { - return null; - } - - return pipingCalculation; + return null; } /// @@ -121,7 +105,7 @@ /// The calculation to configure. /// false when the has a /// set which is not available in , true otherwise. - private bool ReadHydraulicBoundaryData(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) + private bool TryReadHydraulicBoundaryData(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) { if (readCalculation.HydraulicBoundaryLocation != null) { @@ -156,7 +140,7 @@ /// The calculation to configure. /// false when the has a /// set which is not available in , true otherwise. - private bool ReadSurfaceLine(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) + private bool TryReadSurfaceLine(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) { if (readCalculation.SurfaceLine != null) { @@ -184,7 +168,7 @@ /// The calculation to configure. /// false when entry or exit point is set without , /// or when entry or exit point is invalid, true otherwise. - private bool ReadEntryExitPoint(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) + private bool TryReadEntryExitPoint(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) { bool hasEntryPoint = readCalculation.EntryPointL.HasValue; bool hasExitPoint = readCalculation.ExitPointL.HasValue; @@ -218,7 +202,7 @@ try { - pipingCalculation.InputParameters.ExitPointL = (RoundedDouble)exitPoint; + pipingCalculation.InputParameters.ExitPointL = (RoundedDouble) exitPoint; } catch (ArgumentOutOfRangeException e) { @@ -244,7 +228,7 @@ /// when this is set. /// /// true otherwise. - private bool ReadStochasticSoilModel(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) + private bool TryReadStochasticSoilModel(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) { if (readCalculation.StochasticSoilModel != null) { @@ -287,7 +271,7 @@ /// a set which is not available in the . /// /// true otherwise. - private bool ReadStochasticSoilProfile(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) + private bool TryReadStochasticSoilProfile(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) { if (readCalculation.StochasticSoilProfile != null) { @@ -323,85 +307,97 @@ /// The calculation read from the imported file. /// The calculation to configure. /// false when a stochast value (mean or standard deviation) is invalid, true otherwise. - private bool ReadStochasts(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) + private bool TryReadStochasts(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) { - if (readCalculation.PhreaticLevelExitMean.HasValue && readCalculation.PhreaticLevelExitStandardDeviation.HasValue) - { - var normalDistribution = new NormalDistribution(); + return TryReadPhreaticLevelExit(readCalculation, pipingCalculation) + && TryReadDampingFactorExit(readCalculation, pipingCalculation); + } - double mean = readCalculation.PhreaticLevelExitMean.Value; - - try + private bool TryReadDampingFactorExit(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) + { + double? mean = readCalculation.DampingFactorExitMean; + double? standardDeviation = readCalculation.DampingFactorExitStandardDeviation; + if (mean.HasValue && standardDeviation.HasValue) + { + LogNormalDistribution normalDistribution = TryReadLogNormalDistribution(mean.Value, standardDeviation.Value, + PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName, + pipingCalculation.Name); + if (normalDistribution == null) { - normalDistribution.Mean = (RoundedDouble) mean; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.PipingCalculationConfigurationImporter_ReadStochasts_Invalid_mean_0_for_stochast_with_name_1, - mean, - PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName), - pipingCalculation.Name, e); return false; } - double standardDeviation = readCalculation.PhreaticLevelExitStandardDeviation.Value; + pipingCalculation.InputParameters.DampingFactorExit = normalDistribution; + } + return true; + } - try + private bool TryReadPhreaticLevelExit(ReadPipingCalculation readCalculation, PipingCalculationScenario pipingCalculation) + { + double? mean = readCalculation.PhreaticLevelExitMean; + double? standardDeviation = readCalculation.PhreaticLevelExitStandardDeviation; + if (mean.HasValue && standardDeviation.HasValue) + { + NormalDistribution normalDistribution = TryReadNormalDistribution(mean.Value, standardDeviation.Value, + PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName, + pipingCalculation.Name); + if (normalDistribution == null) { - normalDistribution.StandardDeviation = (RoundedDouble) standardDeviation; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.PipingCalculationConfigurationImporter_ReadStochasts_Invalid_standard_deviation_0_for_stochast_with_name_1, - standardDeviation, - PipingCalculationConfigurationSchemaIdentifiers.PhreaticLevelExitStochastName), - pipingCalculation.Name, e); return false; } pipingCalculation.InputParameters.PhreaticLevelExit = normalDistribution; } + return true; + } - if (readCalculation.DampingFactorExitMean.HasValue && readCalculation.DampingFactorExitStandardDeviation.HasValue) + private NormalDistribution TryReadNormalDistribution(double mean, double standardDeviation, string stochastName, string calculationName) + { + var distribution = new NormalDistribution(); + if (TryReadDistributionParameters(distribution, mean, standardDeviation, stochastName, calculationName)) { - var logNormalDistribution = new LogNormalDistribution(); - double mean = readCalculation.DampingFactorExitMean.Value; + return distribution; + } + return null; + } - try - { - logNormalDistribution.Mean = (RoundedDouble)mean; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.PipingCalculationConfigurationImporter_ReadStochasts_Invalid_mean_0_for_stochast_with_name_1, - mean, - PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName), - pipingCalculation.Name, e); - return false; - } + private LogNormalDistribution TryReadLogNormalDistribution(double mean, double standardDeviation, string stochastName, string calculationName) + { + var distribution = new LogNormalDistribution(); + if (TryReadDistributionParameters(distribution, mean, standardDeviation, stochastName, calculationName)) + { + return distribution; + } + return null; + } - double standardDeviation = readCalculation.DampingFactorExitStandardDeviation.Value; - - try - { - logNormalDistribution.StandardDeviation = (RoundedDouble)standardDeviation; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.PipingCalculationConfigurationImporter_ReadStochasts_Invalid_standard_deviation_0_for_stochast_with_name_1, - standardDeviation, - PipingCalculationConfigurationSchemaIdentifiers.DampingFactorExitStochastName), - pipingCalculation.Name, e); - return false; - } - - pipingCalculation.InputParameters.DampingFactorExit = logNormalDistribution; + private bool TryReadDistributionParameters(IDistribution distribution, double mean, double standardDeviation, string stochastName, string calculationName) + { + try + { + distribution.Mean = (RoundedDouble) mean; } + catch (ArgumentOutOfRangeException e) + { + LogOutOfRangeException(string.Format( + Resources.PipingCalculationConfigurationImporter_ReadStochasts_Invalid_Mean_0_for_stochast_with_StochastName_1_, + mean, stochastName), + calculationName, e); + return false; + } + try + { + distribution.StandardDeviation = (RoundedDouble) standardDeviation; + } + catch (ArgumentOutOfRangeException e) + { + LogOutOfRangeException(string.Format( + Resources.PipingCalculationConfigurationImporter_ReadStochasts_Invalid_StandardDeviation_0_for_stochast_with_StochastName_1_, + standardDeviation, stochastName), + calculationName, e); + return false; + } return true; } } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r7c433a2fecb8c13011283032fefffa662b43c8f5 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 7c433a2fecb8c13011283032fefffa662b43c8f5) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -253,20 +253,20 @@ /// /// Looks up a localized string similar to Een gemiddelde van '{0}' is ongeldig voor stochast '{1}'.. /// - public static string PipingCalculationConfigurationImporter_ReadStochasts_Invalid_mean_0_for_stochast_with_name_1 { + public static string PipingCalculationConfigurationImporter_ReadStochasts_Invalid_Mean_0_for_stochast_with_StochastName_1_ { get { - return ResourceManager.GetString("PipingCalculationConfigurationImporter_ReadStochasts_Invalid_mean_0_for_stochast_" + - "with_name_1", resourceCulture); + return ResourceManager.GetString("PipingCalculationConfigurationImporter_ReadStochasts_Invalid_Mean_0_for_stochast_" + + "with_StochastName_1_", resourceCulture); } } /// /// Looks up a localized string similar to Een standaardafwijking van '{0}' is ongeldig voor stochast '{1}'.. /// - public static string PipingCalculationConfigurationImporter_ReadStochasts_Invalid_standard_deviation_0_for_stochast_with_name_1 { + public static string PipingCalculationConfigurationImporter_ReadStochasts_Invalid_StandardDeviation_0_for_stochast_with_StochastName_1_ { get { - return ResourceManager.GetString("PipingCalculationConfigurationImporter_ReadStochasts_Invalid_standard_deviation_0" + - "_for_stochast_with_name_1", resourceCulture); + return ResourceManager.GetString("PipingCalculationConfigurationImporter_ReadStochasts_Invalid_StandardDeviation_0_" + + "for_stochast_with_StochastName_1_", resourceCulture); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx =================================================================== diff -u -r7c433a2fecb8c13011283032fefffa662b43c8f5 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 7c433a2fecb8c13011283032fefffa662b43c8f5) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -297,10 +297,10 @@ Een waarde van '{0}' als uittredepunt is ongeldig. - + Een gemiddelde van '{0}' is ongeldig voor stochast '{1}'. - + Een standaardafwijking van '{0}' is ongeldig voor stochast '{1}'. Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingCalculationConfigurationImporterTest.cs =================================================================== diff -u -rf7a31f0e8db5d1dcb2b08fb9d4fbeb91863ebd82 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingCalculationConfigurationImporterTest.cs (.../PipingCalculationConfigurationImporterTest.cs) (revision f7a31f0e8db5d1dcb2b08fb9d4fbeb91863ebd82) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingCalculationConfigurationImporterTest.cs (.../PipingCalculationConfigurationImporterTest.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -47,9 +47,9 @@ { // Call var importer = new PipingCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - new PipingFailureMechanism()); + new CalculationGroup(), + Enumerable.Empty(), + new PipingFailureMechanism()); // Assert Assert.IsInstanceOf>(importer); @@ -60,9 +60,9 @@ { // Call TestDelegate test = () => new PipingCalculationConfigurationImporter("", - new CalculationGroup(), - null, - new PipingFailureMechanism()); + new CalculationGroup(), + null, + new PipingFailureMechanism()); // Assert var exception = Assert.Throws(test); @@ -74,9 +74,9 @@ { // Call TestDelegate test = () => new PipingCalculationConfigurationImporter("", - new CalculationGroup(), - Enumerable.Empty(), - null); + new CalculationGroup(), + Enumerable.Empty(), + null); // Assert var exception = Assert.Throws(test); @@ -125,9 +125,9 @@ }, "readerPath"); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - new HydraulicBoundaryLocation[0], - pipingFailureMechanism); + calculationGroup, + new HydraulicBoundaryLocation[0], + pipingFailureMechanism); // Call var successful = false; @@ -148,9 +148,9 @@ var calculationGroup = new CalculationGroup(); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - Enumerable.Empty(), - new PipingFailureMechanism()); + calculationGroup, + Enumerable.Empty(), + new PipingFailureMechanism()); // Call var successful = false; @@ -171,9 +171,9 @@ var calculationGroup = new CalculationGroup(); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - new HydraulicBoundaryLocation[0], - new PipingFailureMechanism()); + calculationGroup, + new HydraulicBoundaryLocation[0], + new PipingFailureMechanism()); // Call var successful = false; @@ -195,9 +195,9 @@ var calculationGroup = new CalculationGroup(); var pipingFailureMechanism = new PipingFailureMechanism(); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - new HydraulicBoundaryLocation[0], - pipingFailureMechanism); + calculationGroup, + new HydraulicBoundaryLocation[0], + pipingFailureMechanism); // Call var successful = false; @@ -245,9 +245,9 @@ }, "readerPath"); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - new HydraulicBoundaryLocation[0], - pipingFailureMechanism); + calculationGroup, + new HydraulicBoundaryLocation[0], + pipingFailureMechanism); // Call var successful = false; @@ -295,9 +295,9 @@ }, "readerPath"); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - new HydraulicBoundaryLocation[0], - pipingFailureMechanism); + calculationGroup, + new HydraulicBoundaryLocation[0], + pipingFailureMechanism); // Call var successful = false; @@ -319,9 +319,9 @@ var calculationGroup = new CalculationGroup(); var pipingFailureMechanism = new PipingFailureMechanism(); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - new HydraulicBoundaryLocation[0], - pipingFailureMechanism); + calculationGroup, + new HydraulicBoundaryLocation[0], + pipingFailureMechanism); // Call var successful = false; @@ -347,9 +347,9 @@ var calculationGroup = new CalculationGroup(); var pipingFailureMechanism = new PipingFailureMechanism(); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - new HydraulicBoundaryLocation[0], - pipingFailureMechanism); + calculationGroup, + new HydraulicBoundaryLocation[0], + pipingFailureMechanism); // Call var successful = false; @@ -409,12 +409,12 @@ var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "HRlocatie", 10, 20); var importer = new PipingCalculationConfigurationImporter(filePath, - calculationGroup, - new[] - { - hydraulicBoundaryLocation - }, - pipingFailureMechanism); + calculationGroup, + new[] + { + hydraulicBoundaryLocation + }, + pipingFailureMechanism); // Call bool successful = importer.Import(); Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Importers/WaveConditionsCalculationConfigurationImporter.cs =================================================================== diff -u -r911577ed4bdd54ed724e39b8c221d5aa21510295 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Importers/WaveConditionsCalculationConfigurationImporter.cs (.../WaveConditionsCalculationConfigurationImporter.cs) (revision 911577ed4bdd54ed724e39b8c221d5aa21510295) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Importers/WaveConditionsCalculationConfigurationImporter.cs (.../WaveConditionsCalculationConfigurationImporter.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -87,29 +87,17 @@ Name = readCalculation.Name }; - if (!ReadHydraulicBoundaryLocation(readCalculation, waveConditionsCalculation)) - { - return null; - } - if (!ReadBoundaries(readCalculation, waveConditionsCalculation)) - { - return null; - } ReadStepSize(readCalculation, waveConditionsCalculation); - if (!ReadForeshoreProfile(readCalculation, waveConditionsCalculation)) + + if (TryReadHydraulicBoundaryLocation(readCalculation, waveConditionsCalculation) + && TryReadBoundaries(readCalculation, waveConditionsCalculation) + && TryReadForeshoreProfile(readCalculation, waveConditionsCalculation) + && TryReadOrientation(readCalculation, waveConditionsCalculation) + && TryReadWaveReduction(readCalculation, waveConditionsCalculation)) { - return null; + return waveConditionsCalculation; } - if (!ReadOrientation(readCalculation, waveConditionsCalculation)) - { - return null; - } - if (!ReadWaveReduction(readCalculation, waveConditionsCalculation)) - { - return null; - } - - return waveConditionsCalculation; + return null; } /// @@ -120,7 +108,7 @@ /// false when the has a /// set which is not available in /// , true otherwise. - private bool ReadHydraulicBoundaryLocation(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) + private bool TryReadHydraulicBoundaryLocation(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) { if (readCalculation.HydraulicBoundaryLocation != null) { @@ -147,80 +135,44 @@ /// The calculation read from the imported file. /// The calculation to configure. /// false when one of the boundaries is invalid, true otherwise. - private bool ReadBoundaries(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) + private bool TryReadBoundaries(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) { - if (readCalculation.UpperBoundaryRevetment.HasValue) - { - double upperBoundaryRevetment = readCalculation.UpperBoundaryRevetment.Value; + WaveConditionsInput input = calculation.InputParameters; + return TryReadParameter(readCalculation.UpperBoundaryRevetment, + v => input.UpperBoundaryRevetment = v, + Resources.WaveConditionsCalculationConfigurationImporter_DisplayName_UpperBoundaryRevetment, + calculation.Name) + && TryReadParameter(readCalculation.LowerBoundaryRevetment, + v => input.LowerBoundaryRevetment = v, + Resources.WaveConditionsCalculationConfigurationImporter_DisplayName_LowerBoundaryRevetment, + calculation.Name) + && TryReadParameter(readCalculation.UpperBoundaryWaterLevels, + v => input.UpperBoundaryWaterLevels = v, + Resources.WaveConditionsCalculationConfigurationImporter_DisplayName_UpperBoundaryWaterlevels, + calculation.Name) + && TryReadParameter(readCalculation.LowerBoundaryWaterLevels, + v => input.LowerBoundaryWaterLevels = v, + Resources.WaveConditionsCalculationConfigurationImporter_DisplayName_LowerBoundaryWaterlevels, + calculation.Name); + } - try - { - calculation.InputParameters.UpperBoundaryRevetment = (RoundedDouble) upperBoundaryRevetment; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.WaveConditionsCalculationConfigurationImporter_ReadBoundaries_UpperBoundaryRevetment_0_invalid, - upperBoundaryRevetment), - calculation.Name, e); - return false; - } - } - - if (readCalculation.LowerBoundaryRevetment.HasValue) + private bool TryReadParameter(double? readValue, Action setAsRoundedDouble, string parameterName, string calculationName) + { + if (readValue.HasValue) { - double lowerBoundaryRevetment = readCalculation.LowerBoundaryRevetment.Value; - try { - calculation.InputParameters.LowerBoundaryRevetment = (RoundedDouble) lowerBoundaryRevetment; + setAsRoundedDouble((RoundedDouble)readValue.Value); } catch (ArgumentOutOfRangeException e) { LogOutOfRangeException(string.Format( - Resources.WaveConditionsCalculationConfigurationImporter_ReadBoundaries_LowerBoundaryRevetment_0_invalid, - lowerBoundaryRevetment), - calculation.Name, e); + Resources.WaveConditionsCalculationConfigurationImporter_TryReadParameter_Value_0_ParameterName_1_is_invalid, + readValue.Value, parameterName), + calculationName, e); return false; } } - - if (readCalculation.UpperBoundaryWaterLevels.HasValue) - { - double upperBoundaryWaterLevels = readCalculation.UpperBoundaryWaterLevels.Value; - - try - { - calculation.InputParameters.UpperBoundaryWaterLevels = (RoundedDouble) upperBoundaryWaterLevels; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.WaveConditionsCalculationConfigurationImporter_ReadBoundaries_UpperBoundaryWaterlevels_0_invalid, - upperBoundaryWaterLevels), - calculation.Name, e); - return false; - } - } - - if (readCalculation.LowerBoundaryWaterLevels.HasValue) - { - double lowerBoundaryWaterLevels = readCalculation.LowerBoundaryWaterLevels.Value; - - try - { - calculation.InputParameters.LowerBoundaryWaterLevels = (RoundedDouble) lowerBoundaryWaterLevels; - } - catch (ArgumentOutOfRangeException e) - { - LogOutOfRangeException(string.Format( - Resources.WaveConditionsCalculationConfigurationImporter_ReadBoundaries_LowerBoundaryWaterlevels_0_invalid, - lowerBoundaryWaterLevels), - calculation.Name, e); - return false; - } - } - return true; } @@ -240,7 +192,7 @@ /// false when the has a /// set which is not available in , /// true otherwise. - private bool ReadForeshoreProfile(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) + private bool TryReadForeshoreProfile(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) { if (readCalculation.ForeshoreProfile != null) { @@ -266,7 +218,7 @@ /// The calculation read from the imported file. /// The calculation to configure. /// falce when the orientation is invalid, true otherwise. - private bool ReadOrientation(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) + private bool TryReadOrientation(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) { if (readCalculation.Orientation.HasValue) { @@ -295,7 +247,7 @@ /// The calculation to configure. /// false when there is an invalid wave reduction parameter defined, /// true otherwise. - private bool ReadWaveReduction(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) + private bool TryReadWaveReduction(ReadWaveConditionsCalculation readCalculation, IWaveConditionsCalculation calculation) { if (!ValidateWaveReduction(readCalculation, calculation)) { @@ -341,7 +293,7 @@ || readCalculation.BreakWaterType != null) { LogReadCalculationConversionError( - Resources.WaveConditionsCalculationConfigurationImporter_ValidateWaveReduction_No_foreshoreProfile_provided, + Resources.WaveConditionsCalculationConfigurationImporter_ValidateWaveReduction_No_foreshore_profile_provided, calculation.Name); return false; } Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Properties/Resources.Designer.cs =================================================================== diff -u -rae6ef0985e7b64acca060b6782e21a3446548366 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ae6ef0985e7b64acca060b6782e21a3446548366) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -147,42 +147,42 @@ } /// - /// Looks up a localized string similar to Een waarde van '{0}' als ondergrens bekledingen is ongeldig.. + /// Looks up a localized string similar to ondergrens bekledingen. /// - internal static string WaveConditionsCalculationConfigurationImporter_ReadBoundaries_LowerBoundaryRevetment_0_invalid { + internal static string WaveConditionsCalculationConfigurationImporter_DisplayName_LowerBoundaryRevetment { get { - return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_ReadBoundaries_LowerBoundaryRevetm" + - "ent_0_invalid", resourceCulture); + return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_DisplayName_LowerBoundaryRevetment" + + "", resourceCulture); } } /// - /// Looks up a localized string similar to Een waarde van '{0}' als ondergrens van de rekenreeks is ongeldig.. + /// Looks up a localized string similar to ondergrens van de rekenreeks. /// - internal static string WaveConditionsCalculationConfigurationImporter_ReadBoundaries_LowerBoundaryWaterlevels_0_invalid { + internal static string WaveConditionsCalculationConfigurationImporter_DisplayName_LowerBoundaryWaterlevels { get { - return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_ReadBoundaries_LowerBoundaryWaterl" + - "evels_0_invalid", resourceCulture); + return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_DisplayName_LowerBoundaryWaterleve" + + "ls", resourceCulture); } } /// - /// Looks up a localized string similar to Een waarde van '{0}' als bovengrens bekledingen is ongeldig.. + /// Looks up a localized string similar to bovengrens bekledingen. /// - internal static string WaveConditionsCalculationConfigurationImporter_ReadBoundaries_UpperBoundaryRevetment_0_invalid { + internal static string WaveConditionsCalculationConfigurationImporter_DisplayName_UpperBoundaryRevetment { get { - return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_ReadBoundaries_UpperBoundaryRevetm" + - "ent_0_invalid", resourceCulture); + return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_DisplayName_UpperBoundaryRevetment" + + "", resourceCulture); } } /// - /// Looks up a localized string similar to Een waarde van '{0}' als bovengrens van de rekenreeks is ongeldig.. + /// Looks up a localized string similar to bovengrens van de rekenreeks. /// - internal static string WaveConditionsCalculationConfigurationImporter_ReadBoundaries_UpperBoundaryWaterlevels_0_invalid { + internal static string WaveConditionsCalculationConfigurationImporter_DisplayName_UpperBoundaryWaterlevels { get { - return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_ReadBoundaries_UpperBoundaryWaterl" + - "evels_0_invalid", resourceCulture); + return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_DisplayName_UpperBoundaryWaterleve" + + "ls", resourceCulture); } } @@ -207,6 +207,16 @@ } /// + /// Looks up a localized string similar to Een waarde van '{0}' als {1} is ongeldig.. + /// + internal static string WaveConditionsCalculationConfigurationImporter_TryReadParameter_Value_0_ParameterName_1_is_invalid { + get { + return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_TryReadParameter_Value_0_Parameter" + + "Name_1_is_invalid", resourceCulture); + } + } + + /// /// Looks up a localized string similar to Het opgegeven voorlandprofiel '{0}' heeft geen geometrie en kan daarom niet gebruikt worden.. /// internal static string WaveConditionsCalculationConfigurationImporter_ValidateWaveReduction_ForeshoreProfile_0_has_no_geometry_and_cannot_be_used { @@ -219,10 +229,10 @@ /// /// Looks up a localized string similar to Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen.. /// - internal static string WaveConditionsCalculationConfigurationImporter_ValidateWaveReduction_No_foreshoreProfile_provided { + internal static string WaveConditionsCalculationConfigurationImporter_ValidateWaveReduction_No_foreshore_profile_provided { get { return ResourceManager.GetString("WaveConditionsCalculationConfigurationImporter_ValidateWaveReduction_No_foreshore" + - "Profile_provided", resourceCulture); + "_profile_provided", resourceCulture); } } Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Properties/Resources.resx =================================================================== diff -u -rae6ef0985e7b64acca060b6782e21a3446548366 -rd347acb3d57c61fd3baa1e883551807417db6698 --- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Properties/Resources.resx (.../Resources.resx) (revision ae6ef0985e7b64acca060b6782e21a3446548366) +++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Properties/Resources.resx (.../Resources.resx) (revision d347acb3d57c61fd3baa1e883551807417db6698) @@ -145,17 +145,17 @@ ..\Resources\BekledingenHrConfiguratieSchema.xsd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - - Een waarde van '{0}' als bovengrens bekledingen is ongeldig. + + bovengrens bekledingen - - Een waarde van '{0}' als ondergrens bekledingen is ongeldig. + + ondergrens bekledingen - - Een waarde van '{0}' als bovengrens van de rekenreeks is ongeldig. + + bovengrens van de rekenreeks - - Een waarde van '{0}' als ondergrens van de rekenreeks is ongeldig. + + ondergrens van de rekenreeks Een waarde van '{0}' als oriëntatie is ongeldig. @@ -166,7 +166,10 @@ Het opgegeven voorlandprofiel '{0}' heeft geen geometrie en kan daarom niet gebruikt worden. - + Er is geen voorlandprofiel opgegeven om golfreductie parameters aan toe te voegen. + + Een waarde van '{0}' als {1} is ongeldig. + \ No newline at end of file