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

1374 create configuration for should store dimension #1382

Merged
merged 4 commits into from
Nov 19, 2021

Conversation

abdelr
Copy link
Member

@abdelr abdelr commented Nov 18, 2021

Fixes #1374 (CreateConfigurationFor should store dimension)

@abdelr abdelr added the Importer Observed data importer label Nov 18, 2021
@abdelr abdelr self-assigned this Nov 18, 2021
if (mappingColumn?.Unit == null || mappingColumn.Dimension != null)
continue;

var concreteColumnInfo = columnInfos.FirstOrDefault(x => x.Name == parameter.MappedColumn.Name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

used mappingColumn instead of parameter.MappedColumn

{
var mappingColumn = parameter.MappedColumn;

if (mappingColumn?.Unit == null || mappingColumn.Dimension != null)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why mappingColumn? in the first part of the if but not in the second? this is not logical. Either you fear that mappingColumn is null or you don't fear. But it should always be the same behavior

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If mappingColumn (I have just renamed it to mappedColumn, I think it makes more sense) is null, then the first part will be true and then the second part will not be evaluated. But I agree it is not fully logic to have it only on the first part. I will add it to the second part even though it is totally useless.

if (mappingColumn?.Unit == null || mappingColumn.Dimension != null)
continue;

var concreteColumnInfo = columnInfos.FirstOrDefault(x => x.Name == parameter.MappedColumn.Name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

FirstOrDefault means thius cam be null. Or you do not check for null. Therefor either a check is missing or it should be First

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

True, I changed it to First since null will mean the configuration is wrong and it should actually throw.

mappingColumn.Unit.SelectedUnit == UnitDescription.InvalidUnit)
{
mappingColumn.Dimension = concreteColumnInfo.DefaultDimension;
mappingColumn.Unit = new UnitDescription(mappingColumn.Dimension.BaseUnit.Name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this supposed to be the baseUnit or the DefaultUnit? We also have a DEfaultUnitName property directly

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right, DefaultUnitName should be the one.

@@ -109,53 +109,9 @@ private void setDataFormat(IList<DataFormatParameter> formatParameters)
View.SetMappingSource(_mappings);
ValidateMapping();
InitializeErrorUnit();
setDimensionsForMappings();
//setDimensionsForMappings();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

@abdelr abdelr requested a review from msevestre November 19, 2021 20:19
Copy link
Member

@msevestre msevestre left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok

@@ -60,7 +60,7 @@ private void setDimensionsForMappings(IReadOnlyList<ColumnInfo> columnInfos)
if (mappedColumn?.Unit == null || mappedColumn?.Dimension != null)
continue;

var concreteColumnInfo = columnInfos.First(x => x.Name == mappedColumn.Name);
var concreteColumnInfo = columnInfos.First(x => x.DisplayName == mappedColumn.Name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the displayName of a column Info? Do we have instances where it's not the same as Name? I think this makes sense to use DisplayName but I don't know why we have this in the first place

@msevestre msevestre merged commit fe9e0f5 into develop Nov 19, 2021
@msevestre msevestre deleted the 1374_CreateConfigurationFor_should_store_dimension branch November 19, 2021 20:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Importer Observed data importer
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CreateConfigurationFor(string dataPath, string sheetName = null) does not store dimension of columns
2 participants