Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingCalculationData.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingCalculationData.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingCalculationData.cs (revision 13a82b54dbaeb009ebbb5664208df2de6805a8a0) @@ -0,0 +1,41 @@ +// Copyright (C) Stichting Deltares 2016. 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 Ringtoets.HydraRing.Data; + +namespace Ringtoets.HydraRing.Calculation +{ + /// + /// Container of all data necessary for configuring a Hydra-Ring calculation. + /// + public class HydraRingCalculationData + { + /// + /// Gets or sets the . + /// + public HydraRingFailureMechanismType FailureMechanismType { get; set; } + + /// + /// Gets or sets the . + /// + public HydraulicBoundaryLocation HydraulicBoundaryLocation { get; set; } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingConfiguration.cs =================================================================== diff -u -r9e9c66250bb4043a30d397361fad334edd619037 -r13a82b54dbaeb009ebbb5664208df2de6805a8a0 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingConfiguration.cs (.../HydraRingConfiguration.cs) (revision 9e9c66250bb4043a30d397361fad334edd619037) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/HydraRingConfiguration.cs (.../HydraRingConfiguration.cs) (revision 13a82b54dbaeb009ebbb5664208df2de6805a8a0) @@ -24,7 +24,6 @@ using System.Collections.Specialized; using System.Globalization; using System.Linq; -using Ringtoets.HydraRing.Data; namespace Ringtoets.HydraRing.Calculation { @@ -33,6 +32,7 @@ /// public class HydraRingConfiguration { + private readonly IList hydraRingCalculations; private readonly IEnumerable configurationDefaults; private readonly IEnumerable configurationSettings; @@ -41,6 +41,8 @@ /// public HydraRingConfiguration() { + hydraRingCalculations = new List(); + configurationDefaults = new[] { new HydraRingConfigurationDefaults(HydraRingFailureMechanismType.AssessmentLevel, 1, 26, new[] @@ -671,16 +673,15 @@ public HydraRingUncertaintiesType? UncertaintiesType { get; set; } /// - /// Gets or sets the . + /// Adds a Hydra-Ring calculation to the . /// - public HydraulicBoundaryLocation HydraulicBoundaryLocation { get; set; } + /// The container that holds all data for configuring the calculation. + public void AddHydraRingCalculation(HydraRingCalculationData hydraRingCalculationData) + { + hydraRingCalculations.Add(hydraRingCalculationData); + } /// - /// Gets or sets the . - /// - public HydraRingFailureMechanismType? FailureMechanismType { get; set; } - - /// /// Generates a database creation script that can be used to perform a Hydra-Ring calculation. /// /// The database creation script. @@ -689,8 +690,6 @@ { var configurationDictionary = new Dictionary>(); - ValidateDataBaseCreationScriptInput(); - InitializeHydraulicModelsConfiguration(configurationDictionary); InitializeSectionsConfiguration(configurationDictionary); InitializeDesignTablesConfiguration(configurationDictionary); @@ -701,31 +700,6 @@ return GenerateDataBaseCreationScript(configurationDictionary); } - private void ValidateDataBaseCreationScriptInput() - { - var formattedExceptionMessage = "Cannot generate database creation script: {0} unspecified."; - - if (TimeIntegrationSchemeType == null) - { - throw new InvalidOperationException(string.Format(formattedExceptionMessage, "TimeIntegrationSchemeType")); - } - - if (UncertaintiesType == null) - { - throw new InvalidOperationException(string.Format(formattedExceptionMessage, "UncertaintiesType")); - } - - if (HydraulicBoundaryLocation == null) - { - throw new InvalidOperationException(string.Format(formattedExceptionMessage, "HydraulicBoundaryLocation")); - } - - if (FailureMechanismType == null) - { - throw new InvalidOperationException(string.Format(formattedExceptionMessage, "FailureMechanismType")); - } - } - private void InitializeHydraulicModelsConfiguration(Dictionary> configurationDictionary) { configurationDictionary["HydraulicModels"] = new List @@ -747,174 +721,176 @@ private void InitializeSectionsConfiguration(Dictionary> configurationDictionary) { - configurationDictionary["Sections"] = new List + configurationDictionary["Sections"] = hydraRingCalculations.Select(hydraRingCalculation => new OrderedDictionary { - new OrderedDictionary { - { - "SectionId", 999 // TODO: Dike section integration - }, - { - "PresentationId", 1 // Fixed: no support for combination of multiple dike sections - }, - { - "MainMechanismId", 1 // Fixed: no support for combination of multiple dike sections - }, - { - "Name", "HydraRingLocation" // TODO: Dike section integration - }, - { - "Description", "HydraRingLocation" // TODO: Dike section integration - }, - { - "RingCoordinateBegin", null // TODO: Dike section integration - }, - { - "RingCoordinateEnd", null // TODO: Dike section integration - }, - { - "XCoordinate", null // TODO: Dike cross section integration - }, - { - "YCoordinate", null // TODO: Dike cross section integration - }, - { - "StationId1", HydraulicBoundaryLocation.Id - }, - { - "StationId2", HydraulicBoundaryLocation.Id // Same as "StationId1": no support for coupling two stations - }, - { - "Relative", 100.0 // Fixed: no support for coupling two stations - }, - { - "Normal", null // TODO: Dike cross section integration - }, - { - "Length", null // TODO: Dike section integration - } + "SectionId", 999 // TODO: Dike section integration + }, + { + "PresentationId", 1 // Fixed: no support for combination of multiple dike sections + }, + { + "MainMechanismId", 1 // Fixed: no support for combination of multiple dike sections + }, + { + "Name", "HydraRingLocation" // TODO: Dike section integration + }, + { + "Description", "HydraRingLocation" // TODO: Dike section integration + }, + { + "RingCoordinateBegin", null // TODO: Dike section integration + }, + { + "RingCoordinateEnd", null // TODO: Dike section integration + }, + { + "XCoordinate", null // TODO: Dike cross section integration + }, + { + "YCoordinate", null // TODO: Dike cross section integration + }, + { + "StationId1", hydraRingCalculation.HydraulicBoundaryLocation.Id + }, + { + "StationId2", hydraRingCalculation.HydraulicBoundaryLocation.Id // Same as "StationId1": no support for coupling two stations + }, + { + "Relative", 100.0 // Fixed: no support for coupling two stations + }, + { + "Normal", null // TODO: Dike cross section integration + }, + { + "Length", null // TODO: Dike section integration } - }; + }).ToList(); } private void InitializeDesignTablesConfiguration(Dictionary> configurationDictionary) { - var defaultsForFailureMechanism = configurationDefaults.First(cs => cs.FailureMechanismType == FailureMechanismType); - - configurationDictionary["DesignTables"] = new List - { - new OrderedDictionary - { - { - "SectionId", 999 // TODO: Dike section integration - }, - { - "MechanismId", (int?) FailureMechanismType - }, - { - "LayerId", null // Fixed: no support for revetments - }, - { - "AlternativeId", null // Fixed: no support for piping - }, - { - "Method", defaultsForFailureMechanism.CalculationTypeId - }, - { - "VariableId", defaultsForFailureMechanism.VariableId - }, - { - "LoadVariableId", null // Fixed: not relevant - }, - { - "TableMin", null // Fixed: no support for type 3 computations (see "Method") - }, - { - "TableMax", null // Fixed: no support for type 3 computations (see "Method") - }, - { - "TableStepSize", null // Fixed: no support for type 3 computations (see "Method") - }, - { - "ValueMin", null // Fixed: no support for type 2 computations (see "Method") - }, - { - "ValueMax", null // Fixed: no support for type 2 computations (see "Method") - }, - { - "Beta", null // Fixed: no support for type 2 computations (see "Method") - } - } - }; + configurationDictionary["DesignTables"] = + (from hydraRingCalculation in hydraRingCalculations + let defaultsForFailureMechanism = configurationDefaults.First(cs => cs.FailureMechanismType == hydraRingCalculation.FailureMechanismType) + select new OrderedDictionary + { + { + "SectionId", 999 // TODO: Dike section integration + }, + { + "MechanismId", (int?) hydraRingCalculation.FailureMechanismType + }, + { + "LayerId", null // Fixed: no support for revetments + }, + { + "AlternativeId", null // Fixed: no support for piping + }, + { + "Method", defaultsForFailureMechanism.CalculationTypeId + }, + { + "VariableId", defaultsForFailureMechanism.VariableId + }, + { + "LoadVariableId", null // Fixed: not relevant + }, + { + "TableMin", null // Fixed: no support for type 3 computations (see "Method") + }, + { + "TableMax", null // Fixed: no support for type 3 computations (see "Method") + }, + { + "TableStepSize", null // Fixed: no support for type 3 computations (see "Method") + }, + { + "ValueMin", null // Fixed: no support for type 2 computations (see "Method") + }, + { + "ValueMax", null // Fixed: no support for type 2 computations (see "Method") + }, + { + "Beta", null // Fixed: no support for type 2 computations (see "Method") + } + }).ToList(); } private void InitializeNumericsConfiguration(Dictionary> configurationDictionary) { - configurationDictionary["Numerics"] = configurationSettings - .Where(cs => cs.HydraRingFailureMechanismType == FailureMechanismType) - .Select(cs => new OrderedDictionary - { - { - "SectionId", 999 // TODO: Dike section integration - }, - { - "MechanismId", (int?) FailureMechanismType - }, - { - "LayerId", null // Fixed: no support for revetments - }, - { - "AlternativeId", null // Fixed: no support for piping - }, - { - "SubMechanismId", cs.SubMechanismId - }, - { - "Method", cs.CalculationTechniqueId - }, - { - "FormStartMethod", cs.FormStartMethod - }, - { - "FormNumberOfIterations", cs.FormNumberOfIterations - }, - { - "FormRelaxationFactor", cs.FormRelaxationFactor - }, - { - "FormEpsBeta", cs.FormEpsBeta - }, - { - "FormEpsHOH", cs.FormEpsHOH - }, - { - "FormEpsZFunc", cs.FormEpsZFunc - }, - { - "DsStartMethod", cs.DsStartMethod - }, - { - "DsIterationmethod", 1 // Fixed: Not relevant - }, - { - "DsMinNumberOfIterations", cs.DsMinNumberOfIterations - }, - { - "DsMaxNumberOfIterations", cs.DsMaxNumberOfIterations - }, - { - "DsVarCoefficient", cs.DsVarCoefficient - }, - { - "NiUMin", cs.NiUMin - }, - { - "NiUMax", cs.NiUMax - }, - { - "NiNumberSteps", cs.NiNumberSteps - } - }).ToList(); + var orderDictionaries = new List(); + + foreach (var hydraRingCalculation in hydraRingCalculations) + { + orderDictionaries.AddRange(configurationSettings + .Where(cs => cs.HydraRingFailureMechanismType == hydraRingCalculation.FailureMechanismType) + .Select(cs => new OrderedDictionary + { + { + "SectionId", 999 // TODO: Dike section integration + }, + { + "MechanismId", (int?) hydraRingCalculation.FailureMechanismType + }, + { + "LayerId", null // Fixed: no support for revetments + }, + { + "AlternativeId", null // Fixed: no support for piping + }, + { + "SubMechanismId", cs.SubMechanismId + }, + { + "Method", cs.CalculationTechniqueId + }, + { + "FormStartMethod", cs.FormStartMethod + }, + { + "FormNumberOfIterations", cs.FormNumberOfIterations + }, + { + "FormRelaxationFactor", cs.FormRelaxationFactor + }, + { + "FormEpsBeta", cs.FormEpsBeta + }, + { + "FormEpsHOH", cs.FormEpsHOH + }, + { + "FormEpsZFunc", cs.FormEpsZFunc + }, + { + "DsStartMethod", cs.DsStartMethod + }, + { + "DsIterationmethod", 1 // Fixed: Not relevant + }, + { + "DsMinNumberOfIterations", cs.DsMinNumberOfIterations + }, + { + "DsMaxNumberOfIterations", cs.DsMaxNumberOfIterations + }, + { + "DsVarCoefficient", cs.DsVarCoefficient + }, + { + "NiUMin", cs.NiUMin + }, + { + "NiUMax", cs.NiUMax + }, + { + "NiNumberSteps", cs.NiNumberSteps + } + })); + } + + configurationDictionary["Numerics"] = orderDictionaries; } private void InitializeAreasConfiguration(Dictionary> configurationDictionary) Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj =================================================================== diff -u -r9e196d166be69221bf9cc0285136d20a7310fac8 -r13a82b54dbaeb009ebbb5664208df2de6805a8a0 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 9e196d166be69221bf9cc0285136d20a7310fac8) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Calculation/Ringtoets.HydraRing.Calculation.csproj (.../Ringtoets.HydraRing.Calculation.csproj) (revision 13a82b54dbaeb009ebbb5664208df2de6805a8a0) @@ -39,6 +39,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/HydraRingConfigurationTest.cs =================================================================== diff -u -rde09e649989e2c4f858632345841f7b9971debe3 -r13a82b54dbaeb009ebbb5664208df2de6805a8a0 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/HydraRingConfigurationTest.cs (.../HydraRingConfigurationTest.cs) (revision de09e649989e2c4f858632345841f7b9971debe3) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.Test/HydraRingConfigurationTest.cs (.../HydraRingConfigurationTest.cs) (revision 13a82b54dbaeb009ebbb5664208df2de6805a8a0) @@ -29,84 +29,20 @@ public class HydraRingConfigurationTest { [Test] - public void GenerateDataBaseCreationScript_TimeIntegrationSchemeTypeUnspecified_ThrowsInvalidOperationException() - { - var hydraRingConfiguration = new HydraRingConfiguration - { - UncertaintiesType = HydraRingUncertaintiesType.Model, - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(700003, "", 0, 0, ""), - FailureMechanismType = HydraRingFailureMechanismType.AssessmentLevel - }; - - // Call - TestDelegate test = () => hydraRingConfiguration.GenerateDataBaseCreationScript(); - - // Assert - Assert.Throws(test, "Cannot generate database creation script: TimeIntegrationSchemeType unspecified."); - } - - [Test] - public void GenerateDataBaseCreationScript_UncertaintiesTypeUnspecified_ThrowsInvalidOperationException() - { - var hydraRingConfiguration = new HydraRingConfiguration - { - TimeIntegrationSchemeType = HydraRingTimeIntegrationSchemeType.FBC, - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(700003, "", 0, 0, ""), - FailureMechanismType = HydraRingFailureMechanismType.AssessmentLevel - }; - - // Call - TestDelegate test = () => hydraRingConfiguration.GenerateDataBaseCreationScript(); - - // Assert - Assert.Throws(test, "Cannot generate database creation script: UncertaintiesType unspecified."); - } - - [Test] - public void GenerateDataBaseCreationScript_HydraulicBoundaryLocationUnspecified_ThrowsInvalidOperationException() - { - var hydraRingConfiguration = new HydraRingConfiguration - { - TimeIntegrationSchemeType = HydraRingTimeIntegrationSchemeType.FBC, - UncertaintiesType = HydraRingUncertaintiesType.Model, - FailureMechanismType = HydraRingFailureMechanismType.AssessmentLevel - }; - - // Call - TestDelegate test = () => hydraRingConfiguration.GenerateDataBaseCreationScript(); - - // Assert - Assert.Throws(test, "Cannot generate database creation script: HydraulicBoundaryLocation unspecified."); - } - - [Test] - public void GenerateDataBaseCreationScript_FailureMechanismTypeUnspecified_ThrowsInvalidOperationException() - { - var hydraRingConfiguration = new HydraRingConfiguration - { - TimeIntegrationSchemeType = HydraRingTimeIntegrationSchemeType.FBC, - UncertaintiesType = HydraRingUncertaintiesType.Model, - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(700003, "", 0, 0, "") - }; - - // Call - TestDelegate test = () => hydraRingConfiguration.GenerateDataBaseCreationScript(); - - // Assert - Assert.Throws(test, "Cannot generate database creation script: FailureMechanismType unspecified."); - } - - [Test] public void GenerateDataBaseCreationScript_NonDefaultHydraRingConfiguration_ReturnsExpectedCreationScript() { var hydraRingConfiguration = new HydraRingConfiguration { TimeIntegrationSchemeType = HydraRingTimeIntegrationSchemeType.NTI, - UncertaintiesType = HydraRingUncertaintiesType.Model, - HydraulicBoundaryLocation = new HydraulicBoundaryLocation(700003, "", 0, 0, ""), - FailureMechanismType = HydraRingFailureMechanismType.QVariant + UncertaintiesType = HydraRingUncertaintiesType.Model }; + hydraRingConfiguration.AddHydraRingCalculation(new HydraRingCalculationData + { + FailureMechanismType = HydraRingFailureMechanismType.QVariant, + HydraulicBoundaryLocation = new HydraulicBoundaryLocation(700003, "", 0, 0, "10.0") + }); + var expectedCreationScript = "DELETE FROM [HydraulicModels];" + Environment.NewLine + "INSERT INTO [HydraulicModels] VALUES (3, 2, 'WTI 2017');" + Environment.NewLine + Environment.NewLine +