Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs
===================================================================
diff -u -r2715f4b30426f7295453b30cd7c1af97f060bcaa -rdd5ae117c10d97b388757d9d2a865c0860a64448
--- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs (.../ReferenceLineMetaImporter.cs) (revision 2715f4b30426f7295453b30cd7c1af97f060bcaa)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs (.../ReferenceLineMetaImporter.cs) (revision dd5ae117c10d97b388757d9d2a865c0860a64448)
@@ -24,20 +24,20 @@
using System.IO;
using System.Linq;
using System.Security;
-using System.Windows.Forms;
using Core.Common.IO.Exceptions;
using Core.Common.Utils.Builders;
using Core.Common.Utils.Properties;
using log4net;
using Ringtoets.Common.Data.AssessmentSection;
+using Ringtoets.Common.IO.Exceptions;
using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
using CoreCommonBaseResources = Core.Common.Base.Properties.Resources;
namespace Ringtoets.Common.IO
{
///
/// Imports a and stores in on a ,
- /// taking data from a shapefile containing a polylines.
+ /// taking data from a shape file containing a poly lines.
///
public class ReferenceLineMetaImporter
{
@@ -68,14 +68,17 @@
/// The read objects.
/// Thrown when:
///
- /// - The shape file does not contain the required attributes.
- /// - The assessment section ids in the shape file are not unique or are missing.
/// - The shape file does not contain poly lines.
/// - The shape file contains multiple poly lines.
///
+ /// Thrown when:
+ ///
+ /// - The shape file does not contain the required attributes.
+ /// - The assessment section ids in the shape file are not unique or are missing.
+ ///
public IEnumerable GetReferenceLineMetas()
{
- ICollection referenceLineMetas = ReadReferenceLineMetas();
+ ICollection referenceLineMetas = ReferenceLinesMetaReader.ReadReferenceLinesMetas(shapeFilePath);
ValidateReferenceLineMetas(referenceLineMetas);
@@ -95,7 +98,7 @@
shapeFilePath = files.First();
if (files.Length > 1)
{
- log.Warn(string.Format(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateAndConnectTo_Multiple_shape_files_found_0_Selected_1,
+ log.Warn(string.Format(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateAndConnectTo_Multiple_shape_files_found_FilePath_0_SelectedFilePath_1,
Path.GetDirectoryName(shapeFilePath), Path.GetFileName(shapeFilePath)));
}
}
@@ -131,24 +134,6 @@
}
}
- private ICollection ReadReferenceLineMetas()
- {
- var referenceLinesMetas = new List();
- using (var reader = new ReferenceLinesMetaReader(shapeFilePath))
- {
- ReferenceLineMeta referenceLinesMeta;
- do
- {
- referenceLinesMeta = reader.ReadReferenceLinesMeta();
- if (referenceLinesMeta != null)
- {
- referenceLinesMetas.Add(referenceLinesMeta);
- }
- } while (referenceLinesMeta != null);
- }
- return referenceLinesMetas;
- }
-
private void ValidateReferenceLineMetas(ICollection referenceLineMetas)
{
var referenceLineMetasCount = referenceLineMetas.Count;
@@ -158,20 +143,14 @@
{
var message = new FileReaderErrorMessageBuilder(shapeFilePath)
.Build(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateReferenceLineMetas_AssessmentSection_Ids_Not_Unique);
- log.Warn(message);
-
- MessageBox.Show(message, CoreCommonBaseResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
- throw new CriticalFileReadException(message);
+ throw new CriticalFileValidationException(message);
}
if (referenceLineMetas.Any(rlm => string.IsNullOrEmpty(rlm.AssessmentSectionId)))
{
var message = new FileReaderErrorMessageBuilder(shapeFilePath)
.Build(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateReferenceLineMetas_Missing_AssessmentSection_Ids);
- log.Warn(message);
-
- MessageBox.Show(message, CoreCommonBaseResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error);
- throw new CriticalFileReadException(message);
+ throw new CriticalFileValidationException(message);
}
}
}