Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs =================================================================== diff -u -rdd5ae117c10d97b388757d9d2a865c0860a64448 -r9ccccb49274ddad9696632ec89efda0ce2e34afc --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision dd5ae117c10d97b388757d9d2a865c0860a64448) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 9ccccb49274ddad9696632ec89efda0ce2e34afc) @@ -239,7 +239,7 @@ } /// - /// Looks up a localized string similar to Er zijn meerdere shape files gevonden in '{0}'. '{1}' is gekozen.. + /// Looks up a localized string similar to Meerdere shapebestanden gevonden in '{0}'. Het bestand '{1}' is gebruikt.. /// public static string ReferenceLineMetaImporter_ValidateAndConnectTo_Multiple_shape_files_found_FilePath_0_SelectedFilePath_1 { get { @@ -249,16 +249,16 @@ } /// - /// Looks up a localized string similar to Er is geen shape file gevonden.. + /// Looks up a localized string similar to Geen shapebestand om trajecten te specificeren gevonden in de map '{0}'.. /// - public static string ReferenceLineMetaImporter_ValidateAndConnectTo_No_shape_file_found { + public static string ReferenceLineMetaImporter_ValidateAndConnectTo_No_shape_file_found_in_folder_0 { get { - return ResourceManager.GetString("ReferenceLineMetaImporter_ValidateAndConnectTo_No_shape_file_found", resourceCulture); + return ResourceManager.GetString("ReferenceLineMetaImporter_ValidateAndConnectTo_No_shape_file_found_in_folder_0", resourceCulture); } } /// - /// Looks up a localized string similar to De map locatie is ongeldig.. + /// Looks up a localized string similar to De map met specificaties voor trajecten '{0}' is niet gevonden.. /// public static string ReferenceLineMetaImporter_ValidateDirectory_Directory_Invalid { get { @@ -267,7 +267,7 @@ } /// - /// Looks up a localized string similar to De identificatiecodes van de trajecten (het attribuut 'TRAJECT_ID' in het shape bestand) zijn niet uniek.. + /// Looks up a localized string similar to Meerdere trajecten met dezelfde identificatiecode (attribuut 'TRAJECT_ID') gevonden.. /// public static string ReferenceLineMetaImporter_ValidateReferenceLineMetas_AssessmentSection_Ids_Not_Unique { get { @@ -277,7 +277,7 @@ } /// - /// Looks up a localized string similar to De identificatiecodes van de trajecten (het attribuut 'TRAJECT_ID' in het shape bestand) zijn niet allemaal ingevuld.. + /// Looks up a localized string similar to Trajecten gevonden zonder een geldige identificatiecode (attribuut 'TRAJECT_ID').. /// public static string ReferenceLineMetaImporter_ValidateReferenceLineMetas_Missing_AssessmentSection_Ids { get { @@ -305,30 +305,12 @@ } /// - /// Looks up a localized string similar to Het bestand heeft geen attribuut '{0}'. Dit attribuut is vereist.. + /// Looks up a localized string similar to Het shapebestand '{0}' om dijktrajecten te specificeren moet de attributen 'TRAJECT_ID', 'NORM_SW', en 'NORM_OG' bevatten: '{1}' niet gevonden.. /// - public static string ReferenceLinesMetaReader_File_lacks_required_Attribute_0_ { + public static string ReferenceLinesMetaReader_File_0_lacks_required_Attribute_1_ { get { - return ResourceManager.GetString("ReferenceLinesMetaReader_File_lacks_required_Attribute_0_", resourceCulture); + return ResourceManager.GetString("ReferenceLinesMetaReader_File_0_lacks_required_Attribute_1_", resourceCulture); } } - - /// - /// Looks up a localized string similar to Het bestand heeft de attributen '{0}' niet. Deze attributen zijn vereist.. - /// - public static string ReferenceLinesMetaReader_File_lacks_required_Attributes_0_ { - get { - return ResourceManager.GetString("ReferenceLinesMetaReader_File_lacks_required_Attributes_0_", resourceCulture); - } - } - - /// - /// Looks up a localized string similar to Het bestand bevat geen waarde voor het attribuut 'TRAJECT_ID' in het shape bestand.. - /// - public static string ReferenceLinesMetaReader_TrajectId_is_empty { - get { - return ResourceManager.GetString("ReferenceLinesMetaReader_TrajectId_is_empty", resourceCulture); - } - } } } Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx =================================================================== diff -u -rdd5ae117c10d97b388757d9d2a865c0860a64448 -r9ccccb49274ddad9696632ec89efda0ce2e34afc --- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision dd5ae117c10d97b388757d9d2a865c0860a64448) +++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 9ccccb49274ddad9696632ec89efda0ce2e34afc) @@ -126,9 +126,6 @@ Het bestand mag uitsluitend polylijnen bevatten. - - Het bestand heeft geen attribuut '{0}'. Dit attribuut is vereist. - Het bestand bevat een of meerdere multi-polylijnen. Multi-polylijnen worden niet ondersteund. @@ -159,32 +156,29 @@ {0} shape bestand (*.shp)|*.shp - - Het bestand heeft de attributen '{0}' niet. Deze attributen zijn vereist. + + Het shapebestand '{0}' om dijktrajecten te specificeren moet de attributen 'TRAJECT_ID', 'NORM_SW', en 'NORM_OG' bevatten: '{1}' niet gevonden. - - Het bestand heeft geen attribuut '{0}'. Dit attribuut is vereist. - - - Het bestand bevat geen waarde voor het attribuut 'TRAJECT_ID' in het shape bestand. - ..\Resources\20160624v3 N-waarden voor GEKB en HTKW.csv;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252 - - Er is geen shape file gevonden. + + Geen shapebestand om trajecten te specificeren gevonden in de map '{0}'. - Er zijn meerdere shape files gevonden in '{0}'. '{1}' is gekozen. + Meerdere shapebestanden gevonden in '{0}'. Het bestand '{1}' is gebruikt. - - De map locatie is ongeldig. - - De identificatiecodes van de trajecten (het attribuut 'TRAJECT_ID' in het shape bestand) zijn niet uniek. + Meerdere trajecten met dezelfde identificatiecode (attribuut 'TRAJECT_ID') gevonden. - De identificatiecodes van de trajecten (het attribuut 'TRAJECT_ID' in het shape bestand) zijn niet allemaal ingevuld. + Trajecten gevonden zonder een geldige identificatiecode (attribuut 'TRAJECT_ID'). + + De map met specificaties voor trajecten '{0}' is niet gevonden. + + + Het bestand heeft geen attribuut '{0}'. Dit attribuut is vereist. + \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs =================================================================== diff -u -r239ea628125c5ec4004a843abce2d269af93c431 -r9ccccb49274ddad9696632ec89efda0ce2e34afc --- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs (.../ReferenceLineMetaImporter.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431) +++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLineMetaImporter.cs (.../ReferenceLineMetaImporter.cs) (revision 9ccccb49274ddad9696632ec89efda0ce2e34afc) @@ -86,8 +86,7 @@ var files = GetShapeFilesInFolder(folderpath); if (files.Length == 0) { - var message = new FileReaderErrorMessageBuilder(folderpath) - .Build(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateAndConnectTo_No_shape_file_found); + var message = string.Format(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateAndConnectTo_No_shape_file_found_in_folder_0, folderpath); throw new CriticalFileReadException(message); } @@ -122,8 +121,8 @@ { if (e is IOException || e is SecurityException) { - var message = new FileReaderErrorMessageBuilder(path) - .Build(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateDirectory_Directory_Invalid); + var message = string.Format(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateDirectory_Directory_Invalid, + path); throw new CriticalFileReadException(message, e); } throw; @@ -132,22 +131,22 @@ private void ValidateReferenceLineMetas(ICollection referenceLineMetas) { - var referenceLineMetasCount = referenceLineMetas.Count; - var referenceLineMetasDistinctCount = referenceLineMetas.Select(rlm => rlm.AssessmentSectionId).Distinct().Count(); - - if (referenceLineMetasCount != referenceLineMetasDistinctCount) + if (referenceLineMetas.Any(rlm => string.IsNullOrEmpty(rlm.AssessmentSectionId))) { var message = new FileReaderErrorMessageBuilder(shapeFilePath) - .Build(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateReferenceLineMetas_AssessmentSection_Ids_Not_Unique); + .Build(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateReferenceLineMetas_Missing_AssessmentSection_Ids); throw new CriticalFileValidationException(message); } - if (referenceLineMetas.Any(rlm => string.IsNullOrEmpty(rlm.AssessmentSectionId))) + var referenceLineMetasCount = referenceLineMetas.Count; + var referenceLineMetasDistinctCount = referenceLineMetas.Select(rlm => rlm.AssessmentSectionId).Distinct().Count(); + if (referenceLineMetasCount != referenceLineMetasDistinctCount) { var message = new FileReaderErrorMessageBuilder(shapeFilePath) - .Build(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateReferenceLineMetas_Missing_AssessmentSection_Ids); + .Build(RingtoetsCommonIOResources.ReferenceLineMetaImporter_ValidateReferenceLineMetas_AssessmentSection_Ids_Not_Unique); throw new CriticalFileValidationException(message); } + } } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs =================================================================== diff -u -r50b203a8d5c805fc548fb6b92c70a847190da6a5 -r9ccccb49274ddad9696632ec89efda0ce2e34afc --- Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs (.../ReferenceLinesMetaReader.cs) (revision 50b203a8d5c805fc548fb6b92c70a847190da6a5) +++ Ringtoets/Common/src/Ringtoets.Common.IO/ReferenceLinesMetaReader.cs (.../ReferenceLinesMetaReader.cs) (revision 9ccccb49274ddad9696632ec89efda0ce2e34afc) @@ -64,7 +64,7 @@ using (var reader = OpenPolyLineShapeFile(shapeFilePath)) { - ValidateExistenceOfRequiredAttributes(reader); + ValidateExistenceOfRequiredAttributes(reader, shapeFilePath); return ReadReferenceLinesMetas(reader); } @@ -113,22 +113,17 @@ /// Validates the file by checking if all mandatory attributes are present in the shape file. /// /// The opened shape file reader. - /// Thrown when the shape file lacks one of the mandatory attributes. - private static void ValidateExistenceOfRequiredAttributes(PolylineShapeFileReader polylineShapeFileReader) + /// The file path to the shape file. + /// Thrown when the shape file lacks one of the mandatory attributes. + private static void ValidateExistenceOfRequiredAttributes(PolylineShapeFileReader polylineShapeFileReader, string shapeFilePath) { - IList missingAttributes = GetMissingAttributes(polylineShapeFileReader); - if (missingAttributes.Count == 1) + var missingAttributes = GetMissingAttributes(polylineShapeFileReader); + if (missingAttributes.Any()) { - var message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_lacks_required_Attribute_0_, - missingAttributes[0]); + var message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_0_lacks_required_Attribute_1_, + shapeFilePath, string.Join("', '", missingAttributes)); throw new CriticalFileReadException(message); } - if (missingAttributes.Count > 1) - { - var message = string.Format(RingtoetsCommonIOResources.ReferenceLinesMetaReader_File_lacks_required_Attributes_0_, - string.Join("', '", missingAttributes)); - throw new CriticalFileReadException(message); - } } private static IList GetMissingAttributes(PolylineShapeFileReader polylineShapeFileReader) Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineMetaImporterTest.cs =================================================================== diff -u -r4baac94f94c8e7c05e0103b1b29c251c3418152b -r9ccccb49274ddad9696632ec89efda0ce2e34afc --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineMetaImporterTest.cs (.../ReferenceLineMetaImporterTest.cs) (revision 4baac94f94c8e7c05e0103b1b29c251c3418152b) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLineMetaImporterTest.cs (.../ReferenceLineMetaImporterTest.cs) (revision 9ccccb49274ddad9696632ec89efda0ce2e34afc) @@ -81,7 +81,7 @@ TestDelegate call = () => new ReferenceLineMetaImporter(pathTooLong); // Assert - var expectedExceptionMessage = string.Format("Fout bij het lezen van bestand '{0}': De map locatie is ongeldig.", + var expectedExceptionMessage = string.Format("De map met specificaties voor trajecten '{0}' is niet gevonden.", pathTooLong); CriticalFileReadException exception = Assert.Throws(call); Assert.AreEqual(expectedExceptionMessage, exception.Message); @@ -100,7 +100,7 @@ TestDelegate call = () => new ReferenceLineMetaImporter(pathToNonExistingFolder); // Assert - var expectedExceptionMessage = string.Format("Fout bij het lezen van bestand '{0}': De map locatie is ongeldig.", + var expectedExceptionMessage = string.Format("De map met specificaties voor trajecten '{0}' is niet gevonden.", pathToNonExistingFolder); CriticalFileReadException exception = Assert.Throws(call); Assert.AreEqual(expectedExceptionMessage, exception.Message); @@ -116,7 +116,7 @@ TestDelegate call = () => new ReferenceLineMetaImporter(pathToEmptyFolder); // Assert - var expectedExceptionMessage = string.Format("Fout bij het lezen van bestand '{0}': Er is geen shape file gevonden.", + var expectedExceptionMessage = string.Format(@"Geen shapebestand om trajecten te specificeren gevonden in de map '{0}'.", pathToEmptyFolder); CriticalFileReadException exception = Assert.Throws(call); Assert.AreEqual(expectedExceptionMessage, exception.Message); @@ -132,22 +132,23 @@ Action call = () => new ReferenceLineMetaImporter(pathToFolder); // Assert - var expectedMessage = string.Format("Er zijn meerdere shape files gevonden in '{0}'. 'NBPW_A.shp' is gekozen.", pathToFolder); + var expectedMessage = string.Format(@"Meerdere shapebestanden gevonden in '{0}'. Het bestand 'NBPW_A.shp' is gebruikt.", pathToFolder); TestHelper.AssertLogMessageIsGenerated(call, expectedMessage); } [Test] public void GetReferenceLineMetas_InvalidShapeFile_ThrowsCriticalFileReadException() { // Setup - string pathToEmptyFolder = Path.Combine(testDataPath, "InvalidShapeFile"); - ReferenceLineMetaImporter importer = new ReferenceLineMetaImporter(pathToEmptyFolder); + string pathToInvalid = Path.Combine(testDataPath, "InvalidShapeFile"); + ReferenceLineMetaImporter importer = new ReferenceLineMetaImporter(pathToInvalid); // Call TestDelegate call = () => importer.GetReferenceLineMetas(); // Assert - var expectedExceptionMessage = "Het bestand heeft de attributen 'TRAJECT_ID', 'NORM_SW', 'NORM_OG' niet. Deze attributen zijn vereist."; + var expectedExceptionMessage = string.Format("Het shapebestand '{0}' om dijktrajecten te specificeren moet de attributen 'TRAJECT_ID', 'NORM_SW', en 'NORM_OG' bevatten: {1} niet gevonden.", + Path.Combine(pathToInvalid, "InvalidShapeFile.shp"), "'TRAJECT_ID', 'NORM_SW', 'NORM_OG'"); CriticalFileReadException exception = Assert.Throws(call); Assert.AreEqual(expectedExceptionMessage, exception.Message); } @@ -164,7 +165,8 @@ // Assert var shapeFile = Path.Combine(pathToFolder, "NonUniqueTrajectIds.shp"); - var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': De identificatiecodes van de trajecten (het attribuut 'TRAJECT_ID' in het shape bestand) zijn niet uniek.", shapeFile); + var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Meerdere trajecten met dezelfde identificatiecode (attribuut 'TRAJECT_ID') gevonden.", + shapeFile); CriticalFileValidationException exception = Assert.Throws(call); Assert.AreEqual(expectedMessage, exception.Message); } @@ -181,7 +183,7 @@ // Assert var shapeFile = Path.Combine(pathToFolder, "EmptyTrackId.shp"); - var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': De identificatiecodes van de trajecten (het attribuut 'TRAJECT_ID' in het shape bestand) zijn niet allemaal ingevuld.", shapeFile); + var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': Trajecten gevonden zonder een geldige identificatiecode (attribuut 'TRAJECT_ID').", shapeFile); CriticalFileValidationException exception = Assert.Throws(call); Assert.AreEqual(expectedMessage, exception.Message); } Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLinesMetaReaderTest.cs =================================================================== diff -u -r239ea628125c5ec4004a843abce2d269af93c431 -r9ccccb49274ddad9696632ec89efda0ce2e34afc --- Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLinesMetaReaderTest.cs (.../ReferenceLinesMetaReaderTest.cs) (revision 239ea628125c5ec4004a843abce2d269af93c431) +++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReferenceLinesMetaReaderTest.cs (.../ReferenceLinesMetaReaderTest.cs) (revision 9ccccb49274ddad9696632ec89efda0ce2e34afc) @@ -149,7 +149,7 @@ // Assert var message = Assert.Throws(call).Message; - var expectedMessage = String.Format("Het bestand heeft geen attribuut '{0}'. Dit attribuut is vereist.", + var expectedMessage = String.Format("Het shapebestand '{0}' om dijktrajecten te specificeren moet de attributen 'TRAJECT_ID', 'NORM_SW', en 'NORM_OG' bevatten: '{1}' niet gevonden.", validFilePath, missingAttribute); Assert.AreEqual(expectedMessage, message); } @@ -168,7 +168,7 @@ // Assert var message = Assert.Throws(call).Message; - var expectedMessage = String.Format("Het bestand heeft de attributen '{0}' niet. Deze attributen zijn vereist.", + var expectedMessage = String.Format("Het shapebestand '{0}' om dijktrajecten te specificeren moet de attributen 'TRAJECT_ID', 'NORM_SW', en 'NORM_OG' bevatten: '{1}' niet gevonden.", validFilePath, missingAttributes); Assert.AreEqual(expectedMessage, message); } Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs =================================================================== diff -u -r77ef3a138d3518b9b6ca1fa8157ea6be44c7efcd -r9ccccb49274ddad9696632ec89efda0ce2e34afc --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (.../AssessmentSectionFromFileCommandHandler.cs) (revision 77ef3a138d3518b9b6ca1fa8157ea6be44c7efcd) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Commands/AssessmentSectionFromFileCommandHandler.cs (.../AssessmentSectionFromFileCommandHandler.cs) (revision 9ccccb49274ddad9696632ec89efda0ce2e34afc) @@ -212,7 +212,7 @@ catch (CriticalFileValidationException exception) { MessageBox.Show(exception.Message, BaseResources.Error, MessageBoxButtons.OK, MessageBoxIcon.Error); - log.Warn(exception.Message, exception.InnerException); + log.Error(exception.Message, exception.InnerException); return false; } catch (CriticalFileReadException exception) Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs =================================================================== diff -u -r04e456a3c39bc3a6e9c4cba357964aa9c83f258c -r9ccccb49274ddad9696632ec89efda0ce2e34afc --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs (.../AssessmentSectionFromFileCommandHandlerTest.cs) (revision 04e456a3c39bc3a6e9c4cba357964aa9c83f258c) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Commands/AssessmentSectionFromFileCommandHandlerTest.cs (.../AssessmentSectionFromFileCommandHandlerTest.cs) (revision 9ccccb49274ddad9696632ec89efda0ce2e34afc) @@ -137,7 +137,7 @@ Action action = () => assessmentSectionFromFileCommandHandler.AddAssessmentSectionFromFile(); // Assert - var expectedMessage = string.Format("Fout bij het lezen van bestand '{0}': De map locatie is ongeldig.", pathToNonExistingFolder); + var expectedMessage = string.Format("De map met specificaties voor trajecten '{0}' is niet gevonden.", pathToNonExistingFolder); TestHelper.AssertLogMessageIsGenerated(action, expectedMessage); mockRepository.VerifyAll(); }