-
Notifications
You must be signed in to change notification settings - Fork 1
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
[BI-2355] - Non-informative error message: regression #423
Conversation
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.
Tested, working.
I'm approving, but I'd recommend simplifying using the code in my comments. I tested the functionality before and after applying my change, it works either way.
// replace certain special characters with "" in column names to deal with json flattening issue in tablesaw | ||
// this includes ".", "[", "[" | ||
List<String> columnNames = df.columnNames(); | ||
List<String> namesToReplace = new ArrayList<>(); | ||
for (String name : columnNames) { | ||
if (name.contains(".")) { | ||
if (name.contains(".") || name.contains("[") || name.contains("]")) { | ||
namesToReplace.add(name); | ||
} | ||
} | ||
|
||
List<Column<?>> columns = df.columns(namesToReplace.stream().toArray(String[]::new)); | ||
for (int i=0; i<columns.size(); i++) { | ||
Column<?> column = columns.get(i); | ||
column.setName(namesToReplace.get(i).replace(".","")); | ||
//if more characters, could use replaceall and regex, but this works presently | ||
column.setName(namesToReplace.get(i).replace(".","").replace("[","").replace("]","")); | ||
} |
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 might be missing something, but it seems to me that lines 174-189 could be replaced with the following with the same behavior and efficiency.
// Replace certain special characters with "" in column names to deal with json flattening issue in tablesaw,
// this includes ".", "[", "]".
df.columns().forEach(
(c) -> c.setName(c.name().replace(".","").replace("[","").replace("]",""))
);
You could check with Nick about why the code was initially structured that way, but I think this way is more clear.
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.
Good point, it looks a lot more elegant that way!
src/main/java/org/breedinginsight/brapps/importer/services/FileImportService.java
Outdated
Show resolved
Hide resolved
public ValidationError getPeriodObsVarNameMsg() { | ||
return new ValidationError("observationVariableName", "Period in name is invalid", HttpStatus.BAD_REQUEST); | ||
public ValidationError getInvalidCharObsVarNameMsg() { | ||
return new ValidationError("observationVariableName", "Periods and brackets in name is invalid", HttpStatus.BAD_REQUEST); |
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'm often wrong on matters of grammar, but I think "...in name are invalid" sounds better.
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.
Good catch!
Co-authored-by: mlm483 <[email protected]>
Description
(New branch due to soiled changelist in previous attempt)
Story: BI-2355 - Non-informative error message: regression
This error was due to tablesaw processing brackets weirdly, resulting in the column name stored in data not matching the column name stored in dynamic column names. This was fixed in two parts:
Removing brackets from ontology term names on upload
Preventing ontology terms with brackets in the name from being created by extending the functionality created in BI-2328
Note that this means for the error message re ontology terms not found, periods and brackets will be removed from the invalid ontology term names
Dependencies
bi-web: bug/BI-2355.2
Testing
Test that on upload of an experiment file with invalid ontology term columns headings that contain brackets and/or periods that the unknown error message no longer shows and instead the invalid ontology term message shows
Test that upload of experiment file with valid ontology terms proceeds as expected
Test that the appropriate error is thrown when an ontology term contains ".", "[" and/or "]" and that that error is not thrown when the ontology term does not contain those characters for:
Checklist: