Index: Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql =================================================================== diff -u -r65866d8a02406f9e39791eed599e716628ee4055 -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c --- Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql (.../Migration_17.1_17.2.sql) (revision 65866d8a02406f9e39791eed599e716628ee4055) +++ Application/Ringtoets/src/Application.Ringtoets.Migration.Core/EmbeddedResources/Migration_17.1_17.2.sql (.../Migration_17.1_17.2.sql) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) @@ -87,16 +87,18 @@ [ClosingStructuresFailureMechanismMetaEntityId], [FailureMechanismEntityId], [N2A], + [ClosingStructureCollectionSourcePath], [ForeshoreProfileCollectionSourcePath]) SELECT [ClosingStructuresFailureMechanismMetaEntityId], [FailureMechanismEntityId], [N2A], - CASE WHEN HasForeshoreProfiles THEN "Onbekend" ELSE NULL END - FROM (SELECT *, (SELECT COUNT() - FROM [SOURCEPROJECT].ForeshoreProfileEntity - WHERE CSFM.[FailureMechanismEntityId] = [FailureMechanismEntityId]) as HasForeshoreProfiles - FROM [SOURCEPROJECT].ClosingStructuresFailureMechanismMetaEntity CSFM); + CASE WHEN COUNT([ClosingStructureEntityId]) THEN "Onbekend" ELSE NULL END, + CASE WHEN COUNT([ForeshoreProfileEntityId]) THEN "Onbekend" ELSE NULL END + FROM [SOURCEPROJECT].ClosingStructuresFailureMechanismMetaEntity + LEFT JOIN [SOURCEPROJECT].ClosingStructureEntity USING (FailureMechanismEntityId) + LEFT JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING (FailureMechanismEntityId) + GROUP BY FailureMechanismEntityID; INSERT INTO ClosingStructuresOutputEntity SELECT * FROM [SOURCEPROJECT].ClosingStructuresOutputEntity; INSERT INTO ClosingStructuresSectionResultEntity SELECT * FROM [SOURCEPROJECT].ClosingStructuresSectionResultEntity; INSERT INTO DikeProfileEntity SELECT * FROM [SOURCEPROJECT].DikeProfileEntity; @@ -153,11 +155,10 @@ [GrassCoverErosionOutwardsFailureMechanismMetaEntityId], [FailureMechanismEntityId], [N], - CASE WHEN HasForeshoreProfiles THEN "Onbekend" ELSE NULL END - FROM (SELECT *, (SELECT COUNT() - FROM [SOURCEPROJECT].ForeshoreProfileEntity - WHERE GCEOFM.[FailureMechanismEntityId] = [FailureMechanismEntityId]) as HasForeshoreProfiles - FROM [SOURCEPROJECT].GrassCoverErosionOutwardsFailureMechanismMetaEntity GCEOFM); + CASE WHEN COUNT([ForeshoreProfileEntityId]) THEN "Onbekend" ELSE NULL END + FROM [SOURCEPROJECT].GrassCoverErosionOutwardsFailureMechanismMetaEntity + LEFT JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING (FailureMechanismEntityId) + GROUP BY FailureMechanismEntityID; INSERT INTO GrassCoverErosionOutwardsHydraulicLocationEntity SELECT * FROM [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationEntity; INSERT INTO GrassCoverErosionOutwardsHydraulicLocationOutputEntity SELECT * FROM [SOURCEPROJECT].GrassCoverErosionOutwardsHydraulicLocationOutputEntity; INSERT INTO GrassCoverErosionOutwardsSectionResultEntity SELECT * FROM [SOURCEPROJECT].GrassCoverErosionOutwardsSectionResultEntity; @@ -226,15 +227,12 @@ [HeightStructuresFailureMechanismMetaEntityId], [FailureMechanismEntityId], [N], - CASE WHEN HasStructures THEN "Onbekend" ELSE NULL END, - CASE WHEN HasForeshoreProfiles THEN "Onbekend" ELSE NULL END - FROM (SELECT *, (SELECT COUNT() - FROM [SOURCEPROJECT].HeightStructureEntity - WHERE HSFM.[FailureMechanismEntityId] = [FailureMechanismEntityId]) as HasStructures, - (SELECT COUNT() - FROM [SOURCEPROJECT].ForeshoreProfileEntity - WHERE HSFM.[FailureMechanismEntityId] = [FailureMechanismEntityId]) as HasForeshoreProfiles - FROM [SOURCEPROJECT].HeightStructuresFailureMechanismMetaEntity HSFM); + CASE WHEN COUNT([HeightStructureEntityId]) THEN "Onbekend" ELSE NULL END, + CASE WHEN COUNT([ForeshoreProfileEntityId]) THEN "Onbekend" ELSE NULL END + FROM [SOURCEPROJECT].HeightStructuresFailureMechanismMetaEntity + LEFT JOIN [SOURCEPROJECT].HeightStructureEntity USING (FailureMechanismEntityId) + LEFT JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING (FailureMechanismEntityId) + GROUP BY FailureMechanismEntityID; INSERT INTO HeightStructuresOutputEntity SELECT * FROM [SOURCEPROJECT].HeightStructuresOutputEntity; INSERT INTO HeightStructuresSectionResultEntity SELECT * FROM [SOURCEPROJECT].HeightStructuresSectionResultEntity; INSERT INTO HydraulicLocationEntity SELECT * FROM [SOURCEPROJECT].HydraulicLocationEntity; @@ -276,11 +274,10 @@ [StrengthStabilityPointConstructionFailureMechanismMetaEntityId], [FailureMechanismEntityId], [N], - CASE WHEN HasForeshoreProfiles THEN "Onbekend" ELSE NULL END - FROM (SELECT *, (SELECT COUNT() - FROM [SOURCEPROJECT].ForeshoreProfileEntity - WHERE SPSFM.[FailureMechanismEntityId] = [FailureMechanismEntityId]) as HasForeshoreProfiles - FROM [SOURCEPROJECT].StabilityPointStructuresFailureMechanismMetaEntity SPSFM); + CASE WHEN COUNT([ForeshoreProfileEntityId]) THEN "Onbekend" ELSE NULL END + FROM [SOURCEPROJECT].StabilityPointStructuresFailureMechanismMetaEntity + LEFT JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING (FailureMechanismEntityId) + GROUP BY FailureMechanismEntityId; INSERT INTO StabilityPointStructuresOutputEntity SELECT * FROM [SOURCEPROJECT].StabilityPointStructuresOutputEntity; INSERT INTO StabilityPointStructuresSectionResultEntity SELECT * FROM [SOURCEPROJECT].StabilityPointStructuresSectionResultEntity; INSERT INTO StabilityStoneCoverSectionResultEntity SELECT * FROM [SOURCEPROJECT].StabilityStoneCoverSectionResultEntity; @@ -291,11 +288,11 @@ [ForeshoreProfileCollectionSourcePath]) SELECT [FailureMechanismEntityId], - CASE WHEN HasForeshoreProfiles THEN "Onbekend" ELSE NULL END - FROM (SELECT *, (SELECT COUNT() - FROM [SOURCEPROJECT].ForeshoreProfileEntity - WHERE SSCFM.[FailureMechanismEntityId] = [FailureMechanismEntityId]) as HasForeshoreProfiles - FROM [SOURCEPROJECT].FailureMechanismEntity SSCFM WHERE FailureMechanismType = 7); + CASE WHEN COUNT([ForeshoreProfileEntityId]) THEN "Onbekend" ELSE NULL END + FROM [SOURCEPROJECT].FailureMechanismEntity + LEFT JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING (FailureMechanismEntityID) + WHERE FailureMechanismType = 7 + GROUP BY FailureMechanismEntityID; INSERT INTO StochasticSoilModelEntity SELECT * FROM [SOURCEPROJECT].StochasticSoilModelEntity; INSERT INTO StochasticSoilProfileEntity SELECT * FROM [SOURCEPROJECT].StochasticSoilProfileEntity; INSERT INTO StrengthStabilityLengthwiseConstructionSectionResultEntity SELECT * FROM [SOURCEPROJECT].StrengthStabilityLengthwiseConstructionSectionResultEntity; @@ -320,11 +317,11 @@ [ForeshoreProfileCollectionSourcePath]) SELECT [FailureMechanismEntityId], - CASE WHEN HasForeshoreProfiles THEN "Onbekend" ELSE NULL END - FROM (SELECT *, (SELECT COUNT() - FROM [SOURCEPROJECT].ForeshoreProfileEntity - WHERE WIACFM.[FailureMechanismEntityId] = [FailureMechanismEntityId]) as HasForeshoreProfiles - FROM [SOURCEPROJECT].FailureMechanismEntity WIACFM WHERE FailureMechanismType = 3); + CASE WHEN COUNT([ForeshoreProfileEntityId]) THEN "Onbekend" ELSE NULL END + FROM [SOURCEPROJECT].FailureMechanismEntity + LEFT JOIN [SOURCEPROJECT].ForeshoreProfileEntity USING (FailureMechanismEntityID) + WHERE FailureMechanismType = 3 + GROUP BY FailureMechanismEntityID; /* Insert new data */ Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensions.cs =================================================================== diff -u -reabf1a800431a23b06c8d81dfbf0f46a71bb659b -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c --- Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensions.cs (.../ClosingStructuresFailureMechanismCreateExtensions.cs) (revision eabf1a800431a23b06c8d81dfbf0f46a71bb659b) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensions.cs (.../ClosingStructuresFailureMechanismCreateExtensions.cs) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) @@ -94,8 +94,9 @@ { var metaEntity = new ClosingStructuresFailureMechanismMetaEntity { - ForeshoreProfileCollectionSourcePath = failureMechanism.ForeshoreProfiles.SourcePath.DeepClone(), - N2A = failureMechanism.GeneralInput.N2A + N2A = failureMechanism.GeneralInput.N2A, + ClosingStructureCollectionSourcePath = failureMechanism.ClosingStructures.SourcePath.DeepClone(), + ForeshoreProfileCollectionSourcePath = failureMechanism.ForeshoreProfiles.SourcePath.DeepClone() }; entity.ClosingStructuresFailureMechanismMetaEntities.Add(metaEntity); } Index: Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs =================================================================== diff -u -reabf1a800431a23b06c8d81dfbf0f46a71bb659b -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c --- Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision eabf1a800431a23b06c8d81dfbf0f46a71bb659b) +++ Application/Ringtoets/src/Application.Ringtoets.Storage/Read/FailureMechanismEntityReadExtensions.cs (.../FailureMechanismEntityReadExtensions.cs) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) @@ -264,7 +264,7 @@ entity.ReadCommonFailureMechanismProperties(failureMechanism, collector); entity.ReadHeightStructuresMechanismSectionResults(failureMechanism, collector); entity.ReadForeshoreProfiles(failureMechanism.ForeshoreProfiles, metaEntity.ForeshoreProfileCollectionSourcePath, collector); - entity.ReadHeightStructures(metaEntity.HeightStructureCollectionSourcePath, failureMechanism.HeightStructures, collector); + entity.ReadHeightStructures(failureMechanism.HeightStructures, metaEntity.HeightStructureCollectionSourcePath, collector); entity.ReadGeneralInput(failureMechanism.GeneralInput); ReadHeightStructuresRootCalculationGroup(entity.CalculationGroupEntity, failureMechanism.CalculationsGroup, collector); } @@ -283,8 +283,8 @@ } private static void ReadHeightStructures(this FailureMechanismEntity entity, - string sourcePath, StructureCollection heightStructures, + string sourcePath, ReadConversionCollector collector) { if (sourcePath != null) @@ -425,11 +425,13 @@ ClosingStructuresFailureMechanismMetaEntity metaEntity = entity.ClosingStructuresFailureMechanismMetaEntities.Single(); + entity.ReadForeshoreProfiles(failureMechanism.ForeshoreProfiles, metaEntity.ForeshoreProfileCollectionSourcePath, collector); + entity.ReadClosingStructures(failureMechanism.ClosingStructures, + metaEntity.ClosingStructureCollectionSourcePath, collector); - entity.ReadClosingStructures(failureMechanism.ClosingStructures, collector); entity.ReadGeneralInput(failureMechanism.GeneralInput); ReadClosingStructuresRootCalculationGroup(entity.CalculationGroupEntity, failureMechanism.CalculationsGroup, collector); } @@ -453,12 +455,17 @@ generalInput.N2A = generalClosingStructuresInput.N2A; } - private static void ReadClosingStructures(this FailureMechanismEntity entity, StructureCollection closingStructures, + private static void ReadClosingStructures(this FailureMechanismEntity entity, + StructureCollection closingStructures, + string sourcePath, ReadConversionCollector collector) { - closingStructures.AddRange( - entity.ClosingStructureEntities.OrderBy(fpe => fpe.Order).Select(structureEntity => structureEntity.Read(collector)), - "TODO coolpath"); // TODO + if (sourcePath != null) + { + closingStructures.AddRange(entity.ClosingStructureEntities.OrderBy(fpe => fpe.Order) + .Select(structureEntity => structureEntity.Read(collector)), + sourcePath); + } } private static void ReadClosingStructuresRootCalculationGroup(CalculationGroupEntity rootCalculationGroupEntity, Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensionsTest.cs =================================================================== diff -u -reabf1a800431a23b06c8d81dfbf0f46a71bb659b -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensionsTest.cs (.../ClosingStructuresFailureMechanismCreateExtensionsTest.cs) (revision eabf1a800431a23b06c8d81dfbf0f46a71bb659b) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/ClosingStructures/ClosingStructuresFailureMechanismCreateExtensionsTest.cs (.../ClosingStructuresFailureMechanismCreateExtensionsTest.cs) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) @@ -20,6 +20,7 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; using Application.Ringtoets.Storage.Create; using Application.Ringtoets.Storage.Create.ClosingStructures; @@ -199,10 +200,11 @@ ClosingStructure structure = new TestClosingStructure(); var failureMechanism = new ClosingStructuresFailureMechanism(); + var path = "some path"; failureMechanism.ClosingStructures.AddRange(new [] { structure - }, "some path"); + }, path); var persistenceRegistry = new PersistenceRegistry(); @@ -212,6 +214,12 @@ // Assert Assert.AreEqual(1, entity.ClosingStructureEntities.Count); Assert.IsTrue(persistenceRegistry.Contains(structure)); + + ClosingStructuresFailureMechanismMetaEntity metaEntity = + entity.ClosingStructuresFailureMechanismMetaEntities.Single(); + string entitySourcePath = metaEntity.ClosingStructureCollectionSourcePath; + Assert.AreEqual(path, entitySourcePath); + Assert.AreNotSame(path, entitySourcePath); } [Test] Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo172IntegrationTest.cs =================================================================== diff -u -rc96dfce6fc55cd553d4abe87703f7c17ec35c393 -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo172IntegrationTest.cs (.../MigrationTo172IntegrationTest.cs) (revision c96dfce6fc55cd553d4abe87703f7c17ec35c393) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/MigrationTo172IntegrationTest.cs (.../MigrationTo172IntegrationTest.cs) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) @@ -21,9 +21,7 @@ using System.Collections.ObjectModel; using System.Data; -using System.Data.SQLite; using Application.Ringtoets.Migration.Core; -using Core.Common.Base.IO; using Core.Common.IO.Readers; using Core.Common.TestUtil; using NUnit.Framework; @@ -60,7 +58,11 @@ { AssertTablesContentMigrated(reader, sourceFilePath); + AssertGrassCoverErosionOutwardsFailureMechanism(reader); + AssertStabilityStoneCoverFailureMechanism(reader); + AssertWaveImpactAsphaltCoverFailureMechanism(reader); AssertHeightStructuresFailureMechanism(reader); + AssertClosingStructuresFailureMechanism(reader); AssertVersions(reader); AssertDatabase(reader); @@ -137,31 +139,117 @@ } } + private static void AssertGrassCoverErosionOutwardsFailureMechanism(MigratedDatabaseReader reader) + { + const string validateForeshoreProfileCollectionSourcePath = + "SELECT SUM([IsInvalid]) = 0 " + + "FROM(" + + "SELECT " + + "CASE WHEN " + + "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "OR " + + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + + "THEN 1 ELSE 0 END AS[IsInvalid] " + + "FROM[GrassCoverErosionOutwardsFailureMechanismMetaEntity] " + + "LEFT JOIN[ForeshoreProfileEntity] USING([FailureMechanismEntityId]) " + + "GROUP BY[FailureMechanismEntityId]);"; + reader.AssertReturnedDataIsValid(validateForeshoreProfileCollectionSourcePath); + } + + private static void AssertStabilityStoneCoverFailureMechanism(MigratedDatabaseReader reader) + { + const string validateForeshoreProfileCollectionSourcePath = + "SELECT SUM([IsInvalid]) = 0 " + + "FROM(" + + "SELECT " + + "CASE WHEN " + + "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "OR " + + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + + "THEN 1 ELSE 0 END AS[IsInvalid] " + + "FROM[StabilityStoneCoverFailureMechanismMetaEntity] " + + "LEFT JOIN[ForeshoreProfileEntity] USING([FailureMechanismEntityId]) " + + "GROUP BY[FailureMechanismEntityId]);"; + reader.AssertReturnedDataIsValid(validateForeshoreProfileCollectionSourcePath); + } + + private static void AssertWaveImpactAsphaltCoverFailureMechanism(MigratedDatabaseReader reader) + { + const string validateForeshoreProfileCollectionSourcePath = + "SELECT SUM([IsInvalid]) = 0 " + + "FROM(" + + "SELECT " + + "CASE WHEN " + + "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "OR " + + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + + "THEN 1 ELSE 0 END AS[IsInvalid] " + + "FROM[WaveImpactAsphaltCoverFailureMechanismMetaEntity] " + + "LEFT JOIN[ForeshoreProfileEntity] USING([FailureMechanismEntityId]) " + + "GROUP BY[FailureMechanismEntityId]);"; + reader.AssertReturnedDataIsValid(validateForeshoreProfileCollectionSourcePath); + } + private static void AssertHeightStructuresFailureMechanism(MigratedDatabaseReader reader) { - const string validateSourcePathNull = - "SELECT COUNT() = 0 FROM ( " + - "SELECT[HeightStructuresFailureMechanismMetaEntityId] " + - "FROM HeightStructuresFailureMechanismMetaEntity WHERE [HeightStructureCollectionSourcePath] IS NULL " + - "EXCEPT " + - "SELECT[HeightStructuresFailureMechanismMetaEntityId] " + - "FROM HeightStructuresFailureMechanismMetaEntity HSFM " + - "WHERE HSFM.[FailureMechanismEntityId] NOT IN (SELECT FailureMechanismEntityId FROM HeightStructureEntity HS) " + - "); "; - reader.AssertReturnedDataIsValid(validateSourcePathNull); + const string validateStructuresCollectionSourcePath = + "SELECT SUM([IsInvalid]) = 0 " + + "FROM (SELECT " + + "CASE WHEN " + + "COUNT([HeightStructureEntityId]) AND [HeightStructureCollectionSourcePath] IS NULL " + + "OR " + + "[HeightStructureCollectionSourcePath] IS NOT NULL AND NOT COUNT([HeightStructureEntityId]) " + + "THEN 1 ELSE 0 END AS [IsInvalid] " + + "FROM [HeightStructuresFailureMechanismMetaEntity] " + + "LEFT JOIN [HeightStructureEntity] USING ([FailureMechanismEntityId]) " + + "GROUP BY [FailureMechanismEntityId]);"; + reader.AssertReturnedDataIsValid(validateStructuresCollectionSourcePath); - const string validateSourcePathSet = - "SELECT COUNT() = 0 FROM ( " + - "SELECT[HeightStructuresFailureMechanismMetaEntityId] " + - "FROM HeightStructuresFailureMechanismMetaEntity WHERE [HeightStructureCollectionSourcePath] = \"Onbekend\" " + - "EXCEPT " + - "SELECT[HeightStructuresFailureMechanismMetaEntityId] " + - "FROM HeightStructuresFailureMechanismMetaEntity HSFM " + - "WHERE HSFM.[FailureMechanismEntityId] IN(SELECT FailureMechanismEntityId FROM HeightStructureEntity HS) " + - "); "; - reader.AssertReturnedDataIsValid(validateSourcePathSet); + const string validateForeshoreProfileCollectionSourcePath = + "SELECT SUM([IsInvalid]) = 0 " + + "FROM(" + + "SELECT " + + "CASE WHEN " + + "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "OR " + + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + + "THEN 1 ELSE 0 END AS[IsInvalid] " + + "FROM[HeightStructuresFailureMechanismMetaEntity] " + + "LEFT JOIN[ForeshoreProfileEntity] USING([FailureMechanismEntityId]) " + + "GROUP BY[FailureMechanismEntityId]);"; + reader.AssertReturnedDataIsValid(validateForeshoreProfileCollectionSourcePath); } + private static void AssertClosingStructuresFailureMechanism(MigratedDatabaseReader reader) + { + const string validateStructuresCollectionSourcePath = + "SELECT SUM([IsInvalid]) = 0 " + + "FROM (SELECT " + + "CASE WHEN " + + "COUNT([ClosingStructureEntityId]) AND [ClosingStructureCollectionSourcePath] IS NULL " + + "OR " + + "[ClosingStructureCollectionSourcePath] IS NOT NULL AND NOT COUNT([ClosingStructureEntityId]) " + + "THEN 1 ELSE 0 END AS [IsInvalid] " + + "FROM [ClosingStructuresFailureMechanismMetaEntity] " + + "LEFT JOIN [ClosingStructureEntity] USING ([FailureMechanismEntityId]) " + + "GROUP BY [FailureMechanismEntityId]);"; + reader.AssertReturnedDataIsValid(validateStructuresCollectionSourcePath); + + const string validateForeshoreProfileCollectionSourcePath = + "SELECT SUM([IsInvalid]) = 0 " + + "FROM(" + + "SELECT " + + "CASE WHEN " + + "COUNT([ForeshoreProfileEntityId]) AND[ForeshoreProfileCollectionSourcePath] IS NULL " + + "OR " + + "[ForeshoreProfileCollectionSourcePath] IS NOT NULL AND NOT COUNT([ForeshoreProfileEntityId]) " + + "THEN 1 ELSE 0 END AS[IsInvalid] " + + "FROM[ClosingStructuresFailureMechanismMetaEntity] " + + "LEFT JOIN[ForeshoreProfileEntity] USING([FailureMechanismEntityId]) " + + "GROUP BY[FailureMechanismEntityId]);"; + reader.AssertReturnedDataIsValid(validateForeshoreProfileCollectionSourcePath); + } + private static void AssertLogDatabase(string logFilePath) { using (var reader = new MigrationLogDatabaseReader(logFilePath)) Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs =================================================================== diff -u -reabf1a800431a23b06c8d81dfbf0f46a71bb659b -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision eabf1a800431a23b06c8d81dfbf0f46a71bb659b) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/IntegrationTests/StorageSqLiteIntegrationTest.cs (.../StorageSqLiteIntegrationTest.cs) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) @@ -1092,6 +1092,7 @@ { AssertClosingStructure(expectedClosingStructures[i], actualClosingStructures[i]); } + Assert.AreEqual(expectedClosingStructures.SourcePath, actualClosingStructures.SourcePath); } private static void AssertClosingStructure(ClosingStructure expectedClosingStructure, Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs =================================================================== diff -u -r5dae54648aee26e6eefb07abd0268f98acf4b174 -rf8fd6922e67e0ba9843e79f0db217e914d1c3a8c --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision 5dae54648aee26e6eefb07abd0268f98acf4b174) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/FailureMechanismEntityReadExtensionsTest.cs (.../FailureMechanismEntityReadExtensionsTest.cs) (revision f8fd6922e67e0ba9843e79f0db217e914d1c3a8c) @@ -28,6 +28,7 @@ using Core.Common.Base.Geometry; using NUnit.Framework; using Ringtoets.ClosingStructures.Data; +using Ringtoets.Common.Data; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Hydraulics; @@ -1399,6 +1400,7 @@ public void ReadAsClosingStructuresFailureMechanism_WithClosingStructures_ReturnFailureMechanismWithClosingStructuresSet() { // Setup + const string sourcePath = "some/path"; var entity = new FailureMechanismEntity { CalculationGroupEntity = new CalculationGroupEntity(), @@ -1419,7 +1421,10 @@ }, ClosingStructuresFailureMechanismMetaEntities = { - new ClosingStructuresFailureMechanismMetaEntity() + new ClosingStructuresFailureMechanismMetaEntity + { + ClosingStructureCollectionSourcePath = sourcePath + } } }; var collector = new ReadConversionCollector(); @@ -1429,12 +1434,14 @@ entity.ReadAsClosingStructuresFailureMechanism(failureMechanism, collector); // Assert - Assert.AreEqual(2, failureMechanism.ClosingStructures.Count); + StructureCollection closingStructures = failureMechanism.ClosingStructures; + Assert.AreEqual(2, closingStructures.Count); + Assert.AreEqual(sourcePath, closingStructures.SourcePath); - ClosingStructure child1 = failureMechanism.ClosingStructures[0]; + ClosingStructure child1 = closingStructures[0]; Assert.AreEqual("Child2", child1.Name); - ClosingStructure child2 = failureMechanism.ClosingStructures[1]; + ClosingStructure child2 = closingStructures[1]; Assert.AreEqual("Child1", child2.Name); }