[BI-2328] Experimental observation file import removes periods from column headers#411
[BI-2328] Experimental observation file import removes periods from column headers#411
Conversation
| .additionalInfo(toJsonObject(additionalInfoString)) | ||
| .collector("intern") | ||
| .externalReferences(createExternalReferences()) | ||
| .geoCoordinates(BrApiGeoJSON.builder().geometry(null).type("Feature").build()) |
There was a problem hiding this comment.
What was the reason this was removed?
There was a problem hiding this comment.
this was a problem I had locally. It should not have been uploaded. I will revert it.
-Thanks
| return new ValidationError("observationVariableName", "Period in name is invalid", HttpStatus.BAD_REQUEST); | ||
| } |
There was a problem hiding this comment.
I think it would be good to keep the error messages consistent between TraitValidatortError and TraitFileValidatorError, so for example, this message could be changed to "Period is invalid".
There was a problem hiding this comment.
This is a banner error message. Table messages have a field the tells the user which field contains the error, banner messages do not. So, it was decided that this message should contain the name of the filed.
| if (name != null && name.contains(".")){ | ||
| ValidationError error = traitValidatorErrors.getPeriodObsVarNameMsg(); | ||
| errors.addError(traitValidatorErrors.getRowNumber(i), error); | ||
| } |
There was a problem hiding this comment.
This check is fine as is, but since this validation step is checking the entire trait format, it might be nice to use a regex here so that it can be easily updated in the future to handle additional characters or edge cases.
| if (name != null && name.contains(".")){ | |
| ValidationError error = traitValidatorErrors.getPeriodObsVarNameMsg(); | |
| errors.addError(traitValidatorErrors.getRowNumber(i), error); | |
| } | |
| Pattern pattern = Pattern.compile("\\."); | |
| Matcher matcher = pattern.matcher(name); | |
| boolean containsInvalidCharacter = matcher.find(); | |
| if (name != null && containsInvalidCharacter){ | |
| ValidationError error = traitValidatorErrors.getPeriodObsVarNameMsg(); | |
| errors.addError(traitValidatorErrors.getRowNumber(i), error); | |
| } |
|
Looks good, and tests passed. Thanks for including the test import file! |
BI-2328 Experimental observation file import removes periods from column headers
Added a validation so that a user can no longer add an ontology term with a period (.) in the Name field.
Dependencies
bi-web: bug/BI-2328
Testing
Test 1 (Manually add Ontology)
Test 2 (import Ontology)
Error(s) detected in file, bi_ontology_UAT-tyrwh-oat.xls . (See details below.) Import cannot proceed."Checklist: