Index: Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/Migration_18.1_19.1.sql =================================================================== diff -u -r18db2b511b48fcfb89710dd852b3ca9fb0b83b55 -r2a8e64e10b3b969e48a81f0eb43f20720669a4e7 --- Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/Migration_18.1_19.1.sql (.../Migration_18.1_19.1.sql) (revision 18db2b511b48fcfb89710dd852b3ca9fb0b83b55) +++ Riskeer/Migration/src/Riskeer.Migration.Core/EmbeddedResources/Migration_18.1_19.1.sql (.../Migration_18.1_19.1.sql) (revision 2a8e64e10b3b969e48a81f0eb43f20720669a4e7) @@ -198,7 +198,30 @@ FROM [SOURCEPROJECT].ForeshoreProfileEntity ) USING(ForeshoreProfileEntityId); INSERT INTO ClosingStructuresFailureMechanismMetaEntity SELECT * FROM [SOURCEPROJECT].ClosingStructuresFailureMechanismMetaEntity; -INSERT INTO ClosingStructuresOutputEntity SELECT * FROM [SOURCEPROJECT].ClosingStructuresOutputEntity; +INSERT INTO ClosingStructuresOutputEntity( + [ClosingStructuresOutputEntityId], + [ClosingStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability]) +SELECT + [ClosingStructuresOutputEntityId], + [ClosingStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability] +FROM [SOURCEPROJECT].ClosingStructuresOutputEntity +JOIN [SOURCEPROJECT].ClosingStructuresCalculationEntity USING(ClosingStructuresCalculationEntityId) +WHERE ForeshoreProfileEntityId IS NULL +UNION +SELECT + [ClosingStructuresOutputEntityId], + [ClosingStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability] +FROM [SOURCEPROJECT].ClosingStructuresOutputEntity +JOIN [SOURCEPROJECT].ClosingStructuresCalculationEntity USING(ClosingStructuresCalculationEntityId) +JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING(ForeshoreProfileEntityId) +WHERE (LENGTH(GeometryXML) - LENGTH(REPLACE(REPLACE(GeometryXML, '', ''), '', ''))) / +(LENGTH('') + LENGTH('')) != 1; INSERT INTO ClosingStructuresSectionResultEntity SELECT * FROM [SOURCEPROJECT].ClosingStructuresSectionResultEntity; INSERT INTO DikeProfileEntity SELECT * FROM [SOURCEPROJECT].DikeProfileEntity; INSERT INTO DuneErosionFailureMechanismMetaEntity SELECT * FROM [SOURCEPROJECT].DuneErosionFailureMechanismMetaEntity; @@ -477,7 +500,30 @@ FROM [SOURCEPROJECT].ForeshoreProfileEntity ) USING(ForeshoreProfileEntityId); INSERT INTO HeightStructuresFailureMechanismMetaEntity SELECT * FROM [SOURCEPROJECT].HeightStructuresFailureMechanismMetaEntity; -INSERT INTO HeightStructuresOutputEntity SELECT * FROM [SOURCEPROJECT].HeightStructuresOutputEntity; +INSERT INTO HeightStructuresOutputEntity( + [HeightStructuresOutputEntityId], + [HeightStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability]) +SELECT + [HeightStructuresOutputEntityId], + [HeightStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability] +FROM [SOURCEPROJECT].HeightStructuresOutputEntity +JOIN [SOURCEPROJECT].HeightStructuresCalculationEntity USING(HeightStructuresCalculationEntityId) +WHERE ForeshoreProfileEntityId IS NULL +UNION +SELECT + [HeightStructuresOutputEntityId], + [HeightStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability] +FROM [SOURCEPROJECT].HeightStructuresOutputEntity +JOIN [SOURCEPROJECT].HeightStructuresCalculationEntity USING(HeightStructuresCalculationEntityId) +JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING(ForeshoreProfileEntityId) +WHERE (LENGTH(GeometryXML) - LENGTH(REPLACE(REPLACE(GeometryXML, '', ''), '', ''))) / +(LENGTH('') + LENGTH('')) != 1; INSERT INTO HeightStructuresSectionResultEntity SELECT * FROM [SOURCEPROJECT].HeightStructuresSectionResultEntity; INSERT INTO HydraulicLocationCalculationCollectionEntity SELECT * FROM [SOURCEPROJECT].HydraulicLocationCalculationCollectionEntity; INSERT INTO HydraulicLocationCalculationEntity SELECT * FROM [SOURCEPROJECT].HydraulicLocationCalculationEntity; @@ -721,7 +767,30 @@ FROM [SOURCEPROJECT].ForeshoreProfileEntity ) USING(ForeshoreProfileEntityId); INSERT INTO StabilityPointStructuresFailureMechanismMetaEntity SELECT * FROM [SOURCEPROJECT].StabilityPointStructuresFailureMechanismMetaEntity; -INSERT INTO StabilityPointStructuresOutputEntity SELECT * FROM [SOURCEPROJECT].StabilityPointStructuresOutputEntity; +INSERT INTO StabilityPointStructuresOutputEntity( + [StabilityPointStructuresOutputEntityId], + [StabilityPointStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability]) +SELECT + [StabilityPointStructuresOutputEntityId], + [StabilityPointStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability] +FROM [SOURCEPROJECT].StabilityPointStructuresOutputEntity +JOIN [SOURCEPROJECT].StabilityPointStructuresCalculationEntity USING(StabilityPointStructuresCalculationEntityId) +WHERE ForeshoreProfileEntityId IS NULL +UNION +SELECT + [StabilityPointStructuresOutputEntityId], + [StabilityPointStructuresCalculationEntityId], + [GeneralResultFaultTreeIllustrationPointEntityId], + [Reliability] +FROM [SOURCEPROJECT].StabilityPointStructuresOutputEntity +JOIN [SOURCEPROJECT].StabilityPointStructuresCalculationEntity USING(StabilityPointStructuresCalculationEntityId) +JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING(ForeshoreProfileEntityId) +WHERE (LENGTH(GeometryXML) - LENGTH(REPLACE(REPLACE(GeometryXML, '', ''), '', ''))) / +(LENGTH('') + LENGTH('')) != 1; INSERT INTO StabilityPointStructuresSectionResultEntity SELECT * FROM [SOURCEPROJECT].StabilityPointStructuresSectionResultEntity; INSERT INTO StabilityStoneCoverFailureMechanismMetaEntity SELECT * FROM [SOURCEPROJECT].StabilityStoneCoverFailureMechanismMetaEntity; INSERT INTO StabilityStoneCoverSectionResultEntity SELECT * FROM [SOURCEPROJECT].StabilityStoneCoverSectionResultEntity; Index: Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo191IntegrationTest.cs =================================================================== diff -u -r9553c80cee82b31816f57b4990e5ac40f998eb64 -r2a8e64e10b3b969e48a81f0eb43f20720669a4e7 --- Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo191IntegrationTest.cs (.../MigrationTo191IntegrationTest.cs) (revision 9553c80cee82b31816f57b4990e5ac40f998eb64) +++ Riskeer/Migration/test/Riskeer.Migration.Integration.Test/MigrationTo191IntegrationTest.cs (.../MigrationTo191IntegrationTest.cs) (revision 2a8e64e10b3b969e48a81f0eb43f20720669a4e7) @@ -74,8 +74,13 @@ AssertWaveImpactAsphaltCoverWaveConditionsCalculations(reader, sourceFilePath); AssertHeightStructuresCalculation(reader, sourceFilePath); + AssertHeightStructuresOutput(reader, sourceFilePath); + AssertClosingStructuresCalculation(reader, sourceFilePath); + AssertClosingStructuresOutput(reader, sourceFilePath); + AssertStabilityPointStructuresCalculations(reader, sourceFilePath); + AssertStabilityPointStructuresOutput(reader, sourceFilePath); } AssertLogDatabase(logFilePath); @@ -481,6 +486,17 @@ AssertCalculationsWithInvalidForeshoreProfile(reader, sourceFilePath, calculationEntityName, invalidForeshoreProfileCriteria); } + private static void AssertHeightStructuresOutput(MigratedDatabaseReader reader, string sourceFilePath) + { + const string outputCriteria = "NEW.[HeightStructuresCalculationEntityId] = OLD.[HeightStructuresCalculationEntityId] " + + "AND NEW.[GeneralResultFaultTreeIllustrationPointEntityId] IS OLD.[GeneralResultFaultTreeIllustrationPointEntityId] " + + "AND NEW.[Reliability] IS OLD.[Reliability]"; + AssertOutputsFromCalculationsWithForeshoreProfiles(reader, sourceFilePath, + "HeightStructuresOutputEntity", + "HeightStructuresCalculationEntity", + outputCriteria); + } + private static void AssertClosingStructuresCalculation(MigratedDatabaseReader reader, string sourceFilePath) { const string calculationEntityName = "ClosingStructuresCalculationEntity"; @@ -569,6 +585,17 @@ AssertCalculationsWithInvalidForeshoreProfile(reader, sourceFilePath, calculationEntityName, invalidForeshoreProfileCriteria); } + private static void AssertClosingStructuresOutput(MigratedDatabaseReader reader, string sourceFilePath) + { + const string outputCriteria = "NEW.[ClosingStructuresCalculationEntityId] = OLD.[ClosingStructuresCalculationEntityId] " + + "AND NEW.[GeneralResultFaultTreeIllustrationPointEntityId] IS OLD.[GeneralResultFaultTreeIllustrationPointEntityId] " + + "AND NEW.[Reliability] IS OLD.[Reliability]"; + AssertOutputsFromCalculationsWithForeshoreProfiles(reader, sourceFilePath, + "ClosingStructuresOutputEntity", + "ClosingStructuresCalculationEntity", + outputCriteria); + } + private static void AssertStabilityPointStructuresCalculations(MigratedDatabaseReader reader, string sourceFilePath) { const string calculationEntityName = "StabilityPointStructuresCalculationEntity"; @@ -695,6 +722,17 @@ AssertCalculationsWithInvalidForeshoreProfile(reader, sourceFilePath, calculationEntityName, invalidForeshoreProfileCriteria); } + private static void AssertStabilityPointStructuresOutput(MigratedDatabaseReader reader, string sourceFilePath) + { + const string outputCriteria = "NEW.[StabilityPointStructuresCalculationEntityId] = OLD.[StabilityPointStructuresCalculationEntityId] " + + "AND NEW.[GeneralResultFaultTreeIllustrationPointEntityId] IS OLD.[GeneralResultFaultTreeIllustrationPointEntityId] " + + "AND NEW.[Reliability] IS OLD.[Reliability]"; + AssertOutputsFromCalculationsWithForeshoreProfiles(reader, sourceFilePath, + "StabilityPointStructuresOutputEntity", + "StabilityPointStructuresCalculationEntity", + outputCriteria); + } + private static void AssertCalculationsWithValidForeshoreProfile(MigratedDatabaseReader reader, string sourceFilePath, string calculationEntityName, @@ -774,6 +812,39 @@ reader.AssertReturnedDataIsValid(validateCalculationsWithInvalidForeshoreProfiles); } + private static void AssertOutputsFromCalculationsWithForeshoreProfiles(MigratedDatabaseReader reader, + string sourceFilePath, + string outputEntityName, + string calculationEntityName, + string criteria) + { + string validateOutput = + $"ATTACH DATABASE \"{sourceFilePath}\" AS SOURCEPROJECT; " + + "SELECT COUNT() = " + + "(" + + "SELECT COUNT()" + + "FROM " + + "(" + + $"SELECT {outputEntityName}Id " + + $"FROM [SOURCEPROJECT].{outputEntityName} " + + $"JOIN [SOURCEPROJECT].{calculationEntityName} USING({calculationEntityName}Id) " + + "JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING(ForeshoreProfileEntityId) " + + "WHERE (LENGTH(GeometryXML) - LENGTH(REPLACE(REPLACE(GeometryXML, '', ''), '', ''))) / " + + "(LENGTH('') + LENGTH('')) != 1 " + + "UNION " + + $"SELECT {outputEntityName}Id " + + $"FROM [SOURCEPROJECT].{outputEntityName} " + + $"JOIN [SOURCEPROJECT].{calculationEntityName} USING({calculationEntityName}Id) " + + "WHERE ForeshoreProfileEntityId IS NULL " + + ") " + + ") " + + $"FROM {outputEntityName} NEW " + + $"JOIN [SOURCEPROJECT].{outputEntityName} OLD USING({outputEntityName}Id) " + + $"WHERE {criteria};" + + "DETACH SOURCEPROJECT;"; + reader.AssertReturnedDataIsValid(validateOutput); + } + private static void AssertTablesContentMigrated(MigratedDatabaseReader reader, string sourceFilePath) { string[] tables = @@ -785,7 +856,6 @@ "ClosingStructureEntity", "ClosingStructuresCalculationEntity", "ClosingStructuresFailureMechanismMetaEntity", - "ClosingStructuresOutputEntity", "ClosingStructuresSectionResultEntity", "DikeProfileEntity", "DuneErosionFailureMechanismMetaEntity", @@ -818,7 +888,6 @@ "HeightStructureEntity", "HeightStructuresCalculationEntity", "HeightStructuresFailureMechanismMetaEntity", - "HeightStructuresOutputEntity", "HeightStructuresSectionResultEntity", "HydraulicLocationCalculationCollectionEntity", "HydraulicLocationCalculationEntity", @@ -854,7 +923,6 @@ "StabilityPointStructureEntity", "StabilityPointStructuresCalculationEntity", "StabilityPointStructuresFailureMechanismMetaEntity", - "StabilityPointStructuresOutputEntity", "StabilityPointStructuresSectionResultEntity", "StabilityStoneCoverFailureMechanismMetaEntity", "StabilityStoneCoverSectionResultEntity",