Skip to content
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

1872 importer metaData messed up fixed #1873

Merged
merged 1 commit into from
Jan 25, 2023

Conversation

georgeDaskalakis
Copy link
Contributor

@msevestre @Yuri05 @rwmcintosh this error comes from the fact that when we are setting the mappings for the DataSource, we first set the mapping parameters and then add the grouping ones:

private void loadSheets(IDataSourceFile dataSourceFile, IReadOnlyList<string> sheetNames, string filter, string selectedNamingConvention = null)
{
if (!sheetNames.Any())
{
View.DisableConfirmationView();
return;
}
var sheets = dataSourceFile.DataSheets.GetDataSheetsByName(sheetNames);
var dataMappings = dataSourceFile.Format.Parameters.OfType<MetaDataFormatParameter>().Where(p => p.ColumnName != null).Select(md =>
new MetaDataMappingConverter()
{
Id = md.MetaDataId,
Index = sheetName => md.IsColumn ? dataSourceFile.DataSheets.GetDataSheetByName(sheetName).GetColumnDescription(md.ColumnName).Index : -1
}).ToList();
var mappings = dataMappings.Union
(
dataSourceFile.Format.Parameters.OfType<GroupByDataFormatParameter>().Select(md => new MetaDataMappingConverter()
{
//in case of a duplicate name coming from an excel column used as a grouping by with the same name as a metaData, we add a suffix
Id = dataMappings.ExistsById(md.ColumnName) ? md.ColumnName + Constants.ImporterConstants.GroupingBySuffix : md.ColumnName,
Index = sheetName => dataSourceFile.DataSheets.GetDataSheetByName(sheetName).GetColumnDescription(md.ColumnName).Index
})
).ToList();
_dataSource.SetMappings(dataSourceFile.Path, mappings);

whereas when creating the ParsedDataSet we would just get all the parameters in a row. That means that when the user would set the grouping and afterwards set a mapping parameter, all the mappings set after the grouping would get assigned wrong values.

@georgeDaskalakis georgeDaskalakis self-assigned this Jan 22, 2023
@georgeDaskalakis georgeDaskalakis linked an issue Jan 22, 2023 that may be closed by this pull request
@Yuri05
Copy link
Member

Yuri05 commented Jan 24, 2023

2merge | ¬ 2merge ?

@rwmcintosh
Copy link
Member

2merge | ¬ 2merge ?

My comment is only a suggestion to improve the readability for @georgeDaskalakis.

@georgeDaskalakis
Copy link
Contributor Author

@Yuri05 I have implemented Rob's suggestion - since @msevestre has not had any comments I think we can merge yes

@Yuri05 Yuri05 merged commit 6ef98c4 into develop Jan 25, 2023
@Yuri05 Yuri05 deleted the 1872-importer-metadata-messed-up branch January 25, 2023 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Importer: Meta data messed up
3 participants