Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseContext/HydraulicBoundaryDatabaseQueryBuilder.cs =================================================================== diff -u -r7d124cef8960a865cc8d7db24b3359f7ff9958be -r07955a5bcecef8840417a57c6a704ef788533581 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseContext/HydraulicBoundaryDatabaseQueryBuilder.cs (.../HydraulicBoundaryDatabaseQueryBuilder.cs) (revision 7d124cef8960a865cc8d7db24b3359f7ff9958be) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseContext/HydraulicBoundaryDatabaseQueryBuilder.cs (.../HydraulicBoundaryDatabaseQueryBuilder.cs) (revision 07955a5bcecef8840417a57c6a704ef788533581) @@ -44,7 +44,6 @@ /// /// Returns the query to get the amount of relevant locations from the database. /// - /// Locations are relevant when > 1. /// The query to get the amount of relevant locations from the database. public static string GetRelevantLocationsCountQuery() { @@ -53,26 +52,25 @@ HrdLocationsTableDefinitions.HrdLocationId, HrdLocationsTableDefinitions.Count, HrdLocationsTableDefinitions.TableName, - HrdLocationsTableDefinitions.LocationTypeId + HrdLocationsTableDefinitions.LocationTypeId // Value > 1 makes it relevant ); } /// /// Returns the query to get the all relevant locations from the database. /// - /// Locations are relevant when > 1. /// The query to get the all relevant locations from the database. public static string GetRelevantLocationsQuery() { return string.Format( - "SELECT {0}, {1}, {2}, {3} FROM " + - "{4} WHERE {5} > 1;", + "SELECT {0}, {1}, {2}, {3} FROM {4} WHERE {5} > 1;", HrdLocationsTableDefinitions.HrdLocationId, HrdLocationsTableDefinitions.Name, HrdLocationsTableDefinitions.XCoordinate, HrdLocationsTableDefinitions.YCoordinate, HrdLocationsTableDefinitions.TableName, - HrdLocationsTableDefinitions.LocationTypeId); + HrdLocationsTableDefinitions.LocationTypeId // Value > 1 makes it relevant + ); } } } \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundarySqLiteDatabaseReader.cs =================================================================== diff -u -r7d124cef8960a865cc8d7db24b3359f7ff9958be -r07955a5bcecef8840417a57c6a704ef788533581 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundarySqLiteDatabaseReader.cs (.../HydraulicBoundarySqLiteDatabaseReader.cs) (revision 7d124cef8960a865cc8d7db24b3359f7ff9958be) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundarySqLiteDatabaseReader.cs (.../HydraulicBoundarySqLiteDatabaseReader.cs) (revision 07955a5bcecef8840417a57c6a704ef788533581) @@ -40,9 +40,8 @@ private SQLiteDataReader sqliteDataReader; /// - /// Creates a new instance of , which will use - /// the - /// as its source. + /// Creates a new instance of , + /// which will use the as its source. /// /// The path of the database file to open. /// Thrown when: @@ -62,16 +61,16 @@ /// /// Reads the next location from the database. /// - /// New instance of , based on the data read from the - /// database or null if no data is available. - /// Thrown when the database returned incorrect values for - /// required properties. + /// New instance of , based on the + /// data read from the database or null if no data is available. + /// Thrown when the database returned incorrect + /// values for required properties. public void PrepareReadLocation() { CloseDataReader(); HasNext = false; - var locationsQuery = HydraulicBoundaryDatabaseQueryBuilder.GetRelevantLocationsQuery(); + string locationsQuery = HydraulicBoundaryDatabaseQueryBuilder.GetRelevantLocationsQuery(); sqliteDataReader = CreateDataReader(locationsQuery, new SQLiteParameter { DbType = DbType.String @@ -101,21 +100,24 @@ /// /// Gets the database version from the metadata table. /// - /// Thrown when the database returned incorrect values for - /// required properties. + /// The version found in the database, or an empty string if the version + /// cannot be found. + /// Thrown when the database returned incorrect + /// values for required properties. public string GetVersion() { string versionQuery = HydraulicBoundaryDatabaseQueryBuilder.GetVersionQuery(); var sqliteParameter = new SQLiteParameter { DbType = DbType.String }; - using (var dataReader = CreateDataReader(versionQuery, sqliteParameter)) + using (SQLiteDataReader dataReader = CreateDataReader(versionQuery, sqliteParameter)) { if (!dataReader.Read()) { return ""; } + try { return (string) dataReader[GeneralTableDefinitions.GeneratedVersion]; @@ -132,24 +134,25 @@ /// /// Gets the amount of locations that can be read from the database. /// - /// Thrown when the database returned incorrect values for - /// required properties. + /// Thrown when the database returned incorrect + /// values for required properties. public int GetLocationCount() { string locationCountQuery = HydraulicBoundaryDatabaseQueryBuilder.GetRelevantLocationsCountQuery(); var sqliteParameter = new SQLiteParameter { DbType = DbType.String }; - using (var dataReader = CreateDataReader(locationCountQuery, sqliteParameter)) + using (SQLiteDataReader dataReader = CreateDataReader(locationCountQuery, sqliteParameter)) { if (!dataReader.Read()) { return 0; } + try { - return (int) (long) dataReader[HrdLocationsTableDefinitions.Count]; + return Convert.ToInt32(dataReader[HrdLocationsTableDefinitions.Count]); } catch (InvalidCastException e) { Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/HydraulicBoundaryDatabaseImporter.cs =================================================================== diff -u -r7d124cef8960a865cc8d7db24b3359f7ff9958be -r07955a5bcecef8840417a57c6a704ef788533581 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision 7d124cef8960a865cc8d7db24b3359f7ff9958be) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/HydraulicBoundaryDatabaseImporter.cs (.../HydraulicBoundaryDatabaseImporter.cs) (revision 07955a5bcecef8840417a57c6a704ef788533581) @@ -41,17 +41,9 @@ public class HydraulicBoundaryDatabaseImporter : IDisposable { private readonly ILog log = LogManager.GetLogger(typeof(HydraulicBoundaryDatabaseImporter)); - private bool importIsCancelled; private HydraulicBoundarySqLiteDatabaseReader hydraulicBoundaryDatabaseReader; - public ProgressChangedDelegate ProgressChanged { private get; set; } - - public void Cancel() - { - importIsCancelled = true; - } - /// /// Validates the file and opens a connection. /// @@ -89,13 +81,6 @@ var importResult = GetHydraulicBoundaryDatabase(filePath); - if (importIsCancelled) - { - log.Info(ApplicationResources.HydraulicBoundaryLocationsImporter_Import_cancelled); - importIsCancelled = false; - return false; - } - if (importResult == null) { return false; @@ -115,14 +100,6 @@ } } - private void NotifyProgress(string currentStepName, int currentStep, int totalNumberOfSteps) - { - if (ProgressChanged != null) - { - ProgressChanged(currentStepName, currentStep, totalNumberOfSteps); - } - } - private void HandleException(Exception e) { var message = string.Format(ApplicationResources.HydraulicBoundaryLocationsImporter_CriticalErrorMessage_0_File_Skipped, e.Message); @@ -131,26 +108,17 @@ private HydraulicBoundaryDatabase GetHydraulicBoundaryDatabase(string path) { - NotifyProgress(ApplicationResources.HydraulicBoundaryLocationsImporter_ReadHydraulicBoundaryLocations, 1, 1); - try { - var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase() + var hydraulicBoundaryDatabase = new HydraulicBoundaryDatabase { FilePath = path, Version = hydraulicBoundaryDatabaseReader.GetVersion() }; - var totalNumberOfSteps = hydraulicBoundaryDatabaseReader.GetLocationCount(); - var currentStep = 1; hydraulicBoundaryDatabaseReader.PrepareReadLocation(); while (hydraulicBoundaryDatabaseReader.HasNext) { - if (importIsCancelled) - { - return null; - } - NotifyProgress(ApplicationResources.HydraulicBoundaryLocationsImporter_GetHydraulicBoundaryLocationReadResult, currentStep++, totalNumberOfSteps); try { hydraulicBoundaryDatabase.Locations.Add(hydraulicBoundaryDatabaseReader.ReadLocation()); Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u -r06f9145d8180df7fd26eac086a3f431c181e4d64 -r07955a5bcecef8840417a57c6a704ef788533581 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 06f9145d8180df7fd26eac086a3f431c181e4d64) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 07955a5bcecef8840417a57c6a704ef788533581) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.42000 +// Runtime Version:4.0.30319.18444 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -70,24 +70,6 @@ } /// - /// Looks up a localized string similar to Inlezen van de locaties uit de hydraulische randvoorwaarden database.. - /// - public static string HydraulicBoundaryLocationsImporter_GetHydraulicBoundaryLocationReadResult { - get { - return ResourceManager.GetString("HydraulicBoundaryLocationsImporter_GetHydraulicBoundaryLocationReadResult", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Het importeren van hydraulische randvoorwaarden locaties is afgebroken. Er is geen data ingelezen.. - /// - public static string HydraulicBoundaryLocationsImporter_Import_cancelled { - get { - return ResourceManager.GetString("HydraulicBoundaryLocationsImporter_Import_cancelled", resourceCulture); - } - } - - /// /// Looks up a localized string similar to De hydraulische randvoorwaarden locaties zijn ingelezen.. /// public static string HydraulicBoundaryLocationsImporter_Import_Import_successful { @@ -104,14 +86,5 @@ return ResourceManager.GetString("HydraulicBoundaryLocationsImporter_Import_The_file_is_not_opened", resourceCulture); } } - - /// - /// Looks up a localized string similar to Inlezen van de de hydraulische randvoorwaarden database.. - /// - public static string HydraulicBoundaryLocationsImporter_ReadHydraulicBoundaryLocations { - get { - return ResourceManager.GetString("HydraulicBoundaryLocationsImporter_ReadHydraulicBoundaryLocations", resourceCulture); - } - } } } Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.resx =================================================================== diff -u -r06f9145d8180df7fd26eac086a3f431c181e4d64 -r07955a5bcecef8840417a57c6a704ef788533581 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 06f9145d8180df7fd26eac086a3f431c181e4d64) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 07955a5bcecef8840417a57c6a704ef788533581) @@ -120,18 +120,9 @@ {0} Het bestand wordt overgeslagen. - - Het importeren van hydraulische randvoorwaarden locaties is afgebroken. Er is geen data ingelezen. - De hydraulische randvoorwaarden locaties zijn ingelezen. - - Inlezen van de de hydraulische randvoorwaarden database. - - - Inlezen van de locaties uit de hydraulische randvoorwaarden database. - Er is nog geen bestand geopend. Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/HydraulicBoundaryDatabaseImporterTest.cs =================================================================== diff -u -r7d124cef8960a865cc8d7db24b3359f7ff9958be -r07955a5bcecef8840417a57c6a704ef788533581 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/HydraulicBoundaryDatabaseImporterTest.cs (.../HydraulicBoundaryDatabaseImporterTest.cs) (revision 7d124cef8960a865cc8d7db24b3359f7ff9958be) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/HydraulicBoundaryDatabaseImporterTest.cs (.../HydraulicBoundaryDatabaseImporterTest.cs) (revision 07955a5bcecef8840417a57c6a704ef788533581) @@ -181,82 +181,6 @@ } [Test] - public void Import_CancelOfImportToValidTargetWithValidFile_CancelImportAndLog() - { - // Setup - string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); - - var mocks = new MockRepository(); - var observer = mocks.StrictMock(); - var assessmentSection = mocks.StrictMock(); - mocks.ReplayAll(); - - var importTarget = new HydraulicBoundaryDatabaseContext(assessmentSection); - importTarget.Attach(observer); - - var progressChanged = new List(); - importer.ProgressChanged = (description, currentStep, totalSteps) => { progressChanged.Add(description); }; - - // Precondition - Assert.IsNull(importTarget.Parent.HydraulicBoundaryDatabase); - Assert.IsTrue(File.Exists(validFilePath), string.Format("Precodition failed. File does not exist: {0}", validFilePath)); - - importer.ValidateAndConnectTo(validFilePath); - - importer.Cancel(); - var importResult = true; - - // Call - Action call = () => importResult = importer.Import(importTarget, validFilePath); - - // Assert - TestHelper.AssertLogMessageIsGenerated(call, "Het importeren van hydraulische randvoorwaarden locaties is afgebroken. Er is geen data ingelezen.", 1); - Assert.IsFalse(importResult); - Assert.IsNull(importTarget.Parent.HydraulicBoundaryDatabase); - Assert.AreEqual(1, progressChanged.Count); - Assert.AreEqual(RingtoetsHydraRingPluginResources.HydraulicBoundaryLocationsImporter_ReadHydraulicBoundaryLocations, progressChanged[0]); - - mocks.VerifyAll(); // 'observer' should not be notified - } - - [Test] - public void Import_ReuseOfCancelledImportToValidTargetWithValidFile_ImportHydraulicBoundaryLocationsToCollection() - { - // Setup - string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); - - var mocks = new MockRepository(); - var observer = mocks.StrictMock(); - var assessmentSection = mocks.StrictMock(); - observer.Expect(o => o.UpdateObserver()); - mocks.ReplayAll(); - - var importTarget = new HydraulicBoundaryDatabaseContext(assessmentSection); - importTarget.Attach(observer); - - // Precondition - Assert.IsNull(importTarget.Parent.HydraulicBoundaryDatabase); - Assert.IsTrue(File.Exists(validFilePath)); - - importer.ValidateAndConnectTo(validFilePath); - - // Setup (second part) - importer.Cancel(); - var importResult = importer.Import(importTarget, validFilePath); - Assert.IsFalse(importResult); - - // Call - importResult = importer.Import(importTarget, validFilePath); - - // Assert - Assert.IsTrue(importResult); - Assert.IsNotNull(importTarget.Parent.HydraulicBoundaryDatabase); - Assert.AreEqual(18, importTarget.Parent.HydraulicBoundaryDatabase.Locations.Count); - CollectionAssert.AllItemsAreNotNull(importTarget.Parent.HydraulicBoundaryDatabase.Locations); - CollectionAssert.AllItemsAreUnique(importTarget.Parent.HydraulicBoundaryDatabase.Locations); - } - - [Test] public void Import_ImportingFileWithCorruptSchema_AbortAndLog() { // Setup @@ -270,9 +194,6 @@ string corruptPath = Path.Combine(testDataPath, "corruptschema.sqlite"); var expectedLogMessage = string.Format("Fout bij het lezen van bestand '{0}': Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database. Het bestand wordt overgeslagen.", corruptPath); - var progressChanged = new List(); - importer.ProgressChanged = (description, currentStep, totalSteps) => { progressChanged.Add(description); }; - importTarget.Attach(observer); var importResult = true; @@ -286,8 +207,6 @@ TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); Assert.IsFalse(importResult); Assert.IsNull(importTarget.Parent.HydraulicBoundaryDatabase, "No HydraulicBoundaryDatabase object should be created when import from corrupt database."); - Assert.AreEqual(1, progressChanged.Count); - Assert.AreEqual(RingtoetsHydraRingPluginResources.HydraulicBoundaryLocationsImporter_ReadHydraulicBoundaryLocations, progressChanged[0]); mocks.VerifyAll(); // Expect no calls on 'observer' } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs =================================================================== diff -u -r7d124cef8960a865cc8d7db24b3359f7ff9958be -r07955a5bcecef8840417a57c6a704ef788533581 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs (.../AssessmentSectionView.cs) (revision 7d124cef8960a865cc8d7db24b3359f7ff9958be) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssessmentSectionView.cs (.../AssessmentSectionView.cs) (revision 07955a5bcecef8840417a57c6a704ef788533581) @@ -23,6 +23,7 @@ using System.Linq; using System.Windows.Forms; using Core.Common.Base; +using Core.Common.Base.Geometry; using Core.Components.DotSpatial.Forms; using Core.Components.Gis; using Core.Components.Gis.Data; @@ -105,13 +106,13 @@ private MapData GetReferenceLineData() { - var referenceLinePoints = data.ReferenceLine.Points.ToList(); + Point2D[] referenceLinePoints = data.ReferenceLine.Points.ToArray(); return new MapLineData(referenceLinePoints); } private MapData GetHydraulicBoundaryLocations() { - var hrLocations = data.HydraulicBoundaryDatabase.Locations.Select(h => h.Location).ToArray(); + Point2D[] hrLocations = data.HydraulicBoundaryDatabase.Locations.Select(h => h.Location).ToArray(); return new MapPointData(hrLocations); } Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs =================================================================== diff -u -r7d124cef8960a865cc8d7db24b3359f7ff9958be -r07955a5bcecef8840417a57c6a704ef788533581 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 7d124cef8960a865cc8d7db24b3359f7ff9958be) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/RingtoetsPipingSurfaceLine.cs (.../RingtoetsPipingSurfaceLine.cs) (revision 07955a5bcecef8840417a57c6a704ef788533581) @@ -325,8 +325,7 @@ { throw new ArgumentNullException("point", "Cannot find a point in geometry using a null point."); } - var pointFromGeometry = Points.FirstOrDefault(p => p.Equals(point)); - return pointFromGeometry; + return Points.FirstOrDefault(p => p.Equals(point)); } private static ArgumentException CreatePointNotInGeometryException(Point3D point, string characteristicPointDescription)