Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs =================================================================== diff -u -r146a14cd6e338acf7600d9a1fb3da2a00cbb6e13 -r945edc69f1282c3c10aaa263430f82d620149a29 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs (.../MigrationTo181IntegrationTest.cs) (revision 146a14cd6e338acf7600d9a1fb3da2a00cbb6e13) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo181IntegrationTest.cs (.../MigrationTo181IntegrationTest.cs) (revision 945edc69f1282c3c10aaa263430f82d620149a29) @@ -81,6 +81,7 @@ AssertAssessmentSection(reader, sourceFilePath); AssertHydraulicBoundaryLocationsProperties(reader, sourceFilePath); AssertHydraulicBoundaryLocationsOnAssessmentSection(reader, sourceFilePath); + AssertHydraulicBoundaryLocationsOnGrassCoverErosionOutwardsFailureMechanism(reader, sourceFilePath); AssertPipingSoilLayers(reader); AssertHydraRingPreprocessor(reader); @@ -92,6 +93,8 @@ AssertClosingStructuresOutput(reader, sourceFilePath); AssertHeightStructuresOutput(reader, sourceFilePath); AssertStabilityPointStructuresOutput(reader, sourceFilePath); + + AssertGrassCoverErosionOutwardsFailureMechanismMetaEntity(reader, sourceFilePath ); } AssertLogDatabase(logFilePath); @@ -133,8 +136,6 @@ "GrassCoverErosionInwardsOvertoppingRateOutputEntity", "GrassCoverErosionInwardsSectionResultEntity", "GrassCoverErosionOutwardsFailureMechanismMetaEntity", - "GrassCoverErosionOutwardsHydraulicLocationEntity", - "GrassCoverErosionOutwardsHydraulicLocationOutputEntity", "GrassCoverErosionOutwardsSectionResultEntity", "GrassCoverErosionOutwardsWaveConditionsCalculationEntity", "GrassCoverErosionOutwardsWaveConditionsOutputEntity", @@ -147,7 +148,6 @@ "HeightStructuresSectionResultEntity", "HydraRingPreprocessorEntity", "HydraulicLocationEntity", - "HydraulicLocationOutputEntity", "IllustrationPointResultEntity", "MacroStabilityInwardsCalculationEntity", "MacroStabilityInwardsCalculationOutputEntity", @@ -485,6 +485,30 @@ AssertWaveHeightCalculationEntitiesOnAssessmentSection(reader, queryGenerator); } + private static void AssertHydraulicBoundaryLocationsOnGrassCoverErosionOutwardsFailureMechanism(MigratedDatabaseReader reader, string sourceFilePath) + { + var queryGenerator = new HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator(sourceFilePath); + + AssertDesignWaterLevelCalculationEntitiesOnGrassCoverErosionOutwardsFailureMechanism(reader, queryGenerator); + AssertWaveHeightCalculationEntitiesOnGrassCoverErosionOutwardsFailureMechanism(reader, queryGenerator); + } + + private static void AssertGrassCoverErosionOutwardsFailureMechanismMetaEntity(MigratedDatabaseReader reader, string sourceFilePath) + { + string validateMetaEntity = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT " + + "COUNT() = (SELECT COUNT() FROM [SOURCEPROJECT].GrassCoverErosionOutwardsFailureMechanismMetaEntity) " + + "FROM GrassCoverErosionOutwardsFailureMechanismMetaEntity new " + + "JOIN [SOURCEPROJECT].GrassCoverErosionOutwardsFailureMechanismMetaEntity source USING (GrassCoverErosionOutwardsFailureMechanismMetaEntityId) " + + "WHERE new.FailureMechanismEntityId = source.FailureMechanismEntityId " + + "AND new.N = source.N " + + "AND new.ForeshoreProfileCollectionSourcePath IS source.ForeshoreProfileCollectionSourcePath; " + + "DETACH DATABASE SOURCEPROJECT;"; + + reader.AssertReturnedDataIsValid(validateMetaEntity); + } + #region Migrated Hydraulic Boundary Locations on Assessment section private static void AssertWaveHeightCalculationEntitiesOnAssessmentSection(MigratedDatabaseReader reader, @@ -883,5 +907,366 @@ } #endregion + + #region Migrated Hydraulic Boundary Locations on Grass Cover Erosion Outwards Failure Mechanism + + private static void AssertDesignWaterLevelCalculationEntitiesOnGrassCoverErosionOutwardsFailureMechanism(MigratedDatabaseReader reader, + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator queryGenerator) + { + reader.AssertReturnedDataIsValid(queryGenerator.GetNrOfHydraulicBoundaryLocationCalculationsPerFailureMechanism( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetNrOfHydraulicBoundaryLocationCalculationsPerFailureMechanism( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaterLevelCalculationsForMechanismSpecificSignalingNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetNrOfHydraulicBoundaryLocationCalculationsPerFailureMechanism( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm)); + + reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedDesignWaterLevelCalculationsValidationQuery(NormativeNormType.SignalingNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedDesignWaterLevelCalculationOutputsValidationQuery(NormativeNormType.SignalingNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedDesignWaterLevelCalculationsValidationQuery(NormativeNormType.LowerLimitNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedDesignWaterLevelCalculationOutputsValidationQuery(NormativeNormType.LowerLimitNorm)); + + reader.AssertReturnedDataIsValid(queryGenerator.GetNewCalculationsValidationQuery( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm)); + reader.AssertReturnedDataIsValid(HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.GetNewCalculationOutputsValidationQuery( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm)); + } + + private static void AssertWaveHeightCalculationEntitiesOnGrassCoverErosionOutwardsFailureMechanism(MigratedDatabaseReader reader, + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator queryGenerator) + { + reader.AssertReturnedDataIsValid(queryGenerator.GetNrOfHydraulicBoundaryLocationCalculationsPerFailureMechanism( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetNrOfHydraulicBoundaryLocationCalculationsPerFailureMechanism( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaveHeightCalculationsForMechanismSpecificSignalingNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetNrOfHydraulicBoundaryLocationCalculationsPerFailureMechanism( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm)); + + reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedWaveHeightCalculationsValidationQuery(NormativeNormType.SignalingNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedWaveHeightCalculationOutputsValidationQuery(NormativeNormType.SignalingNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedWaveHeightCalculationsValidationQuery(NormativeNormType.LowerLimitNorm)); + reader.AssertReturnedDataIsValid(queryGenerator.GetMigratedWaveHeightCalculationOutputsValidationQuery(NormativeNormType.LowerLimitNorm)); + + reader.AssertReturnedDataIsValid(queryGenerator.GetNewCalculationsValidationQuery( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm)); + reader.AssertReturnedDataIsValid(HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.GetNewCalculationOutputsValidationQuery( + HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator.CalculationType.WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm)); + } + + private class HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator + { + /// + /// Enum to indicate the hydraulic location calculation type. + /// + public enum CalculationType + { + /// + /// Represents the water level calculations for the mechanism specific factorized signaling norm. + /// + WaterLevelCalculationsForMechanismSpecificFactorizedSignalingNorm = 1, + + /// + /// Represents the water level calculations for the mechanism specific signaling norm. + /// + WaterLevelCalculationsForMechanismSpecificSignalingNorm = 2, + + /// + /// Represents the water level calculations for the mechanism specific lower limit norm. + /// + WaterLevelCalculationsForMechanismSpecificLowerLimitNorm = 3, + + /// + /// Represents the wave height calculations for the mechanism specific factorized signaling norm. + /// + WaveHeightCalculationsForMechanismSpecificFactorizedSignalingNorm = 4, + + /// + /// Represents the wave height calculations for the mechanism specific signaling norm. + /// + WaveHeightCalculationsForMechanismSpecificSignalingNorm = 5, + + /// + /// Represents the wave height calculations for the mechanism specific lower limit norm. + /// + WaveHeightCalculationsForMechanismSpecificLowerLimitNorm = 6 + } + + private readonly string sourceFilePath; + + public HydraulicLocationOnGrassCoverErosionOutwardsFailureMechanismValidationQueryGenerator(string sourceFilePath) + { + if (string.IsNullOrWhiteSpace(sourceFilePath)) + { + throw new ArgumentException(@"Sourcefile path cannot be null or empty", + nameof(sourceFilePath)); + } + + this.sourceFilePath = sourceFilePath; + } + + /// + /// Generates a query to validate the number of created hydraulic boundary location calculations per failure mechanism section. + /// + /// The type of calculation that should be validated. + /// The query to validate the number of hydraulic boundary location calculations per assessment section. + public string GetNrOfHydraulicBoundaryLocationCalculationsPerFailureMechanism(CalculationType calculationType) + { + return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = 0 " + + "FROM " + + "( " + + "SELECT " + + "[FailureMechanismEntityId], " + + "COUNT(distinct GrassCoverErosionOutwardsHydraulicLocationEntityId) as OldCount, " + + "NEWCount " + + "FROM [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationEntity " + + "JOIN [SOURCEPROJECT].FailureMechanismEntity USING (FailureMechanismEntityId) " + + "LEFT JOIN " + + "( " + + "SELECT " + + "[FailureMechanismEntityId], " + + "COUNT(distinct HydraulicLocationEntityId) AS NewCount " + + "FROM GrassCoverErosionOutwardsFailureMechanismMetaEntity " + + "JOIN HydraulicLocationCalculationCollectionEntity " + + $"ON HydraulicLocationCalculationCollectionEntity{(int) calculationType}Id = HydraulicLocationCalculationCollectionEntityId " + + "JOIN HydraulicLocationCalculationCollectionToHydraulicCalculationEntity USING (HydraulicLocationCalculationCollectionEntityId) " + + "JOIN HydraulicLocationCalculationEntity USING (HydraulicLocationCalculationEntityId) " + + "JOIN FailureMechanismEntity USING (FailureMechanismEntityId) " + + "GROUP BY GrassCoverErosionOutwardsFailureMechanismMetaEntityId " + + ") USING (FailureMechanismEntityId) " + + "GROUP BY FailureMechanismEntityId " + + ") " + + "WHERE OldCount IS NOT NewCount; " + + "DETACH DATABASE SOURCEPROJECT;"; + } + + /// + /// Generates a query to validate if the hydraulic boundary calculation input for the wave height calculations + /// are migrated correctly. + /// + /// The norm type to generate the query for. + /// A query to validate the hydraulic boundary location calculation input for the wave height calculations. + /// Thrown when + /// is an invalid value of . + /// Thrown when is a valid value, + /// but is unsupported. + public string GetMigratedDesignWaterLevelCalculationsValidationQuery(NormativeNormType normType) + { + CalculationType calculationType = ConvertToDesignWaterLevelCalculationType(normType); + + return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT " + + "COUNT() = 0 " + + "FROM GrassCoverErosionOutwardsFailureMechanismMetaEntity gceofmme " + + "JOIN HydraulicLocationCalculationCollectionEntity hlcce " + + $"ON gceofmme.HydraulicLocationCalculationCollectionEntity{(int)calculationType}Id = hlcce.HydraulicLocationCalculationCollectionEntityId " + + "JOIN HydraulicLocationCalculationCollectionToHydraulicCalculationEntity USING (HydraulicLocationCalculationCollectionEntityId) " + + "JOIN HydraulicLocationCalculationEntity NEW USING (HydraulicLocationCalculationEntityId) " + + "JOIN [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationEntity OLD ON OLD.GrassCoverErosionOutwardsHydraulicLocationEntityId = NEW.HydraulicLocationEntityId " + + "JOIN FailureMechanismEntity USING (FailureMechanismEntityId) " + + "JOIN AssessmentSectionEntity ase USING (AssessmentSectionEntityId) " + + $"WHERE OLD.ShouldDesignWaterLevelIllustrationPointsBeCalculated != NEW.ShouldIllustrationPointsBeCalculated AND ase.NormativeNormType = {(int)normType}; " + + "DETACH DATABASE SOURCEPROJECT;"; + } + + /// + /// Generates a query to validate if the hydraulic boundary location calculation outputs related to the design water level calculations + /// are migrated correctly to the corresponding calculation entities. + /// + /// The norm type to generate the query for. + /// A query to validate the hydraulic boundary location calculation outputs. + /// Thrown when + /// is an invalid value of . + /// Thrown when is an unsupported value, + /// but is unsupported. + public string GetMigratedDesignWaterLevelCalculationOutputsValidationQuery(NormativeNormType normType) + { + CalculationType calculationType = ConvertToDesignWaterLevelCalculationType(normType); + + return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT " + + "COUNT() = ( " + + "SELECT COUNT() " + + "FROM [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationOutputEntity " + + "JOIN [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationEntity USING (GrassCoverErosionOutwardsHydraulicLocationEntityId) " + + "JOIN [SOURCEPROJECT].FailureMechanismEntity USING (FailureMechanismEntityId) " + + "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " + + $"WHERE HydraulicLocationOutputType = 1 AND NormativeNormType = {(int) normType}" + + ") " + + "FROM GrassCoverErosionOutwardsFailureMechanismMetaEntity gceofmme " + + "JOIN HydraulicLocationCalculationCollectionEntity hlcce " + + $"ON gceofmme.HydraulicLocationCalculationCollectionEntity{(int) calculationType}Id = hlcce.HydraulicLocationCalculationCollectionEntityId " + + "JOIN HydraulicLocationCalculationCollectionToHydraulicCalculationEntity USING (HydraulicLocationCalculationCollectionEntityId) " + + "JOIN HydraulicLocationCalculationEntity USING (HydraulicLocationCalculationEntityId) " + + "JOIN HydraulicLocationOutputEntity NEW USING (HydraulicLocationCalculationEntityId) " + + "JOIN [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationOutputEntity OLD ON NEW.GeneralResultSubMechanismIllustrationPointEntityId IS OLD.GeneralResultSubMechanismIllustrationPointEntityId " + + "AND NEW.Result IS OLD.Result " + + "AND NEW.TargetProbability IS OLD.TargetProbability " + + "AND NEW.TargetReliability IS OLD.TargetReliability " + + "AND NEW.CalculatedProbability IS OLD.CalculatedProbability " + + "AND NEW.CalculatedReliability IS OLD.CalculatedReliability " + + "AND NEW.CalculationConvergence = OLD.CalculationConvergence; " + + "DETACH DATABASE SOURCEPROJECT;"; + } + + /// + /// Generates a query to validate if the hydraulic boundary calculation input for the wave height calculations + /// are migrated correctly. + /// + /// The norm type to generate the query for. + /// A query to validate the hydraulic boundary location calculation input for the wave height calculations. + /// Thrown when + /// is an invalid value of . + /// Thrown when is a valid value, + /// but is unsupported. + public string GetMigratedWaveHeightCalculationsValidationQuery(NormativeNormType normType) + { + CalculationType calculationType = ConvertToWaveHeightCalculationType(normType); + + return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT " + + "COUNT() = 0 " + + "FROM GrassCoverErosionOutwardsFailureMechanismMetaEntity gceofmme " + + "JOIN HydraulicLocationCalculationCollectionEntity hlcce " + + $"ON gceofmme.HydraulicLocationCalculationCollectionEntity{(int) calculationType}Id = hlcce.HydraulicLocationCalculationCollectionEntityId " + + "JOIN HydraulicLocationCalculationCollectionToHydraulicCalculationEntity USING (HydraulicLocationCalculationCollectionEntityId) " + + "JOIN HydraulicLocationCalculationEntity NEW USING (HydraulicLocationCalculationEntityId) " + + "JOIN [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationEntity OLD ON OLD.GrassCoverErosionOutwardsHydraulicLocationEntityId = NEW.HydraulicLocationEntityId " + + "JOIN FailureMechanismEntity USING (FailureMechanismEntityId) " + + "JOIN AssessmentSectionEntity ase USING (AssessmentSectionEntityId) " + + $"WHERE OLD.ShouldWaveHeightIllustrationPointsBeCalculated != NEW.ShouldIllustrationPointsBeCalculated AND ase.NormativeNormType = {(int) normType}; " + + "DETACH DATABASE SOURCEPROJECT;"; + } + + /// + /// Generates a query to validate if the hydraulic boundary location calculation outputs related to the design water level calculations + /// are migrated correctly to the corresponding calculation entities. + /// + /// The norm type to generate the query for. + /// A query to validate the hydraulic boundary location calculation outputs. + /// Thrown when + /// is an invalid value of . + /// Thrown when is an unsupported value, + /// but is unsupported. + public string GetMigratedWaveHeightCalculationOutputsValidationQuery(NormativeNormType normType) + { + CalculationType calculationType = ConvertToWaveHeightCalculationType(normType); + + return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT " + + "COUNT() = ( " + + "SELECT COUNT() " + + "FROM [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationOutputEntity " + + "JOIN [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationEntity USING (GrassCoverErosionOutwardsHydraulicLocationEntityId) " + + "JOIN [SOURCEPROJECT].FailureMechanismEntity USING (FailureMechanismEntityId) " + + "JOIN [SOURCEPROJECT].AssessmentSectionEntity USING (AssessmentSectionEntityId) " + + $"WHERE HydraulicLocationOutputType = 2 AND NormativeNormType = {(int) normType}" + + ") " + + "FROM GrassCoverErosionOutwardsFailureMechanismMetaEntity gceofmme " + + "JOIN HydraulicLocationCalculationCollectionEntity hlcce " + + $"ON gceofmme.HydraulicLocationCalculationCollectionEntity{(int) calculationType}Id = hlcce.HydraulicLocationCalculationCollectionEntityId " + + "JOIN HydraulicLocationCalculationCollectionToHydraulicCalculationEntity USING (HydraulicLocationCalculationCollectionEntityId) " + + "JOIN HydraulicLocationCalculationEntity USING (HydraulicLocationCalculationEntityId) " + + "JOIN HydraulicLocationOutputEntity NEW USING (HydraulicLocationCalculationEntityId) " + + "JOIN [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationOutputEntity OLD ON NEW.GeneralResultSubMechanismIllustrationPointEntityId IS OLD.GeneralResultSubMechanismIllustrationPointEntityId " + + "AND NEW.Result IS OLD.Result " + + "AND NEW.TargetProbability IS OLD.TargetProbability " + + "AND NEW.TargetReliability IS OLD.TargetReliability " + + "AND NEW.CalculatedProbability IS OLD.CalculatedProbability " + + "AND NEW.CalculatedReliability IS OLD.CalculatedReliability " + + "AND NEW.CalculationConvergence = OLD.CalculationConvergence; " + + "DETACH DATABASE SOURCEPROJECT;"; + } + + /// + /// Generates a query to validate the new hydraulic boundary location calculations that are not based on migrated data. + /// + /// The type of calculation on which the input should be validated. + /// The query to validate the hydraulic boundary location calculation input. + public string GetNewCalculationsValidationQuery(CalculationType calculationType) + { + return $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = (SELECT COUNT() FROM [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationEntity) " + + "FROM GrassCoverErosionOutwardsFailureMechanismMetaEntity " + + "JOIN HydraulicLocationCalculationCollectionEntity " + + $"ON HydraulicLocationCalculationCollectionEntity{(int) calculationType}Id = HydraulicLocationCalculationCollectionEntityId " + + "JOIN HydraulicLocationCalculationCollectionToHydraulicCalculationEntity USING (HydraulicLocationCalculationCollectionEntityId) " + + "JOIN HydraulicLocationCalculationEntity hlce USING (HydraulicLocationCalculationEntityId) " + + "WHERE hlce.ShouldIllustrationPointsBeCalculated = 0;" + + "DETACH DATABASE SOURCEPROJECT;"; + } + + /// + /// Generates a query to validate the new hydraulic boundary location calculation outputs that are not based on migrated data. + /// + /// The type of calculation on which the output should be validated. + /// The query to validate the hydraulic boundary location calculation input. + public static string GetNewCalculationOutputsValidationQuery(CalculationType calculationType) + { + return "SELECT " + + "COUNT() = 0 " + + "FROM GrassCoverErosionOutwardsFailureMechanismMetaEntity " + + "JOIN HydraulicLocationCalculationCollectionEntity " + + $"ON HydraulicLocationCalculationCollectionEntity{(int) calculationType}Id = HydraulicLocationCalculationCollectionEntityId " + + "JOIN HydraulicLocationCalculationCollectionToHydraulicCalculationEntity USING (HydraulicLocationCalculationCollectionEntityId) " + + "JOIN HydraulicLocationCalculationEntity USING (HydraulicLocationCalculationEntityId) " + + "JOIN HydraulicLocationOutputEntity USING (HydraulicLocationCalculationEntityId); "; + } + + /// + /// Converts the to the corresponding design water level calculation from . + /// + /// The norm type to convert. + /// Returns the converted . + /// Thrown when + /// is an invalid value of . + /// Thrown when is an unsupported value, + /// but is unsupported. + private static CalculationType ConvertToDesignWaterLevelCalculationType(NormativeNormType normType) + { + if (!Enum.IsDefined(typeof(NormativeNormType), normType)) + { + throw new InvalidEnumArgumentException(nameof(normType), (int) normType, typeof(NormativeNormType)); + } + + switch (normType) + { + case NormativeNormType.LowerLimitNorm: + return CalculationType.WaterLevelCalculationsForMechanismSpecificLowerLimitNorm; + case NormativeNormType.SignalingNorm: + return CalculationType.WaterLevelCalculationsForMechanismSpecificSignalingNorm; + default: + throw new NotSupportedException(); + } + } + + /// + /// Converts the to the corresponding wave height calculation from . + /// + /// The norm type to convert. + /// Returns the converted . + /// Thrown when + /// is an invalid value of . + /// Thrown when is an unsupported value, + /// but is unsupported. + private static CalculationType ConvertToWaveHeightCalculationType(NormativeNormType normType) + { + if (!Enum.IsDefined(typeof(NormativeNormType), normType)) + { + throw new InvalidEnumArgumentException(nameof(normType), (int) normType, typeof(NormativeNormType)); + } + + switch (normType) + { + case NormativeNormType.LowerLimitNorm: + return CalculationType.WaveHeightCalculationsForMechanismSpecificLowerLimitNorm; + case NormativeNormType.SignalingNorm: + return CalculationType.WaveHeightCalculationsForMechanismSpecificSignalingNorm; + default: + throw new NotSupportedException(); + } + } + } + + #endregion } } \ No newline at end of file