Index: Ringtoets/Common/src/Ringtoets.Common.Data/Exceptions/ForeshoreProfileUpdateException.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.Data/Exceptions/ForeshoreProfileUpdateException.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Exceptions/ForeshoreProfileUpdateException.cs (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -0,0 +1,68 @@
+// Copyright (C) Stichting Deltares 2017. 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.Runtime.Serialization;
+
+namespace Ringtoets.Common.Data.Exceptions
+{
+ ///
+ /// Exception that is thrown when updating data of a foreshore profile has failed.
+ ///
+ [Serializable]
+ public class ForeshoreProfileUpdateException : Exception
+ {
+ ///
+ /// Initializes a new instance of the class.
+ ///
+ public ForeshoreProfileUpdateException() { }
+
+ ///
+ /// Initializes a new instance of the class
+ /// with a specified error message.
+ ///
+ /// The error message that explains the reason for the exception.
+ public ForeshoreProfileUpdateException(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 null if no inner exception is specified.
+ public ForeshoreProfileUpdateException(string message, Exception inner) : base(message, inner) { }
+
+ ///
+ /// Initializes a new instance of with
+ /// serialized data.
+ /// The that holds the serialized
+ /// object data about the exception being thrown.
+ /// The that contains contextual
+ /// information about the source or destination.
+ /// The parameter is
+ /// null.
+ /// The class name is null or
+ /// is zero (0).
+ protected ForeshoreProfileUpdateException(SerializationInfo info, StreamingContext context) : base(info, context) { }
+ }
+}
Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj
===================================================================
diff -u -r16a70f4e510b2667a5fcea88d6a34c410d18e168 -r670a5510c7638037a4f7e0c3efea0a261085bfbb
--- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 16a70f4e510b2667a5fcea88d6a34c410d18e168)
+++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -59,6 +59,7 @@
+
Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/IDikeProfileUpdateDataStrategy.cs
===================================================================
diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r670a5510c7638037a4f7e0c3efea0a261085bfbb
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/IDikeProfileUpdateDataStrategy.cs (.../IDikeProfileUpdateDataStrategy.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/IDikeProfileUpdateDataStrategy.cs (.../IDikeProfileUpdateDataStrategy.cs) (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -28,7 +28,7 @@
namespace Ringtoets.Common.IO.FileImporters
{
///
- /// Interface describing the method of updating the date model after new
+ /// Interface describing the method of updating the data model after new
/// dike profiles have been imported.
///
public interface IDikeProfileUpdateDataStrategy
Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/IForeshoreProfileUpdateDataStrategy.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/IForeshoreProfileUpdateDataStrategy.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/IForeshoreProfileUpdateDataStrategy.cs (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -0,0 +1,51 @@
+// Copyright (C) Stichting Deltares 2017. 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 Core.Common.Base;
+using Ringtoets.Common.Data.DikeProfiles;
+
+namespace Ringtoets.Common.IO.FileImporters
+{
+ ///
+ /// Interface describing the method of updating the data model after new
+ /// foreshore profiles have been imported.
+ ///
+ public interface IForeshoreProfileUpdateDataStrategy
+ {
+ ///
+ /// Adds the imported data to the .
+ ///
+ /// The target collection which needs
+ /// to be updated.
+ /// The imported foreshore profiles.
+ /// The source path from where the foreshore
+ /// profiles were imported from.
+ /// An of updated instances.
+ /// Thrown when any input argument
+ /// is null.
+ IEnumerable UpdateForeshoreProfilesWithImportedData(
+ ForeshoreProfileCollection targetDataCollection,
+ IEnumerable importedDataCollection,
+ string sourceFilePath);
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r8b389428ece343431969fce2e902a7b241f2b372 -r670a5510c7638037a4f7e0c3efea0a261085bfbb
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 8b389428ece343431969fce2e902a7b241f2b372)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -79,6 +79,7 @@
+
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Exceptions/ForeshoreProfileUpdateExceptionTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Exceptions/ForeshoreProfileUpdateExceptionTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Exceptions/ForeshoreProfileUpdateExceptionTest.cs (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -0,0 +1,32 @@
+// Copyright (C) Stichting Deltares 2017. 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.TestUtil;
+using NUnit.Framework;
+using Ringtoets.Common.Data.Exceptions;
+
+namespace Ringtoets.Common.Data.Test.Exceptions
+{
+ [TestFixture]
+ public class ForeshoreProfileUpdateExceptionTest :
+ CustomExceptionDesignGuidelinesTestFixture {}
+}
\ No newline at end of file
Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj
===================================================================
diff -u -r16a70f4e510b2667a5fcea88d6a34c410d18e168 -r670a5510c7638037a4f7e0c3efea0a261085bfbb
--- Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 16a70f4e510b2667a5fcea88d6a34c410d18e168)
+++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/Ringtoets.Common.Data.Test.csproj (.../Ringtoets.Common.Data.Test.csproj) (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -71,6 +71,7 @@
+
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ForeshoreProfileReplaceDataStrategy.cs
===================================================================
diff -u
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ForeshoreProfileReplaceDataStrategy.cs (revision 0)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/FileImporters/ForeshoreProfileReplaceDataStrategy.cs (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -0,0 +1,245 @@
+// Copyright (C) Stichting Deltares 2017. 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.Linq;
+using Core.Common.Base;
+using Ringtoets.ClosingStructures.Data;
+using Ringtoets.Common.Data.DikeProfiles;
+using Ringtoets.Common.Data.Exceptions;
+using Ringtoets.Common.Data.FailureMechanism;
+using Ringtoets.Common.Data.Structures;
+using Ringtoets.Common.Data.UpdateDataStrategies;
+using Ringtoets.Common.IO.FileImporters;
+using Ringtoets.GrassCoverErosionOutwards.Data;
+using Ringtoets.HeightStructures.Data;
+using Ringtoets.Integration.Plugin.Properties;
+using Ringtoets.StabilityPointStructures.Data;
+using Ringtoets.StabilityStoneCover.Data;
+using Ringtoets.WaveImpactAsphaltCover.Data;
+
+namespace Ringtoets.Integration.Plugin.FileImporters
+{
+ ///
+ /// A
+ /// to replace foreshore profiles with imported dike profiles.
+ ///
+ public class ForeshoreProfileReplaceDataStrategy : ReplaceDataStrategyBase,
+ IForeshoreProfileUpdateDataStrategy
+ {
+ ///
+ /// Initializes a .
+ ///
+ /// The failure mechanism in which the foreshore
+ /// profiles are updated.
+ /// Thrown when
+ /// is null.
+ /// Thrown when
+ /// is not supported.
+ public ForeshoreProfileReplaceDataStrategy(IFailureMechanism failureMechanism) : base(failureMechanism)
+ {
+ if (!(failureMechanism is WaveImpactAsphaltCoverFailureMechanism)
+ && !(failureMechanism is StabilityStoneCoverFailureMechanism)
+ && !(failureMechanism is GrassCoverErosionOutwardsFailureMechanism)
+ && !(failureMechanism is HeightStructuresFailureMechanism)
+ && !(failureMechanism is StabilityPointStructuresFailureMechanism)
+ && !(failureMechanism is ClosingStructuresFailureMechanism))
+ {
+ throw new NotSupportedException($"Can't apply this strategy for {failureMechanism.GetType()}.");
+ }
+ }
+
+ public IEnumerable UpdateForeshoreProfilesWithImportedData(ForeshoreProfileCollection targetDataCollection,
+ IEnumerable importedDataCollection,
+ string sourceFilePath)
+ {
+ try
+ {
+ return ReplaceTargetCollectionWithImportedData(targetDataCollection, importedDataCollection, sourceFilePath);
+ }
+ catch (UpdateDataException e)
+ {
+ string message = string.Format(
+ Resources.ForeshoreProfileReplaceDataStrategy_UpdateForeshoreProfilesWithImportedData_Importing_ForeshoreProfiles_failed_Reason_0,
+ e.Message);
+
+ throw new ForeshoreProfileUpdateException(message, e);
+ }
+ }
+
+ protected override IEnumerable ClearData(IFailureMechanism failureMechanism)
+ {
+ // TODO: Clearing the output will be implemented as part of WTI-1116
+ var waveImpactAsphaltCoverFailureMechanism = failureMechanism as WaveImpactAsphaltCoverFailureMechanism;
+ if (waveImpactAsphaltCoverFailureMechanism != null)
+ {
+ return ClearForeshoreProfilesDependentData(waveImpactAsphaltCoverFailureMechanism);
+ }
+
+ var stabilityStoneCoverFailureMechanism = failureMechanism as StabilityStoneCoverFailureMechanism;
+ if (stabilityStoneCoverFailureMechanism != null)
+ {
+ return ClearForeshoreProfilesDependentData(stabilityStoneCoverFailureMechanism);
+ }
+
+ var grassCoverErosionOutwardsFailureMechanism = failureMechanism as GrassCoverErosionOutwardsFailureMechanism;
+ if (grassCoverErosionOutwardsFailureMechanism != null)
+ {
+ return ClearForeshoreProfilesDependentData(grassCoverErosionOutwardsFailureMechanism);
+ }
+
+ var heightStructuresFailureMechanism = failureMechanism as HeightStructuresFailureMechanism;
+ if (heightStructuresFailureMechanism != null)
+ {
+ return ClearForeshoreProfilesDependentData(heightStructuresFailureMechanism);
+ }
+
+ var stabilityPointStructuresFailureMechanism = failureMechanism as StabilityPointStructuresFailureMechanism;
+ if (stabilityPointStructuresFailureMechanism != null)
+ {
+ return ClearForeshoreProfilesDependentData(stabilityPointStructuresFailureMechanism);
+ }
+
+ var closingStructuresFailureMechanism = failureMechanism as ClosingStructuresFailureMechanism;
+ if (closingStructuresFailureMechanism != null)
+ {
+ return ClearForeshoreProfileDependentData(closingStructuresFailureMechanism);
+ }
+
+ return Enumerable.Empty();
+ }
+
+ private static IEnumerable ClearForeshoreProfileDependentData(ClosingStructuresFailureMechanism closingStructuresFailureMechanism)
+ {
+ IEnumerable> affectedCalculations =
+ closingStructuresFailureMechanism.Calculations
+ .OfType>()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null);
+
+ var affectedObjects = new List();
+ foreach (var calculation in affectedCalculations)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ affectedObjects.Add(calculation.InputParameters);
+ }
+
+ closingStructuresFailureMechanism.ForeshoreProfiles.Clear();
+ affectedObjects.Add(closingStructuresFailureMechanism.ForeshoreProfiles);
+ return affectedObjects;
+ }
+
+ private static IEnumerable ClearForeshoreProfilesDependentData(StabilityPointStructuresFailureMechanism stabilityPointStructuresFailureMechanism)
+ {
+ IEnumerable> affectedCalculations =
+ stabilityPointStructuresFailureMechanism.Calculations
+ .OfType>()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null);
+
+ var affectedObjects = new List();
+ foreach (var calculation in affectedCalculations)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ affectedObjects.Add(calculation.InputParameters);
+ }
+
+ stabilityPointStructuresFailureMechanism.ForeshoreProfiles.Clear();
+ affectedObjects.Add(stabilityPointStructuresFailureMechanism.ForeshoreProfiles);
+ return affectedObjects;
+ }
+
+ private static IEnumerable ClearForeshoreProfilesDependentData(HeightStructuresFailureMechanism heightStructuresFailureMechanism)
+ {
+ IEnumerable> affectedCalculations =
+ heightStructuresFailureMechanism.Calculations
+ .OfType>()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null);
+
+ var affectedObjects = new List();
+ foreach (var calculation in affectedCalculations)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ affectedObjects.Add(calculation.InputParameters);
+ }
+
+ heightStructuresFailureMechanism.ForeshoreProfiles.Clear();
+ affectedObjects.Add(heightStructuresFailureMechanism.ForeshoreProfiles);
+ return affectedObjects;
+ }
+
+ private static IEnumerable ClearForeshoreProfilesDependentData(GrassCoverErosionOutwardsFailureMechanism grassCoverErosionOutwardsFailureMechanism)
+ {
+ IEnumerable affectedCalculations =
+ grassCoverErosionOutwardsFailureMechanism.Calculations
+ .OfType()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null);
+
+ var affectedObjects = new List();
+ foreach (var calculation in affectedCalculations)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ affectedObjects.Add(calculation.InputParameters);
+ }
+
+ grassCoverErosionOutwardsFailureMechanism.ForeshoreProfiles.Clear();
+ affectedObjects.Add(grassCoverErosionOutwardsFailureMechanism.ForeshoreProfiles);
+ return affectedObjects;
+ }
+
+ private static IEnumerable ClearForeshoreProfilesDependentData(StabilityStoneCoverFailureMechanism stabilityStoneCoverFailureMechanism)
+ {
+ IEnumerable affectedCalculations =
+ stabilityStoneCoverFailureMechanism.Calculations
+ .OfType()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null);
+
+ var affectedObjects = new List();
+ foreach (var calculation in affectedCalculations)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ affectedObjects.Add(calculation.InputParameters);
+ }
+
+ stabilityStoneCoverFailureMechanism.ForeshoreProfiles.Clear();
+ affectedObjects.Add(stabilityStoneCoverFailureMechanism.ForeshoreProfiles);
+ return affectedObjects;
+ }
+
+ private static IEnumerable ClearForeshoreProfilesDependentData(WaveImpactAsphaltCoverFailureMechanism waveImpactAsphaltCoverFailureMechanism)
+ {
+ IEnumerable affectedCalculations =
+ waveImpactAsphaltCoverFailureMechanism.Calculations
+ .OfType()
+ .Where(calc => calc.InputParameters.ForeshoreProfile != null);
+
+ var affectedObjects = new List();
+ foreach (var calculation in affectedCalculations)
+ {
+ calculation.InputParameters.ForeshoreProfile = null;
+ affectedObjects.Add(calculation.InputParameters);
+ }
+
+ waveImpactAsphaltCoverFailureMechanism.ForeshoreProfiles.Clear();
+ affectedObjects.Add(waveImpactAsphaltCoverFailureMechanism.ForeshoreProfiles);
+ return affectedObjects;
+ }
+ }
+}
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs
===================================================================
diff -u -r802ea30d1fe8fbae93e58dff9ab054dbabca11ae -r670a5510c7638037a4f7e0c3efea0a261085bfbb
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 802ea30d1fe8fbae93e58dff9ab054dbabca11ae)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -181,6 +181,16 @@
}
///
+ /// Looks up a localized string similar to Het importeren van voorlandprofielen is mislukt: {0}.
+ ///
+ public static string ForeshoreProfileReplaceDataStrategy_UpdateForeshoreProfilesWithImportedData_Importing_ForeshoreProfiles_failed_Reason_0 {
+ get {
+ return ResourceManager.GetString("ForeshoreProfileReplaceDataStrategy_UpdateForeshoreProfilesWithImportedData_Impor" +
+ "ting_ForeshoreProfiles_failed_Reason_0", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Voorlandprofiellocaties.
///
public static string ForeshoreProfilesImporter_DisplayName {
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx
===================================================================
diff -u -r2fbb7b54b29f25f69c4c53cdb40f3704dccf5620 -r670a5510c7638037a4f7e0c3efea0a261085bfbb
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 2fbb7b54b29f25f69c4c53cdb40f3704dccf5620)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Properties/Resources.resx (.../Resources.resx) (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -169,4 +169,7 @@
Selecteer een achtergrondkaart.
+
+ Het importeren van voorlandprofielen is mislukt: {0}
+
\ No newline at end of file
Index: Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj
===================================================================
diff -u -r16ffb4842cab4a8c457638eef546fd87bea3f0f6 -r670a5510c7638037a4f7e0c3efea0a261085bfbb
--- Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision 16ffb4842cab4a8c457638eef546fd87bea3f0f6)
+++ Ringtoets/Integration/src/Ringtoets.Integration.Plugin/Ringtoets.Integration.Plugin.csproj (.../Ringtoets.Integration.Plugin.csproj) (revision 670a5510c7638037a4f7e0c3efea0a261085bfbb)
@@ -54,6 +54,7 @@
Properties\GlobalAssembly.cs
+
@@ -278,6 +279,7 @@
+