Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs =================================================================== diff -u -r693cdb62ee142136d80bc08f36fa506fe9c64438 -r9393d671e0b4e1e8c76e5fcf32f61d5c3a5998b2 --- Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs (.../PipingConfigurationImporter.cs) (revision 693cdb62ee142136d80bc08f36fa506fe9c64438) +++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Importers/PipingConfigurationImporter.cs (.../PipingConfigurationImporter.cs) (revision 9393d671e0b4e1e8c76e5fcf32f61d5c3a5998b2) @@ -20,14 +20,18 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; 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.Piping.Data; using Ringtoets.Piping.IO.Properties; using Ringtoets.Piping.IO.Readers; +using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources; namespace Ringtoets.Piping.IO.Importers { @@ -38,15 +42,32 @@ { private static readonly ILog log = LogManager.GetLogger(typeof(PipingConfigurationImporter)); + private readonly IEnumerable hydraulicBoundaryLocations; + + private List validCalculationItems; + /// /// Creates a new instance of . /// /// The path to the file to import from. /// The calculation group to update. + /// The hydraulic boundary locations used to check if + /// the imported objects contain the right location. /// Thrown when any parameter is null. - public PipingConfigurationImporter(string filePath, CalculationGroup importTarget) - : base(filePath, importTarget) {} + public PipingConfigurationImporter(string filePath, + CalculationGroup importTarget, + IEnumerable hydraulicBoundaryLocations) + : base(filePath, importTarget) + { + if (hydraulicBoundaryLocations == null) + { + throw new ArgumentNullException(nameof(hydraulicBoundaryLocations)); + } + this.hydraulicBoundaryLocations = hydraulicBoundaryLocations; + validCalculationItems = new List(); + } + protected override void LogImportCanceledMessage() { log.Info(Resources.PipingConfigurationImporter_LogImportCanceledMessage_import_canceled_no_data_read); @@ -62,9 +83,65 @@ return false; } + NotifyProgress("Valideren berekening configuratie.", 2, 3); + + foreach (IReadPipingCalculationItem readItem in readResult.ImportedItems) + { + if (Canceled) + { + return false; + } + + ValidateReadItems(readItem); + } + + NotifyProgress(RingtoetsCommonIOResources.Importer_ProgressText_Adding_imported_data_to_DataModel, 3, 3); +// AddItemsToModel(); + return true; + } + + private void ValidateReadItems(IReadPipingCalculationItem readItem) + { + var readCalculation = readItem as ReadPipingCalculation; + var readCalculationGroup = readItem as ReadPipingCalculationGroup; + + if (readCalculation != null) + { + ValidateCalculation(readCalculation); + } + + if (readCalculationGroup != null) + { + ValidateCalculationGroup(readCalculationGroup); + } } + private void ValidateCalculation(ReadPipingCalculation readCalculation) + { + if (readCalculation.HydraulicBoundaryLocation != null) + { + if (hydraulicBoundaryLocations.All(hbl => hbl.Name != readCalculation.HydraulicBoundaryLocation)) + { + log.Warn("Hydraulische randvoorwaarde locatie bestaat niet. Berekening overgeslagen."); + } + } + + validCalculationItems.Add(readCalculation); + + // Validate when set: + // - HR location + // - Surface line + // - Stochastic soil model + // - Stochastic soil profile + // Validate the stochastic soil model crosses the surface line when set + // Validate the stochastic soil profile is part of the soil model + } + + private static void ValidateCalculationGroup(ReadPipingCalculationGroup readCalculationGroup) + { + } + private ReadResult ReadConfiguration() { try