Index: Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/DikeProfilesImporter.cs
===================================================================
diff -u -r1f549a37af503f5da697652b5e5199f8d29ac0fe -r56ac4eb28f5fcc5b20117474e9e4030399d6806a
--- Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision 1f549a37af503f5da697652b5e5199f8d29ac0fe)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/FileImporters/DikeProfilesImporter.cs (.../DikeProfilesImporter.cs) (revision 56ac4eb28f5fcc5b20117474e9e4030399d6806a)
@@ -27,42 +27,62 @@
using Ringtoets.Common.Data.AssessmentSection;
using Ringtoets.Common.Data.DikeProfiles;
using Ringtoets.Common.IO.DikeProfiles;
+using Ringtoets.Common.IO.FileImporters.MessageProviders;
using Ringtoets.Common.IO.Properties;
+using RingtoetsCommonDataResources = Ringtoets.Common.Data.Properties.Resources;
namespace Ringtoets.Common.IO.FileImporters
{
///
/// Imports point shapefiles containing dike profile locations and text files containing dike schematizations.
///
- public class DikeProfilesImporter : ProfilesImporter>
+ public class DikeProfilesImporter : ProfilesImporter
{
+ private readonly IDikeProfileUpdateDataStrategy dikeProfileUpdateDataStrategy;
+ private IEnumerable updatedInstances;
+
///
/// Creates a new instance of .
///
/// The dike profiles to import on.
/// The reference line used to check if the
/// objects found in the file are intersecting it.
/// The path to the file to import from.
- /// Thrown when ,
- /// or is null.
- public DikeProfilesImporter(ObservableList importTarget, ReferenceLine referenceLine, string filePath)
- : base(referenceLine, filePath, importTarget) {}
+ /// The strategy to update the dike profiles
+ /// with the imported data.
+ /// The message provide to provide the messages during importer action.
+ /// Thrown when any input parameter is null.
+ public DikeProfilesImporter(DikeProfileCollection importTarget, ReferenceLine referenceLine,
+ string filePath,
+ IDikeProfileUpdateDataStrategy dikeProfileUpdateStrategy,
+ IImporterMessageProvider messageProvider)
+ : base(referenceLine, filePath, importTarget, messageProvider)
+ {
+ if (dikeProfileUpdateStrategy == null)
+ {
+ throw new ArgumentNullException(nameof(dikeProfileUpdateStrategy));
+ }
+ dikeProfileUpdateDataStrategy = dikeProfileUpdateStrategy;
+ updatedInstances = Enumerable.Empty();
+ }
+
protected override void CreateProfiles(ReadResult importProfileLocationResult,
ReadResult importDikeProfileDataResult)
{
IEnumerable importedDikeProfiles = CreateDikeProfiles(importProfileLocationResult.Items,
importDikeProfileDataResult.Items);
- foreach (DikeProfile dikeProfile in importedDikeProfiles)
- {
- ImportTarget.Add(dikeProfile);
- }
+ updatedInstances = dikeProfileUpdateDataStrategy.UpdateDikeProfilesWithImportedData(ImportTarget,
+ importedDikeProfiles,
+ FilePath);
}
protected override void LogImportCanceledMessage()
{
- Log.Info(Resources.DikeProfilesImporter_HandleUserCancelingImport_dikeprofile_import_aborted);
+ string logMessage = MessageProvider.GetCancelledLogMessageText(
+ RingtoetsCommonDataResources.DikeProfileCollection_TypeDescriptor);
+ Log.Info(logMessage);
}
protected override bool DikeProfileDataIsValid(DikeProfileData data, string prflFilePath)
@@ -75,6 +95,14 @@
return false;
}
+ protected override void DoPostImportUpdates()
+ {
+ foreach (IObservable updatedInstance in updatedInstances)
+ {
+ updatedInstance.NotifyObservers();
+ }
+ }
+
private IEnumerable CreateDikeProfiles(IEnumerable dikeProfileLocationCollection,
ICollection dikeProfileDataCollection)
{
@@ -83,7 +111,7 @@
{
string id = dikeProfileLocation.Id;
- var dikeProfileData = GetMatchingDikeProfileData(dikeProfileDataCollection, id);
+ DikeProfileData dikeProfileData = GetMatchingDikeProfileData(dikeProfileDataCollection, id);
if (dikeProfileData == null)
{
Log.ErrorFormat(Resources.DikeProfilesImporter_GetMatchingDikeProfileData_no_dikeprofiledata_for_location_0_, id);
@@ -99,7 +127,7 @@
private static DikeProfile CreateDikeProfile(ProfileLocation dikeProfileLocation, DikeProfileData dikeProfileData)
{
- var dikeProfile = new DikeProfile(dikeProfileLocation.Point, dikeProfileData.DikeGeometry,
+ return new DikeProfile(dikeProfileLocation.Point, dikeProfileData.DikeGeometry,
dikeProfileData.ForeshoreGeometry.Select(fg => fg.Point).ToArray(),
CreateBreakWater(dikeProfileData),
new DikeProfile.ConstructionProperties
@@ -110,8 +138,6 @@
Orientation = dikeProfileData.Orientation,
DikeHeight = dikeProfileData.DikeHeight
});
-
- return dikeProfile;
}
}
}
\ No newline at end of file