-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
1409 importer handling of imvalid files #1437
Changes from 2 commits
b728d54
3f308dc
e53b503
0c922de
a219c50
50be51b
1421907
86eacc7
d76ef41
2a41306
aa1c1f8
4ea57b1
cb2c8a3
3a58ecb
066441e
bb32d68
72834f9
f6b6adc
70ba716
dd693a3
566ca79
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<string, IDataSet> DataSets { get; } | ||
IEnumerable<string> NamesFromConvention(); | ||
NanSettings NanSettings { get; set; } | ||
ImportedDataSet DataSetAt(int index); | ||
ImportedDataSet ImportedDataSetAt(int index); | ||
IDataSet DataSetAt(int index); | ||
ParseErrors ValidateDataSourceUnits(IReadOnlyList<ColumnInfo> columnInfos); | ||
} | ||
|
||
|
@@ -155,7 +155,26 @@ public IEnumerable<string> NamesFromConvention() | |
return _importer.NamesFromConvention(_configuration.NamingConventions, _configuration.FileName, DataSets, _mappings); | ||
} | ||
|
||
public ImportedDataSet DataSetAt(int index) | ||
public IDataSet DataSetAt(int index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's talk about this in the meeting. I don't understand what this is doing. |
||
{ | ||
var sheetIndex = 0; | ||
var sheet = DataSets.GetEnumerator(); | ||
var accumulatedIndexes = 0; | ||
while (sheet.MoveNext() && index >= 0) | ||
{ | ||
if (sheet.Current.Data.Count() > index) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. (sheet.Current.Data.Count() 3 times in the same while loop. Maybe cache it? |
||
{ | ||
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<ColumnI | |
return errors; | ||
} | ||
|
||
ParseErrors IDataSource.ValidateDataSourceUnits(IReadOnlyList<ColumnInfo> columnInfos) | ||
public ParseErrors ValidateDataSourceUnits(IReadOnlyList<ColumnInfo> columnInfos) | ||
{ | ||
var errors = validateUnitsSupportedAndSameDimension(columnInfos); | ||
errors.Add(validateErrorAgainstMeasurement(columnInfos)); | ||
|
This file was deleted.
This file was deleted.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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<string, IDataSet> _lastLoadedDataSets = new Cache<string, IDataSet>(); | ||
|
||
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<string> 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])) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. somehow this feels like this code belongs in the presenter. |
||
{ | ||
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,14 +328,19 @@ private void refreshErrorMarks() | |
{ | ||
if (_lastLoadedDataSets.Contains(x.Text)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. this codes for which image to show also belongs in the presenter |
||
{ | ||
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; | ||
} | ||
|
||
x.ImageIndex = -1; | ||
}); | ||
} | ||
|
||
public void SetTabMarks(ParseErrors errors) | ||
{ | ||
SetTabMarks(errors, _lastLoadedDataSets); | ||
} | ||
|
||
public void SetTabMarks(ParseErrors errors, Cache<string, IDataSet> loadedDataSets) | ||
{ | ||
_lastErrors = errors; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't like this as a cache exposed. DataSet are added outside of the DataSource as it stands