From b728d54b6aca7b840856a398c2fe4e03f4ba1256 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Tue, 11 Jan 2022 11:39:18 +0100 Subject: [PATCH 01/20] Should consider columns with string values --- tests/OSPSuite.R.Tests/Data/BookStrings.xlsx | Bin 0 -> 15797 bytes tests/OSPSuite.R.Tests/OSPSuite.R.Tests.csproj | 3 +++ .../Services/DataImporterTaskSpecs.cs | 9 +++++++++ 3 files changed, 12 insertions(+) create mode 100644 tests/OSPSuite.R.Tests/Data/BookStrings.xlsx diff --git a/tests/OSPSuite.R.Tests/Data/BookStrings.xlsx b/tests/OSPSuite.R.Tests/Data/BookStrings.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..249afeec31db74e16670c869f171c30568399ebe GIT binary patch literal 15797 zcmeIZRa~6O);$ct-7R=uP05kO%sPJO}6v;Pd}`{2!iy(ZnH{9(u%}GqF~o9V&?xbST2FwGc@} zN_pHqRb$Xp`9slC*e}5)&lq4|k6s7m^A;v>m72Aj55HIONGyrMD}^UQ9*thGW+uzg>Qs zg)o1R9b#m76Kzq~gDUs#l1Uf$M)31RqMsqLhbubE;)diH#+>YWd8ToTNPT0ih`hL* z%DDM3f6%zUoa&nZbrZW$bNSTBGu%gZEH|8H6V~Z6I%xcZ{2N&h&6n6{{woA-ZQ1oW z@){Em`ZDH?rV;wEQ=;T<|BrB4oPCRM9z9ThDA0NSl`a6qaoP9qbM7264h#qa;Qm)lLl5#o`gYqh! zFaBs?nUH;#NlNy@I+^hS`YSqX^xpOc2oTWA3kZ54X{FEy>v`!>Cb0J)XI6?d2Efh*2P7pdzs;_##wAz~f?HAx#LB*5u zpvnfeoWuBubnp43q60X-5Duy1=~T2q2Yr*pFCK%IgjaWOl@(1n%qsP>>^a}L=@?pe zeiu&fKzZ_@k;xcTc*l%<%Q*3VfF$S2TfLU~VkFb8mkp|?bntx0FC72V8X(C1oh0rc zg?1$X`aA)mAp&4#TrKHbZ0s%cZE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**rFZ&zsy49YS;!7t{fA?Ua+3cE@So?O{$=>{x&)xeACc-;e0pv8 z`b@}g(-*+{|ECc6UnfLf8~>;B{I@9(&>ZwH<3GOmZ#wkXIIs1`zmYHj^#5;am<7yw(r>MxjLih4NZW^cvvx4(M-y z&$zz;e(#6AHhsO@^xM>x;1AQ+drz+sUT@v}MzA9Mh4An6@2`p9Yn0c$`rjzsfE*ey zlm99?em3xbRUEGoUN>ESBXCjv72$Ua<~73WLgzOE6y0AD41SkAuOVLN{=XqO=zl@{ ze^mmn0bi%nzX918egXb_cK=Iq{TlFfiuxOnnenfK{Ktg#HQ0Y9c)y{5fP|QUfc}>5 ny*B^P$oyCHA(p?G{~4#{B*6fy%uk6O;5arw- PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs b/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs index 3b1af6603..2a680ad17 100644 --- a/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs +++ b/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs @@ -296,5 +296,14 @@ public void should_get_add_and_remove_all_loaded_sheets_from_single_string() _configuration.ClearLoadedSheets(); sut.GetAllLoadedSheets(_configuration).ShouldBeEmpty(); } + + [Observation] + public void should_consider_columns_with_string_values() + { + var configuration = sut.CreateConfigurationFor(getFileFullName("BookStrings.xlsx")); + configuration.Parameters.Exists(x => (x as MappingDataFormatParameter).ColumnName == "Time [h]").ShouldBeTrue(); + configuration.Parameters.Exists(x => (x as MappingDataFormatParameter).ColumnName == "Measurement [mg/l]").ShouldBeTrue(); + configuration.Parameters.Exists(x => (x as MappingDataFormatParameter).ColumnName == "Error [mg/l]").ShouldBeTrue(); + } } } From 3f308dc82ef5e9501f7737d3e250471a2d849978 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Tue, 11 Jan 2022 12:52:02 +0100 Subject: [PATCH 02/20] based format on first valid sheet --- .../Services/Importer.cs | 17 +++++++++++------ tests/OSPSuite.R.Tests/Data/BookStrings.xlsx | Bin 15797 -> 15868 bytes .../Services/DataImporterTaskSpecs.cs | 2 +- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs index b4cb4f32e..977d56a08 100644 --- a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs +++ b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs @@ -102,8 +102,18 @@ public IDataSourceFile LoadFile(IReadOnlyList columnInfos, string fi if (dataSource.DataSheets == null) return null; - CalculateFormat(dataSource, columnInfos, metaDataCategories, dataSource.DataSheets.Keys.FirstOrDefault()); + foreach(var x in dataSource.DataSheets.Keys) + { + CalculateFormat(dataSource, columnInfos, metaDataCategories, x); + if (dataSource.AvailableFormats?.Count > 0) + break; + }; + + if (dataSource.AvailableFormats.Count == 0) + throw new UnsupportedFormatException(dataSource.Path); + + dataSource.Format = dataSource.AvailableFormats.FirstOrDefault(); return dataSource; } @@ -113,11 +123,6 @@ public void CalculateFormat(IDataSourceFile dataSource, IReadOnlyList NamesFromConvention diff --git a/tests/OSPSuite.R.Tests/Data/BookStrings.xlsx b/tests/OSPSuite.R.Tests/Data/BookStrings.xlsx index 249afeec31db74e16670c869f171c30568399ebe..346cd883e7e8e1d830c3e7339091feb43692c976 100644 GIT binary patch delta 2759 zcmY*bc{tRK7M{Ua2H6=Q%OGovWvnAhgzODwx zNSZlh8;N0B)2?`=>^T%#gKoBN{ZwpO#BA3B)eW!#Zgw0Uj>^hz_;*Z3tH~gVnVA9p z<)TeSp$$%P(xl49Q+0t}wa_}v`;>TXr-7GFp|wic&!TfKxB~eH)+fJHz7sGWp)ic6 z`j1AC@#4K%)4S0XTehxwP#tCrQC=IbBHG-NEO%{#Tq=Oqfk;18il(T0^bNJU#;}72 zSW;Dswcs36Z*a5TY(rL9$aEOA=VpAn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Mva~dHu zd|m3*%Teze@HS884;;~LZ6TfSI9J6mf6s^UN%|sf169i7!dKxXx-D^k%qvCmf9!Oq zQV*YTS!!a;rz|C5C59r2+&OmP#_LImdcvbZs$C>p3}qGU8mRII2bxa_Ohft~qv#U( zxB5H1M7Kwp9DADF8bnfzD6BGx`}nCN_`iB0cX$*1=8)gr_bslz7ET)Tged7p`Y^Y4 z{VY~YCtSsM_}ea;j8aTBvUr_<9!>v#)YVO>gKw1Gk)2zzh1&3cy)7=eh? z$r{*l{_kbO8Q=W>2w)kTNdLMfAdtkNr+yV)02mdJ1h8k+I5>TmOrAl3 zp8-+`dG7!G2%r$6;8?%|Va|b90EQJLfox+zKHxVqFhJT=4Xh7Xnd(aYC;p+wBMy^F=oiZ&Ityf(nsM}<2L3WV LdE}ANzq@|`^mFZ7 diff --git a/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs b/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs index 2a680ad17..5936d7dbf 100644 --- a/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs +++ b/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs @@ -298,7 +298,7 @@ public void should_get_add_and_remove_all_loaded_sheets_from_single_string() } [Observation] - public void should_consider_columns_with_string_values() + public void should_consider_columns_with_string_values_and_skip_invalid_sheets() { var configuration = sut.CreateConfigurationFor(getFileFullName("BookStrings.xlsx")); configuration.Parameters.Exists(x => (x as MappingDataFormatParameter).ColumnName == "Time [h]").ShouldBeTrue(); From e53b503c8f0365b4ee072aff30cd1fba6408f4d7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Tue, 11 Jan 2022 13:22:37 +0100 Subject: [PATCH 03/20] Fixing tests --- .../Services/Importer.cs | 9 +++------ .../Data/invalid.xlsx | Bin 0 -> 9550 bytes .../OSPSuite.Presentation.Tests.csproj | 3 +++ .../Services/DataImporterSpecs.cs | 7 +++---- 4 files changed, 9 insertions(+), 10 deletions(-) create mode 100644 tests/OSPSuite.Presentation.Tests/Data/invalid.xlsx diff --git a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs index 977d56a08..00f84a149 100644 --- a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs +++ b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs @@ -107,14 +107,10 @@ public IDataSourceFile LoadFile(IReadOnlyList columnInfos, string fi { CalculateFormat(dataSource, columnInfos, metaDataCategories, x); if (dataSource.AvailableFormats?.Count > 0) - break; + return dataSource; }; - if (dataSource.AvailableFormats.Count == 0) - throw new UnsupportedFormatException(dataSource.Path); - - dataSource.Format = dataSource.AvailableFormats.FirstOrDefault(); - return dataSource; + throw new UnsupportedFormatException(dataSource.Path); } public void CalculateFormat(IDataSourceFile dataSource, IReadOnlyList columnInfos, IReadOnlyList metaDataCategories, string sheetName) @@ -123,6 +119,7 @@ public void CalculateFormat(IDataSourceFile dataSource, IReadOnlyList NamesFromConvention diff --git a/tests/OSPSuite.Presentation.Tests/Data/invalid.xlsx b/tests/OSPSuite.Presentation.Tests/Data/invalid.xlsx new file mode 100644 index 0000000000000000000000000000000000000000..8280229ee2af00418e7e6bf38fd779978419a1da GIT binary patch literal 9550 zcmeHNRa6|?w#D6D4-(vh1()FN7F;_>;}9e`1cyN5?hq0rKybI1A|AhwrT|n14Duc1A`BP z0%s`YG3CL)LI3~X<3D%?dXvT-yE!rXP7*J$bSkyT zH#k-BLwoKi_=~EM2gszJOwmPQhBV}on`M+>y?MS=tU-Qrd{4N=crC1G1ussQ$b#6utB()Z1lTjf!F7EvhCTqS4FR+#l zSzy|l7f6-RL4SrUxCeFw>`(?3W*J~|k%@IHv$F%#fcLHRk!BiJ*vp-BWdtk;Ko%Kg z7CqGm*FjG#MC%fga+OZ9<|tE;#GL@%!HX z%n2i)kS7jo8^r+uc%om8%22LjX+8Ho!}{A%ZEf5LM~YE^N_iRHz>O~{D9K$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uite.Presentation.Tests/OSPSuite.Presentation.Tests.csproj b/tests/OSPSuite.Presentation.Tests/OSPSuite.Presentation.Tests.csproj index 869e8f0ce..3ee09c30d 100644 --- a/tests/OSPSuite.Presentation.Tests/OSPSuite.Presentation.Tests.csproj +++ b/tests/OSPSuite.Presentation.Tests/OSPSuite.Presentation.Tests.csproj @@ -58,6 +58,9 @@ PreserveNewest + + PreserveNewest + PreserveNewest diff --git a/tests/OSPSuite.Presentation.Tests/Services/DataImporterSpecs.cs b/tests/OSPSuite.Presentation.Tests/Services/DataImporterSpecs.cs index a89a6d0e3..919c887a9 100644 --- a/tests/OSPSuite.Presentation.Tests/Services/DataImporterSpecs.cs +++ b/tests/OSPSuite.Presentation.Tests/Services/DataImporterSpecs.cs @@ -208,10 +208,9 @@ public void should_correctly_notify_and_return_empty_on_invalid_file_type() [Observation] public void should_correctly_notify_and_return_empty_on_invalid_file_format() { - sut.ImportFromConfiguration(_importerConfiguration, _metaDataCategories, _columnInfos, _dataImporterSettings, - getFileFullName( - "sample1.xlsx")).Count.ShouldBeEqualTo(0); - A.CallTo(() => _dialogCreator.MessageBoxError(Error.UnsupportedFileFormat(getFileFullName("sample1.xlsx")))).MustHaveHappened(); + var invalidFileName = getFileFullName("invalid.xlsx"); + sut.ImportFromConfiguration(_importerConfiguration, _metaDataCategories, _columnInfos, _dataImporterSettings, invalidFileName).Count.ShouldBeEqualTo(0); + A.CallTo(() => _dialogCreator.MessageBoxError(Error.UnsupportedFileFormat(invalidFileName))).MustHaveHappened(); } [Observation] From 0c922de7241b7ab92ca876f14172d6ca45ca9f02 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Sat, 15 Jan 2022 21:47:53 +0100 Subject: [PATCH 04/20] Collecting errors instead of throwing on first --- src/OSPSuite.Assets/UIConstants.cs | 3 + .../Core/BaseGridColumnNotFoundException.cs | 11 ++++ .../Core/ColumnNotFoundException.cs | 11 ++++ .../Core/DataSource.cs | 58 +++++++++++----- .../Core/EmptyDataSetsException.cs | 12 ---- .../Core/EmptyNamingConventionsException.cs | 11 ++++ .../Core/ErrorUnitException.cs | 11 ---- .../Core/Exceptions/ParseErrorDescription.cs | 66 +++++++++++++++++++ .../Core/Helpers/CachedListHelpers.cs | 24 +++++++ .../Core/IDataSet.cs | 10 +-- .../Core/ImporterExceptions.cs | 38 ----------- .../Core/ImporterParsingException.cs | 19 ++++++ ...consistenMoleculeAndMolWeitghtException.cs | 11 ++++ ...onsistentDimensionBetweenUnitsException.cs | 11 ---- .../Core/InvalidDimensionException.cs | 11 ---- .../Core/InvalidMappingColumnException.cs | 13 ---- .../Core/MismatchingArrayLengthsException.cs | 12 ---- .../Core/NanException.cs | 11 ---- .../Core/NullNamingConventionsException.cs | 11 ++++ .../Services/Importer.cs | 4 +- .../Importer/IImporterDataPresenter.cs | 2 + .../Importer/ImporterDataPresenter.cs | 6 ++ .../Presenters/Importer/ImporterPresenter.cs | 18 +++-- .../Views/Importer/IImporterDataView.cs | 4 ++ .../Importer/ImporterDataView.Designer.cs | 24 ++++++- .../Views/Importer/ImporterDataView.cs | 16 ++++- .../Views/Importer/ImporterDataView.resx | 46 ++++++++++++- .../Import/DataSourceSpecs.cs | 10 +-- .../Presenters/ImporterPresenterSpecs.cs | 5 +- 29 files changed, 331 insertions(+), 158 deletions(-) create mode 100644 src/OSPSuite.Infrastructure.Import/Core/BaseGridColumnNotFoundException.cs create mode 100644 src/OSPSuite.Infrastructure.Import/Core/ColumnNotFoundException.cs delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/EmptyDataSetsException.cs create mode 100644 src/OSPSuite.Infrastructure.Import/Core/EmptyNamingConventionsException.cs delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/ErrorUnitException.cs create mode 100644 src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs create mode 100644 src/OSPSuite.Infrastructure.Import/Core/Helpers/CachedListHelpers.cs delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/ImporterExceptions.cs create mode 100644 src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs create mode 100644 src/OSPSuite.Infrastructure.Import/Core/InconsistenMoleculeAndMolWeitghtException.cs delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/InconsistentDimensionBetweenUnitsException.cs delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/InvalidDimensionException.cs delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/InvalidMappingColumnException.cs delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/MismatchingArrayLengthsException.cs delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/NanException.cs create mode 100644 src/OSPSuite.Infrastructure.Import/Core/NullNamingConventionsException.cs diff --git a/src/OSPSuite.Assets/UIConstants.cs b/src/OSPSuite.Assets/UIConstants.cs index f95e3890b..2918dca50 100644 --- a/src/OSPSuite.Assets/UIConstants.cs +++ b/src/OSPSuite.Assets/UIConstants.cs @@ -1,9 +1,11 @@ using System; using System.Collections.Generic; +using System.Data; using System.Drawing; using System.Linq; using System.Text; using OSPSuite.Assets.Extensions; +using OSPSuite.Utility.Collections; using OSPSuite.Utility.Extensions; namespace OSPSuite.Assets @@ -1275,6 +1277,7 @@ public static class Error public static readonly string NaNOnData = "Data contains NaN values at imported columns. Select a different action for NaN values or clean your data."; public static readonly string UnsupportedFileType = "The type of file that you are trying to open is not currently supported"; public static readonly string CannotRemoveBaseGridColumnStillInUse = "Cannot remove base grid column still used by other columns"; + public static string ParseErrorMessage(IEnumerable errors) => "There were errors while parsing your data: " + string.Join(". ", errors); public static string ErrorWhenPlottingDataRepository(int sheetName, string exceptionMessage) => $"Plotting data set number:{sheetName} produced the following error: {exceptionMessage}"; diff --git a/src/OSPSuite.Infrastructure.Import/Core/BaseGridColumnNotFoundException.cs b/src/OSPSuite.Infrastructure.Import/Core/BaseGridColumnNotFoundException.cs new file mode 100644 index 000000000..ed3ff0a89 --- /dev/null +++ b/src/OSPSuite.Infrastructure.Import/Core/BaseGridColumnNotFoundException.cs @@ -0,0 +1,11 @@ +using OSPSuite.Assets; + +namespace OSPSuite.Infrastructure.Import.Core +{ + public class BaseGridColumnNotFoundException : AbstractImporterException + { + public BaseGridColumnNotFoundException(string columnName) : base(Error.BaseGridColumnNotFoundException(columnName)) + { + } + } +} diff --git a/src/OSPSuite.Infrastructure.Import/Core/ColumnNotFoundException.cs b/src/OSPSuite.Infrastructure.Import/Core/ColumnNotFoundException.cs new file mode 100644 index 000000000..b53787a07 --- /dev/null +++ b/src/OSPSuite.Infrastructure.Import/Core/ColumnNotFoundException.cs @@ -0,0 +1,11 @@ +using OSPSuite.Assets; + +namespace OSPSuite.Infrastructure.Import.Core +{ + public class ColumnNotFoundException : AbstractImporterException + { + public ColumnNotFoundException(string columnName) : base(Error.ColumnNotFound(columnName)) + { + } + } +} diff --git a/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs b/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs index 3cc17b7e0..f68191f27 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs @@ -3,9 +3,12 @@ using System.Linq; using OSPSuite.Core.Domain; using OSPSuite.Core.Import; +using OSPSuite.Infrastructure.Import.Core.Exceptions; +using OSPSuite.Infrastructure.Import.Core.Helpers; using OSPSuite.Infrastructure.Import.Extensions; using OSPSuite.Infrastructure.Import.Services; using OSPSuite.Utility.Collections; +using OSPSuite.Utility.Extensions; namespace OSPSuite.Infrastructure.Import.Core { @@ -16,7 +19,7 @@ public interface IDataSource { void SetDataFormat(IDataFormat dataFormat); void SetNamingConvention(string namingConvention); - void AddSheets(Cache dataSheets, IReadOnlyList columnInfos, string filter); + Cache> AddSheets(Cache dataSheets, IReadOnlyList columnInfos, string filter); void SetMappings(string fileName, IEnumerable mappings); ImporterConfiguration GetImporterConfiguration(); IEnumerable GetMappings(); @@ -24,7 +27,7 @@ public interface IDataSource IEnumerable NamesFromConvention(); NanSettings NanSettings { get; set; } ImportedDataSet DataSetAt(int index); - void ValidateDataSourceUnits(IReadOnlyList columnInfos); + Cache> ValidateDataSourceUnits(IReadOnlyList columnInfos); } public class DataSource : IDataSource @@ -72,16 +75,18 @@ private Cache filterSheets(Cache dataSheet return filteredDataSheets; } - public void AddSheets(Cache dataSheets, IReadOnlyList columnInfos, string filter) - { + public Cache> AddSheets(Cache dataSheets, IReadOnlyList columnInfos, string filter) + { _importer.AddFromFile(_configuration.Format, filterSheets(dataSheets, filter), columnInfos, this); if (NanSettings == null || !double.TryParse(NanSettings.Indicator, out var indicator)) indicator = double.NaN; + var errors = new Cache>(); foreach (var dataSet in DataSets.KeyValues) { if (NanSettings != null && NanSettings.Action == NanSettings.ActionType.Throw) { - dataSet.Value.ThrowsOnNan(indicator); + if (dataSet.Value.NanValuesExist(indicator)) + CachedListHelpers.Add(errors, dataSet.Value, new NaNParseErrorDescription()); } else { @@ -91,9 +96,10 @@ public void AddSheets(Cache dataSheets, IReadOnlyList string.Join(".", d.Description.Where(metaData => metaData.Value != null).Select(metaData => metaData.Value))); - throw new EmptyDataSetsException(emptyDataSetsNames); + CachedListHelpers.Add(errors, dataSet.Value, new EmptyDataSetsParseErrorDescription(emptyDataSetsNames)); } } + return errors; } public void SetMappings(string fileName, IEnumerable mappings) @@ -145,8 +151,9 @@ public ImportedDataSet DataSetAt(int index) } //checks that the dimension of all the units coming from columns for error have the same dimension to the corresponding measurement - private void validateErrorAgainstMeasurement(IReadOnlyList columnInfos) + private Cache> validateErrorAgainstMeasurement(IReadOnlyList columnInfos) { + var errors = new Cache>(); foreach (var column in columnInfos.Where(c => !c.IsAuxiliary())) { foreach (var relatedColumn in columnInfos.Where(c => c.IsAuxiliary() && c.RelatedColumnOf == column.Name)) @@ -162,7 +169,10 @@ private void validateErrorAgainstMeasurement(IReadOnlyList columnInf continue; if (errorColumn.Value != null && measurementColumn.Value.Count != errorColumn.Value.Count) - throw new MismatchingArrayLengthsException(); + { + CachedListHelpers.Add(errors, dataSet, new MismatchingArrayLengthsParseErrorDescription()); + continue; + } var errorDimension = errorColumn.Key.Column.Dimension; var measurementDimension = measurementColumn.Key.Column.Dimension; @@ -177,7 +187,10 @@ private void validateErrorAgainstMeasurement(IReadOnlyList columnInf var measurementSupportedDimension = column.SupportedDimensions.FirstOrDefault(x => x.HasUnit(measurementColumn.Value.ElementAt(i).Unit)); var errorSupportedDimension = column.SupportedDimensions.FirstOrDefault(x => x.HasUnit(errorColumn.Value.ElementAt(i).Unit)); if (measurementSupportedDimension != errorSupportedDimension) - throw new ErrorUnitException(); + { + CachedListHelpers.Add(errors, dataSet, new ErrorUnitParseErrorDescription()); + continue; + } } } else @@ -189,17 +202,22 @@ private void validateErrorAgainstMeasurement(IReadOnlyList columnInf continue; if (measurementDimension != errorDimension) - throw new ErrorUnitException(); + { + CachedListHelpers.Add(errors, dataSet, new ErrorUnitParseErrorDescription()); + continue; + } } } } } } + return errors; } //checks that all units coming from a mapped column unit belong to a valid dimension for this mapping //and also that they are all of the same dimension within every data set. - private void validateUnitsSupportedAndSameDimension(IReadOnlyList columnInfos) + private Cache> validateUnitsSupportedAndSameDimension(IReadOnlyList columnInfos) { + var errors = new Cache>(); foreach (var columnInfo in columnInfos) { foreach (var dataSet in DataSets) @@ -227,22 +245,30 @@ private void validateUnitsSupportedAndSameDimension(IReadOnlyList co //if the unit specified does not belong to one of the supported dimensions of the mapping if (dimension == null) - throw new InvalidDimensionException(currentValue.Unit, columnInfo.DisplayName); + { + CachedListHelpers.Add(errors, dataSet, new InvalidDimensionParseErrorDescription(currentValue.Unit, columnInfo.DisplayName)); + continue; + } //if the unit specified is not of the same dimension as the other units of the same data set if (dimension != dimensionOfFirstUnit) - throw new InconsistentDimensionBetweenUnitsException(columnInfo.DisplayName); + { + CachedListHelpers.Add(errors, dataSet, new InconsistentDimensionBetweenUnitsParseErrorDescription(columnInfo.DisplayName)); + continue; + } } } } } } + return errors; } - void IDataSource.ValidateDataSourceUnits(IReadOnlyList columnInfos) + Cache> IDataSource.ValidateDataSourceUnits(IReadOnlyList columnInfos) { - validateUnitsSupportedAndSameDimension(columnInfos); - validateErrorAgainstMeasurement(columnInfos); + var errors = validateUnitsSupportedAndSameDimension(columnInfos); + validateErrorAgainstMeasurement(columnInfos).KeyValues.Each(x => CachedListHelpers.Add(errors, x.Key, x.Value)); + return errors; } } diff --git a/src/OSPSuite.Infrastructure.Import/Core/EmptyDataSetsException.cs b/src/OSPSuite.Infrastructure.Import/Core/EmptyDataSetsException.cs deleted file mode 100644 index 851955bbc..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/EmptyDataSetsException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using OSPSuite.Assets; -using System.Collections.Generic; - -namespace OSPSuite.Infrastructure.Import.Core -{ - public class EmptyDataSetsException : AbstractImporterException - { - public EmptyDataSetsException(IEnumerable dataSetNames) : base(Error.EmptyDataSet($"{string.Join(", ", dataSetNames)}")) - { - } - } -} diff --git a/src/OSPSuite.Infrastructure.Import/Core/EmptyNamingConventionsException.cs b/src/OSPSuite.Infrastructure.Import/Core/EmptyNamingConventionsException.cs new file mode 100644 index 000000000..23cbf2c56 --- /dev/null +++ b/src/OSPSuite.Infrastructure.Import/Core/EmptyNamingConventionsException.cs @@ -0,0 +1,11 @@ +using OSPSuite.Assets; + +namespace OSPSuite.Infrastructure.Import.Core +{ + public class EmptyNamingConventionsException : AbstractImporterException + { + public EmptyNamingConventionsException() : base(Error.NamingConventionEmpty) + { + } + } +} diff --git a/src/OSPSuite.Infrastructure.Import/Core/ErrorUnitException.cs b/src/OSPSuite.Infrastructure.Import/Core/ErrorUnitException.cs deleted file mode 100644 index e77fe5e17..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/ErrorUnitException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using OSPSuite.Assets; - -namespace OSPSuite.Infrastructure.Import.Core -{ - public class ErrorUnitException : AbstractImporterException - { - public ErrorUnitException() : base(Error.InvalidErrorDimension) - { - } - } -} diff --git a/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs b/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs new file mode 100644 index 000000000..ed9cdd821 --- /dev/null +++ b/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs @@ -0,0 +1,66 @@ +using OSPSuite.Assets; +using System.Collections.Generic; + +namespace OSPSuite.Infrastructure.Import.Core.Exceptions +{ + public abstract class ParseErrorDescription + { + public string Message { get; protected set; } + } + + public class InvalidDimensionParseErrorDescription : ParseErrorDescription + { + public InvalidDimensionParseErrorDescription(string invalidUnit, string mappingName) + { + Message = Error.InvalidDimensionException(invalidUnit, mappingName); + } + } + + public class NaNParseErrorDescription : ParseErrorDescription + { + public NaNParseErrorDescription() + { + Message = Error.NaNOnData; + } + } + + public class MismatchingArrayLengthsParseErrorDescription : ParseErrorDescription + { + public MismatchingArrayLengthsParseErrorDescription() + { + Message = Error.MismatchingArrayLengths; + } + } + + public class InvalidMappingColumnParseErrorDescription : ParseErrorDescription + { + public InvalidMappingColumnParseErrorDescription() + { + Message = Error.InvalidMappingColumn; + } + } + + public class InconsistentDimensionBetweenUnitsParseErrorDescription : ParseErrorDescription + { + public InconsistentDimensionBetweenUnitsParseErrorDescription(string mappingName) + { + Message = Error.InconsistentDimensionBetweenUnitsException(mappingName); + } + } + + public class ErrorUnitParseErrorDescription : ParseErrorDescription + { + public ErrorUnitParseErrorDescription() + { + Message = Error.InvalidErrorDimension; + } + } + + public class EmptyDataSetsParseErrorDescription : ParseErrorDescription + { + public EmptyDataSetsParseErrorDescription(IEnumerable dataSetNames) + { + Message = Error.EmptyDataSet($"{string.Join(", ", dataSetNames)}"); + } + } +} diff --git a/src/OSPSuite.Infrastructure.Import/Core/Helpers/CachedListHelpers.cs b/src/OSPSuite.Infrastructure.Import/Core/Helpers/CachedListHelpers.cs new file mode 100644 index 000000000..ba490612d --- /dev/null +++ b/src/OSPSuite.Infrastructure.Import/Core/Helpers/CachedListHelpers.cs @@ -0,0 +1,24 @@ +using OSPSuite.Utility.Collections; +using System.Collections.Generic; + +namespace OSPSuite.Infrastructure.Import.Core.Helpers +{ + static public class CachedListHelpers + { + public static void Add(Cache> cache, T1 key, T2 x) + { + if (cache.Contains(key)) + cache[key].Add(x); + else + cache.Add(key, new List() { x }); + } + + public static void Add(Cache> cache, T1 key, IEnumerable list) + { + if (cache.Contains(key)) + cache[key].AddRange(list); + else + cache.Add(key, new List(list)); + } + } +} diff --git a/src/OSPSuite.Infrastructure.Import/Core/IDataSet.cs b/src/OSPSuite.Infrastructure.Import/Core/IDataSet.cs index cb4380a30..0ea7d3ebd 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/IDataSet.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/IDataSet.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Linq; namespace OSPSuite.Infrastructure.Import.Core @@ -19,7 +20,7 @@ public interface IDataSet { IReadOnlyList Data { get; } void ClearNan(double indicator); - void ThrowsOnNan(double indicator); + bool NanValuesExist(double indicator); void AddData(IEnumerable range); } @@ -34,10 +35,9 @@ public void AddData(IEnumerable range) _data.AddRange(range); } - public void ThrowsOnNan(double indicator) + public bool NanValuesExist(double indicator) { - if (_data.Any(dataSet => dataSet.Data.Any(pair => pair.Key.ColumnInfo.IsMandatory && pair.Value.Any(point => point.Measurement == indicator || double.IsNaN(point.Measurement))))) - throw new NanException(); + return _data.Any(dataSet => dataSet.Data.Any(pair => pair.Key.ColumnInfo.IsMandatory && pair.Value.Any(point => point.Measurement == indicator || double.IsNaN(point.Measurement)))); } public void ClearNan(double indicator) diff --git a/src/OSPSuite.Infrastructure.Import/Core/ImporterExceptions.cs b/src/OSPSuite.Infrastructure.Import/Core/ImporterExceptions.cs deleted file mode 100644 index 32967ba65..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/ImporterExceptions.cs +++ /dev/null @@ -1,38 +0,0 @@ -using OSPSuite.Assets; - -namespace OSPSuite.Infrastructure.Import.Core -{ - public class EmptyNamingConventionsException : AbstractImporterException - { - public EmptyNamingConventionsException() : base(Error.NamingConventionEmpty) - { - } - } - - public class NullNamingConventionsException : AbstractImporterException - { - public NullNamingConventionsException() : base(Error.NamingConventionNull) - { - } - } - - public class InconsistentMoleculeAndMolWeightException : AbstractImporterException - { - public InconsistentMoleculeAndMolWeightException() : base(Error.InconsistentMoleculeAndMolWeightException) - { - } - } - - public class ColumnNotFoundException : AbstractImporterException - { - public ColumnNotFoundException(string columnName) : base(Error.ColumnNotFound(columnName)) - { - } - } - public class BaseGridColumnNotFoundException : AbstractImporterException - { - public BaseGridColumnNotFoundException(string columnName) : base(Error.BaseGridColumnNotFoundException(columnName)) - { - } - } -} \ No newline at end of file diff --git a/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs b/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs new file mode 100644 index 000000000..2bcd5310d --- /dev/null +++ b/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs @@ -0,0 +1,19 @@ +using OSPSuite.Assets; +using OSPSuite.Infrastructure.Import.Core.Exceptions; +using OSPSuite.Utility.Collections; +using System.Collections.Generic; +using System.Linq; + +namespace OSPSuite.Infrastructure.Import.Core +{ + public class ImporterParsingException : AbstractImporterException + { + public Cache>FaultyDataSet { get; private set; } + + public ImporterParsingException(Cache> faultyDataSets) + : base(Error.ParseErrorMessage(faultyDataSets.KeyValues.SelectMany(x => x.Value.Select(y => $"{x.Key} => {y.Message}")))) + { + FaultyDataSet = faultyDataSets; + } + } +} \ No newline at end of file diff --git a/src/OSPSuite.Infrastructure.Import/Core/InconsistenMoleculeAndMolWeitghtException.cs b/src/OSPSuite.Infrastructure.Import/Core/InconsistenMoleculeAndMolWeitghtException.cs new file mode 100644 index 000000000..b0f83f24b --- /dev/null +++ b/src/OSPSuite.Infrastructure.Import/Core/InconsistenMoleculeAndMolWeitghtException.cs @@ -0,0 +1,11 @@ +using OSPSuite.Assets; + +namespace OSPSuite.Infrastructure.Import.Core +{ + public class InconsistentMoleculeAndMolWeightException : AbstractImporterException + { + public InconsistentMoleculeAndMolWeightException() : base(Error.InconsistentMoleculeAndMolWeightException) + { + } + } +} diff --git a/src/OSPSuite.Infrastructure.Import/Core/InconsistentDimensionBetweenUnitsException.cs b/src/OSPSuite.Infrastructure.Import/Core/InconsistentDimensionBetweenUnitsException.cs deleted file mode 100644 index e1b300a5f..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/InconsistentDimensionBetweenUnitsException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using OSPSuite.Assets; - -namespace OSPSuite.Infrastructure.Import.Core -{ - public class InconsistentDimensionBetweenUnitsException : AbstractImporterException - { - public InconsistentDimensionBetweenUnitsException(string mappingName) : base(Error.InconsistentDimensionBetweenUnitsException(mappingName)) - { - } - } -} diff --git a/src/OSPSuite.Infrastructure.Import/Core/InvalidDimensionException.cs b/src/OSPSuite.Infrastructure.Import/Core/InvalidDimensionException.cs deleted file mode 100644 index bcde79126..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/InvalidDimensionException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using OSPSuite.Assets; - -namespace OSPSuite.Infrastructure.Import.Core -{ - public class InvalidDimensionException : AbstractImporterException - { - public InvalidDimensionException(string invalidUnit, string mappingName) : base(Error.InvalidDimensionException(invalidUnit, mappingName)) - { - } - } -} diff --git a/src/OSPSuite.Infrastructure.Import/Core/InvalidMappingColumnException.cs b/src/OSPSuite.Infrastructure.Import/Core/InvalidMappingColumnException.cs deleted file mode 100644 index ef695b639..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/InvalidMappingColumnException.cs +++ /dev/null @@ -1,13 +0,0 @@ -using OSPSuite.Assets; -using OSPSuite.Utility.Exceptions; - -namespace OSPSuite.Infrastructure.Import.Core -{ - public class InvalidMappingColumnException : OSPSuiteException - { - InvalidMappingColumnException() : base(Error.InvalidMappingColumn) - { - - } - } -} diff --git a/src/OSPSuite.Infrastructure.Import/Core/MismatchingArrayLengthsException.cs b/src/OSPSuite.Infrastructure.Import/Core/MismatchingArrayLengthsException.cs deleted file mode 100644 index fe19fa86e..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/MismatchingArrayLengthsException.cs +++ /dev/null @@ -1,12 +0,0 @@ -using OSPSuite.Assets; -using OSPSuite.Utility.Exceptions; - -namespace OSPSuite.Infrastructure.Import.Core -{ - public class MismatchingArrayLengthsException : OSPSuiteException - { - public MismatchingArrayLengthsException() : base(Error.MismatchingArrayLengths) - { - } - } -} diff --git a/src/OSPSuite.Infrastructure.Import/Core/NanException.cs b/src/OSPSuite.Infrastructure.Import/Core/NanException.cs deleted file mode 100644 index f9d4205ca..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/NanException.cs +++ /dev/null @@ -1,11 +0,0 @@ -using OSPSuite.Assets; - -namespace OSPSuite.Infrastructure.Import.Core -{ - public class NanException : AbstractImporterException - { - public NanException() : base(Error.NaNOnData) - { - } - } -} diff --git a/src/OSPSuite.Infrastructure.Import/Core/NullNamingConventionsException.cs b/src/OSPSuite.Infrastructure.Import/Core/NullNamingConventionsException.cs new file mode 100644 index 000000000..6bae85480 --- /dev/null +++ b/src/OSPSuite.Infrastructure.Import/Core/NullNamingConventionsException.cs @@ -0,0 +1,11 @@ +using OSPSuite.Assets; + +namespace OSPSuite.Infrastructure.Import.Core +{ + public class NullNamingConventionsException : AbstractImporterException + { + public NullNamingConventionsException() : base(Error.NamingConventionNull) + { + } + } +} diff --git a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs index 00f84a149..a89ad7977 100644 --- a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs +++ b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs @@ -299,7 +299,9 @@ DataImporterSettings dataImporterSettings sheets.Add(key, dataSourceFile.DataSheets[key]); } - dataSource.AddSheets(sheets, columnInfos, configuration.FilterString); + var errors = dataSource.AddSheets(sheets, columnInfos, configuration.FilterString); + if (errors.Any()) + throw new ImporterParsingException(errors); return (DataSourceToDataSets(dataSource, metaDataCategories, dataImporterSettings, configuration.Id), missingSheets); } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs index 6d7961d87..bc8e317ae 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Data; using OSPSuite.Infrastructure.Import.Core; +using OSPSuite.Infrastructure.Import.Core.Exceptions; using OSPSuite.Presentation.Views.Importer; using OSPSuite.Utility.Collections; @@ -63,5 +64,6 @@ IReadOnlyList columnInfos void SetFilter(string FilterString); void GetFormatBasedOnCurrentSheet(); void ResetLoadedSheets(); + void SetTabMarks(Cache> errors, IEnumerable loadedSheets); } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs index 70d623ff3..5093f38e9 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs @@ -4,6 +4,7 @@ using System.Linq; using OSPSuite.Core.Import; using OSPSuite.Infrastructure.Import.Core; +using OSPSuite.Infrastructure.Import.Core.Exceptions; using OSPSuite.Infrastructure.Import.Services; using OSPSuite.Presentation.Views.Importer; using OSPSuite.Utility.Collections; @@ -266,5 +267,10 @@ public void ResetLoadedSheets() Sheets.Clear(); View.ResetImportButtons(); } + + public void SetTabMarks(Cache> errors, IEnumerable loadedSheets) + { + + } } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs index 13fd076fa..920be96c4 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs @@ -8,12 +8,14 @@ using OSPSuite.Core.Serialization.Xml; using OSPSuite.Core.Services; using OSPSuite.Infrastructure.Import.Core; +using OSPSuite.Infrastructure.Import.Core.Exceptions; using OSPSuite.Infrastructure.Import.Core.Mappers; using OSPSuite.Infrastructure.Import.Services; using OSPSuite.Presentation.Views.Importer; using OSPSuite.Utility.Collections; using OSPSuite.Utility.Extensions; using ImporterConfiguration = OSPSuite.Core.Import.ImporterConfiguration; +using OSPSuite.Infrastructure.Import.Core.Helpers; namespace OSPSuite.Presentation.Presenters.Importer { @@ -176,9 +178,9 @@ private void loadSheetsFromDataPresenter(object sender, ImportSheetsEventArgs ar } } - private void validateDataSource(IDataSource dataSource) + private Cache> validateDataSource(IDataSource dataSource) { - dataSource.ValidateDataSourceUnits(_columnInfos); + return dataSource.ValidateDataSourceUnits(_columnInfos); } private void loadSheets(IDataSourceFile dataSourceFile, Cache sheets, string filter, string selectedNamingConvention = null) @@ -205,9 +207,15 @@ private void loadSheets(IDataSourceFile dataSourceFile, Cache _dataSource.SetMappings(dataSourceFile.Path, mappings); _dataSource.NanSettings = _nanPresenter.Settings; _dataSource.SetDataFormat(_columnMappingPresenter.GetDataFormat()); - _dataSource.AddSheets(sheets, _columnInfos, filter); + var errors = _dataSource.AddSheets(sheets, _columnInfos, filter); - validateDataSource(_dataSource); + validateDataSource(_dataSource).KeyValues.Each(x => CachedListHelpers.Add(errors, x.Key, x.Value)); + if (errors.Any()) + { + //ToDo: mark tabs + _dataSource.DataSets.Keys + throw new ImporterParsingException(errors); + } var keys = new List() { @@ -264,7 +272,7 @@ private void onImporterDataChanged(object sender, EventArgs args) catch (AbstractImporterException e) { _dialogCreator.MessageBoxError(e.Message); - if (e is NanException || e is ErrorUnitException) + if (e is ImporterParsingException) _view.DisableConfirmationView(); } } diff --git a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs index d7300f6c5..e82df101e 100644 --- a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs +++ b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs @@ -1,5 +1,8 @@ using System.Collections.Generic; +using OSPSuite.Infrastructure.Import.Core; +using OSPSuite.Infrastructure.Import.Core.Exceptions; using OSPSuite.Presentation.Presenters.Importer; +using OSPSuite.Utility.Collections; namespace OSPSuite.Presentation.Views.Importer { @@ -18,5 +21,6 @@ public interface IImporterDataView : IView void SetFilter(string filter); string SelectedTab { get; set; } string GetFilter(); + void SetTabMarks(Cache> errors, IEnumerable loadedSheets); } } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs index dee12e0cd..40bf8d40d 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs @@ -31,6 +31,7 @@ protected override void Dispose(bool disposing) /// private void InitializeComponent() { + this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImporterDataView)); this.rootLayoutControl = new DevExpress.XtraLayout.LayoutControl(); this.useForImportCheckEdit = new DevExpress.XtraEditors.CheckEdit(); @@ -45,6 +46,8 @@ private void InitializeComponent() this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem(); this.dataViewingGridControl = new DevExpress.XtraGrid.GridControl(); this.dataViewingGridView = new DevExpress.XtraGrid.Views.Grid.GridView(); + this.imageCollection1 = new DevExpress.Utils.ImageCollection(this.components); + this.dpiAwareImageCollection1 = new DevExpress.Utils.DPIAwareImageCollection(this.components); ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rootLayoutControl)).BeginInit(); this.rootLayoutControl.SuspendLayout(); @@ -58,6 +61,8 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridControl)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridView)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.imageCollection1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.dpiAwareImageCollection1)).BeginInit(); this.SuspendLayout(); // // rootLayoutControl @@ -81,11 +86,11 @@ private void InitializeComponent() this.useForImportCheckEdit.AllowHtmlTextInToolTip = DevExpress.Utils.DefaultBoolean.True; this.useForImportCheckEdit.Location = new System.Drawing.Point(2, 1022); this.useForImportCheckEdit.Name = "useForImportCheckEdit"; - this.useForImportCheckEdit.Properties.Caption = Captions.Importer.UseFiltersForImport; + this.useForImportCheckEdit.Properties.Caption = "Use filters for importing data"; this.useForImportCheckEdit.Size = new System.Drawing.Size(478, 24); this.useForImportCheckEdit.StyleController = this.rootLayoutControl; this.useForImportCheckEdit.TabIndex = 11; - this.useForImportCheckEdit.ToolTip = Captions.Importer.UseFiltersForImportTooltip; + this.useForImportCheckEdit.ToolTip = resources.GetString("useForImportCheckEdit.ToolTip"); this.useForImportCheckEdit.ToolTipAnchor = DevExpress.Utils.ToolTipAnchor.Cursor; // // btnImport @@ -193,6 +198,17 @@ private void InitializeComponent() this.dataViewingGridView.Name = "dataViewingGridView"; this.dataViewingGridView.OptionsView.ColumnAutoWidth = false; // + // imageCollection1 + // + this.imageCollection1.ImageStream = ((DevExpress.Utils.ImageCollectionStreamer)(resources.GetObject("imageCollection1.ImageStream"))); + this.imageCollection1.Images.SetKeyName(0, "OK.ico"); + this.imageCollection1.Images.SetKeyName(1, "Cancel.ico"); + // + // dpiAwareImageCollection1 + // + this.dpiAwareImageCollection1.Owner = this; + this.dpiAwareImageCollection1.Stream = ((DevExpress.Utils.DPIAwareImageCollectionStreamer)(resources.GetObject("dpiAwareImageCollection1.Stream"))); + // // ImporterDataView // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); @@ -214,6 +230,8 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridControl)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridView)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.imageCollection1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.dpiAwareImageCollection1)).EndInit(); this.ResumeLayout(false); } @@ -233,5 +251,7 @@ private void InitializeComponent() private DevExpress.XtraEditors.CheckEdit useForImportCheckEdit; private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1; private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1; + private ImageCollection imageCollection1; + private DPIAwareImageCollection dpiAwareImageCollection1; } } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs index ad1c506d7..9b1be3b7f 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs @@ -9,10 +9,14 @@ using DevExpress.XtraTab.Buttons; using DevExpress.XtraTab.ViewInfo; using OSPSuite.Assets; +using OSPSuite.Infrastructure.Import.Core; +using OSPSuite.Infrastructure.Import.Core.Exceptions; using OSPSuite.Presentation.Presenters.Importer; using OSPSuite.Presentation.Views.Importer; using OSPSuite.UI.Controls; using OSPSuite.UI.Extensions; +using OSPSuite.Utility.Collections; +using OSPSuite.Utility.Extensions; namespace OSPSuite.UI.Views.Importer { @@ -222,11 +226,10 @@ public string GetActiveFilterCriteria() public void AddTabs(List sheetNames) { + importerTabControl.Images = imageCollection1; //we should seek an alternative foreach (var sheetName in sheetNames) - { importerTabControl.TabPages.Add(sheetName); - } hideCloseButtonForSingleTab(); } @@ -291,5 +294,14 @@ public string GetFilter() { return DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(dataViewingGridView.ActiveFilterCriteria); } + + public void SetTabMarks(Cache> errors, Cache loadedSheets) + { + importerTabControl.TabPages.Each((x, i) => + { + if (errors.Contains(x)) + x.ImageIndex = 0 + }); + } } } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx b/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx index 9a47dec47..6a3714624 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx @@ -117,8 +117,50 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - + 17, 17 + + + When selected, the filter will apply to the data during the import process. When deselected, the filter only affects this view. Check documentation for more information on defining filters: <href=https://docs.open-systems-pharmacology.org/shared-tools-and-example-workflows/features-of-tables#filtering>https://docs.open-systems-pharmacology.org/shared-tools-and-example-workflows/features-of-tables#filtering</href> + + + 163, 17 + + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFpEZXZFeHByZXNzLlV0aWxzLnYyMS4yLCBWZXJzaW9uPTIxLjIu + My4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI4OGQxNzU0ZDcwMGU0OWEMAwAAAFFT + eXN0ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRv + a2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAAChEZXZFeHByZXNzLlV0aWxzLkltYWdlQ29sbGVjdGlvblN0 + cmVhbWVyAgAAAAlJbWFnZVNpemUERGF0YQQHE1N5c3RlbS5EcmF3aW5nLlNpemUDAAAAAgIAAAAF/P// + /xNTeXN0ZW0uRHJhd2luZy5TaXplAgAAAAV3aWR0aAZoZWlnaHQAAAgIAwAAABAAAAAQAAAACQUAAAAP + BQAAALIDAAAC4QEAAIlQTkcNChoKAAAADUlIRFIA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6LetenEjf2ZNdieZ5CXm + zHz5fK6iVhLzdcSA0Z/3LozCK8gzm3eiywnBj2IAC+2aNl+vL0TIvDA95PnkOPU6hMyIAZyYOEfjhX/l + 431Vzei56LA0bCghaE9VilCMZyMXPZUVmYse6DZMqegIgB9CbOzDneqzhAAAAABJRU5ErkJgggs= + + + + 338, 17 + + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFpEZXZFeHByZXNzLlV0aWxzLnYyMS4yLCBWZXJzaW9uPTIxLjIu + My4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI4OGQxNzU0ZDcwMGU0OWEFAQAAADBE + ZXZFeHByZXNzLlV0aWxzLkRQSUF3YXJlSW1hZ2VDb2xsZWN0aW9uU3RyZWFtZXIAAAAAAgAAAAs= + \ No newline at end of file diff --git a/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs b/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs index 0064f7dda..5233d8715 100644 --- a/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs +++ b/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs @@ -233,7 +233,7 @@ public void throw_on_empty_dataset() { var sheets = new Cache(); sheets.Add("sheet1", new DataSheet() { RawData = new UnformattedData() }); - The.Action(() => sut.AddSheets(sheets, _columnInfos, "")).ShouldThrowAn(); + sut.AddSheets(sheets, _columnInfos, "").ShouldNotBeEmpty(); } } public class When_validating_geometric_error : concern_for_DataSource @@ -729,7 +729,7 @@ protected override void Because() [Observation] public void should_not_be_valid() { - The.Action(() => sut.ValidateDataSourceUnits(_columnInfos)).ShouldThrowAn(); + sut.ValidateDataSourceUnits(_columnInfos).ShouldNotBeEmpty(); } } @@ -819,7 +819,7 @@ protected override void Because() [Observation] public void should_be_valid() { - The.Action(() => sut.ValidateDataSourceUnits(_columnInfos)).ShouldThrowAn(); + sut.ValidateDataSourceUnits(_columnInfos).ShouldNotBeEmpty(); } } @@ -892,7 +892,7 @@ protected override void Because() [Observation] public void should_be_valid() { - The.Action(() => sut.ValidateDataSourceUnits(_columnInfos)).ShouldThrowAn(); + sut.ValidateDataSourceUnits(_columnInfos).ShouldNotBeEmpty(); } } @@ -965,7 +965,7 @@ protected override void Because() [Observation] public void should_be_valid() { - The.Action(() => sut.ValidateDataSourceUnits(_columnInfos)).ShouldThrowAn(); + sut.ValidateDataSourceUnits(_columnInfos).ShouldNotBeEmpty(); } } } \ No newline at end of file diff --git a/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs b/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs index a404bca63..84d85a816 100644 --- a/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs +++ b/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs @@ -12,6 +12,7 @@ using OSPSuite.Core.Serialization.Xml; using OSPSuite.Core.Services; using OSPSuite.Infrastructure.Import.Core; +using OSPSuite.Infrastructure.Import.Core.Exceptions; using OSPSuite.Infrastructure.Import.Core.Mappers; using OSPSuite.Infrastructure.Import.Services; using OSPSuite.Presentation.Presenters.Importer; @@ -316,7 +317,9 @@ public class When_mapping_completed_with_loaded_data_with_wrong_mapping : concer protected override void Because() { - A.CallTo(() => _dataSource.ValidateDataSourceUnits(A>.Ignored)).Throws(); + var errors = new Cache>(); + errors.Add(new DataSet(), new List() { new MismatchingArrayLengthsParseErrorDescription() }); + A.CallTo(() => _dataSource.ValidateDataSourceUnits(A>.Ignored)).Returns(errors); _sheets = new Cache(); _sheets.Add("sheet1", A.Fake()); _importerDataPresenter.OnImportSheets += Raise.With(new ImportSheetsEventArgs() {Filter = "", DataSourceFile = _dataSourceFile, Sheets = _sheets}); From a219c50bbd00c0b10d6b52f372f5d4d1b14e0197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Mon, 17 Jan 2022 11:48:08 +0100 Subject: [PATCH 05/20] Showing error messages and marks --- .../Importer/IImporterDataPresenter.cs | 2 +- .../Importer/ImporterDataPresenter.cs | 4 +- .../Presenters/Importer/ImporterPresenter.cs | 7 +-- .../Views/Importer/IImporterDataView.cs | 2 +- src/OSPSuite.UI/Properties/licenses.licx | 3 ++ .../Importer/ImporterDataView.Designer.cs | 48 +++++++++++++++++-- .../Views/Importer/ImporterDataView.cs | 45 ++++++++++++++--- .../Views/Importer/ImporterDataView.resx | 32 ++++++------- 8 files changed, 108 insertions(+), 35 deletions(-) create mode 100644 src/OSPSuite.UI/Properties/licenses.licx diff --git a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs index bc8e317ae..954dd9821 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs @@ -64,6 +64,6 @@ IReadOnlyList columnInfos void SetFilter(string FilterString); void GetFormatBasedOnCurrentSheet(); void ResetLoadedSheets(); - void SetTabMarks(Cache> errors, IEnumerable loadedSheets); + void SetTabMarks(Cache> errors, Cache loadedDataSets); } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs index 5093f38e9..c2fcf13f7 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs @@ -268,9 +268,9 @@ public void ResetLoadedSheets() View.ResetImportButtons(); } - public void SetTabMarks(Cache> errors, IEnumerable loadedSheets) + public void SetTabMarks(Cache> errors, Cache loadedDataSets) { - + View.SetTabMarks(errors, loadedDataSets); } } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs index 920be96c4..ef0ba060d 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs @@ -210,12 +210,7 @@ private void loadSheets(IDataSourceFile dataSourceFile, Cache var errors = _dataSource.AddSheets(sheets, _columnInfos, filter); validateDataSource(_dataSource).KeyValues.Each(x => CachedListHelpers.Add(errors, x.Key, x.Value)); - if (errors.Any()) - { - //ToDo: mark tabs - _dataSource.DataSets.Keys - throw new ImporterParsingException(errors); - } + _importerDataPresenter.SetTabMarks(errors, _dataSource.DataSets); var keys = new List() { diff --git a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs index e82df101e..1ed83a8ac 100644 --- a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs +++ b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs @@ -21,6 +21,6 @@ public interface IImporterDataView : IView void SetFilter(string filter); string SelectedTab { get; set; } string GetFilter(); - void SetTabMarks(Cache> errors, IEnumerable loadedSheets); + void SetTabMarks(Cache> errors, Cache loadedDataSets); } } diff --git a/src/OSPSuite.UI/Properties/licenses.licx b/src/OSPSuite.UI/Properties/licenses.licx new file mode 100644 index 000000000..b3c81b8b1 --- /dev/null +++ b/src/OSPSuite.UI/Properties/licenses.licx @@ -0,0 +1,3 @@ +DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v21.2, Version=21.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v21.2, Version=21.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a +DevExpress.XtraLayout.LayoutControl, DevExpress.XtraLayout.v21.2, Version=21.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs index 40bf8d40d..59c1762c6 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs @@ -34,6 +34,7 @@ private void InitializeComponent() this.components = new System.ComponentModel.Container(); System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(ImporterDataView)); this.rootLayoutControl = new DevExpress.XtraLayout.LayoutControl(); + this.labelControlError = new DevExpress.XtraEditors.LabelControl(); this.useForImportCheckEdit = new DevExpress.XtraEditors.CheckEdit(); this.btnImport = new DevExpress.XtraEditors.SimpleButton(); this.btnImportAll = new DevExpress.XtraEditors.SimpleButton(); @@ -44,10 +45,12 @@ private void InitializeComponent() this.layoutItemImportCurrent = new DevExpress.XtraLayout.LayoutControlItem(); this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem(); this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem(); + this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem(); this.dataViewingGridControl = new DevExpress.XtraGrid.GridControl(); this.dataViewingGridView = new DevExpress.XtraGrid.Views.Grid.GridView(); this.imageCollection1 = new DevExpress.Utils.ImageCollection(this.components); this.dpiAwareImageCollection1 = new DevExpress.Utils.DPIAwareImageCollection(this.components); + this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rootLayoutControl)).BeginInit(); this.rootLayoutControl.SuspendLayout(); @@ -59,14 +62,17 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.layoutItemImportCurrent)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridControl)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridView)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.imageCollection1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dpiAwareImageCollection1)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit(); this.SuspendLayout(); // // rootLayoutControl // + this.rootLayoutControl.Controls.Add(this.labelControlError); this.rootLayoutControl.Controls.Add(this.useForImportCheckEdit); this.rootLayoutControl.Controls.Add(this.btnImport); this.rootLayoutControl.Controls.Add(this.btnImportAll); @@ -81,6 +87,17 @@ private void InitializeComponent() this.rootLayoutControl.TabIndex = 0; this.rootLayoutControl.Text = "rootLayoutControl"; // + // labelControlError + // + this.labelControlError.Appearance.ForeColor = System.Drawing.Color.Red; + this.labelControlError.Appearance.Options.UseForeColor = true; + this.labelControlError.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Vertical; + this.labelControlError.Location = new System.Drawing.Point(2, 951); + this.labelControlError.Name = "labelControlError"; + this.labelControlError.Size = new System.Drawing.Size(1453, 16); + this.labelControlError.StyleController = this.rootLayoutControl; + this.labelControlError.TabIndex = 12; + // // useForImportCheckEdit // this.useForImportCheckEdit.AllowHtmlTextInToolTip = DevExpress.Utils.DefaultBoolean.True; @@ -118,7 +135,7 @@ private void InitializeComponent() this.importerTabControl.Location = new System.Drawing.Point(2, 2); this.importerTabControl.Margin = new System.Windows.Forms.Padding(3, 4, 3, 4); this.importerTabControl.Name = "importerTabControl"; - this.importerTabControl.Size = new System.Drawing.Size(1453, 1015); + this.importerTabControl.Size = new System.Drawing.Size(1453, 945); this.importerTabControl.TabIndex = 5; // // Root @@ -130,7 +147,9 @@ private void InitializeComponent() this.layoutItemImportAll, this.layoutItemImportCurrent, this.emptySpaceItem1, - this.layoutControlItem1}); + this.layoutControlItem1, + this.layoutControlItem2, + this.emptySpaceItem2}); this.Root.Name = "Root"; this.Root.Padding = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0); this.Root.Size = new System.Drawing.Size(1457, 1050); @@ -141,7 +160,7 @@ private void InitializeComponent() this.importerLayoutControlItem.Control = this.importerTabControl; this.importerLayoutControlItem.Location = new System.Drawing.Point(0, 0); this.importerLayoutControlItem.Name = "importerLayoutControlItem"; - this.importerLayoutControlItem.Size = new System.Drawing.Size(1457, 1019); + this.importerLayoutControlItem.Size = new System.Drawing.Size(1457, 949); this.importerLayoutControlItem.TextSize = new System.Drawing.Size(0, 0); this.importerLayoutControlItem.TextVisible = false; // @@ -181,6 +200,16 @@ private void InitializeComponent() this.layoutControlItem1.TextSize = new System.Drawing.Size(0, 0); this.layoutControlItem1.TextVisible = false; // + // layoutControlItem2 + // + this.layoutControlItem2.Control = this.labelControlError; + this.layoutControlItem2.Location = new System.Drawing.Point(0, 949); + this.layoutControlItem2.Name = "layoutControlItem2"; + this.layoutControlItem2.Size = new System.Drawing.Size(1457, 20); + this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0); + this.layoutControlItem2.TextVisible = false; + this.layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; + // // dataViewingGridControl // this.dataViewingGridControl.Dock = System.Windows.Forms.DockStyle.Fill; @@ -209,6 +238,14 @@ private void InitializeComponent() this.dpiAwareImageCollection1.Owner = this; this.dpiAwareImageCollection1.Stream = ((DevExpress.Utils.DPIAwareImageCollectionStreamer)(resources.GetObject("dpiAwareImageCollection1.Stream"))); // + // emptySpaceItem2 + // + this.emptySpaceItem2.AllowHotTrack = false; + this.emptySpaceItem2.Location = new System.Drawing.Point(0, 969); + this.emptySpaceItem2.Name = "emptySpaceItem2"; + this.emptySpaceItem2.Size = new System.Drawing.Size(1457, 50); + this.emptySpaceItem2.TextSize = new System.Drawing.Size(0, 0); + // // ImporterDataView // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); @@ -228,10 +265,12 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.layoutItemImportCurrent)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridControl)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridView)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.imageCollection1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dpiAwareImageCollection1)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit(); this.ResumeLayout(false); } @@ -253,5 +292,8 @@ private void InitializeComponent() private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1; private ImageCollection imageCollection1; private DPIAwareImageCollection dpiAwareImageCollection1; + private DevExpress.XtraEditors.LabelControl labelControlError; + private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2; + private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2; } } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs index 9b1be3b7f..2bb91fe01 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs @@ -28,6 +28,8 @@ public partial class ImporterDataView : BaseUserControl, IImporterDataView private bool sheetImportedFlag; private bool allSheetsImportedFlag; private bool allImportButtonsDisabledFlag; + private Cache> _lastErrors = new Cache>(); + private Cache _lastLoadedDataSets = new Cache(); public ImporterDataView() { @@ -227,7 +229,6 @@ public string GetActiveFilterCriteria() public void AddTabs(List sheetNames) { importerTabControl.Images = imageCollection1; - //we should seek an alternative foreach (var sheetName in sheetNames) importerTabControl.TabPages.Add(sheetName); @@ -289,18 +290,50 @@ public void SetFilter(string filter) useForImportCheckEdit.Checked = true; } - public string SelectedTab { get; set; } + private string _selectedTab; + public string SelectedTab { + get => _selectedTab; + set + { + _selectedTab = value; + refreshErrorMessage(); + } + } public string GetFilter() { return DevExpress.Data.Filtering.CriteriaToWhereClauseHelper.GetDataSetWhere(dataViewingGridView.ActiveFilterCriteria); } - public void SetTabMarks(Cache> errors, Cache loadedSheets) + private void refreshErrorMessage() + { + + if (_lastLoadedDataSets.Contains(SelectedTab) && _lastErrors.Contains(_lastLoadedDataSets[SelectedTab])) + { + labelControlError.Text = Error.ParseErrorMessage(_lastErrors[_lastLoadedDataSets[SelectedTab]].Select(x => x.Message)); + layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; + } + else + { + labelControlError.Text = ""; + layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; + } + } + + public void SetTabMarks(Cache> errors, Cache loadedDataSets) { - importerTabControl.TabPages.Each((x, i) => + _lastErrors = errors; + _lastLoadedDataSets = loadedDataSets; + refreshErrorMessage(); + + importerTabControl.TabPages.Each(x => { - if (errors.Contains(x)) - x.ImageIndex = 0 + if (loadedDataSets.Contains(x.Text)) + { + x.ImageIndex = errors.Contains(loadedDataSets[x.Text]) ? 1 : 0; + return; + } + + x.ImageIndex = -1; }); } } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx b/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx index 6a3714624..bca4f022b 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx @@ -135,22 +135,22 @@ a2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAAChEZXZFeHByZXNzLlV0aWxzLkltYWdlQ29sbGVjdGlvblN0 cmVhbWVyAgAAAAlJbWFnZVNpemUERGF0YQQHE1N5c3RlbS5EcmF3aW5nLlNpemUDAAAAAgIAAAAF/P// /xNTeXN0ZW0uRHJhd2luZy5TaXplAgAAAAV3aWR0aAZoZWlnaHQAAAgIAwAAABAAAAAQAAAACQUAAAAP - BQAAALIDAA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GSevcF8vMOCRvsAYEJt/U0v + WN6MCP5mBA9NRR76vFpDTRUt0ms5d2VFU/ct50xVMm5I41YEfHsYe6i0mPN9+1RVAfqhE+oNDUULWVgI + Cf9jMEi9l/WVRTGAeehLmKOvj0MtPUSWNXpA7FtvMASoaIOL1udVTNJdXVIrCbWqaZYLkgA1xw0uc4jG + LHNB5NpbpsnVRTVVk1xWpwsZLui3rXpxI39mTXYnmeQl5sx8+XyuolYS83XEgNGf9y6MwivIM5t3ossJ + wY9iAAvtmjZfry9EyLwwPeT55Dj1OoTMiAGcmDhH44V/5eN9Vc3oueiwNGwoIWhPVYpQjGcjFz2VFZmL + Hug2TKnoCIAfQmzsw53qs4QAAAAASUVORK5CYIIL From 50be51b72123191954bcb13ee54325c8cde62308 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Mon, 17 Jan 2022 13:10:53 +0100 Subject: [PATCH 06/20] Updating error message --- src/OSPSuite.Assets/UIConstants.cs | 2 ++ .../Core/ImporterParsingException.cs | 2 +- .../Presenters/Importer/ImporterPresenter.cs | 5 +++++ .../Views/Importer/ImporterDataView.cs | 19 ++++++++++++------- 4 files changed, 20 insertions(+), 8 deletions(-) diff --git a/src/OSPSuite.Assets/UIConstants.cs b/src/OSPSuite.Assets/UIConstants.cs index 2918dca50..aded6eab1 100644 --- a/src/OSPSuite.Assets/UIConstants.cs +++ b/src/OSPSuite.Assets/UIConstants.cs @@ -1277,6 +1277,8 @@ public static class Error public static readonly string NaNOnData = "Data contains NaN values at imported columns. Select a different action for NaN values or clean your data."; public static readonly string UnsupportedFileType = "The type of file that you are trying to open is not currently supported"; public static readonly string CannotRemoveBaseGridColumnStillInUse = "Cannot remove base grid column still used by other columns"; + public static readonly string SimpleParseErrorMessage = "There were errors while parsing your data. Navigate to the sheets to read the concrete error."; + public static string ParseErrorMessage(IEnumerable errors) => "There were errors while parsing your data: " + string.Join(". ", errors); public static string ErrorWhenPlottingDataRepository(int sheetName, string exceptionMessage) => $"Plotting data set number:{sheetName} produced the following error: {exceptionMessage}"; diff --git a/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs b/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs index 2bcd5310d..c1ea52069 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs @@ -11,7 +11,7 @@ public class ImporterParsingException : AbstractImporterException public Cache>FaultyDataSet { get; private set; } public ImporterParsingException(Cache> faultyDataSets) - : base(Error.ParseErrorMessage(faultyDataSets.KeyValues.SelectMany(x => x.Value.Select(y => $"{x.Key} => {y.Message}")))) + : base(Error.SimpleParseErrorMessage) { FaultyDataSet = faultyDataSets; } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs index ef0ba060d..bfa694b7c 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs @@ -211,6 +211,11 @@ private void loadSheets(IDataSourceFile dataSourceFile, Cache validateDataSource(_dataSource).KeyValues.Each(x => CachedListHelpers.Add(errors, x.Key, x.Value)); _importerDataPresenter.SetTabMarks(errors, _dataSource.DataSets); + if (errors.Any()) + { + throw new ImporterParsingException(errors); + } + var keys = new List() { diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs index 2bb91fe01..a0afb6e96 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs @@ -233,6 +233,7 @@ public void AddTabs(List sheetNames) importerTabControl.TabPages.Add(sheetName); hideCloseButtonForSingleTab(); + refreshErrorMarks(); } private void hideCloseButtonForSingleTab() @@ -319,22 +320,26 @@ private void refreshErrorMessage() } } - public void SetTabMarks(Cache> errors, Cache loadedDataSets) + private void refreshErrorMarks() { - _lastErrors = errors; - _lastLoadedDataSets = loadedDataSets; - refreshErrorMessage(); - importerTabControl.TabPages.Each(x => { - if (loadedDataSets.Contains(x.Text)) + if (_lastLoadedDataSets.Contains(x.Text)) { - x.ImageIndex = errors.Contains(loadedDataSets[x.Text]) ? 1 : 0; + x.ImageIndex = _lastErrors.Contains(_lastLoadedDataSets[x.Text]) ? 1 : 0; return; } x.ImageIndex = -1; }); } + + public void SetTabMarks(Cache> errors, Cache loadedDataSets) + { + _lastErrors = errors; + _lastLoadedDataSets = loadedDataSets; + refreshErrorMessage(); + refreshErrorMarks(); + } } } From 1421907daaa3e057811a7fc90af2b4fa5aa292ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Mon, 17 Jan 2022 13:30:27 +0100 Subject: [PATCH 07/20] Fixing test --- .../Importer/Presenters/ImporterPresenterSpecs.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs b/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs index 84d85a816..c1a77be47 100644 --- a/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs +++ b/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs @@ -319,7 +319,7 @@ protected override void Because() { var errors = new Cache>(); errors.Add(new DataSet(), new List() { new MismatchingArrayLengthsParseErrorDescription() }); - A.CallTo(() => _dataSource.ValidateDataSourceUnits(A>.Ignored)).Returns(errors); + A.CallTo(() => _dataSource.AddSheets(A>.Ignored, A>.Ignored, A.Ignored)).Returns(errors); _sheets = new Cache(); _sheets.Add("sheet1", A.Fake()); _importerDataPresenter.OnImportSheets += Raise.With(new ImportSheetsEventArgs() {Filter = "", DataSourceFile = _dataSourceFile, Sheets = _sheets}); From 86eacc72eb00aa1de7409758ec3ec60e251cedd8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Fri, 28 Jan 2022 14:19:17 +0100 Subject: [PATCH 08/20] CalculateFormat does not have side effects --- src/OSPSuite.Dimensions | 2 +- .../Core/DataSourceFile.cs | 12 +++++++++++- .../Services/IDataImporter.cs | 2 +- .../Services/Importer.cs | 7 +++---- .../Presenters/Importer/ImporterDataPresenter.cs | 2 +- 5 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/OSPSuite.Dimensions b/src/OSPSuite.Dimensions index 067cccc17..4f2fb135f 160000 --- a/src/OSPSuite.Dimensions +++ b/src/OSPSuite.Dimensions @@ -1 +1 @@ -Subproject commit 067cccc17df5677782f3c292d0fa0ae4e4295ef1 +Subproject commit 4f2fb135f7d22447d0b15a66e6db5123576ba446 diff --git a/src/OSPSuite.Infrastructure.Import/Core/DataSourceFile.cs b/src/OSPSuite.Infrastructure.Import/Core/DataSourceFile.cs index 95bfc817e..fce250758 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/DataSourceFile.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/DataSourceFile.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Linq; using OSPSuite.Infrastructure.Import.Services; using OSPSuite.Utility.Collections; @@ -23,7 +24,16 @@ public abstract class DataSourceFile : IDataSourceFile public IDataFormat Format { get; set; } - public IList AvailableFormats { get; set; } + private IList _availableFormats; + public IList AvailableFormats + { + get => _availableFormats; + set + { + _availableFormats = value; + Format = value.FirstOrDefault(); + } + } protected DataSourceFile(IImportLogger logger) { diff --git a/src/OSPSuite.Infrastructure.Import/Services/IDataImporter.cs b/src/OSPSuite.Infrastructure.Import/Services/IDataImporter.cs index e0a1556b7..9a1ec9dfc 100644 --- a/src/OSPSuite.Infrastructure.Import/Services/IDataImporter.cs +++ b/src/OSPSuite.Infrastructure.Import/Services/IDataImporter.cs @@ -109,7 +109,7 @@ public ImporterConfiguration ConfigurationFromData(string dataPath, IReadOnlyLis var dataSourceFile = _importer.LoadFile(columnInfos, dataPath, metaDataCategories); if (!string.IsNullOrEmpty(sheetName)) { - _importer.CalculateFormat(dataSourceFile, columnInfos, metaDataCategories, sheetName); + dataSourceFile.AvailableFormats = _importer.CalculateFormat(dataSourceFile, columnInfos, metaDataCategories, sheetName).ToList(); } configuration.CloneParametersFrom(dataSourceFile.Format.Parameters.ToList()); diff --git a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs index a89ad7977..b8b712de6 100644 --- a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs +++ b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs @@ -44,7 +44,7 @@ IReadOnlyList DataSourceToDataSets(IDataSo DataImporterSettings dataImporterSettings ); - void CalculateFormat(IDataSourceFile dataSource, IReadOnlyList columnInfos, IReadOnlyList metaDataCategories, string sheetName); + IEnumerable CalculateFormat(IDataSourceFile dataSource, IReadOnlyList columnInfos, IReadOnlyList metaDataCategories, string sheetName); } public class Importer : IImporter @@ -113,13 +113,12 @@ public IDataSourceFile LoadFile(IReadOnlyList columnInfos, string fi throw new UnsupportedFormatException(dataSource.Path); } - public void CalculateFormat(IDataSourceFile dataSource, IReadOnlyList columnInfos, IReadOnlyList metaDataCategories, string sheetName) + public IEnumerable CalculateFormat(IDataSourceFile dataSource, IReadOnlyList columnInfos, IReadOnlyList metaDataCategories, string sheetName) { if (sheetName == null) throw new UnsupportedFormatException(dataSource.Path); - dataSource.AvailableFormats = AvailableFormats(dataSource.DataSheets[sheetName].RawData, columnInfos, metaDataCategories).ToList(); - dataSource.Format = dataSource.AvailableFormats.FirstOrDefault(); + return AvailableFormats(dataSource.DataSheets[sheetName].RawData, columnInfos, metaDataCategories); } public IEnumerable NamesFromConvention diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs index c2fcf13f7..18393bb96 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs @@ -257,7 +257,7 @@ public string GetActiveFilterCriteria() public void GetFormatBasedOnCurrentSheet() { - _importer.CalculateFormat(_dataSourceFile, _columnInfos, _metaDataCategories, _currentSheetName); + _dataSourceFile.AvailableFormats = _importer.CalculateFormat(_dataSourceFile, _columnInfos, _metaDataCategories, _currentSheetName).ToList(); ResetLoadedSheets(); SetDataFormat(_dataSourceFile.Format, _dataSourceFile.AvailableFormats); } From d76ef41e05a2a069f26bdd77b7867490cad966e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Fri, 28 Jan 2022 15:04:20 +0100 Subject: [PATCH 09/20] Fixing tests --- src/OSPSuite.Infrastructure.Import/Services/Importer.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs index b8b712de6..468d71f12 100644 --- a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs +++ b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs @@ -105,7 +105,7 @@ public IDataSourceFile LoadFile(IReadOnlyList columnInfos, string fi foreach(var x in dataSource.DataSheets.Keys) { - CalculateFormat(dataSource, columnInfos, metaDataCategories, x); + dataSource.AvailableFormats = CalculateFormat(dataSource, columnInfos, metaDataCategories, x).ToList(); if (dataSource.AvailableFormats?.Count > 0) return dataSource; }; From 2a41306b56d2f778aeb4d38a04513d19ff690345 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Fri, 4 Feb 2022 09:59:17 +0100 Subject: [PATCH 10/20] Using string interpolation --- src/OSPSuite.Assets/UIConstants.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/OSPSuite.Assets/UIConstants.cs b/src/OSPSuite.Assets/UIConstants.cs index aded6eab1..7719f818e 100644 --- a/src/OSPSuite.Assets/UIConstants.cs +++ b/src/OSPSuite.Assets/UIConstants.cs @@ -1279,7 +1279,7 @@ public static class Error public static readonly string CannotRemoveBaseGridColumnStillInUse = "Cannot remove base grid column still used by other columns"; public static readonly string SimpleParseErrorMessage = "There were errors while parsing your data. Navigate to the sheets to read the concrete error."; - public static string ParseErrorMessage(IEnumerable errors) => "There were errors while parsing your data: " + string.Join(". ", errors); + public static string ParseErrorMessage(IEnumerable errors) => $"There were errors while parsing your data: {string.Join(". ", errors)}"; public static string ErrorWhenPlottingDataRepository(int sheetName, string exceptionMessage) => $"Plotting data set number:{sheetName} produced the following error: {exceptionMessage}"; From aa1c1f8ee0559bb24632437f57341602c31581e0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Fri, 4 Feb 2022 13:43:16 +0100 Subject: [PATCH 11/20] Changing return type from Cache to a new class --- .../Core/DataSource.cs | 66 ++++++++++++++----- .../Core/ImporterParsingException.cs | 4 +- .../Importer/IImporterDataPresenter.cs | 2 +- .../Importer/ImporterDataPresenter.cs | 2 +- .../Presenters/Importer/ImporterPresenter.cs | 4 +- .../Views/Importer/IImporterDataView.cs | 2 +- .../Views/Importer/ImporterDataView.cs | 6 +- .../Import/DataSourceSpecs.cs | 10 +-- .../Presenters/ImporterPresenterSpecs.cs | 2 +- 9 files changed, 65 insertions(+), 33 deletions(-) diff --git a/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs b/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs index f68191f27..3ac6488b9 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs @@ -12,6 +12,38 @@ namespace OSPSuite.Infrastructure.Import.Core { + public class ParseErrors + { + private Cache> _errors = new Cache>(onMissingKey: _ => new List()); + + public bool Any() => _errors.Any(); + + public bool Contains(IDataSet key) => _errors.Contains(key); + + public IEnumerable ErrorsFor(IDataSet key) => _errors[key]; + + public void Add(IDataSet key, ParseErrorDescription x) + { + Add(key, new List() { x }); + } + + public void Add(ParseErrors other) + { + foreach (var x in other._errors.KeyValues) + { + Add(x.Key, x.Value); + } + } + + public void Add(IDataSet key, IEnumerable list) + { + if (_errors.Contains(key)) + _errors[key].AddRange(list); + else + _errors.Add(key, new List(list)); + } + } + /// /// Collection of DataSets /// @@ -19,7 +51,7 @@ public interface IDataSource { void SetDataFormat(IDataFormat dataFormat); void SetNamingConvention(string namingConvention); - Cache> AddSheets(Cache dataSheets, IReadOnlyList columnInfos, string filter); + ParseErrors AddSheets(Cache dataSheets, IReadOnlyList columnInfos, string filter); void SetMappings(string fileName, IEnumerable mappings); ImporterConfiguration GetImporterConfiguration(); IEnumerable GetMappings(); @@ -27,7 +59,7 @@ public interface IDataSource IEnumerable NamesFromConvention(); NanSettings NanSettings { get; set; } ImportedDataSet DataSetAt(int index); - Cache> ValidateDataSourceUnits(IReadOnlyList columnInfos); + ParseErrors ValidateDataSourceUnits(IReadOnlyList columnInfos); } public class DataSource : IDataSource @@ -75,18 +107,18 @@ private Cache filterSheets(Cache dataSheet return filteredDataSheets; } - public Cache> AddSheets(Cache dataSheets, IReadOnlyList columnInfos, string filter) + public ParseErrors AddSheets(Cache dataSheets, IReadOnlyList columnInfos, string filter) { _importer.AddFromFile(_configuration.Format, filterSheets(dataSheets, filter), columnInfos, this); if (NanSettings == null || !double.TryParse(NanSettings.Indicator, out var indicator)) indicator = double.NaN; - var errors = new Cache>(); + var errors = new ParseErrors(); foreach (var dataSet in DataSets.KeyValues) { if (NanSettings != null && NanSettings.Action == NanSettings.ActionType.Throw) { if (dataSet.Value.NanValuesExist(indicator)) - CachedListHelpers.Add(errors, dataSet.Value, new NaNParseErrorDescription()); + errors.Add(dataSet.Value, new NaNParseErrorDescription()); } else { @@ -96,7 +128,7 @@ public Cache> AddSheets(Cache string.Join(".", d.Description.Where(metaData => metaData.Value != null).Select(metaData => metaData.Value))); - CachedListHelpers.Add(errors, dataSet.Value, new EmptyDataSetsParseErrorDescription(emptyDataSetsNames)); + errors.Add(dataSet.Value, new EmptyDataSetsParseErrorDescription(emptyDataSetsNames)); } } return errors; @@ -151,9 +183,9 @@ public ImportedDataSet DataSetAt(int index) } //checks that the dimension of all the units coming from columns for error have the same dimension to the corresponding measurement - private Cache> validateErrorAgainstMeasurement(IReadOnlyList columnInfos) + private ParseErrors validateErrorAgainstMeasurement(IReadOnlyList columnInfos) { - var errors = new Cache>(); + var errors = new ParseErrors(); foreach (var column in columnInfos.Where(c => !c.IsAuxiliary())) { foreach (var relatedColumn in columnInfos.Where(c => c.IsAuxiliary() && c.RelatedColumnOf == column.Name)) @@ -170,7 +202,7 @@ private Cache> validateErrorAgainstMeasure if (errorColumn.Value != null && measurementColumn.Value.Count != errorColumn.Value.Count) { - CachedListHelpers.Add(errors, dataSet, new MismatchingArrayLengthsParseErrorDescription()); + errors.Add(dataSet, new MismatchingArrayLengthsParseErrorDescription()); continue; } @@ -188,7 +220,7 @@ private Cache> validateErrorAgainstMeasure var errorSupportedDimension = column.SupportedDimensions.FirstOrDefault(x => x.HasUnit(errorColumn.Value.ElementAt(i).Unit)); if (measurementSupportedDimension != errorSupportedDimension) { - CachedListHelpers.Add(errors, dataSet, new ErrorUnitParseErrorDescription()); + errors.Add(dataSet, new ErrorUnitParseErrorDescription()); continue; } } @@ -203,7 +235,7 @@ private Cache> validateErrorAgainstMeasure if (measurementDimension != errorDimension) { - CachedListHelpers.Add(errors, dataSet, new ErrorUnitParseErrorDescription()); + errors.Add(dataSet, new ErrorUnitParseErrorDescription()); continue; } } @@ -215,9 +247,9 @@ private Cache> validateErrorAgainstMeasure } //checks that all units coming from a mapped column unit belong to a valid dimension for this mapping //and also that they are all of the same dimension within every data set. - private Cache> validateUnitsSupportedAndSameDimension(IReadOnlyList columnInfos) + private ParseErrors validateUnitsSupportedAndSameDimension(IReadOnlyList columnInfos) { - var errors = new Cache>(); + var errors = new ParseErrors(); foreach (var columnInfo in columnInfos) { foreach (var dataSet in DataSets) @@ -246,14 +278,14 @@ private Cache> validateUnitsSupportedAndSa //if the unit specified does not belong to one of the supported dimensions of the mapping if (dimension == null) { - CachedListHelpers.Add(errors, dataSet, new InvalidDimensionParseErrorDescription(currentValue.Unit, columnInfo.DisplayName)); + errors.Add(dataSet, new InvalidDimensionParseErrorDescription(currentValue.Unit, columnInfo.DisplayName)); continue; } //if the unit specified is not of the same dimension as the other units of the same data set if (dimension != dimensionOfFirstUnit) { - CachedListHelpers.Add(errors, dataSet, new InconsistentDimensionBetweenUnitsParseErrorDescription(columnInfo.DisplayName)); + errors.Add(dataSet, new InconsistentDimensionBetweenUnitsParseErrorDescription(columnInfo.DisplayName)); continue; } } @@ -264,10 +296,10 @@ private Cache> validateUnitsSupportedAndSa return errors; } - Cache> IDataSource.ValidateDataSourceUnits(IReadOnlyList columnInfos) + ParseErrors IDataSource.ValidateDataSourceUnits(IReadOnlyList columnInfos) { var errors = validateUnitsSupportedAndSameDimension(columnInfos); - validateErrorAgainstMeasurement(columnInfos).KeyValues.Each(x => CachedListHelpers.Add(errors, x.Key, x.Value)); + errors.Add(validateErrorAgainstMeasurement(columnInfos)); return errors; } } diff --git a/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs b/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs index c1ea52069..115a6e2af 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/ImporterParsingException.cs @@ -8,9 +8,9 @@ namespace OSPSuite.Infrastructure.Import.Core { public class ImporterParsingException : AbstractImporterException { - public Cache>FaultyDataSet { get; private set; } + public ParseErrors FaultyDataSet { get; private set; } - public ImporterParsingException(Cache> faultyDataSets) + public ImporterParsingException(ParseErrors faultyDataSets) : base(Error.SimpleParseErrorMessage) { FaultyDataSet = faultyDataSets; diff --git a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs index 954dd9821..b9264ba74 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs @@ -64,6 +64,6 @@ IReadOnlyList columnInfos void SetFilter(string FilterString); void GetFormatBasedOnCurrentSheet(); void ResetLoadedSheets(); - void SetTabMarks(Cache> errors, Cache loadedDataSets); + void SetTabMarks(ParseErrors errors, Cache loadedDataSets); } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs index 18393bb96..05f2d8394 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs @@ -268,7 +268,7 @@ public void ResetLoadedSheets() View.ResetImportButtons(); } - public void SetTabMarks(Cache> errors, Cache loadedDataSets) + public void SetTabMarks(ParseErrors errors, Cache loadedDataSets) { View.SetTabMarks(errors, loadedDataSets); } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs index bfa694b7c..edb5ac909 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs @@ -178,7 +178,7 @@ private void loadSheetsFromDataPresenter(object sender, ImportSheetsEventArgs ar } } - private Cache> validateDataSource(IDataSource dataSource) + private ParseErrors validateDataSource(IDataSource dataSource) { return dataSource.ValidateDataSourceUnits(_columnInfos); } @@ -209,7 +209,7 @@ private void loadSheets(IDataSourceFile dataSourceFile, Cache _dataSource.SetDataFormat(_columnMappingPresenter.GetDataFormat()); var errors = _dataSource.AddSheets(sheets, _columnInfos, filter); - validateDataSource(_dataSource).KeyValues.Each(x => CachedListHelpers.Add(errors, x.Key, x.Value)); + errors.Add(validateDataSource(_dataSource)); _importerDataPresenter.SetTabMarks(errors, _dataSource.DataSets); if (errors.Any()) { diff --git a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs index 1ed83a8ac..b959de3ee 100644 --- a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs +++ b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs @@ -21,6 +21,6 @@ public interface IImporterDataView : IView void SetFilter(string filter); string SelectedTab { get; set; } string GetFilter(); - void SetTabMarks(Cache> errors, Cache loadedDataSets); + void SetTabMarks(ParseErrors errors, Cache loadedDataSets); } } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs index a0afb6e96..43e8b2154 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs @@ -28,7 +28,7 @@ public partial class ImporterDataView : BaseUserControl, IImporterDataView private bool sheetImportedFlag; private bool allSheetsImportedFlag; private bool allImportButtonsDisabledFlag; - private Cache> _lastErrors = new Cache>(); + private ParseErrors _lastErrors = new ParseErrors(); private Cache _lastLoadedDataSets = new Cache(); public ImporterDataView() @@ -310,7 +310,7 @@ private void refreshErrorMessage() if (_lastLoadedDataSets.Contains(SelectedTab) && _lastErrors.Contains(_lastLoadedDataSets[SelectedTab])) { - labelControlError.Text = Error.ParseErrorMessage(_lastErrors[_lastLoadedDataSets[SelectedTab]].Select(x => x.Message)); + labelControlError.Text = Error.ParseErrorMessage(_lastErrors.ErrorsFor(_lastLoadedDataSets[SelectedTab]).Select(x => x.Message)); layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; } else @@ -334,7 +334,7 @@ private void refreshErrorMarks() }); } - public void SetTabMarks(Cache> errors, Cache loadedDataSets) + public void SetTabMarks(ParseErrors errors, Cache loadedDataSets) { _lastErrors = errors; _lastLoadedDataSets = loadedDataSets; diff --git a/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs b/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs index 5233d8715..6c058fb2e 100644 --- a/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs +++ b/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs @@ -233,7 +233,7 @@ public void throw_on_empty_dataset() { var sheets = new Cache(); sheets.Add("sheet1", new DataSheet() { RawData = new UnformattedData() }); - sut.AddSheets(sheets, _columnInfos, "").ShouldNotBeEmpty(); + sut.AddSheets(sheets, _columnInfos, "").Any().ShouldBeFalse(); } } public class When_validating_geometric_error : concern_for_DataSource @@ -729,7 +729,7 @@ protected override void Because() [Observation] public void should_not_be_valid() { - sut.ValidateDataSourceUnits(_columnInfos).ShouldNotBeEmpty(); + sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeFalse(); } } @@ -819,7 +819,7 @@ protected override void Because() [Observation] public void should_be_valid() { - sut.ValidateDataSourceUnits(_columnInfos).ShouldNotBeEmpty(); + sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeFalse(); } } @@ -892,7 +892,7 @@ protected override void Because() [Observation] public void should_be_valid() { - sut.ValidateDataSourceUnits(_columnInfos).ShouldNotBeEmpty(); + sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeFalse(); } } @@ -965,7 +965,7 @@ protected override void Because() [Observation] public void should_be_valid() { - sut.ValidateDataSourceUnits(_columnInfos).ShouldNotBeEmpty(); + sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeFalse(); } } } \ No newline at end of file diff --git a/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs b/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs index c1a77be47..8cfdb86ab 100644 --- a/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs +++ b/tests/OSPSuite.Presentation.Tests/Importer/Presenters/ImporterPresenterSpecs.cs @@ -317,7 +317,7 @@ public class When_mapping_completed_with_loaded_data_with_wrong_mapping : concer protected override void Because() { - var errors = new Cache>(); + var errors = new ParseErrors(); errors.Add(new DataSet(), new List() { new MismatchingArrayLengthsParseErrorDescription() }); A.CallTo(() => _dataSource.AddSheets(A>.Ignored, A>.Ignored, A.Ignored)).Returns(errors); _sheets = new Cache(); From 4ea57b1f5220bef2b3b9780eb964c5a8eabd3cd2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Fri, 4 Feb 2022 14:15:35 +0100 Subject: [PATCH 12/20] Misc changes --- .../Core/Exceptions/ParseErrorDescription.cs | 3 ++- .../Core/IDataSet.cs | 14 +++++++++++++- .../Services/Importer.cs | 2 +- 3 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs b/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs index ed9cdd821..2cbc50d0a 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs @@ -1,4 +1,5 @@ using OSPSuite.Assets; +using OSPSuite.Utility.Extensions; using System.Collections.Generic; namespace OSPSuite.Infrastructure.Import.Core.Exceptions @@ -60,7 +61,7 @@ public class EmptyDataSetsParseErrorDescription : ParseErrorDescription { public EmptyDataSetsParseErrorDescription(IEnumerable dataSetNames) { - Message = Error.EmptyDataSet($"{string.Join(", ", dataSetNames)}"); + Message = Error.EmptyDataSet($"{dataSetNames.ToString(", ")}"); } } } diff --git a/src/OSPSuite.Infrastructure.Import/Core/IDataSet.cs b/src/OSPSuite.Infrastructure.Import/Core/IDataSet.cs index 0ea7d3ebd..6528525ac 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/IDataSet.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/IDataSet.cs @@ -37,7 +37,19 @@ public void AddData(IEnumerable range) public bool NanValuesExist(double indicator) { - return _data.Any(dataSet => dataSet.Data.Any(pair => pair.Key.ColumnInfo.IsMandatory && pair.Value.Any(point => point.Measurement == indicator || double.IsNaN(point.Measurement)))); + //returns true if for any ParsedDataSet + return _data.Any( + //any SimulationPoint + dataSet => dataSet.Data.Any( + //belonging to a mandatory column + pair => pair.Key.ColumnInfo.IsMandatory && + //is NaN or marked as NaN + pair.Value.Any( + point => point.Measurement == indicator || + double.IsNaN(point.Measurement) + ) + ) + ); } public void ClearNan(double indicator) diff --git a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs index 468d71f12..ac7fd0aae 100644 --- a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs +++ b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs @@ -106,7 +106,7 @@ public IDataSourceFile LoadFile(IReadOnlyList columnInfos, string fi foreach(var x in dataSource.DataSheets.Keys) { dataSource.AvailableFormats = CalculateFormat(dataSource, columnInfos, metaDataCategories, x).ToList(); - if (dataSource.AvailableFormats?.Count > 0) + if (dataSource.AvailableFormats.Any()) return dataSource; }; From cb2c8a3296a313a5456727341521a19466800dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Fri, 4 Feb 2022 14:29:52 +0100 Subject: [PATCH 13/20] Fixing test --- .../Import/DataSourceSpecs.cs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs b/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs index 6c058fb2e..e013644da 100644 --- a/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs +++ b/tests/OSPSuite.Infrastructure.Tests/Import/DataSourceSpecs.cs @@ -233,7 +233,7 @@ public void throw_on_empty_dataset() { var sheets = new Cache(); sheets.Add("sheet1", new DataSheet() { RawData = new UnformattedData() }); - sut.AddSheets(sheets, _columnInfos, "").Any().ShouldBeFalse(); + sut.AddSheets(sheets, _columnInfos, "").Any().ShouldBeTrue(); } } public class When_validating_geometric_error : concern_for_DataSource @@ -729,7 +729,7 @@ protected override void Because() [Observation] public void should_not_be_valid() { - sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeFalse(); + sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeTrue(); } } @@ -819,7 +819,7 @@ protected override void Because() [Observation] public void should_be_valid() { - sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeFalse(); + sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeTrue(); } } @@ -892,7 +892,7 @@ protected override void Because() [Observation] public void should_be_valid() { - sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeFalse(); + sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeTrue(); } } @@ -965,7 +965,7 @@ protected override void Because() [Observation] public void should_be_valid() { - sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeFalse(); + sut.ValidateDataSourceUnits(_columnInfos).Any().ShouldBeTrue(); } } } \ No newline at end of file From 066441e47e5803a57c149d0e98d51f9214ddbe8e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Fri, 4 Feb 2022 14:53:29 +0100 Subject: [PATCH 14/20] fixing tests --- tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs b/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs index 5936d7dbf..634115833 100644 --- a/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs +++ b/tests/OSPSuite.R.Tests/Services/DataImporterTaskSpecs.cs @@ -301,9 +301,9 @@ public void should_get_add_and_remove_all_loaded_sheets_from_single_string() public void should_consider_columns_with_string_values_and_skip_invalid_sheets() { var configuration = sut.CreateConfigurationFor(getFileFullName("BookStrings.xlsx")); - configuration.Parameters.Exists(x => (x as MappingDataFormatParameter).ColumnName == "Time [h]").ShouldBeTrue(); - configuration.Parameters.Exists(x => (x as MappingDataFormatParameter).ColumnName == "Measurement [mg/l]").ShouldBeTrue(); - configuration.Parameters.Exists(x => (x as MappingDataFormatParameter).ColumnName == "Error [mg/l]").ShouldBeTrue(); + configuration.Parameters.Any(x => (x as MappingDataFormatParameter).ColumnName == "Time [h]").ShouldBeTrue(); + configuration.Parameters.Any(x => (x as MappingDataFormatParameter).ColumnName == "Measurement [mg/l]").ShouldBeTrue(); + configuration.Parameters.Any(x => (x as MappingDataFormatParameter).ColumnName == "Error [mg/l]").ShouldBeTrue(); } } } From bb32d68a03a2a9eb1d1169061d0e5255f555a4fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Fri, 4 Feb 2022 15:08:02 +0100 Subject: [PATCH 15/20] restoring test --- .../Services/DataImporterSpecs.cs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/tests/OSPSuite.Presentation.Tests/Services/DataImporterSpecs.cs b/tests/OSPSuite.Presentation.Tests/Services/DataImporterSpecs.cs index fdcafb742..98570bbc3 100644 --- a/tests/OSPSuite.Presentation.Tests/Services/DataImporterSpecs.cs +++ b/tests/OSPSuite.Presentation.Tests/Services/DataImporterSpecs.cs @@ -213,10 +213,9 @@ public void should_correctly_notify_and_return_empty_on_invalid_file_type() [Observation] public void should_correctly_notify_and_return_empty_on_invalid_file_format() { - sut.ImportFromConfiguration(_importerConfiguration, _metaDataCategories, _columnInfos, _dataImporterSettings, - getFileFullName( - "sample1.xlsx")).Count.ShouldBeEqualTo(0); - A.CallTo(() => _dialogCreator.MessageBoxError(Error.UnsupportedFileFormat(getFileFullName("sample1.xlsx")))).MustHaveHappened(); + var invalidFileName = getFileFullName("invalid.xlsx"); + sut.ImportFromConfiguration(_importerConfiguration, _metaDataCategories, _columnInfos, _dataImporterSettings, invalidFileName).Count.ShouldBeEqualTo(0); + A.CallTo(() => _dialogCreator.MessageBoxError(Error.UnsupportedFileFormat(invalidFileName))).MustHaveHappened(); } From 72834f9b49014e9091c6e142f9a0781436cf9335 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Mon, 7 Feb 2022 18:08:37 +0100 Subject: [PATCH 16/20] Using dynamic images plus misc fixes --- .../Core/DataSource.cs | 27 ++++++++++++--- .../Core/Exceptions/ParseErrorDescription.cs | 8 +++++ .../Core/Helpers/CachedListHelpers.cs | 24 ------------- .../Services/Importer.cs | 2 +- .../Importer/IImporterDataPresenter.cs | 1 + .../Importer/ImporterDataPresenter.cs | 5 +++ .../Presenters/Importer/ImporterPresenter.cs | 8 ++--- .../Views/Importer/IImporterDataView.cs | 1 + .../Views/Importer/IImporterView.cs | 2 -- src/OSPSuite.UI/Properties/licenses.licx | 3 -- .../Importer/ImporterDataView.Designer.cs | 34 +++++++------------ .../Views/Importer/ImporterDataView.cs | 19 +++++++---- .../Views/Importer/ImporterView.Designer.cs | 32 +---------------- .../Views/Importer/ImporterView.cs | 6 ---- .../DataSetToDataRepositoryMapperSpecs.cs | 12 +++---- 15 files changed, 75 insertions(+), 109 deletions(-) delete mode 100644 src/OSPSuite.Infrastructure.Import/Core/Helpers/CachedListHelpers.cs delete mode 100644 src/OSPSuite.UI/Properties/licenses.licx diff --git a/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs b/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs index 86cd4d9d6..ddd7f2717 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs @@ -4,7 +4,6 @@ using OSPSuite.Core.Domain; using OSPSuite.Core.Import; using OSPSuite.Infrastructure.Import.Core.Exceptions; -using OSPSuite.Infrastructure.Import.Core.Helpers; using OSPSuite.Infrastructure.Import.Extensions; using OSPSuite.Infrastructure.Import.Services; using OSPSuite.Utility.Collections; @@ -58,7 +57,8 @@ public interface IDataSource Cache DataSets { get; } IEnumerable NamesFromConvention(); NanSettings NanSettings { get; set; } - ImportedDataSet DataSetAt(int index); + ImportedDataSet ImportedDataSetAt(int index); + IDataSet DataSetAt(int index); ParseErrors ValidateDataSourceUnits(IReadOnlyList columnInfos); } @@ -155,7 +155,26 @@ public IEnumerable NamesFromConvention() return _importer.NamesFromConvention(_configuration.NamingConventions, _configuration.FileName, DataSets, _mappings); } - public ImportedDataSet DataSetAt(int index) + public IDataSet DataSetAt(int index) + { + var sheetIndex = 0; + var sheet = DataSets.GetEnumerator(); + var accumulatedIndexes = 0; + while (sheet.MoveNext() && index >= 0) + { + if (sheet.Current.Data.Count() > index) + { + return sheet.Current; + } + + index -= sheet.Current.Data.Count(); + sheetIndex++; + accumulatedIndexes += sheet.Current.Data.Count(); + } + return null; + } + + public ImportedDataSet ImportedDataSetAt(int index) { var sheetIndex = 0; var sheet = DataSets.GetEnumerator(); @@ -296,7 +315,7 @@ private ParseErrors validateUnitsSupportedAndSameDimension(IReadOnlyList columnInfos) + public ParseErrors ValidateDataSourceUnits(IReadOnlyList columnInfos) { var errors = validateUnitsSupportedAndSameDimension(columnInfos); errors.Add(validateErrorAgainstMeasurement(columnInfos)); diff --git a/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs b/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs index 2cbc50d0a..7d6da5d62 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/Exceptions/ParseErrorDescription.cs @@ -64,4 +64,12 @@ public EmptyDataSetsParseErrorDescription(IEnumerable dataSetNames) Message = Error.EmptyDataSet($"{dataSetNames.ToString(", ")}"); } } + + public class NonMonotonicalTimeParseErrorDescription : ParseErrorDescription + { + public NonMonotonicalTimeParseErrorDescription(string message) + { + Message = message; + } + } } diff --git a/src/OSPSuite.Infrastructure.Import/Core/Helpers/CachedListHelpers.cs b/src/OSPSuite.Infrastructure.Import/Core/Helpers/CachedListHelpers.cs deleted file mode 100644 index ba490612d..000000000 --- a/src/OSPSuite.Infrastructure.Import/Core/Helpers/CachedListHelpers.cs +++ /dev/null @@ -1,24 +0,0 @@ -using OSPSuite.Utility.Collections; -using System.Collections.Generic; - -namespace OSPSuite.Infrastructure.Import.Core.Helpers -{ - static public class CachedListHelpers - { - public static void Add(Cache> cache, T1 key, T2 x) - { - if (cache.Contains(key)) - cache[key].Add(x); - else - cache.Add(key, new List() { x }); - } - - public static void Add(Cache> cache, T1 key, IEnumerable list) - { - if (cache.Contains(key)) - cache[key].AddRange(list); - else - cache.Add(key, new List(list)); - } - } -} diff --git a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs index 4f1a2b4c1..673dfb4e8 100644 --- a/src/OSPSuite.Infrastructure.Import/Services/Importer.cs +++ b/src/OSPSuite.Infrastructure.Import/Services/Importer.cs @@ -189,7 +189,7 @@ public IReadOnlyList DataSourceToDataSets( for (var i = 0; i < dataSource.DataSets.SelectMany(ds => ds.Data).Count(); i++) { - var dataRepoMapping = _dataRepositoryMapper.ConvertImportDataSet(dataSource.DataSetAt(i)); + var dataRepoMapping = _dataRepositoryMapper.ConvertImportDataSet(dataSource.ImportedDataSetAt(i)); var dataRepo = dataRepoMapping.DataRepository; dataRepo.ConfigurationId = id; determineMolecularWeight(metaDataCategories, dataImporterSettings, dataRepo); diff --git a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs index b9264ba74..9be097f14 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs @@ -65,5 +65,6 @@ IReadOnlyList columnInfos void GetFormatBasedOnCurrentSheet(); void ResetLoadedSheets(); void SetTabMarks(ParseErrors errors, Cache loadedDataSets); + void SetTabMarks(ParseErrors errors); } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs index 05f2d8394..33844bfb2 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs @@ -272,5 +272,10 @@ public void SetTabMarks(ParseErrors errors, Cache loadedDataSe { View.SetTabMarks(errors, loadedDataSets); } + + public void SetTabMarks(ParseErrors errors) + { + View.SetTabMarks(errors); + } } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs index 1013d1588..fb78727dc 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterPresenter.cs @@ -15,7 +15,6 @@ using OSPSuite.Utility.Collections; using OSPSuite.Utility.Extensions; using ImporterConfiguration = OSPSuite.Core.Import.ImporterConfiguration; -using OSPSuite.Infrastructure.Import.Core.Helpers; namespace OSPSuite.Presentation.Presenters.Importer { @@ -100,14 +99,15 @@ private void plotDataSet(object sender, DataSetSelectedEventArgs e) { try { - _view.HideExtraErrors(); - var dataRepository = _dataRepositoryMapper.ConvertImportDataSet(_dataSource.DataSetAt(e.Index)); + var dataRepository = _dataRepositoryMapper.ConvertImportDataSet(_dataSource.ImportedDataSetAt(e.Index)); _confirmationPresenter.PlotDataRepository(dataRepository.DataRepository); } catch (InvalidArgumentException invalidException) { - _view.ShowExtraErrors(Error.ErrorWhenPlottingDataRepository(e.Index, invalidException.Message)); _view.DisableConfirmationView(); + var errors = new ParseErrors(); + errors.Add(_dataSource.DataSetAt(e.Index), new NonMonotonicalTimeParseErrorDescription(Error.ErrorWhenPlottingDataRepository(e.Index, invalidException.Message))); + _importerDataPresenter.SetTabMarks(errors); } } diff --git a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs index b959de3ee..73b454265 100644 --- a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs +++ b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs @@ -22,5 +22,6 @@ public interface IImporterDataView : IView string SelectedTab { get; set; } string GetFilter(); void SetTabMarks(ParseErrors errors, Cache loadedDataSets); + void SetTabMarks(ParseErrors errors); } } diff --git a/src/OSPSuite.Presentation/Views/Importer/IImporterView.cs b/src/OSPSuite.Presentation/Views/Importer/IImporterView.cs index 9c1715b46..baf5d990c 100644 --- a/src/OSPSuite.Presentation/Views/Importer/IImporterView.cs +++ b/src/OSPSuite.Presentation/Views/Importer/IImporterView.cs @@ -11,7 +11,5 @@ public interface IImporterView : IView void EnableConfirmationView(); void DisableConfirmationView(); void AddNanView(INanView nanView); - void ShowExtraErrors(string errorMessage); - void HideExtraErrors(); } } diff --git a/src/OSPSuite.UI/Properties/licenses.licx b/src/OSPSuite.UI/Properties/licenses.licx deleted file mode 100644 index b3c81b8b1..000000000 --- a/src/OSPSuite.UI/Properties/licenses.licx +++ /dev/null @@ -1,3 +0,0 @@ -DevExpress.XtraEditors.CheckEdit, DevExpress.XtraEditors.v21.2, Version=21.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a -DevExpress.XtraGrid.GridControl, DevExpress.XtraGrid.v21.2, Version=21.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a -DevExpress.XtraLayout.LayoutControl, DevExpress.XtraLayout.v21.2, Version=21.2.3.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs index 59c1762c6..d10009601 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs @@ -45,10 +45,9 @@ private void InitializeComponent() this.layoutItemImportCurrent = new DevExpress.XtraLayout.LayoutControlItem(); this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem(); this.layoutControlItem1 = new DevExpress.XtraLayout.LayoutControlItem(); - this.layoutControlItem2 = new DevExpress.XtraLayout.LayoutControlItem(); + this.layoutControlItemError = new DevExpress.XtraLayout.LayoutControlItem(); this.dataViewingGridControl = new DevExpress.XtraGrid.GridControl(); this.dataViewingGridView = new DevExpress.XtraGrid.Views.Grid.GridView(); - this.imageCollection1 = new DevExpress.Utils.ImageCollection(this.components); this.dpiAwareImageCollection1 = new DevExpress.Utils.DPIAwareImageCollection(this.components); this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); @@ -62,10 +61,9 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.layoutItemImportCurrent)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).BeginInit(); + ((System.ComponentModel.ISupportInitialize)(this.layoutControlItemError)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridControl)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridView)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.imageCollection1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.dpiAwareImageCollection1)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit(); this.SuspendLayout(); @@ -148,7 +146,7 @@ private void InitializeComponent() this.layoutItemImportCurrent, this.emptySpaceItem1, this.layoutControlItem1, - this.layoutControlItem2, + this.layoutControlItemError, this.emptySpaceItem2}); this.Root.Name = "Root"; this.Root.Padding = new DevExpress.XtraLayout.Utils.Padding(0, 0, 0, 0); @@ -202,13 +200,13 @@ private void InitializeComponent() // // layoutControlItem2 // - this.layoutControlItem2.Control = this.labelControlError; - this.layoutControlItem2.Location = new System.Drawing.Point(0, 949); - this.layoutControlItem2.Name = "layoutControlItem2"; - this.layoutControlItem2.Size = new System.Drawing.Size(1457, 20); - this.layoutControlItem2.TextSize = new System.Drawing.Size(0, 0); - this.layoutControlItem2.TextVisible = false; - this.layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; + this.layoutControlItemError.Control = this.labelControlError; + this.layoutControlItemError.Location = new System.Drawing.Point(0, 949); + this.layoutControlItemError.Name = "layoutControlItem2"; + this.layoutControlItemError.Size = new System.Drawing.Size(1457, 20); + this.layoutControlItemError.TextSize = new System.Drawing.Size(0, 0); + this.layoutControlItemError.TextVisible = false; + this.layoutControlItemError.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; // // dataViewingGridControl // @@ -227,12 +225,6 @@ private void InitializeComponent() this.dataViewingGridView.Name = "dataViewingGridView"; this.dataViewingGridView.OptionsView.ColumnAutoWidth = false; // - // imageCollection1 - // - this.imageCollection1.ImageStream = ((DevExpress.Utils.ImageCollectionStreamer)(resources.GetObject("imageCollection1.ImageStream"))); - this.imageCollection1.Images.SetKeyName(0, "OK.ico"); - this.imageCollection1.Images.SetKeyName(1, "Cancel.ico"); - // // dpiAwareImageCollection1 // this.dpiAwareImageCollection1.Owner = this; @@ -265,10 +257,9 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.layoutItemImportCurrent)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.layoutControlItem2)).EndInit(); + ((System.ComponentModel.ISupportInitialize)(this.layoutControlItemError)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridControl)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dataViewingGridView)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.imageCollection1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.dpiAwareImageCollection1)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit(); this.ResumeLayout(false); @@ -290,10 +281,9 @@ private void InitializeComponent() private DevExpress.XtraEditors.CheckEdit useForImportCheckEdit; private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1; private DevExpress.XtraLayout.LayoutControlItem layoutControlItem1; - private ImageCollection imageCollection1; private DPIAwareImageCollection dpiAwareImageCollection1; private DevExpress.XtraEditors.LabelControl labelControlError; - private DevExpress.XtraLayout.LayoutControlItem layoutControlItem2; + private DevExpress.XtraLayout.LayoutControlItem layoutControlItemError; private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem2; } } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs index 43e8b2154..0e9f6a186 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs @@ -10,11 +10,11 @@ using DevExpress.XtraTab.ViewInfo; using OSPSuite.Assets; using OSPSuite.Infrastructure.Import.Core; -using OSPSuite.Infrastructure.Import.Core.Exceptions; using OSPSuite.Presentation.Presenters.Importer; using OSPSuite.Presentation.Views.Importer; using OSPSuite.UI.Controls; using OSPSuite.UI.Extensions; +using OSPSuite.UI.Services; using OSPSuite.Utility.Collections; using OSPSuite.Utility.Extensions; @@ -23,6 +23,7 @@ namespace OSPSuite.UI.Views.Importer public partial class ImporterDataView : BaseUserControl, IImporterDataView { private IImporterDataPresenter _dataPresenter; + private readonly IImageListRetriever _imageListRetriever; private string _contextMenuSelectedTab; private bool sheetImportedFlag; @@ -31,7 +32,7 @@ public partial class ImporterDataView : BaseUserControl, IImporterDataView private ParseErrors _lastErrors = new ParseErrors(); private Cache _lastLoadedDataSets = new Cache(); - public ImporterDataView() + public ImporterDataView(IImageListRetriever imageListRetriever) { InitializeComponent(); btnImport.Click += (s, a) => OnEvent(onButtonImportClicked, s, a); @@ -50,6 +51,7 @@ public ImporterDataView() btnImport.Text = Captions.Importer.LoadCurrentSheet; allImportButtonsDisabledFlag = false; dataViewingGridView.OptionsBehavior.Editable = false; + _imageListRetriever = imageListRetriever; } public override void InitializeResources() @@ -228,7 +230,7 @@ public string GetActiveFilterCriteria() public void AddTabs(List sheetNames) { - importerTabControl.Images = imageCollection1; + importerTabControl.Images = _imageListRetriever.AllImages16x16; foreach (var sheetName in sheetNames) importerTabControl.TabPages.Add(sheetName); @@ -311,12 +313,12 @@ private void refreshErrorMessage() if (_lastLoadedDataSets.Contains(SelectedTab) && _lastErrors.Contains(_lastLoadedDataSets[SelectedTab])) { labelControlError.Text = Error.ParseErrorMessage(_lastErrors.ErrorsFor(_lastLoadedDataSets[SelectedTab]).Select(x => x.Message)); - layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; + layoutControlItemError.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; } else { labelControlError.Text = ""; - layoutControlItem2.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; + layoutControlItemError.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } } @@ -326,7 +328,7 @@ private void refreshErrorMarks() { if (_lastLoadedDataSets.Contains(x.Text)) { - x.ImageIndex = _lastErrors.Contains(_lastLoadedDataSets[x.Text]) ? 1 : 0; + x.ImageIndex = _lastErrors.Contains(_lastLoadedDataSets[x.Text]) ? _imageListRetriever.ImageIndex(ApplicationIcons.Cancel) : _imageListRetriever.ImageIndex(ApplicationIcons.OK); return; } @@ -334,6 +336,11 @@ private void refreshErrorMarks() }); } + public void SetTabMarks(ParseErrors errors) + { + SetTabMarks(errors, _lastLoadedDataSets); + } + public void SetTabMarks(ParseErrors errors, Cache loadedDataSets) { _lastErrors = errors; diff --git a/src/OSPSuite.UI/Views/Importer/ImporterView.Designer.cs b/src/OSPSuite.UI/Views/Importer/ImporterView.Designer.cs index d6db54c69..66493535b 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterView.Designer.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterView.Designer.cs @@ -32,7 +32,6 @@ protected override void Dispose(bool disposing) private void InitializeComponent() { this.rootLayoutControl = new DevExpress.XtraLayout.LayoutControl(); - this._labelExtraErrors = new DevExpress.XtraEditors.LabelControl(); this.applyMappingBtn = new OSPSuite.UI.Controls.UxSimpleButton(); this.saveMappingBtn = new OSPSuite.UI.Controls.UxSimpleButton(); this.sourceFilePanelControl = new DevExpress.XtraEditors.PanelControl(); @@ -49,7 +48,6 @@ private void InitializeComponent() this.emptySpaceItem2 = new DevExpress.XtraLayout.EmptySpaceItem(); this.applyMappingLayoutControlItem = new DevExpress.XtraLayout.LayoutControlItem(); this.emptySpaceItem1 = new DevExpress.XtraLayout.EmptySpaceItem(); - this.layoutControlItemExtraError = new DevExpress.XtraLayout.LayoutControlItem(); ((System.ComponentModel.ISupportInitialize)(this.errorProvider)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.rootLayoutControl)).BeginInit(); this.rootLayoutControl.SuspendLayout(); @@ -67,12 +65,10 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.applyMappingLayoutControlItem)).BeginInit(); ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).BeginInit(); - ((System.ComponentModel.ISupportInitialize)(this.layoutControlItemExtraError)).BeginInit(); this.SuspendLayout(); // // rootLayoutControl // - this.rootLayoutControl.Controls.Add(this._labelExtraErrors); this.rootLayoutControl.Controls.Add(this.applyMappingBtn); this.rootLayoutControl.Controls.Add(this.saveMappingBtn); this.rootLayoutControl.Controls.Add(this.sourceFilePanelControl); @@ -88,18 +84,6 @@ private void InitializeComponent() this.rootLayoutControl.Size = new System.Drawing.Size(1309, 780); this.rootLayoutControl.TabIndex = 0; // - // _labelExtraErrors - // - this._labelExtraErrors.Appearance.ForeColor = System.Drawing.Color.Red; - this._labelExtraErrors.Appearance.Options.UseForeColor = true; - this._labelExtraErrors.AutoSizeMode = DevExpress.XtraEditors.LabelAutoSizeMode.Vertical; - this._labelExtraErrors.Location = new System.Drawing.Point(12, 482); - this._labelExtraErrors.Name = "_labelExtraErrors"; - this._labelExtraErrors.Size = new System.Drawing.Size(464, 1); - this._labelExtraErrors.StyleController = this.rootLayoutControl; - this._labelExtraErrors.TabIndex = 11; - this._labelExtraErrors.Visible = false; - // // applyMappingBtn // this.applyMappingBtn.Location = new System.Drawing.Point(187, 741); @@ -169,8 +153,7 @@ private void InitializeComponent() this.saveMappingBtnLayoutControlItem, this.emptySpaceItem2, this.applyMappingLayoutControlItem, - this.emptySpaceItem1, - this.layoutControlItemExtraError}); + this.emptySpaceItem1}); this.Root.Name = "Root"; this.Root.Size = new System.Drawing.Size(1309, 780); this.Root.TextVisible = false; @@ -253,16 +236,6 @@ private void InitializeComponent() this.emptySpaceItem1.Size = new System.Drawing.Size(15, 31); this.emptySpaceItem1.TextSize = new System.Drawing.Size(0, 0); // - // layoutControlItemExtraError - // - this.layoutControlItemExtraError.Control = this._labelExtraErrors; - this.layoutControlItemExtraError.Location = new System.Drawing.Point(0, 470); - this.layoutControlItemExtraError.Name = "layoutControlItemExtraError"; - this.layoutControlItemExtraError.Size = new System.Drawing.Size(468, 5); - this.layoutControlItemExtraError.Text = " "; - this.layoutControlItemExtraError.TextSize = new System.Drawing.Size(0, 0); - this.layoutControlItemExtraError.TextVisible = false; - // // ImporterView // this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 16F); @@ -288,7 +261,6 @@ private void InitializeComponent() ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem2)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.applyMappingLayoutControlItem)).EndInit(); ((System.ComponentModel.ISupportInitialize)(this.emptySpaceItem1)).EndInit(); - ((System.ComponentModel.ISupportInitialize)(this.layoutControlItemExtraError)).EndInit(); this.ResumeLayout(false); } @@ -312,7 +284,5 @@ private void InitializeComponent() private UxSimpleButton applyMappingBtn; private DevExpress.XtraLayout.LayoutControlItem applyMappingLayoutControlItem; private DevExpress.XtraLayout.EmptySpaceItem emptySpaceItem1; - private DevExpress.XtraEditors.LabelControl _labelExtraErrors; - private DevExpress.XtraLayout.LayoutControlItem layoutControlItemExtraError; } } \ No newline at end of file diff --git a/src/OSPSuite.UI/Views/Importer/ImporterView.cs b/src/OSPSuite.UI/Views/Importer/ImporterView.cs index ab0cd929d..8f5e301fc 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterView.cs @@ -91,12 +91,6 @@ public void AddNanView(INanView nanView) { nanPanelControl.FillWith(nanView); } - - public void ShowExtraErrors(string errorMessage) - { - _labelExtraErrors.Text = errorMessage; - layoutControlItemExtraError.ContentVisible = true; - } public void HideExtraErrors() { _labelExtraErrors.Text = ""; diff --git a/tests/OSPSuite.Infrastructure.Tests/Import/DataSetToDataRepositoryMapperSpecs.cs b/tests/OSPSuite.Infrastructure.Tests/Import/DataSetToDataRepositoryMapperSpecs.cs index 835d19e6b..a5e61e3c1 100644 --- a/tests/OSPSuite.Infrastructure.Tests/Import/DataSetToDataRepositoryMapperSpecs.cs +++ b/tests/OSPSuite.Infrastructure.Tests/Import/DataSetToDataRepositoryMapperSpecs.cs @@ -200,7 +200,7 @@ protected override void Context() _parsedDataSetInconsistentLLOQ = _parsedDataSetLLOQ; _parsedDataSetInconsistentLLOQ.First(x => x.Key.ColumnInfo.Name == "Concentration").Value.ElementAt(0).Lloq = 2; - A.CallTo(() => _dataSourceLLOQ.DataSetAt(A.Ignored)).Returns(new ImportedDataSet + A.CallTo(() => _dataSourceLLOQ.ImportedDataSetAt(A.Ignored)).Returns(new ImportedDataSet ( "file", "sheet1", @@ -210,7 +210,7 @@ protected override void Context() ) ); - A.CallTo(() => _dataSourceInconsistentLLOQ.DataSetAt(A.Ignored)).Returns(new ImportedDataSet + A.CallTo(() => _dataSourceInconsistentLLOQ.ImportedDataSetAt(A.Ignored)).Returns(new ImportedDataSet ( "file", "sheet1", @@ -220,7 +220,7 @@ protected override void Context() ) ); - A.CallTo(() => _dataSourceUnitFromColumn.DataSetAt(A.Ignored)).Returns(new ImportedDataSet + A.CallTo(() => _dataSourceUnitFromColumn.ImportedDataSetAt(A.Ignored)).Returns(new ImportedDataSet ( "file", "sheet1", @@ -238,7 +238,7 @@ public class When_mapping_a_data_repository : concern_for_DataSetToDataRepositor { protected override void Because() { - _result = sut.ConvertImportDataSet(_dataSourceInconsistentLLOQ.DataSetAt(0)); + _result = sut.ConvertImportDataSet(_dataSourceInconsistentLLOQ.ImportedDataSetAt(0)); } [Observation] @@ -253,7 +253,7 @@ public class When_mapping_a_data_repository_with_inconsistent_lloq : concern_for { protected override void Because() { - _result = sut.ConvertImportDataSet(_dataSourceLLOQ.DataSetAt(0)); + _result = sut.ConvertImportDataSet(_dataSourceLLOQ.ImportedDataSetAt(0)); } [Observation] @@ -279,7 +279,7 @@ public class When_mapping_a_data_repository_with_unit_from_a_column : concern_fo { protected override void Because() { - _result = sut.ConvertImportDataSet(_dataSourceUnitFromColumn.DataSetAt(0)); + _result = sut.ConvertImportDataSet(_dataSourceUnitFromColumn.ImportedDataSetAt(0)); } [Observation] From f6b6adcfa4dbd7011c3b3f9eae3aab0b56ebdba7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Mon, 7 Feb 2022 18:14:28 +0100 Subject: [PATCH 17/20] Cleaning resource file --- .../Views/Importer/ImporterDataView.resx | 43 ------------------- 1 file changed, 43 deletions(-) diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx b/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx index bca4f022b..29a1e5cd6 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx @@ -120,47 +120,4 @@ 17, 17 - - When selected, the filter will apply to the data during the import process. When deselected, the filter only affects this view. Check documentation for more information on defining filters: <href=https://docs.open-systems-pharmacology.org/shared-tools-and-example-workflows/features-of-tables#filtering>https://docs.open-systems-pharmacology.org/shared-tools-and-example-workflows/features-of-tables#filtering</href> - - - 163, 17 - - - - - AAEAAAD/////AQAAAAAAAAAMAgAAAFpEZXZFeHByZXNzLlV0aWxzLnYyMS4yLCBWZXJzaW9uPTIxLjIu - My4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI4OGQxNzU0ZDcwMGU0OWEMAwAAAFFT - eXN0ZW0uRHJhd2luZywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRv - a2VuPWIwM2Y1ZjdmMTFkNTBhM2EFAQAAAChEZXZFeHByZXNzLlV0aWxzLkltYWdlQ29sbGVjdGlvblN0 - cmVhbWVyAgAAAAlJbWFnZVNpemUERGF0YQQHE1N5c3RlbS5EcmF3aW5nLlNpemUDAAAAAgIAAAAF/P// - /xNTeXN0ZW0uRHJhd2luZy5TaXplAgAAAAV3aWR0aAZoZWlnaHQAAAgIAwAAABAAAAAQAAAACQUAAAAP - BQAAAJgDAAAC1AEAAIlQTkcNChoKAAAADUlIRFIAAAAQAAAAEAgGAAAAH/P/YQAAAARnQU1BAACxjwv8 - YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAAAF2SURBVDhPY8AF0s4Ys8bvcrFI3OPqmbjHQwsoxAiRIQBS - T3l6Jux0+5ew2+0/Bt7p9i1xm4coVCkmiN3l+girRjQcv8N5AlQLAiTscHmCTTE6Dt1mBcSW/2N3u9dC - tTIwhG/xD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BWZXJzaW9uPTIxLjIu - My4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI4OGQxNzU0ZDcwMGU0OWEFAQAAADBE - ZXZFeHByZXNzLlV0aWxzLkRQSUF3YXJlSW1hZ2VDb2xsZWN0aW9uU3RyZWFtZXIAAAAAAgAAAAs= - - \ No newline at end of file From 70ba7161e30f4187972cf14835a550e99dc9afbe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Mon, 7 Feb 2022 20:12:24 +0100 Subject: [PATCH 18/20] missing changes --- src/OSPSuite.Infrastructure.Import/Core/DataSource.cs | 7 ++++--- src/OSPSuite.UI/Views/Importer/ImporterView.cs | 5 ----- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs b/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs index ddd7f2717..2a9aaf475 100644 --- a/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs +++ b/src/OSPSuite.Infrastructure.Import/Core/DataSource.cs @@ -162,14 +162,15 @@ public IDataSet DataSetAt(int index) var accumulatedIndexes = 0; while (sheet.MoveNext() && index >= 0) { - if (sheet.Current.Data.Count() > index) + var countOnSheet = sheet.Current.Data.Count(); + if (countOnSheet > index) { return sheet.Current; } - index -= sheet.Current.Data.Count(); + index -= countOnSheet; sheetIndex++; - accumulatedIndexes += sheet.Current.Data.Count(); + accumulatedIndexes += countOnSheet; } return null; } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterView.cs b/src/OSPSuite.UI/Views/Importer/ImporterView.cs index 8f5e301fc..58682a06d 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterView.cs @@ -91,10 +91,5 @@ public void AddNanView(INanView nanView) { nanPanelControl.FillWith(nanView); } - public void HideExtraErrors() - { - _labelExtraErrors.Text = ""; - layoutControlItemExtraError.ContentVisible = false; - } } } \ No newline at end of file From dd693a3ab2082fcccf9b595870403f8c0cba7a15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Mon, 7 Feb 2022 21:16:01 +0100 Subject: [PATCH 19/20] Moving logic to presenter --- .../Importer/IImporterDataPresenter.cs | 13 +++++++ .../Importer/ImporterDataPresenter.cs | 16 +++++++-- .../Views/Importer/IImporterDataView.cs | 3 +- .../Views/Importer/ImporterDataView.cs | 35 +++++++------------ 4 files changed, 41 insertions(+), 26 deletions(-) diff --git a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs index 9be097f14..494173799 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/IImporterDataPresenter.cs @@ -66,5 +66,18 @@ IReadOnlyList columnInfos void ResetLoadedSheets(); void SetTabMarks(ParseErrors errors, Cache loadedDataSets); void SetTabMarks(ParseErrors errors); + + } + + public class TabMarkInfo + { + public string ErrorMessage { get; private set; } + public bool IsLoaded { get; private set; } + public bool ContainsError { get => ErrorMessage != null; } + public TabMarkInfo(string errorMessage, bool isLoaded) + { + ErrorMessage = errorMessage; + IsLoaded = isLoaded; + } } } diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs index 33844bfb2..5f791f6e5 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs @@ -2,6 +2,7 @@ using System.Collections.Generic; using System.Data; using System.Linq; +using OSPSuite.Assets; using OSPSuite.Core.Import; using OSPSuite.Infrastructure.Import.Core; using OSPSuite.Infrastructure.Import.Core.Exceptions; @@ -19,6 +20,8 @@ public class ImporterDataPresenter : AbstractPresenter _metaDataCategories; private readonly Cache _sheetsForViewing; private string _currentSheetName; + private ParseErrors _lastErrors = new ParseErrors(); + private Cache _lastLoadedDataSets = new Cache(); public Cache Sheets { get; set; } public event EventHandler OnFormatChanged = delegate { }; @@ -270,12 +273,21 @@ public void ResetLoadedSheets() public void SetTabMarks(ParseErrors errors, Cache loadedDataSets) { - View.SetTabMarks(errors, loadedDataSets); + _lastErrors = errors; + _lastLoadedDataSets = loadedDataSets; + var tabMarkInfos = new Cache(onMissingKey: _ => new TabMarkInfo(errorMessage : null, isLoaded : false)); + foreach (var loadedDataSet in loadedDataSets) + { + var errorsForDataSet = _lastErrors.ErrorsFor(loadedDataSet); + var errorMessage = errorsForDataSet.Any() ? Error.ParseErrorMessage(errorsForDataSet.Select(x => x.Message)) : null; + var info = new TabMarkInfo(errorMessage: errorMessage, isLoaded: true); + } + View.SetTabMarks(tabMarkInfos); } public void SetTabMarks(ParseErrors errors) { - View.SetTabMarks(errors); + SetTabMarks(errors, _lastLoadedDataSets); } } } diff --git a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs index 73b454265..8a8a7e479 100644 --- a/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs +++ b/src/OSPSuite.Presentation/Views/Importer/IImporterDataView.cs @@ -21,7 +21,6 @@ public interface IImporterDataView : IView void SetFilter(string filter); string SelectedTab { get; set; } string GetFilter(); - void SetTabMarks(ParseErrors errors, Cache loadedDataSets); - void SetTabMarks(ParseErrors errors); + void SetTabMarks(Cache tabMarks); } } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs index 0e9f6a186..255215b7c 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs @@ -24,13 +24,11 @@ public partial class ImporterDataView : BaseUserControl, IImporterDataView { private IImporterDataPresenter _dataPresenter; private readonly IImageListRetriever _imageListRetriever; - + private Cache _tabMarks; private string _contextMenuSelectedTab; private bool sheetImportedFlag; private bool allSheetsImportedFlag; private bool allImportButtonsDisabledFlag; - private ParseErrors _lastErrors = new ParseErrors(); - private Cache _lastLoadedDataSets = new Cache(); public ImporterDataView(IImageListRetriever imageListRetriever) { @@ -309,42 +307,35 @@ public string GetFilter() private void refreshErrorMessage() { - - if (_lastLoadedDataSets.Contains(SelectedTab) && _lastErrors.Contains(_lastLoadedDataSets[SelectedTab])) + var tabMark = _tabMarks[SelectedTab]; + if (tabMark.ContainsError) { - labelControlError.Text = Error.ParseErrorMessage(_lastErrors.ErrorsFor(_lastLoadedDataSets[SelectedTab]).Select(x => x.Message)); + labelControlError.Text = tabMark.ErrorMessage; layoutControlItemError.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Always; + return; } - else - { - labelControlError.Text = ""; - layoutControlItemError.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; - } + + layoutControlItemError.Visibility = DevExpress.XtraLayout.Utils.LayoutVisibility.Never; } private void refreshErrorMarks() { importerTabControl.TabPages.Each(x => { - if (_lastLoadedDataSets.Contains(x.Text)) + var tabMark = _tabMarks[x.Text]; + if (!tabMark.IsLoaded) { - x.ImageIndex = _lastErrors.Contains(_lastLoadedDataSets[x.Text]) ? _imageListRetriever.ImageIndex(ApplicationIcons.Cancel) : _imageListRetriever.ImageIndex(ApplicationIcons.OK); + x.ImageIndex = -1; return; } - x.ImageIndex = -1; + x.ImageIndex = tabMark.ContainsError ? _imageListRetriever.ImageIndex(ApplicationIcons.Cancel) : _imageListRetriever.ImageIndex(ApplicationIcons.OK); }); } - public void SetTabMarks(ParseErrors errors) - { - SetTabMarks(errors, _lastLoadedDataSets); - } - - public void SetTabMarks(ParseErrors errors, Cache loadedDataSets) + public void SetTabMarks(Cache tabMarks) { - _lastErrors = errors; - _lastLoadedDataSets = loadedDataSets; + _tabMarks = tabMarks; refreshErrorMessage(); refreshErrorMarks(); } From 566ca796e6db6daaa0f9e18c513bdafbf951873c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Abdel=20Rodr=C3=ADguez?= Date: Mon, 7 Feb 2022 21:51:04 +0100 Subject: [PATCH 20/20] Proper initialization and resources --- .../Presenters/Importer/ImporterDataPresenter.cs | 7 +++---- .../Views/Importer/ImporterDataView.Designer.cs | 1 - src/OSPSuite.UI/Views/Importer/ImporterDataView.cs | 4 ++-- .../Views/Importer/ImporterDataView.resx | 13 ++++++++++++- 4 files changed, 17 insertions(+), 8 deletions(-) diff --git a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs index 5f791f6e5..d26e4c64f 100644 --- a/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs +++ b/src/OSPSuite.Presentation/Presenters/Importer/ImporterDataPresenter.cs @@ -20,7 +20,6 @@ public class ImporterDataPresenter : AbstractPresenter _metaDataCategories; private readonly Cache _sheetsForViewing; private string _currentSheetName; - private ParseErrors _lastErrors = new ParseErrors(); private Cache _lastLoadedDataSets = new Cache(); public Cache Sheets { get; set; } @@ -273,14 +272,14 @@ public void ResetLoadedSheets() public void SetTabMarks(ParseErrors errors, Cache loadedDataSets) { - _lastErrors = errors; _lastLoadedDataSets = loadedDataSets; var tabMarkInfos = new Cache(onMissingKey: _ => new TabMarkInfo(errorMessage : null, isLoaded : false)); - foreach (var loadedDataSet in loadedDataSets) + foreach (var loadedDataSet in loadedDataSets.KeyValues) { - var errorsForDataSet = _lastErrors.ErrorsFor(loadedDataSet); + var errorsForDataSet = errors.ErrorsFor(loadedDataSet.Value); var errorMessage = errorsForDataSet.Any() ? Error.ParseErrorMessage(errorsForDataSet.Select(x => x.Message)) : null; var info = new TabMarkInfo(errorMessage: errorMessage, isLoaded: true); + tabMarkInfos.Add(loadedDataSet.Key, info); } View.SetTabMarks(tabMarkInfos); } diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs index d10009601..6ed9e5cd9 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.Designer.cs @@ -105,7 +105,6 @@ private void InitializeComponent() this.useForImportCheckEdit.Size = new System.Drawing.Size(478, 24); this.useForImportCheckEdit.StyleController = this.rootLayoutControl; this.useForImportCheckEdit.TabIndex = 11; - this.useForImportCheckEdit.ToolTip = resources.GetString("useForImportCheckEdit.ToolTip"); this.useForImportCheckEdit.ToolTipAnchor = DevExpress.Utils.ToolTipAnchor.Cursor; // // btnImport diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs index 255215b7c..92fe34940 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.cs @@ -9,7 +9,6 @@ using DevExpress.XtraTab.Buttons; using DevExpress.XtraTab.ViewInfo; using OSPSuite.Assets; -using OSPSuite.Infrastructure.Import.Core; using OSPSuite.Presentation.Presenters.Importer; using OSPSuite.Presentation.Views.Importer; using OSPSuite.UI.Controls; @@ -24,7 +23,7 @@ public partial class ImporterDataView : BaseUserControl, IImporterDataView { private IImporterDataPresenter _dataPresenter; private readonly IImageListRetriever _imageListRetriever; - private Cache _tabMarks; + private Cache _tabMarks = new Cache(onMissingKey: _ => new TabMarkInfo(null, false)); private string _contextMenuSelectedTab; private bool sheetImportedFlag; private bool allSheetsImportedFlag; @@ -61,6 +60,7 @@ public override void InitializeResources() layoutItemImportAll.AdjustLargeButtonSize(); layoutItemImportCurrent.AdjustLargeButtonSize(); ApplicationIcon = ApplicationIcons.Excel; + useForImportCheckEdit.ToolTip = Captions.Importer.UseFiltersForImportTooltip; useForImportCheckEdit.CheckedChanged += (s, a) => OnEvent(() => _dataPresenter.TriggerOnDataChanged()); dataViewingGridView.ColumnFilterChanged += (s, a) => OnEvent(() => _dataPresenter.TriggerOnDataChanged()); diff --git a/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx b/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx index 29a1e5cd6..e8eddc643 100644 --- a/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx +++ b/src/OSPSuite.UI/Views/Importer/ImporterDataView.resx @@ -117,7 +117,18 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - + + 17, 17 + + + 338, 17 + + + AAEAAAD/////AQAAAAAAAAAMAgAAAFpEZXZFeHByZXNzLlV0aWxzLnYyMS4yLCBWZXJzaW9uPTIxLjIu + My4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI4OGQxNzU0ZDcwMGU0OWEFAQAAADBE + ZXZFeHByZXNzLlV0aWxzLkRQSUF3YXJlSW1hZ2VDb2xsZWN0aW9uU3RyZWFtZXIAAAAAAgAAAAs= + + \ No newline at end of file