Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/HydraulicBoundaryDatabaseImporter.cs =================================================================== diff -u -r02088b12d2e6c8993414a50a045043e0be062897 -raf6fa199641fa9c756bfb8c96727a359f08ae1a3 --- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision 02088b12d2e6c8993414a50a045043e0be062897) +++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision af6fa199641fa9c756bfb8c96727a359f08ae1a3) @@ -169,7 +169,8 @@ // Locations directory of HLCD location ids and HRD location ids var locationidsDictionary = hydraulicLocationConfigurationDatabaseReader.GetLocationsIdByTrackId(trackId); - var filter = new HydraulicBoundaryLocationFilter(); + var filter = new HydraulicBoundaryLocationFilter( + HydraulicDatabaseHelper.GetHydraulicBoundarySettingsDatabase(hydraulicBoundaryDatabase.FilePath)); // Prepare query to fetch hrd locations hydraulicBoundaryDatabaseReader.PrepareReadLocation(); Index: Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraulicBoundaryLocationFilter.cs =================================================================== diff -u -re4565100f14feece0bea5bc7acf9eef9acf7a8e6 -raf6fa199641fa9c756bfb8c96727a359f08ae1a3 --- Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraulicBoundaryLocationFilter.cs (.../HydraulicBoundaryLocationFilter.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6) +++ Ringtoets/Common/src/Ringtoets.Common.IO/HydraRing/HydraulicBoundaryLocationFilter.cs (.../HydraulicBoundaryLocationFilter.cs) (revision af6fa199641fa9c756bfb8c96727a359f08ae1a3) @@ -22,7 +22,7 @@ using System; using System.Collections.Generic; using System.Linq; -using Ringtoets.Common.IO.Properties; +using Core.Common.IO.Exceptions; using Ringtoets.HydraRing.Data; namespace Ringtoets.Common.IO.HydraRing @@ -35,17 +35,27 @@ { private readonly List locationsToFilterOut; - public HydraulicBoundaryLocationFilter() + /// + /// Creates a new instance of , which uses the settings + /// database at as its source. + /// + /// The path to the settings database containing a table + /// with filtered locations. + /// Thrown when: + /// + /// The contains invalid characters. + /// No file could be found at . + /// Unable to open database file. + /// + /// + public HydraulicBoundaryLocationFilter(string databaseFilePath) { - string[] idsAsText = Resources.HydraulicBoundaryLocationsFilterList.Split(new[] + using (var reader = new HydraRingSettingsDatabaseReader(databaseFilePath)) { - Environment.NewLine, - "\n" - }, StringSplitOptions.RemoveEmptyEntries); - var filterList = new List(idsAsText.Skip(1).Select(long.Parse)); // Skip the header, parse the remainder - filterList.Sort(); - - locationsToFilterOut = filterList; + var filterList = reader.ReadExcludedLocations().ToList(); + filterList.Sort(); + locationsToFilterOut = filterList; + } } /// Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -r25d6b191a8ffd5dce434ddd07650aa1b9a76e699 -raf6fa199641fa9c756bfb8c96727a359f08ae1a3 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 25d6b191a8ffd5dce434ddd07650aa1b9a76e699) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision af6fa199641fa9c756bfb8c96727a359f08ae1a3) @@ -574,87 +574,6 @@ } /// - /// Looks up a localized string similar to LocationID - ///300130 - ///300131 - ///300189 - ///300353 - ///300354 - ///300355 - ///300357 - ///300358 - ///300359 - ///300360 - ///300361 - ///300362 - ///300363 - ///300364 - ///300365 - ///300366 - ///300367 - ///300368 - ///300369 - ///300370 - ///300371 - ///300372 - ///300373 - ///300374 - ///300375 - ///300376 - ///300608 - ///300609 - ///300610 - ///300611 - ///300612 - ///300633 - ///300634 - ///300635 - ///300636 - ///300637 - ///300657 - ///300658 - ///300659 - ///300660 - ///300661 - ///300662 - ///300663 - ///300664 - ///300665 - ///300703 - ///300704 - ///300745 - ///300748 - ///300761 - ///300762 - ///300765 - ///300766 - ///300767 - ///300824 - ///300825 - ///300826 - ///300828 - ///300829 - ///300830 - ///300864 - ///300865 - ///301595 - ///301596 - ///301597 - ///301598 - ///301599 - ///301600 - ///301601 - ///301602 - ///301603 - ///3016 [rest of string was truncated]";. - /// - public static string HydraulicBoundaryLocationsFilterList { - get { - return ResourceManager.GetString("HydraulicBoundaryLocationsFilterList", resourceCulture); - } - } - - /// /// Looks up a localized string similar to TRAJECT_ID;N ///1-1;3 ///1-2;2 Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -r25d6b191a8ffd5dce434ddd07650aa1b9a76e699 -raf6fa199641fa9c756bfb8c96727a359f08ae1a3 --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 25d6b191a8ffd5dce434ddd07650aa1b9a76e699) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision af6fa199641fa9c756bfb8c96727a359f08ae1a3) @@ -408,9 +408,6 @@ De hydraulische randvoorwaardenlocaties zijn ingelezen. - - ..\Resources\Exceptions_DoNotCalculate.csv;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - Een profiellocatie met ID '{0}' ligt niet op de referentielijn. Locatie wordt overgeslagen. Fisheye: Tag af6fa199641fa9c756bfb8c96727a359f08ae1a3 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/Resources/Exceptions_DoNotCalculate.csv'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj =================================================================== diff -u -r02088b12d2e6c8993414a50a045043e0be062897 -raf6fa199641fa9c756bfb8c96727a359f08ae1a3 --- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 02088b12d2e6c8993414a50a045043e0be062897) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision af6fa199641fa9c756bfb8c96727a359f08ae1a3) @@ -101,7 +101,6 @@ - Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraulicBoundaryLocationFilterTest.cs =================================================================== diff -u -re4565100f14feece0bea5bc7acf9eef9acf7a8e6 -raf6fa199641fa9c756bfb8c96727a359f08ae1a3 --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraulicBoundaryLocationFilterTest.cs (.../HydraulicBoundaryLocationFilterTest.cs) (revision e4565100f14feece0bea5bc7acf9eef9acf7a8e6) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/HydraRing/HydraulicBoundaryLocationFilterTest.cs (.../HydraulicBoundaryLocationFilterTest.cs) (revision af6fa199641fa9c756bfb8c96727a359f08ae1a3) @@ -19,6 +19,9 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.IO; +using Core.Common.IO.Exceptions; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.IO.HydraRing; @@ -27,7 +30,29 @@ [TestFixture] public class HydraulicBoundaryLocationFilterTest { + private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Common.IO, "HydraulicBoundaryLocationFilter"); + [Test] + public void Constructor_InvalidCharactersInPath_ThrowsCriticalFileReadException() + { + // Call + TestDelegate test = () => new HydraulicBoundaryLocationFilter(">"); + + // Assert + Assert.Throws(test); + } + + [Test] + public void Constructor_SettingsNotExisting_ThrowsArgumentException() + { + // Call + TestDelegate test = () => new HydraulicBoundaryLocationFilter(Path.Combine(testDataPath, "notExisting")); + + // Assert + Assert.Throws(test); + } + + [Test] [TestCase(-1)] [TestCase(long.MinValue)] [TestCase(303192)] @@ -38,7 +63,7 @@ public void ShouldInclude_NameNotInFilterSet_ReturnsTrue(long id) { // Setup - var filter = new HydraulicBoundaryLocationFilter(); + var filter = new HydraulicBoundaryLocationFilter(Path.Combine(testDataPath, "hrd.config.sqlite")); // Call bool shouldBeIncluded = filter.ShouldInclude(id); @@ -53,7 +78,7 @@ public void ShouldInclude_NameInFilterSet_ReturnsFalse(long id) { // Setup - var filter = new HydraulicBoundaryLocationFilter(); + var filter = new HydraulicBoundaryLocationFilter(Path.Combine(testDataPath, "hrd.config.sqlite")); // Call bool shouldBeIncluded = filter.ShouldInclude(id); Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/test-data/HydraulicBoundaryLocationFilter/hrd.config.sqlite =================================================================== diff -u Binary files differ Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/test-data/completeWithLocationsToBeFilteredOut.config.sqlite =================================================================== diff -u -r25d6b191a8ffd5dce434ddd07650aa1b9a76e699 -raf6fa199641fa9c756bfb8c96727a359f08ae1a3 Binary files differ Index: Ringtoets/Integration/test/Ringtoets.Integration.Plugin.Test/test-data/copyOfCompleteWithLocationsToBeFilteredOut.config.sqlite =================================================================== diff -u -r25d6b191a8ffd5dce434ddd07650aa1b9a76e699 -raf6fa199641fa9c756bfb8c96727a359f08ae1a3 Binary files differ