Index: Core/Common/src/Core.Common.IO/Core.Common.IO.csproj =================================================================== diff -u -rcd709418712e8fa50e2e8a0da0e2488139ac9054 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Core/Common/src/Core.Common.IO/Core.Common.IO.csproj (.../Core.Common.IO.csproj) (revision cd709418712e8fa50e2e8a0da0e2488139ac9054) +++ Core/Common/src/Core.Common.IO/Core.Common.IO.csproj (.../Core.Common.IO.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -48,6 +48,8 @@ + + Index: Core/Common/src/Core.Common.IO/Readers/DatabaseReaderBase.cs =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Core/Common/src/Core.Common.IO/Readers/DatabaseReaderBase.cs (.../DatabaseReaderBase.cs) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Core/Common/src/Core.Common.IO/Readers/DatabaseReaderBase.cs (.../DatabaseReaderBase.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -102,9 +102,9 @@ DataSource = databaseFile, ReadOnly = true, ForeignKeys = true - }; + }.ConnectionString; - Connection = new SQLiteConnection(connectionStringBuilder.ConnectionString); + Connection = new SQLiteConnection(connectionStringBuilder); Connection.Open(); } } Index: Core/Common/src/Core.Common.IO/Readers/IRowBasedDatabaseReader.cs =================================================================== diff -u --- Core/Common/src/Core.Common.IO/Readers/IRowBasedDatabaseReader.cs (revision 0) +++ Core/Common/src/Core.Common.IO/Readers/IRowBasedDatabaseReader.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,60 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; + +namespace Core.Common.IO.Readers +{ + /// + /// This interface can be used for data bases to implement a row/column based way of reading records. + /// + public interface IRowBasedDatabaseReader + { + /// + /// Gets the path of the database being read. + /// + string Path { get; } + + /// + /// Moves the reader to the next record in the database. + /// + void MoveNext(); + + /// + /// Reads a value at column from the database. + /// + /// The expected type of value in the column with name . + /// The name of the column to read from. + /// The read value from the column with name . + /// Thrown when the value in the column was not of type . + T Read(string columnName); + + /// + /// Reads the value in the column with name from the + /// current row that's being pointed at. + /// + /// The type of object to read. + /// The name of the column to read from. + /// The value in the column, or null if the value was . + /// Thrown when the value in the column could not be casted to type . + T? ReadOrNull(string columnName) where T : struct; + } +} \ No newline at end of file Index: Core/Common/src/Core.Common.IO/Readers/ReadResult.cs =================================================================== diff -u --- Core/Common/src/Core.Common.IO/Readers/ReadResult.cs (revision 0) +++ Core/Common/src/Core.Common.IO/Readers/ReadResult.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,56 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Collections.Generic; + +namespace Core.Common.IO.Readers +{ + /// + /// This class can be used in importers to return a result from a method where some critical error + /// may have occurred. The type of items which are collected is supplied by . + /// + /// The type of the items which are returned in this result as . + public class ReadResult + { + /// + /// Creates a new instance of , for which the + /// is set to . + /// + /// value indicating whether an error has occurred while collecting + /// the import items for this . + public ReadResult(bool errorOccurred) + { + CriticalErrorOccurred = errorOccurred; + ImportedItems = new T[0]; + } + + /// + /// Gets or sets the of items that were imported. + /// + public ICollection ImportedItems { get; set; } + + /// + /// Gets or sets the representing whether an critical error has occurred during + /// import. + /// + public bool CriticalErrorOccurred { get; private set; } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.IO.Test/Core.Common.IO.Test.csproj =================================================================== diff -u -rcd709418712e8fa50e2e8a0da0e2488139ac9054 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Core/Common/test/Core.Common.IO.Test/Core.Common.IO.Test.csproj (.../Core.Common.IO.Test.csproj) (revision cd709418712e8fa50e2e8a0da0e2488139ac9054) +++ Core/Common/test/Core.Common.IO.Test/Core.Common.IO.Test.csproj (.../Core.Common.IO.Test.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -42,6 +42,7 @@ + Index: Core/Common/test/Core.Common.IO.Test/Readers/ReadResultTest.cs =================================================================== diff -u --- Core/Common/test/Core.Common.IO.Test/Readers/ReadResultTest.cs (revision 0) +++ Core/Common/test/Core.Common.IO.Test/Readers/ReadResultTest.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,22 @@ +using Core.Common.IO.Readers; +using NUnit.Framework; + +namespace Core.Common.IO.Test.Readers +{ + [TestFixture] + public class ReadResultTest + { + [Test] + [TestCase(true)] + [TestCase(false)] + public void Constructor_CriticalErrorOccuredOrNot_InitializesCollectionAndSetsCriticalErrorOccuredProperty(bool errorOccurred) + { + // Call + var readResult = new ReadResult(errorOccurred); + + // Assert + CollectionAssert.IsEmpty(readResult.ImportedItems); + Assert.AreEqual(errorOccurred, readResult.CriticalErrorOccurred); + } + } +} \ No newline at end of file Index: Core/Common/test/Core.Common.TestUtil/TestDataPath.cs =================================================================== diff -u -rf98cc7191a717793f69485dad2923cd34f6d48de -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision f98cc7191a717793f69485dad2923cd34f6d48de) +++ Core/Common/test/Core.Common.TestUtil/TestDataPath.cs (.../TestDataPath.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -41,30 +41,34 @@ public static readonly TestDataPath IO = System.IO.Path.Combine("Core", "Components", "test", "Core.Components.Gis.IO.Test"); } } - + public static class Plugins { public static readonly TestDataPath DotSpatial = System.IO.Path.Combine("Core", "Plugins", "test", "Core.Plugins.DotSpatial.Test"); } - } public static class Ringtoets { - public static class Piping + public static class Common { - public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "Piping", "test", "Ringtoets.Piping.IO.Test"); + public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "Common", "test", "Ringtoets.Common.IO.Test"); } - public static class Common + public static class HydraRing { - public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "Common", "test", "Ringtoets.Common.IO.Test"); + public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "HydraRing", "test", "Ringtoets.HydraRing.IO.Test"); } public static class Integration { public static readonly TestDataPath Forms = System.IO.Path.Combine("Ringtoets", "Integration", "test", "Ringtoets.Integration.Forms.Test"); } + + public static class Piping + { + public static readonly TestDataPath IO = System.IO.Path.Combine("Ringtoets", "Piping", "test", "Ringtoets.Piping.IO.Test"); + } } } } \ No newline at end of file Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs =================================================================== diff -u -rf9058d5293ecb785069c5b6b4c554dc6800ee771 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs (.../AddNewDemoDikeAssessmentSectionCommand.cs) (revision f9058d5293ecb785069c5b6b4c554dc6800ee771) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoDikeAssessmentSectionCommand.cs (.../AddNewDemoDikeAssessmentSectionCommand.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -1,10 +1,10 @@ using System; using System.IO; using System.Linq; - using Core.Common.Controls.Commands; using Core.Common.Gui; using Core.Common.Utils.Reflection; +using Ringtoets.HydraRing.Plugin; using Ringtoets.Integration.Data; using Ringtoets.Piping.Data; using Ringtoets.Piping.Plugin.FileImporter; @@ -52,10 +52,23 @@ { Name = "Demo dijktraject" }; + InitializeDemoHydraulicBoundaryDatabase(demoAssessmentSection); InitializeDemoPipingData(demoAssessmentSection); return demoAssessmentSection; } + private void InitializeDemoHydraulicBoundaryDatabase(DikeAssessmentSection demoAssessmentSection) + { + var hydraulicBoundaryDatabase = demoAssessmentSection.HydraulicBoundaryDatabase; + + using (var tempPath = new TemporaryImportFile("HRD_dutchcoastsouth.sqlite")) + { + hydraulicBoundaryDatabase.FilePath = tempPath.FilePath; + var hydraulicBoundaryDatabaseImporter = new HydraulicBoundaryLocationsImporter(); + hydraulicBoundaryDatabaseImporter.Import(hydraulicBoundaryDatabase.Locations, tempPath.FilePath); + } + } + private void InitializeDemoPipingData(DikeAssessmentSection demoAssessmentSection) { var pipingFailureMechanism = demoAssessmentSection.PipingFailureMechanism; Index: Demo/Ringtoets/src/Demo.Ringtoets/Demo.Ringtoets.csproj =================================================================== diff -u -r61f3b606ba0003553fe583462bab6e493043be5e -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Demo/Ringtoets/src/Demo.Ringtoets/Demo.Ringtoets.csproj (.../Demo.Ringtoets.csproj) (revision 61f3b606ba0003553fe583462bab6e493043be5e) +++ Demo/Ringtoets/src/Demo.Ringtoets/Demo.Ringtoets.csproj (.../Demo.Ringtoets.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -110,6 +110,18 @@ Ringtoets.Common.Data False + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + + + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} + Ringtoets.HydraRing.IO + + + {0A0B4576-1FD4-4836-880C-A7829ACB944A} + Ringtoets.HydraRing.Plugin + {11f1f874-45af-43e4-8ae5-15a5c9593e28} Ringtoets.Integration.Data @@ -151,6 +163,7 @@ + Index: Demo/Ringtoets/src/Demo.Ringtoets/Resources/HRD_dutchcoastsouth.sqlite =================================================================== diff -u Binary files differ Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs =================================================================== diff -u -rf9058d5293ecb785069c5b6b4c554dc6800ee771 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision f9058d5293ecb785069c5b6b4c554dc6800ee771) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoDikeAssessmentSectionCommandTest.cs (.../AddNewDemoDikeAssessmentSectionCommandTest.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -61,6 +61,10 @@ var demoAssessmentSection = (DikeAssessmentSection) project.Items[0]; Assert.AreEqual("Demo dijktraject", demoAssessmentSection.Name); + Assert.IsNotEmpty(demoAssessmentSection.HydraulicBoundaryDatabase.FilePath); + var hydraulicBoundaryLocations = demoAssessmentSection.HydraulicBoundaryDatabase.Locations.ToArray(); + Assert.AreEqual(18, hydraulicBoundaryLocations.Length); + var profiles = demoAssessmentSection.PipingFailureMechanism.SoilProfiles.ToArray(); Assert.AreEqual(26, profiles.Length); var surfaceLines = demoAssessmentSection.PipingFailureMechanism.SurfaceLines.ToArray(); Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Demo.Ringtoets.Test.csproj =================================================================== diff -u -r503ce83bfc5077074351e8d10b18ab8c1343f6b2 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Demo.Ringtoets.Test.csproj (.../Demo.Ringtoets.Test.csproj) (revision 503ce83bfc5077074351e8d10b18ab8c1343f6b2) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Demo.Ringtoets.Test.csproj (.../Demo.Ringtoets.Test.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -85,6 +85,10 @@ {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data + + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} + Ringtoets.HydraRing.Data + {11f1f874-45af-43e4-8ae5-15a5c9593e28} Ringtoets.Integration.Data Index: Ringtoets.sln =================================================================== diff -u -rf98cc7191a717793f69485dad2923cd34f6d48de -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets.sln (.../Ringtoets.sln) (revision f98cc7191a717793f69485dad2923cd34f6d48de) +++ Ringtoets.sln (.../Ringtoets.sln) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -259,6 +259,14 @@ EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.HydraRing.Forms.Test", "Ringtoets\HydraRing\test\Ringtoets.HydraRing.Forms.Test\Ringtoets.HydraRing.Forms.Test.csproj", "{EC6B2FE8-C211-4C62-BEAC-AFD5B47197CA}" EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.HydraRing.IO", "Ringtoets\HydraRing\src\Ringtoets.HydraRing.IO\Ringtoets.HydraRing.IO.csproj", "{B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.HydraRing.Plugin", "Ringtoets\HydraRing\src\Ringtoets.HydraRing.Plugin\Ringtoets.HydraRing.Plugin.csproj", "{0A0B4576-1FD4-4836-880C-A7829ACB944A}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.HydraRing.IO.Test", "Ringtoets\HydraRing\test\Ringtoets.HydraRing.IO.Test\Ringtoets.HydraRing.IO.Test.csproj", "{CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}" +EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Ringtoets.HydraRing.Plugin.Test", "Ringtoets\HydraRing\test\Ringtoets.HydraRing.Plugin.Test\Ringtoets.HydraRing.Plugin.Test.csproj", "{B4C237B2-88B4-4A39-925A-BA0ED2F34D23}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution CreateInstaller|x86 = CreateInstaller|x86 @@ -996,6 +1004,46 @@ {EC6B2FE8-C211-4C62-BEAC-AFD5B47197CA}.Release|x86.Build.0 = Release|x86 {EC6B2FE8-C211-4C62-BEAC-AFD5B47197CA}.ReleaseForCodeCoverage|x86.ActiveCfg = Release|x86 {EC6B2FE8-C211-4C62-BEAC-AFD5B47197CA}.ReleaseForCodeCoverage|x86.Build.0 = Release|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.CreateInstaller|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.CreateInstaller|x86.Build.0 = ReleaseForCodeCoverage|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.CreateInstallerWithDemoProject|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.CreateInstallerWithDemoProject|x86.Build.0 = ReleaseForCodeCoverage|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.Debug|x86.ActiveCfg = Debug|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.Debug|x86.Build.0 = Debug|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.Release|x86.ActiveCfg = Release|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.Release|x86.Build.0 = Release|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.CreateInstaller|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.CreateInstaller|x86.Build.0 = ReleaseForCodeCoverage|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.CreateInstallerWithDemoProject|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.CreateInstallerWithDemoProject|x86.Build.0 = ReleaseForCodeCoverage|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.Debug|x86.ActiveCfg = Debug|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.Debug|x86.Build.0 = Debug|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.Release|x86.ActiveCfg = Release|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.Release|x86.Build.0 = Release|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.ReleaseForCodeCoverage|x86.ActiveCfg = ReleaseForCodeCoverage|x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A}.ReleaseForCodeCoverage|x86.Build.0 = ReleaseForCodeCoverage|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.CreateInstaller|x86.ActiveCfg = Release|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.CreateInstaller|x86.Build.0 = Release|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.CreateInstallerWithDemoProject|x86.Build.0 = Release|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.Debug|x86.ActiveCfg = Debug|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.Debug|x86.Build.0 = Debug|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.Release|x86.ActiveCfg = Release|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.Release|x86.Build.0 = Release|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.ReleaseForCodeCoverage|x86.ActiveCfg = Release|x86 + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221}.ReleaseForCodeCoverage|x86.Build.0 = Release|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.CreateInstaller|x86.ActiveCfg = Release|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.CreateInstaller|x86.Build.0 = Release|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.CreateInstallerWithDemoProject|x86.ActiveCfg = Release|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.CreateInstallerWithDemoProject|x86.Build.0 = Release|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.Debug|x86.ActiveCfg = Debug|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.Debug|x86.Build.0 = Debug|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.Release|x86.ActiveCfg = Release|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.Release|x86.Build.0 = Release|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.ReleaseForCodeCoverage|x86.ActiveCfg = Release|x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23}.ReleaseForCodeCoverage|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -1108,9 +1156,13 @@ {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} = {B31E1A9B-D13E-42CD-BEDD-9D4A709CE7BD} {888D4097-8BC2-4703-9FB1-8744C94D525E} = {B31E1A9B-D13E-42CD-BEDD-9D4A709CE7BD} {EFB9B7E0-82A8-40CA-95C8-B56B4AC02294} = {B31E1A9B-D13E-42CD-BEDD-9D4A709CE7BD} + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} = {B31E1A9B-D13E-42CD-BEDD-9D4A709CE7BD} + {0A0B4576-1FD4-4836-880C-A7829ACB944A} = {B31E1A9B-D13E-42CD-BEDD-9D4A709CE7BD} {175406DB-C0DA-42A7-968C-0C17CF2257B1} = {435F0AB1-1180-47D3-9BCB-3B5FF365236C} {BFD6A78A-237A-413F-8DC3-8EC6E8C5809C} = {435F0AB1-1180-47D3-9BCB-3B5FF365236C} {EC6B2FE8-C211-4C62-BEAC-AFD5B47197CA} = {435F0AB1-1180-47D3-9BCB-3B5FF365236C} + {CA7B5888-2BC9-4FE2-9F58-FBC6D7ED8221} = {435F0AB1-1180-47D3-9BCB-3B5FF365236C} + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23} = {435F0AB1-1180-47D3-9BCB-3B5FF365236C} EndGlobalSection GlobalSection(TextTemplating) = postSolution TextTemplating = 1 Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/HydraulicBoundaryLocation.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,55 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using Core.Common.Base.Geometry; + +namespace Ringtoets.HydraRing.Data +{ + public class HydraulicBoundaryLocation + { + public HydraulicBoundaryLocation(long id, string name, double x, double y) + { + Id = id; + Name = name; + Location = new Point2D(x, y); + } + + /// + /// Gets the database id of . + /// + public long Id { get; private set; } + + /// + /// Gets the name of . + /// + public string Name { get; private set; } + + /// + /// Gets the X-coordinate of . + /// + public Point2D Location { get; set; } + + public override string ToString() + { + return Name; + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/Ringtoets.HydraRing.Data.csproj =================================================================== diff -u -r5d2266c055328eb7f13376df384683af71e3fee3 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/Ringtoets.HydraRing.Data.csproj (.../Ringtoets.HydraRing.Data.csproj) (revision 5d2266c055328eb7f13376df384683af71e3fee3) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Data/Ringtoets.HydraRing.Data.csproj (.../Ringtoets.HydraRing.Data.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -39,6 +39,7 @@ Properties\GlobalAssembly.cs + @@ -50,6 +51,10 @@ + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + {c90b77da-e421-43cc-b82e-529651bc21ac} Core.Common.Version Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -rf98cc7191a717793f69485dad2923cd34f6d48de -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision f98cc7191a717793f69485dad2923cd34f6d48de) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17929 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. @@ -22,7 +22,7 @@ [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - internal class Resources { + public class Resources { private static global::System.Resources.ResourceManager resourceMan; @@ -36,7 +36,7 @@ /// Returns the cached ResourceManager instance used by this class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Resources.ResourceManager ResourceManager { + public static global::System.Resources.ResourceManager ResourceManager { get { if (object.ReferenceEquals(resourceMan, null)) { global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.HydraRing.Forms.Properties.Resources", typeof(Resources).Assembly); @@ -51,7 +51,7 @@ /// resource lookups using this strongly typed resource class. /// [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] - internal static global::System.Globalization.CultureInfo Culture { + public static global::System.Globalization.CultureInfo Culture { get { return resourceCulture; } @@ -63,7 +63,7 @@ /// /// Looks up a localized string similar to {0} mag niet 'null' zijn.. /// - internal static string HydraulicBoundaryDatabaseContext_HydraulicBoundaryDatabaseContext__0__cannot_bet__null__ { + public static string HydraulicBoundaryDatabaseContext_HydraulicBoundaryDatabaseContext__0__cannot_bet__null__ { get { return ResourceManager.GetString("HydraulicBoundaryDatabaseContext_HydraulicBoundaryDatabaseContext__0__cannot_bet_" + "_null__", resourceCulture); @@ -73,11 +73,20 @@ /// /// Looks up a localized string similar to De assessment sectie. /// - internal static string HydraulicBoundaryDatabaseContext_HydraulicBoundaryDatabaseContext_The_assessment_section { + public static string HydraulicBoundaryDatabaseContext_HydraulicBoundaryDatabaseContext_The_assessment_section { get { return ResourceManager.GetString("HydraulicBoundaryDatabaseContext_HydraulicBoundaryDatabaseContext_The_assessment_" + "section", resourceCulture); } } + + /// + /// Looks up a localized string similar to Locaties van de hydraulische randvoorwaarden. + /// + public static string HydraulicBoundaryLocationsCollection_DisplayName { + get { + return ResourceManager.GetString("HydraulicBoundaryLocationsCollection_DisplayName", resourceCulture); + } + } } } Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Properties/Resources.resx =================================================================== diff -u -rf98cc7191a717793f69485dad2923cd34f6d48de -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Properties/Resources.resx (.../Resources.resx) (revision f98cc7191a717793f69485dad2923cd34f6d48de) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Properties/Resources.resx (.../Resources.resx) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -1,107 +1,129 @@  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - text/microsoft-resx - - - 1.3 - - - System.Resources.ResXResourceReader, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - - System.Resources.ResXResourceWriter, System.Windows.Forms, Version=2.0.3500.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + mimetype: application/x-microsoft.net.object.bytearray.base64 + value : The object must be serialized into a byte array + : using a System.ComponentModel.TypeConverter + : and then encoded with base64 encoding. + --> + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + {0} mag niet 'null' zijn. De assessment sectie + + Locaties van de hydraulische randvoorwaarden + \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Ringtoets.HydraRing.Forms.csproj =================================================================== diff -u -rf98cc7191a717793f69485dad2923cd34f6d48de -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Ringtoets.HydraRing.Forms.csproj (.../Ringtoets.HydraRing.Forms.csproj) (revision f98cc7191a717793f69485dad2923cd34f6d48de) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Forms/Ringtoets.HydraRing.Forms.csproj (.../Ringtoets.HydraRing.Forms.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -69,7 +69,7 @@ - ResXFileCodeGenerator + PublicResXFileCodeGenerator Resources.Designer.cs Designer Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Exceptions/HydraulicBoundaryDatabaseReadException.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Exceptions/HydraulicBoundaryDatabaseReadException.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Exceptions/HydraulicBoundaryDatabaseReadException.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,29 @@ +using System; + +namespace Ringtoets.HydraRing.IO.Exceptions +{ + public class HydraulicBoundaryDatabaseReadException : Exception + { + /// + /// Initializes a new instance of the class. + /// + public HydraulicBoundaryDatabaseReadException() {} + + /// + /// Initializes a new instance of the class + /// with a specified error message. + /// + /// The error message that explains the reason for the exception. + public HydraulicBoundaryDatabaseReadException(string message) : base(message) {} + + /// + /// Initializes a new instance of the class + /// with a specified error message and a reference to the inner exception that is + /// the cause of this exception. + /// + /// The error message that explains the reason for the exception. + /// The exception that is the cause of the current exception, + /// or a null reference if no inner exception is specified. + public HydraulicBoundaryDatabaseReadException(string message, Exception inner) : base(message, inner) {} + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseColumns.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseColumns.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseColumns.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,11 @@ +namespace Ringtoets.HydraRing.IO +{ + internal static class HydraulicBoundaryDatabaseColumns + { + internal const string LocationCount = "LocationCount"; + internal const string LocationName = "LocationName"; + internal const string LocationId = "LocationId"; + internal const string LocationX = "LocationX"; + internal const string LocationY = "LocationY"; + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseReader.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseReader.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/HydraulicBoundaryDatabaseReader.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,170 @@ +using System; +using System.Data; +using System.Data.SQLite; +using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; +using Core.Common.Utils.Builders; +using Ringtoets.HydraRing.Data; +using Ringtoets.HydraRing.IO.Properties; + +namespace Ringtoets.HydraRing.IO +{ + public class HydraulicBoundaryDatabaseReader : DatabaseReaderBase, IRowBasedDatabaseReader + { + private SQLiteDataReader dataReader; + + /// + /// Creates a new instance of which will use the + /// as its source. + /// + /// The path of the database file to open. + /// Thrown when: + /// + /// The contains invalid characters. + /// No file could be found at . + /// Preparing the queries to read from the database failed. + /// + /// + public HydraulicBoundaryDatabaseReader(string databaseFilePath) + : base(databaseFilePath) + { + InitializeReader(); + } + + /// + /// Gets the total number of profiles that can be read from the database. + /// + public int Count { get; private set; } + + /// + /// Gets the value true if profiles can be read using the . + /// false otherwise. + /// + public bool HasNext { get; private set; } + + public HydraulicBoundaryLocation ReadLocation() + { + if (!HasNext) + { + return null; + } + + try + { + return ReadHydraulicBoundaryLocation(); + } + catch (InvalidCastException e) + { + var message = new FileReaderErrorMessageBuilder(Path).Build("Kritieke fout opgetreden bij het uitlezen van waardes uit kolommen in de database."); + throw new CriticalFileReadException(message, e); + } + } + + public override void Dispose() + { + if (dataReader != null) + { + dataReader.Dispose(); + } + base.Dispose(); + } + + /// + /// Moves the reader to the next record in the database. + /// + public void MoveNext() + { + HasNext = dataReader.Read() || (dataReader.NextResult() && dataReader.Read()); + } + + public T Read(string columnName) + { + return (T) dataReader[columnName]; + } + + public T? ReadOrNull(string columnName) where T : struct + { + var valueObject = dataReader[columnName]; + if (valueObject.Equals(DBNull.Value)) + { + return null; + } + return (T) valueObject; + } + + private HydraulicBoundaryLocation ReadHydraulicBoundaryLocation() + { + try + { + var id = Read(HydraulicBoundaryDatabaseColumns.LocationId); + var name = Read(HydraulicBoundaryDatabaseColumns.LocationName); + var x = Read(HydraulicBoundaryDatabaseColumns.LocationX); + var y = Read(HydraulicBoundaryDatabaseColumns.LocationY); + MoveNext(); + return new HydraulicBoundaryLocation(id, name, x, y); + } + catch (InvalidCastException) + { + MoveNext(); + throw; + } + } + + /// + /// + private void InitializeReader() + { + ReadLocations(); + MoveNext(); + } + + /// + /// + private void ReadLocations() + { + var countQuery = string.Format("SELECT count(*) as {0} FROM HRDLocations WHERE LocationTypeId > 1 ;", HydraulicBoundaryDatabaseColumns.LocationCount); + + var locationsQuery = string.Format( + "SELECT HRDLocationId as {0}, Name as {1}, XCoordinate as {2}, YCoordinate as {3} FROM HRDLocations WHERE LocationTypeId > 1;", + HydraulicBoundaryDatabaseColumns.LocationId, + HydraulicBoundaryDatabaseColumns.LocationName, + HydraulicBoundaryDatabaseColumns.LocationX, + HydraulicBoundaryDatabaseColumns.LocationY); + + CreateDataReader(string.Join(" ", countQuery, locationsQuery), new SQLiteParameter + { + DbType = DbType.String + }); + } + + private void CreateDataReader(string queryString, params SQLiteParameter[] parameters) + { + using (var query = new SQLiteCommand(Connection) + { + CommandText = queryString + }) + { + query.Parameters.AddRange(parameters); + + try + { + dataReader = query.ExecuteReader(); + GetCount(); + } + catch (SQLiteException exception) + { + Dispose(); + var message = new FileReaderErrorMessageBuilder(Path).Build(Resources.Error_HydraulicBoundaryLocation_read_from_database); + throw new CriticalFileReadException(message, exception); + } + } + } + + private void GetCount() + { + dataReader.Read(); + Count = (int) Read(HydraulicBoundaryDatabaseColumns.LocationCount); + dataReader.NextResult(); + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/AssemblyInfo.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/AssemblyInfo.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/AssemblyInfo.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,6 @@ +using System.Reflection; +using System.Runtime.InteropServices; + +[assembly: AssemblyTitle("Ringtoets.HydraRing.IO")] +[assembly: AssemblyProduct("Ringtoets.HydraRing.IO")] +[assembly: Guid("B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70")] \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.Designer.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.Designer.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.Designer.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,72 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Ringtoets.HydraRing.IO.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.HydraRing.IO.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Kon geen locaties verkrijgen van de database.. + /// + public static string Error_HydraulicBoundaryLocation_read_from_database { + get { + return ResourceManager.GetString("Error_HydraulicBoundaryLocation_read_from_database", resourceCulture); + } + } + } +} Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.resx =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.resx (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Properties/Resources.resx (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,123 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Kon geen locaties verkrijgen van de database. + + \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/Ringtoets.HydraRing.IO.csproj (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,105 @@ + + + + + + Debug + x86 + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} + Library + Properties + Ringtoets.HydraRing.IO + Ringtoets.HydraRing.IO + v4.0 + 512 + + + true + full + false + DEBUG;TRACE + prompt + + + none + true + TRACE + prompt + + + TRACE + true + true + pdbonly + prompt + AllRules.ruleset + + + + + + + ..\..\..\..\packages\System.Data.SQLite.Core.1.0.99.0\lib\net40\System.Data.SQLite.dll + True + + + + + Properties\GlobalAssembly.cs + + + + + + + True + True + Resources.resx + + + + + Copying.licenseheader + + + + + + {E344867E-9AC9-44C8-88A5-8185681679A9} + Core.Common.IO + + + {F49BD8B2-332A-4C91-A196-8CCE0A2C7D98} + Core.Common.Utils + + + {c90b77da-e421-43cc-b82e-529651bc21ac} + Core.Common.Version + + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + + + + This project references NuGet package(s) that are missing on this computer. Enable NuGet Package Restore to download them. For more information, see http://go.microsoft.com/fwlink/?LinkID=322105. The missing file is {0}. + + + + + \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/packages.config =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/packages.config (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.IO/packages.config (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,4 @@ + + + + \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/HydraulicBoundaryLocationsImporter.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/HydraulicBoundaryLocationsImporter.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/HydraulicBoundaryLocationsImporter.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,213 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Drawing; +using Core.Common.Base.IO; +using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; +using log4net; +using Ringtoets.HydraRing.Data; +using Ringtoets.HydraRing.IO; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; +using RingtoetsHydraRingFormsResources = Ringtoets.HydraRing.Forms.Properties.Resources; +using ApplicationResources = Ringtoets.HydraRing.Plugin.Properties.Resources; + +namespace Ringtoets.HydraRing.Plugin +{ + public class HydraulicBoundaryLocationsImporter : IFileImporter + { + private readonly ILog log = LogManager.GetLogger(typeof(HydraulicBoundaryLocationsImporter)); + private bool shouldCancel; + + /// + /// Gets the name of the . + /// + public string Name + { + get + { + return RingtoetsHydraRingFormsResources.HydraulicBoundaryLocationsCollection_DisplayName; + } + } + + /// + /// Gets the category of the . + /// + public string Category + { + get + { + return RingtoetsCommonFormsResources.Ringtoets_Category; + } + } + + /// + /// Gets the image of the . + /// + /// This image can be used in selection and/or progress dialogs. + public Bitmap Image + { + get + { + return RingtoetsCommonFormsResources.DatabaseIcon; + } + } + + /// + /// Gets the of the item supported by the . + /// + /// Gets the file filter of the . + /// + public string FileFilter + { + get + { + return string.Format("{0} (*.sqlite)|*.sqlite", RingtoetsCommonFormsResources.SelectDatabaseFile_FilterName); + } + } + + /// + /// Sets the action to perform when progress has changed. + /// + public ProgressChangedDelegate ProgressChanged { get; set; } + + /// + /// This method imports the data to an item from a file at the given location. + /// + /// The item to perform the import on. + /// The path of the file to import the data from. + /// true if the import was successful. false otherwise. + public bool Import(object targetItem, string filePath) + { + var importResult = ReadHydraulicBoundaryLocations(filePath); + + if (!importResult.CriticalErrorOccurred) + { + if (!shouldCancel) + { + AddImportedDataToModel(targetItem, importResult); + log.Info("Locaties uit de hydraulische randvoorwaarden ingelezen"); + return true; + } + + log.Info(ApplicationResources.HydraulicBoundaryLocationsImporter_Import_cancelled); + shouldCancel = false; + } + + return false; + } + + /// + /// This method cancels an import. + /// + public void Cancel() + { + shouldCancel = true; + } + + private ReadResult ReadHydraulicBoundaryLocations(string path) + { + NotifyProgress("Inlezen van de de hydraulische randvoorwaarden database", 1, 1); + + try + { + using (var hydraulicBoundaryDatabaseReader = new HydraulicBoundaryDatabaseReader(path)) + { + return GetHydraulicBoundaryLocationReadResult(path, hydraulicBoundaryDatabaseReader); + } + } + catch (CriticalFileReadException e) + { + HandleException(e); + } + return new ReadResult(true); + } + + private void HandleException(Exception e) + { + var message = string.Format(ApplicationResources.HydraulicBoundaryLocationsImporter_CriticalErrorMessage_0_File_Skipped, e.Message); + log.Error(message); + } + + private ReadResult GetHydraulicBoundaryLocationReadResult(string path, HydraulicBoundaryDatabaseReader hydraulicBoundaryDatabaseReader) + { + var totalNumberOfSteps = hydraulicBoundaryDatabaseReader.Count; + var currentStep = 1; + + var locations = new Collection(); + while (hydraulicBoundaryDatabaseReader.HasNext) + { + if (shouldCancel) + { + return new ReadResult(false); + } + try + { + NotifyProgress("Inlezen van de locaties uit de hydraulische randvoorwaarden database", currentStep++, totalNumberOfSteps); + locations.Add(hydraulicBoundaryDatabaseReader.ReadLocation()); + } + catch (CriticalFileReadException e) + { + var message = string.Format(ApplicationResources.HydraulicBoundaryLocationsImporter_CriticalErrorMessage_0_File_Skipped, path); + log.Error(message, e); + return new ReadResult(true); + } + } + return new ReadResult(false) + { + ImportedItems = locations + }; + } + + private void AddImportedDataToModel(object target, ReadResult imported) + { + var targetCollection = (ICollection) target; + + int totalProfileCount = imported.ImportedItems.Count; + NotifyProgress(ApplicationResources.HydraulicBoundaryLocationsImporter_Adding_imported_data_to_model, totalProfileCount, totalProfileCount); + + foreach (var item in imported.ImportedItems) + { + targetCollection.Add(item); + } + } + + private void NotifyProgress(string currentStepName, int currentStep, int totalNumberOfSteps) + { + if (ProgressChanged != null) + { + ProgressChanged(currentStepName, currentStep, totalNumberOfSteps); + } + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/AssemblyInfo.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/AssemblyInfo.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/AssemblyInfo.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,31 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("Ringtoets.HydraRing.Plugin")] +[assembly: AssemblyProduct("Ringtoets.HydraRing.Plugin")] +[assembly: Guid("043d55f4-3724-4623-9a7b-02e7f488c7d5")] \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.Designer.cs =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.Designer.cs (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.Designer.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,90 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.42000 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Ringtoets.HydraRing.Plugin.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + public class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.HydraRing.Plugin.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + public static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Geïmporteerde data toevoegen aan faalmechanisme. + /// + public static string HydraulicBoundaryLocationsImporter_Adding_imported_data_to_model { + get { + return ResourceManager.GetString("HydraulicBoundaryLocationsImporter_Adding_imported_data_to_model", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to {0} Het bestand wordt overgeslagen.. + /// + public static string HydraulicBoundaryLocationsImporter_CriticalErrorMessage_0_File_Skipped { + get { + return ResourceManager.GetString("HydraulicBoundaryLocationsImporter_CriticalErrorMessage_0_File_Skipped", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Locaties van hydraulische randvoorwaarden importeren is afgebroken. Er is geen data ingelezen.. + /// + public static string HydraulicBoundaryLocationsImporter_Import_cancelled { + get { + return ResourceManager.GetString("HydraulicBoundaryLocationsImporter_Import_cancelled", resourceCulture); + } + } + } +} Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.resx =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.resx (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Properties/Resources.resx (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,129 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Geïmporteerde data toevoegen aan faalmechanisme + + + {0} Het bestand wordt overgeslagen. + + + Locaties van hydraulische randvoorwaarden importeren is afgebroken. Er is geen data ingelezen. + + \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Ringtoets.HydraRing.Plugin.csproj =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Ringtoets.HydraRing.Plugin.csproj (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/Ringtoets.HydraRing.Plugin.csproj (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,112 @@ + + + + + + Debug + x86 + {0A0B4576-1FD4-4836-880C-A7829ACB944A} + Library + Properties + Ringtoets.HydraRing.Plugin + Ringtoets.HydraRing.Plugin + v4.0 + 512 + + + true + full + false + DEBUG;TRACE + prompt + + + none + true + TRACE + prompt + + + TRACE + true + true + pdbonly + prompt + AllRules.ruleset + + + + ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll + True + + + + + + + + Properties\GlobalAssembly.cs + + + + + True + True + Resources.resx + + + + + Copying.licenseheader + + + + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {E344867E-9AC9-44C8-88A5-8185681679A9} + Core.Common.IO + + + {c90b77da-e421-43cc-b82e-529651bc21ac} + Core.Common.Version + + + {4d840673-3812-4338-a352-84854e32b8a0} + Ringtoets.Common.Forms + + + {11F1F874-45AF-43E4-8AE5-15A5C9593E28} + Ringtoets.Integration.Data + + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + + + {efb9b7e0-82a8-40ca-95c8-b56b4ac02294} + Ringtoets.HydraRing.Forms + + + {B69D5B6C-6E14-4FA9-9EBC-8F97678CDB70} + Ringtoets.HydraRing.IO + + + + + PublicResXFileCodeGenerator + Resources.Designer.cs + + + + + \ No newline at end of file Index: Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/packages.config =================================================================== diff -u --- Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/packages.config (revision 0) +++ Ringtoets/HydraRing/src/Ringtoets.HydraRing.Plugin/packages.config (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,27 @@ + + + + + + \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/HydraulicBoundaryLocationTest.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/HydraulicBoundaryLocationTest.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/HydraulicBoundaryLocationTest.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,28 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using NUnit.Framework; + +namespace Ringtoets.HydraRing.Data.Test +{ + [TestFixture] + public class HydraulicBoundaryLocationTest {} +} \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/Ringtoets.HydraRing.Data.Test.csproj =================================================================== diff -u -r5d2266c055328eb7f13376df384683af71e3fee3 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/Ringtoets.HydraRing.Data.Test.csproj (.../Ringtoets.HydraRing.Data.Test.csproj) (revision 5d2266c055328eb7f13376df384683af71e3fee3) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Data.Test/Ringtoets.HydraRing.Data.Test.csproj (.../Ringtoets.HydraRing.Data.Test.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -32,10 +32,15 @@ x86 + + ..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + True + + @@ -48,6 +53,7 @@ Copying.licenseheader + + \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/packages.config =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/packages.config (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/packages.config (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,27 @@ + + + + + + \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/test-data/HydraulicBoundaryLocationReader/complete.sqlite =================================================================== diff -u Binary files differ Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/test-data/HydraulicBoundaryLocationReader/corruptschema.sqlite =================================================================== diff -u Binary files differ Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.IO.Test/test-data/HydraulicBoundaryLocationReader/empty.sqlite =================================================================== diff -u Binary files differ Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/HydraulicBoundaryLocationsImporterTest.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/HydraulicBoundaryLocationsImporterTest.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/HydraulicBoundaryLocationsImporterTest.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,283 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using Core.Common.Base; +using Core.Common.Base.IO; +using Core.Common.TestUtil; +using Core.Common.Utils.Builders; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.HydraRing.Data; +using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; +using RingtoetsHydraRingFormsResources = Ringtoets.HydraRing.Forms.Properties.Resources; +using RingtoetsHydraRingPluginResources = Ringtoets.HydraRing.Plugin.Properties.Resources; +using RingtoetsHydraRingIOResources = Ringtoets.HydraRing.IO.Properties.Resources; +using RingtoetsFormsResources = Ringtoets.Common.Forms.Properties.Resources; + +namespace Ringtoets.HydraRing.Plugin.Test +{ + [TestFixture] + public class HydraulicBoundaryLocationsImporterTest + { + private readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.HydraRing.IO, "HydraulicBoundaryLocationReader"); + private int progress; + + [SetUp] + public void SetUp() + { + progress = 0; + } + + [Test] + public void DefaultConstructor_ExpectedValues() + { + // Prepare + var expectedFileFilter = string.Format("{0} (*.sqlite)|*.sqlite", RingtoetsCommonFormsResources.SelectDatabaseFile_FilterName); + + // Call + var importer = new HydraulicBoundaryLocationsImporter(); + + // Assert + Assert.IsInstanceOf(importer); + Assert.AreEqual(RingtoetsHydraRingFormsResources.HydraulicBoundaryLocationsCollection_DisplayName, importer.Name); + Assert.AreEqual(RingtoetsFormsResources.Ringtoets_Category, importer.Category); + Assert.AreEqual(16, importer.Image.Width); + Assert.AreEqual(16, importer.Image.Height); + Assert.AreEqual(typeof(HydraulicBoundaryLocation), importer.SupportedItemType); + Assert.AreEqual(expectedFileFilter, importer.FileFilter); + Assert.IsNull(importer.ProgressChanged); + } + + [Test] + [TestCase("/")] + [TestCase("nonexisting.sqlit")] + public void Import_FromNonExistingFileOrInvalidFile_LogError(string filename) + { + // Setup + string validFilePath = Path.Combine(testDataPath, filename); + + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + mocks.ReplayAll(); + + var observableList = new ObservableList(); + observableList.Attach(observer); + var importer = new HydraulicBoundaryLocationsImporter + { + ProgressChanged = IncrementProgress + }; + + // Precondition + CollectionAssert.IsEmpty(observableList); + var importResult = true; + + // Call + Action call = () => importResult = importer.Import(observableList, validFilePath); + + // Assert + TestHelper.AssertLogMessages(call, messages => + { + string[] messageArray = messages.ToArray(); + var message = string.Format(RingtoetsHydraRingPluginResources.HydraulicBoundaryLocationsImporter_CriticalErrorMessage_0_File_Skipped, String.Empty); + StringAssert.EndsWith(message, messageArray[0]); + }); + Assert.IsFalse(importResult); + CollectionAssert.IsEmpty(observableList); + Assert.AreEqual(1, progress); + + mocks.VerifyAll(); // 'observer' should not be notified + } + + [Test] + public void Import_ImportingToValidTargetWithValidFile_ImportHydraulicBoundaryLocationsToCollection() + { + // Setup + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + var importer = new HydraulicBoundaryLocationsImporter(); + var importTarget = new List(); + Assert.IsTrue(File.Exists(validFilePath), string.Format("Precodition failed. File does not exist: {0}", validFilePath)); + + // Call + var importResult = importer.Import(importTarget, validFilePath); + + // Assert + Assert.IsTrue(importResult); + Assert.AreEqual(18, importTarget.Count); + CollectionAssert.AllItemsAreNotNull(importTarget); + CollectionAssert.AllItemsAreUnique(importTarget); + } + + [Test] + public void Import_CancelOfImportToValidTargetWithValidFile_CancelImportAndLog() + { + // Setup + string validFilePath = Path.Combine(testDataPath, "complete.sqlite"); + + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + mocks.ReplayAll(); + + var observableList = new ObservableList(); + observableList.Attach(observer); + + var importer = new HydraulicBoundaryLocationsImporter + { + ProgressChanged = IncrementProgress + }; + + // Precondition + CollectionAssert.IsEmpty(observableList); + Assert.IsTrue(File.Exists(validFilePath), string.Format("Precodition failed. File does not exist: {0}", validFilePath)); + + importer.Cancel(); + var importResult = true; + + // Call + Action call = () => importResult = importer.Import(observableList, validFilePath); + + // Assert + TestHelper.AssertLogMessageIsGenerated(call, "Locaties van hydraulische randvoorwaarden importeren is afgebroken. Er is geen data ingelezen.", 1); + Assert.IsFalse(importResult); + CollectionAssert.IsEmpty(observableList); + Assert.AreEqual(1, progress); + + 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(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var observableList = new ObservableList(); + observableList.Attach(observer); + + var importer = new HydraulicBoundaryLocationsImporter + { + ProgressChanged = IncrementProgress + }; + + // Precondition + CollectionAssert.IsEmpty(observableList); + Assert.IsTrue(File.Exists(validFilePath)); + + // Setup (second part) + importer.Cancel(); + var importResult = importer.Import(observableList, validFilePath); + Assert.IsFalse(importResult); + + // Call + importResult = importer.Import(observableList, validFilePath); + + // Assert + Assert.IsTrue(importResult); + Assert.AreEqual(18, observableList.Count); + CollectionAssert.AllItemsAreNotNull(observableList); + CollectionAssert.AllItemsAreUnique(observableList); + } + + [Test] + public void Import_ImportingToValidTargetWithEmptyFile_AbortImportAndLog() + { + // Setup + string corruptPath = Path.Combine(testDataPath, "empty.sqlite"); + + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + mocks.ReplayAll(); + + var importer = new HydraulicBoundaryLocationsImporter + { + ProgressChanged = IncrementProgress + }; + + var observableHydraulicBoundaryLocationList = new ObservableList(); + observableHydraulicBoundaryLocationList.Attach(observer); + + var importResult = true; + + // Call + Action call = () => importResult = importer.Import(observableHydraulicBoundaryLocationList, corruptPath); + + // Assert + + var internalErrorMessage = new FileReaderErrorMessageBuilder(corruptPath).Build(RingtoetsHydraRingIOResources.Error_HydraulicBoundaryLocation_read_from_database); + var expectedLogMessage = string.Format(RingtoetsHydraRingPluginResources.HydraulicBoundaryLocationsImporter_CriticalErrorMessage_0_File_Skipped, + internalErrorMessage); + + TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); + Assert.IsFalse(importResult); + CollectionAssert.IsEmpty(observableHydraulicBoundaryLocationList, "No items should be added to collection when importin an empty database."); + Assert.AreEqual(1, progress); + + mocks.VerifyAll(); // Expect no calls on 'observer' + } + + [Test] + public void Import_ImportingFileWithCorruptSchema_AbortAndLog() + { + // Setup + string corruptPath = Path.Combine(testDataPath, "corruptschema.sqlite"); + + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + mocks.ReplayAll(); + + var importer = new HydraulicBoundaryLocationsImporter + { + ProgressChanged = IncrementProgress + }; + + var observableHydraulicBoundaryLocationList = new ObservableList(); + observableHydraulicBoundaryLocationList.Attach(observer); + + var importResult = true; + + // Call + Action call = () => importResult = importer.Import(observableHydraulicBoundaryLocationList, corruptPath); + + // Assert + var expectedLogMessage = string.Format(RingtoetsHydraRingPluginResources.HydraulicBoundaryLocationsImporter_CriticalErrorMessage_0_File_Skipped, corruptPath); + + TestHelper.AssertLogMessageIsGenerated(call, expectedLogMessage, 1); + Assert.IsFalse(importResult); + CollectionAssert.IsEmpty(observableHydraulicBoundaryLocationList, "No items should be added to collection when import from corrupt database."); + Assert.AreEqual(2, progress); + + mocks.VerifyAll(); // Expect no calls on 'observer' + } + + private void IncrementProgress(string a, int b, int c) + { + progress++; + } + } +} \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/Properties/AssemblyInfo.cs =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/Properties/AssemblyInfo.cs (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/Properties/AssemblyInfo.cs (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,40 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System.Reflection; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. + +[assembly: AssemblyTitle("Ringtoets.HydraRing.Plugin.Test")] +[assembly: AssemblyProduct("Ringtoets.HydraRing.Plugin.Test")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. + +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM + +[assembly: Guid("B4C237B2-88B4-4A39-925A-BA0ED2F34D23")] \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/Ringtoets.HydraRing.Plugin.Test.csproj =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/Ringtoets.HydraRing.Plugin.Test.csproj (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/Ringtoets.HydraRing.Plugin.Test.csproj (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,99 @@ + + + + + Debug + x86 + {B4C237B2-88B4-4A39-925A-BA0ED2F34D23} + Library + Properties + Ringtoets.HydraRing.Plugin.Test + Ringtoets.HydraRing.Plugin.Test + v4.0 + 512 + + + true + full + false + bin\Debug\ + DEBUG;TRACE + prompt + 4 + x86 + + + pdbonly + true + bin\Release\ + TRACE + prompt + 4 + x86 + + + + ..\..\..\..\packages\NUnit.2.6.4\lib\nunit.framework.dll + True + + + ..\..\..\..\packages\RhinoMocks.3.6.1\lib\net\Rhino.Mocks.dll + True + + + + + + + + + + + + Copying.licenseheader + + + + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {f49bd8b2-332a-4c91-a196-8cce0a2c7d98} + Core.Common.Utils + + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + + + {4d840673-3812-4338-a352-84854e32b8a0} + Ringtoets.Common.Forms + + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + + + {efb9b7e0-82a8-40ca-95c8-b56b4ac02294} + Ringtoets.HydraRing.Forms + + + {b69d5b6c-6e14-4fa9-9ebc-8f97678cdb70} + Ringtoets.HydraRing.IO + + + {0A0B4576-1FD4-4836-880C-A7829ACB944A} + Ringtoets.HydraRing.Plugin + + + + + \ No newline at end of file Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/packages.config =================================================================== diff -u --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/packages.config (revision 0) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Plugin.Test/packages.config (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -0,0 +1,5 @@ + + + + + \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/HydraulicBoundary/HydraulicBoundaryDatabase.cs =================================================================== diff -u -r9745cf23c0ce16a076f08ce8ed726882c490c646 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/HydraulicBoundary/HydraulicBoundaryDatabase.cs (.../HydraulicBoundaryDatabase.cs) (revision 9745cf23c0ce16a076f08ce8ed726882c490c646) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/HydraulicBoundary/HydraulicBoundaryDatabase.cs (.../HydraulicBoundaryDatabase.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -19,12 +19,24 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections.Generic; using Core.Common.Base; +using Ringtoets.HydraRing.Data; namespace Ringtoets.Integration.Data.HydraulicBoundary { public class HydraulicBoundaryDatabase : Observable { + public HydraulicBoundaryDatabase() + { + Locations = new ObservableList(); + } + public string FilePath { get; set; } + + /// + /// Gets the hydraulic boundary locations. + /// + public IEnumerable Locations { get; private set; } } } \ No newline at end of file Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs =================================================================== diff -u -r5e0721f34fbf44e8aad51cfd4ff6abc8aa061494 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5e0721f34fbf44e8aad51cfd4ff6abc8aa061494) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -1,7 +1,7 @@ //------------------------------------------------------------------------------ // // This code was generated by a tool. -// Runtime Version:4.0.30319.17929 +// Runtime Version:4.0.30319.42000 // // Changes to this file may cause incorrect behavior and will be lost if // the code is regenerated. Index: Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj =================================================================== diff -u -r5e0721f34fbf44e8aad51cfd4ff6abc8aa061494 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision 5e0721f34fbf44e8aad51cfd4ff6abc8aa061494) +++ Ringtoets/Integration/src/Ringtoets.Integration.Data/Ringtoets.Integration.Data.csproj (.../Ringtoets.Integration.Data.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -81,6 +81,10 @@ Ringtoets.Common.Placeholder False + + {70F8CC9C-5BC8-4FB2-B201-EAE7FA8088C2} + Ringtoets.HydraRing.Data + {ce994cc9-6f6a-48ac-b4be-02c30a21f4db} Ringtoets.Piping.Data Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj =================================================================== diff -u -rf98cc7191a717793f69485dad2923cd34f6d48de -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision f98cc7191a717793f69485dad2923cd34f6d48de) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -43,6 +43,7 @@ + @@ -113,6 +114,10 @@ Ringtoets.Common.Placeholder False + + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} + Ringtoets.HydraRing.Data + {EFB9B7E0-82A8-40CA-95C8-B56B4AC02294} Ringtoets.HydraRing.Forms Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs =================================================================== diff -u -r17574077c6720e02c10f23ac3a0354db35855a05 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 17574077c6720e02c10f23ac3a0354db35855a05) +++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/RingtoetsGuiPlugin.cs (.../RingtoetsGuiPlugin.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -37,6 +37,7 @@ using Ringtoets.Common.Forms.PresentationObjects; using Ringtoets.Common.Placeholder; using Ringtoets.HydraRing.Forms.PresentationObjects; +using Ringtoets.HydraRing.Plugin; using Ringtoets.Integration.Data; using Ringtoets.Integration.Data.Contribution; using Ringtoets.Integration.Data.Placeholders; @@ -187,7 +188,7 @@ { new ReferenceLineContext(nodeData.ReferenceLine, nodeData), nodeData.FailureMechanismContribution, - new HydraulicBoundaryDatabaseContext (nodeData.HydraulicBoundaryDatabase, nodeData) + new HydraulicBoundaryDatabaseContext(nodeData.HydraulicBoundaryDatabase, nodeData) }; childNodes.AddRange(nodeData.GetFailureMechanisms()); @@ -376,7 +377,11 @@ var connectionItem = new StrictContextMenuItem( RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Connect, RingtoetsCommonFormsResources.HydraulicBoundaryDatabase_Connect_ToolTip, - RingtoetsCommonFormsResources.DatabaseIcon, (sender, args) => SelectDatabaseFile(nodeData)); + RingtoetsCommonFormsResources.DatabaseIcon, (sender, args) => + { + SelectDatabaseFile(nodeData); + ImportDatabaseFileLovations(nodeData); + }); var toetsPeilItem = new StrictContextMenuItem( RingtoetsCommonFormsResources.Toetspeil_Calculate, @@ -415,6 +420,12 @@ } } + private void ImportDatabaseFileLovations(HydraulicBoundaryDatabaseContext nodeData) + { + var hydraulicBoundaryLocationsImporter = new HydraulicBoundaryLocationsImporter(); + hydraulicBoundaryLocationsImporter.Import(nodeData.BoundaryDatabase.Locations, nodeData.BoundaryDatabase.FilePath); + } + private static void ValidateSelectedFile(HydraulicBoundaryDatabaseContext nodeData, string selectedFile) { try Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj =================================================================== diff -u -rdd7a5cfb0343fa2350b4143232b94cbba37612e9 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision dd7a5cfb0343fa2350b4143232b94cbba37612e9) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Ringtoets.Piping.IO.csproj (.../Ringtoets.Piping.IO.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -52,7 +52,6 @@ - Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/CriticalProfileProperties.cs (.../CriticalProfileProperties.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -21,6 +21,7 @@ using System; using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using Ringtoets.Piping.IO.Properties; Fisheye: Tag 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/IRowBasedDatabaseReader.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile1DReader.cs (.../SoilProfile1DReader.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -21,6 +21,7 @@ using System; using System.Data.SQLite; +using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Builders; Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfile/SoilProfile2DReader.cs (.../SoilProfile2DReader.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -21,6 +21,7 @@ using System; using System.Data.SQLite; +using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Builders; Fisheye: Tag 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 refers to a dead (removed) revision in file `Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingReadResult.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSoilProfilesImporter.cs (.../PipingSoilProfilesImporter.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -25,6 +25,7 @@ using System.Drawing; using Core.Common.Base.IO; using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; using log4net; using Ringtoets.Piping.Data; using Ringtoets.Piping.IO.Exceptions; @@ -84,13 +85,13 @@ } } + public ProgressChangedDelegate ProgressChanged { get; set; } + public void Cancel() { shouldCancel = true; } - public ProgressChangedDelegate ProgressChanged { get; set; } - public bool Import(object targetItem, string filePath) { var importResult = ReadSoilProfiles(filePath); @@ -110,7 +111,7 @@ return false; } - private PipingReadResult ReadSoilProfiles(string path) + private ReadResult ReadSoilProfiles(string path) { NotifyProgress(ApplicationResources.PipingSoilProfilesImporter_Reading_database, 1, 1); @@ -125,7 +126,7 @@ { HandleException(path, e); } - return new PipingReadResult(true); + return new ReadResult(true); } private void HandleException(string path, Exception e) @@ -135,7 +136,7 @@ log.Error(message); } - private PipingReadResult GetProfileReadResult(string path, PipingSoilProfileReader soilProfileReader) + private ReadResult GetProfileReadResult(string path, PipingSoilProfileReader soilProfileReader) { var totalNumberOfSteps = soilProfileReader.Count; var currentStep = 1; @@ -145,7 +146,7 @@ { if (shouldCancel) { - return new PipingReadResult(false); + return new ReadResult(false); } try { @@ -163,18 +164,18 @@ var message = string.Format(ApplicationResources.PipingSoilProfilesImporter_CriticalErrorMessage_0_File_Skipped, path, e.Message); log.Error(message); - return new PipingReadResult(true); + return new ReadResult(true); } } - return new PipingReadResult(false) + return new ReadResult(false) { ImportedItems = profiles }; } - private void AddImportedDataToModel(object target, PipingReadResult imported) + private void AddImportedDataToModel(object target, ReadResult imported) { - var targetCollection = (ICollection)target; + var targetCollection = (ICollection) target; int totalProfileCount = imported.ImportedItems.Count; NotifyProgress(ApplicationResources.PipingSoilProfilesImporter_Adding_imported_data_to_model, totalProfileCount, totalProfileCount); @@ -189,7 +190,7 @@ { if (ProgressChanged != null) { - ProgressChanged(currentStepName, currentStep, totalNumberOfSteps); + ProgressChanged(currentStepName, currentStep, totalNumberOfSteps); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs =================================================================== diff -u -r657702880ff3dc471e8e034e6111944c948305b6 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision 657702880ff3dc471e8e034e6111944c948305b6) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/FileImporter/PipingSurfaceLinesCsvImporter.cs (.../PipingSurfaceLinesCsvImporter.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -24,12 +24,11 @@ using System.Drawing; using System.IO; using System.Linq; - using Core.Common.Base.Geometry; using Core.Common.Base.IO; using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; using log4net; - using Ringtoets.Piping.Data; using Ringtoets.Piping.IO; using Ringtoets.Piping.IO.Exceptions; @@ -47,8 +46,8 @@ public class PipingSurfaceLinesCsvImporter : IFileImporter { private readonly ILog log; + private readonly string characteristicPointsFileSubExtension = ".krp"; private bool shouldCancel; - private string characteristicPointsFileSubExtension = ".krp"; public PipingSurfaceLinesCsvImporter() { @@ -96,13 +95,13 @@ } } + public ProgressChangedDelegate ProgressChanged { get; set; } + public void Cancel() { shouldCancel = true; } - public ProgressChangedDelegate ProgressChanged { get; set; } - public bool Import(object targetItem, string filePath) { var importSurfaceLinesResult = ReadPipingSurfaceLines(filePath); @@ -136,15 +135,15 @@ return true; } - private PipingReadResult ReadCharacteristicPoints(string surfaceLineFilePath) + private ReadResult ReadCharacteristicPoints(string surfaceLineFilePath) { var path = surfaceLineFilePath.Insert(surfaceLineFilePath.Length - 4, characteristicPointsFileSubExtension); var hasCharacteristicPointsFile = File.Exists(path); if (!hasCharacteristicPointsFile) { log.Info(string.Format(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_Import_No_characteristic_points_file_for_surface_line_file_expecting_file_0_, path)); - return new PipingReadResult(false); + return new ReadResult(false); } PipingCharacteristicPointsCsvReader reader; @@ -159,7 +158,7 @@ var stepName = string.Format(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_Read_PipingSurfaceLines_0_, Path.GetFileName(path)); - + int itemCount; try { @@ -172,7 +171,6 @@ return HandleCriticalCharacteristicPointsReadError(e); } - var readCharacteristicPointsLocations = new List(itemCount); for (int i = 0; i < itemCount && !shouldCancel; i++) { @@ -197,7 +195,7 @@ reader.Dispose(); - return new PipingReadResult(false) + return new ReadResult(false) { ImportedItems = readCharacteristicPointsLocations }; @@ -211,7 +209,7 @@ } } - private PipingReadResult ReadPipingSurfaceLines(string path) + private ReadResult ReadPipingSurfaceLines(string path) { PipingSurfaceLinesCsvReader reader; try @@ -263,7 +261,7 @@ reader.Dispose(); - return new PipingReadResult(false) + return new ReadResult(false) { ImportedItems = readSurfaceLines }; @@ -295,27 +293,27 @@ } } - private PipingReadResult HandleCriticalSurfaceLineReadError(Exception e) + private ReadResult HandleCriticalSurfaceLineReadError(Exception e) { var message = string.Format(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_CriticalErrorMessage_0_File_Skipped, e.Message); log.Error(message); - return new PipingReadResult(true); + return new ReadResult(true); } - private PipingReadResult HandleCriticalCharacteristicPointsReadError(Exception e) + private ReadResult HandleCriticalCharacteristicPointsReadError(Exception e) { var message = string.Format(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_CriticalErrorMessage_0_File_Skipped, e.Message); log.Error(message); - return new PipingReadResult(true); + return new ReadResult(true); } private void AddImportedDataToModel(object target, ICollection readSurfaceLines, ICollection readCharacteristicPointsLocations) { NotifyProgress(RingtoetsPluginResources.PipingSurfaceLinesCsvImporter_Adding_imported_data_to_model, readSurfaceLines.Count, readSurfaceLines.Count); - var targetCollection = (ICollection)target; + var targetCollection = (ICollection) target; foreach (var readSurfaceLine in readSurfaceLines) { var characteristicPointsLocation = readCharacteristicPointsLocations.FirstOrDefault(cpl => cpl.Name == readSurfaceLine.Name); Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs =================================================================== diff -u -rf98cc7191a717793f69485dad2923cd34f6d48de -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision f98cc7191a717793f69485dad2923cd34f6d48de) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/PipingGuiPlugin.cs (.../PipingGuiPlugin.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -619,7 +619,6 @@ PipingFormsResources.PipingCalculationGroup_CalculateAll_ToolTip, RingtoetsFormsResources.CalculateAllIcon, (o, args) => { CalculateAll(group); }); - if (!group.GetPipingCalculations().Any()) { menuItem.Enabled = false; @@ -634,10 +633,7 @@ var menuItem = new StrictContextMenuItem( RingtoetsFormsResources.Validate_all, PipingFormsResources.PipingCalculationGroup_Validate_All_ToolTip, - RingtoetsFormsResources.ValidateAllIcon, (o, args) => - { - ValidateAll(group); - }); + RingtoetsFormsResources.ValidateAllIcon, (o, args) => { ValidateAll(group); }); if (!group.GetPipingCalculations().Any()) { @@ -840,7 +836,7 @@ /// The calculation group context that is the target /// of the drag & drop operation. public DroppingPipingCalculationWithinSameContainer(PipingCalculationGroupContext originalOwnerContext, PipingCalculationGroupContext target) : - base(originalOwnerContext, target) { } + base(originalOwnerContext, target) {} } /// @@ -857,7 +853,7 @@ /// The calculation group context that is the target /// of the drag & drop operation. public DroppingPipingCalculationToNewContainer(PipingCalculationGroupContext originalOwnerContext, PipingCalculationGroupContext target) : - base(originalOwnerContext, target) { } + base(originalOwnerContext, target) {} public override void Execute(object draggedData, IPipingCalculationItem pipingCalculationItem, int newPosition, TreeViewControl treeViewControl) { @@ -866,8 +862,11 @@ NotifyObservers(); // Try to start a name edit action when an item with the same name was already present - if (target.WrappedData.Children.Except(new[] { pipingCalculationItem }).Any(c => c.Name.Equals(pipingCalculationItem.Name))) + if (target.WrappedData.Children.Except(new[] { + pipingCalculationItem + }).Any(c => c.Name.Equals(pipingCalculationItem.Name))) + { treeViewControl.TryRenameNodeForData(draggedData); } } Index: Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Ringtoets/Piping/src/Ringtoets.Piping.Plugin/Ringtoets.Piping.Plugin.csproj (.../Ringtoets.Piping.Plugin.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -62,7 +62,6 @@ - Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/CriticalProfilePropertiesTest.cs (.../CriticalProfilePropertiesTest.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -1,9 +1,9 @@ using System; using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using NUnit.Framework; using Rhino.Mocks; -using Ringtoets.Piping.IO.Exceptions; using Ringtoets.Piping.IO.Properties; using Ringtoets.Piping.IO.SoilProfile; Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile1DReaderTest.cs (.../SoilProfile1DReaderTest.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -1,6 +1,7 @@ using System; using System.Linq; using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using NUnit.Framework; using Rhino.Mocks; Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs =================================================================== diff -u -r6298a5e4fbc259636c874b25c847021c05baf033 -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 6298a5e4fbc259636c874b25c847021c05baf033) +++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/SoilProfile/SoilProfile2DReaderTest.cs (.../SoilProfile2DReaderTest.cs) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -1,6 +1,7 @@ using System; using System.Linq; using Core.Common.IO.Exceptions; +using Core.Common.IO.Readers; using Core.Common.Utils.Builders; using NUnit.Framework; using Rhino.Mocks; @@ -17,13 +18,13 @@ private IRowBasedDatabaseReader reader; private readonly byte[] someGeometry = StringGeometryHelper.GetByteArray("" + - "" + - "001.1101.1" + - "" + - "" + - "001.1101.1" + - "" + - "" + + "" + + "001.1101.1" + + "" + + "" + + "001.1101.1" + + "" + + "" + ""); [SetUp] Fisheye: Tag 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 refers to a dead (removed) revision in file `Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/FileImporter/PipingReadResultTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj =================================================================== diff -u -r654d3a712eedbdeea718dc0448c5544f09e053cd -r98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187 --- Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 654d3a712eedbdeea718dc0448c5544f09e053cd) +++ Ringtoets/Piping/test/Ringtoets.Piping.Plugin.Test/Ringtoets.Piping.Plugin.Test.csproj (.../Ringtoets.Piping.Plugin.Test.csproj) (revision 98fc85d8cecf9edae9fe7c1f2f47b60ecda5e187) @@ -63,7 +63,6 @@ - @@ -88,6 +87,10 @@ {30e4c2ae-719e-4d70-9fa9-668a9767fbfa} Core.Common.Gui + + {e344867e-9ac9-44c8-88a5-8185681679a9} + Core.Common.IO + {f49bd8b2-332a-4c91-a196-8cce0a2c7d98} Core.Common.Utils