Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/CalculationConfigurationImporter.cs (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -0,0 +1,53 @@
+// 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 Core.Common.Base.IO;
+using log4net;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.IO.Properties;
+
+namespace Ringtoets.Common.IO.FileImporters
+{
+ ///
+ /// Base class for importing a calculation configuration from an XML file and
+ /// storing it on a .
+ ///
+ public abstract class CalculationConfigurationImporter : FileImporterBase
+ {
+ private static readonly ILog log = LogManager.GetLogger(typeof(CalculationConfigurationImporter));
+
+ ///
+ /// Creates a new instance of .
+ ///
+ /// The path to the file to import from.
+ /// The calculation group to update.
+ /// Thrown when any parameter is
+ /// null.
+ protected CalculationConfigurationImporter(string filePath, CalculationGroup importTarget)
+ : base(filePath, importTarget) {}
+
+ protected override void LogImportCanceledMessage()
+ {
+ log.Info(Resources.CalculationConfigurationImporter_LogImportCanceledMessage_Import_canceled_no_data_read);
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rae137e9d1b26f1b37e47f2b4a6bf9ae03c6c9b2e -rfc204f9f1958c10c27c00e43fc2dba43565f7b35
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision ae137e9d1b26f1b37e47f2b4a6bf9ae03c6c9b2e)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -82,6 +82,16 @@
}
///
+ /// Looks up a localized string similar to Berekeningenconfiguratie importeren afgebroken. Geen data ingelezen..
+ ///
+ public static string CalculationConfigurationImporter_LogImportCanceledMessage_Import_canceled_no_data_read {
+ get {
+ return ResourceManager.GetString("CalculationConfigurationImporter_LogImportCanceledMessage_Import_canceled_no_data" +
+ "_read", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to <?xml version="1.0" encoding="utf-8"?>
///
///<!--
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx
===================================================================
diff -u -rae137e9d1b26f1b37e47f2b4a6bf9ae03c6c9b2e -rfc204f9f1958c10c27c00e43fc2dba43565f7b35
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision ae137e9d1b26f1b37e47f2b4a6bf9ae03c6c9b2e)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -525,4 +525,7 @@
..\Resources\StochastSchema.xsd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
+ Berekeningenconfiguratie importeren afgebroken. Geen data ingelezen.
+
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -rfde0ecf7d1d897337907d512aab471ead4a4c5e4 -rfc204f9f1958c10c27c00e43fc2dba43565f7b35
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision fde0ecf7d1d897337907d512aab471ead4a4c5e4)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -63,6 +63,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/FileImporters/CalculationConfigurationImporterTest.cs (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -0,0 +1,79 @@
+// 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 Core.Common.Base.IO;
+using Core.Common.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Calculation;
+using Ringtoets.Common.IO.FileImporters;
+
+namespace Ringtoets.Common.IO.Test.FileImporters
+{
+ [TestFixture]
+ public class CalculationConfigurationImporterTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var importer = new TestCalculationConfigurationImporter("",
+ new CalculationGroup());
+
+ // Assert
+ Assert.IsInstanceOf>(importer);
+ }
+
+ [Test]
+ public void Import_CancelingImport_CancelImportAndLog()
+ {
+ // Setup
+ var importer = new TestCalculationConfigurationImporter("",
+ new CalculationGroup());
+
+ importer.SetProgressChanged((description, step, steps) => { importer.Cancel(); });
+
+ // Call
+ Action call = () => importer.Import();
+
+ // Assert
+ TestHelper.AssertLogMessageIsGenerated(call, "Berekeningenconfiguratie importeren afgebroken. Geen data ingelezen.", 1);
+ }
+
+ private class TestCalculationConfigurationImporter : CalculationConfigurationImporter
+ {
+ public TestCalculationConfigurationImporter(string filePath, CalculationGroup importTarget)
+ : base(filePath, importTarget) {}
+
+ protected override bool OnImport()
+ {
+ NotifyProgress("Progress", 1, 1);
+
+ if (Canceled)
+ {
+ return false;
+ }
+
+ return true;
+ }
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj
===================================================================
diff -u -rfde0ecf7d1d897337907d512aab471ead4a4c5e4 -rfc204f9f1958c10c27c00e43fc2dba43565f7b35
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision fde0ecf7d1d897337907d512aab471ead4a4c5e4)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -66,6 +66,7 @@
+
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs
===================================================================
diff -u -rb0021f2db39d2455a22c14bd3708ff2fc2a9e817 -rfc204f9f1958c10c27c00e43fc2dba43565f7b35
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs (.../PipingConfigurationImporter.cs) (revision b0021f2db39d2455a22c14bd3708ff2fc2a9e817)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs (.../PipingConfigurationImporter.cs) (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -23,14 +23,14 @@
using System.Collections.Generic;
using System.Linq;
using Core.Common.Base.Data;
-using Core.Common.Base.IO;
using Core.Common.IO.Exceptions;
using Core.Common.IO.Readers;
using log4net;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.Hydraulics;
using Ringtoets.Common.Data.Probabilistics;
using Ringtoets.Common.IO.Exceptions;
+using Ringtoets.Common.IO.FileImporters;
using Ringtoets.Common.IO.Readers;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.IO.Properties;
@@ -42,9 +42,10 @@
namespace Ringtoets.Piping.IO.Importers
{
///
- /// Imports a piping configuration and stores it on a .
+ /// Imports a piping configuration from an XML file and stores it on a
+ /// .
///
- public class PipingConfigurationImporter : FileImporterBase
+ public class PipingConfigurationImporter : CalculationConfigurationImporter
{
private static readonly ILog log = LogManager.GetLogger(typeof(PipingConfigurationImporter));
@@ -80,11 +81,6 @@
this.failureMechanism = failureMechanism;
}
- protected override void LogImportCanceledMessage()
- {
- log.Info(Resources.PipingConfigurationImporter_LogImportCanceledMessage_Import_canceled_no_data_read);
- }
-
protected override bool OnImport()
{
NotifyProgress(Resources.PipingConfigurationImporter_ProgressText_Reading_configuration, 1, 3);
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526 -rfc204f9f1958c10c27c00e43fc2dba43565f7b35
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -226,16 +226,6 @@
}
///
- /// Looks up a localized string similar to Berekeningenconfiguratie importeren afgebroken. Geen data ingelezen..
- ///
- public static string PipingConfigurationImporter_LogImportCanceledMessage_Import_canceled_no_data_read {
- get {
- return ResourceManager.GetString("PipingConfigurationImporter_LogImportCanceledMessage_Import_canceled_no_data_read" +
- "", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Inlezen berekeningenconfiguratie..
///
public static string PipingConfigurationImporter_ProgressText_Reading_configuration {
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx
===================================================================
diff -u -r5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526 -rfc204f9f1958c10c27c00e43fc2dba43565f7b35
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 5735c9b5c663a0bc7762d1b1eb1483e5c4cfe526)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -278,9 +278,6 @@
Er zijn stochastische ondergrondschematisaties zonder geldige kans van voorkomen.
-
- Berekeningenconfiguratie importeren afgebroken. Geen data ingelezen.
-
{0}
Er is geen berekeningenconfiguratie geïmporteerd.
Index: Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingConfigurationImporterTest.cs
===================================================================
diff -u -ra30456917268fbd9a24f24c3695b15389d4ca092 -rfc204f9f1958c10c27c00e43fc2dba43565f7b35
--- Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingConfigurationImporterTest.cs (.../PipingConfigurationImporterTest.cs) (revision a30456917268fbd9a24f24c3695b15389d4ca092)
+++ Ringtoets/Piping/test/Ringtoets.Piping.IO.Test/Importers/PipingConfigurationImporterTest.cs (.../PipingConfigurationImporterTest.cs) (revision fc204f9f1958c10c27c00e43fc2dba43565f7b35)
@@ -30,6 +30,7 @@
using NUnit.Framework;
using Ringtoets.Common.Data.Calculation;
using Ringtoets.Common.Data.Hydraulics;
+using Ringtoets.Common.IO.FileImporters;
using Ringtoets.Piping.Data;
using Ringtoets.Piping.IO.Importers;
using Ringtoets.Piping.Primitives;
@@ -52,7 +53,7 @@
new PipingFailureMechanism());
// Assert
- Assert.IsInstanceOf>(importer);
+ Assert.IsInstanceOf(importer);
}
[Test]