Skip to content

BI-1183 - Import Validations: Ontology-specific observation criteria#210

Merged
nickpalladino merged 97 commits intodevelopfrom
feature/BI-1183
Oct 25, 2022
Merged

BI-1183 - Import Validations: Ontology-specific observation criteria#210
nickpalladino merged 97 commits intodevelopfrom
feature/BI-1183

Conversation

@nickpalladino
Copy link
Member

@nickpalladino nickpalladino commented Sep 12, 2022

Description

Story: BI-1183

  • Added import template dynamic column processing for phenotypes
  • Added validations of phenotype column data

Dependencies

Testing

  • Example test file included. Test validations to ensure they are working according to card acceptance criteria.
  • demo.xlsx

Checklist:

  • I have performed a self-review of my own code
  • I have tested my code and ensured it meets the acceptance criteria of the story
  • I have tested that my code works with both the brapi-java-server and BreedBase
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: <please include a link to TAF run>

rob-ouser-bi and others added 27 commits August 3, 2022 16:49
Converted semaphore to use Redisson's semaphore (distributed semaphore)
…ce/impl design pattern

Introduced flag to suppress refreshing cache on startup if desired (useful for integration tests)
@nickpalladino nickpalladino requested review from a team, HMS17 and timparsons and removed request for a team October 4, 2022 17:53
@Override
public Map<String, ImportPreviewStatistics> process(List<BrAPIImport> importRows,
Map<Integer, PendingImport> mappedBrAPIImport, Program program, User user, boolean commit) throws ValidatorException {
Map<Integer, PendingImport> mappedBrAPIImport, Table table,
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor thing, but is there a reason you went with Table table here and in Processor.java and then Table data in other files?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope, I will change them all to data to be consistent. Pushed changes.

ValidationErrors validationErrors = new ValidationErrors();

// Get dynamic phenotype columns for processing
List<Column<?>> phenotypeCols = fileMappingUtil.getDynamicColumns(data, "ExperimentsTemplateMap");
Copy link
Member

Choose a reason for hiding this comment

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

Is there a constant that's defined anywhere for the ExperimentsTemplateMap? If not, can that be added?

Copy link
Member Author

Choose a reason for hiding this comment

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

No, I'll add one. Pushed changes.

Comment on lines +70 to +71
Function3<String, Integer, Integer, ApiResponse<Pair<Optional<T>, Optional<BrAPIAcceptedSearchResponse>>>> searchGetMethod3,
Function4<BrAPIWSMIMEDataTypes, String, Integer, Integer, ApiResponse<Pair<Optional<T>, Optional<BrAPIAcceptedSearchResponse>>>> searchGetMethod4,
Copy link
Member

Choose a reason for hiding this comment

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

For naming of these to parameters, what about:

  • searchGetMethod3 goes back to searchGetMethod
  • searchGetMethod4 changes to searchGetMethodWithMimeType

Copy link
Member Author

Choose a reason for hiding this comment

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

Sounds good, also added method to reuse, pushed changes.

Copy link
Member

@timparsons timparsons left a comment

Choose a reason for hiding this comment

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

I had tried importing 4 files:

Result: FAIL - Error during validation:

java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.get(Optional.java:141)
	at org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor.validateObservationValue(ExperimentProcessor.java:757)
	at org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor.process(ExperimentProcessor.java:209)
	at org.breedinginsight.brapps.importer.services.processors.ProcessorManager.process(ProcessorManager.java:65)
	at org.breedinginsight.brapps.importer.model.imports.experimentObservation.ExperimentImportService.process(ExperimentImportService.java:71)
	at org.breedinginsight.brapps.importer.services.FileImportService.lambda$processFile$4(FileImportService.java:406)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1771)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1763)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Result: PASS - was presented with the preview table

Result: PASS - Error showing unrecognized columns

Result: FAIL - Error during validation:

java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.get(Optional.java:141)
	at org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor.validateObservationValue(ExperimentProcessor.java:757)
	at org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor.process(ExperimentProcessor.java:209)
	at org.breedinginsight.brapps.importer.services.processors.ProcessorManager.process(ProcessorManager.java:65)
	at org.breedinginsight.brapps.importer.model.imports.experimentObservation.ExperimentImportService.process(ExperimentImportService.java:71)
	at org.breedinginsight.brapps.importer.services.FileImportService.lambda$processFile$4(FileImportService.java:406)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1771)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1763)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Traits used: bi_ontology_template_v11_2021-12-01-test-ontology-with-method-desc.xls

@nickpalladino
Copy link
Member Author

I had tried importing 4 files:

* [BI_1183_valid_columns.csv](https://github.com/Breeding-Insight/bi-api/files/9748497/BI_1183_valid_columns.csv)

Result: FAIL - Error during validation:

java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.get(Optional.java:141)
	at org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor.validateObservationValue(ExperimentProcessor.java:757)
	at org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor.process(ExperimentProcessor.java:209)
	at org.breedinginsight.brapps.importer.services.processors.ProcessorManager.process(ProcessorManager.java:65)
	at org.breedinginsight.brapps.importer.model.imports.experimentObservation.ExperimentImportService.process(ExperimentImportService.java:71)
	at org.breedinginsight.brapps.importer.services.FileImportService.lambda$processFile$4(FileImportService.java:406)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1771)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1763)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)
* [BI_1183_valid_with_data.csv](https://github.com/Breeding-Insight/bi-api/files/9748498/BI_1183_valid_with_data.csv)

Result: PASS - was presented with the preview table

* [BI_1183_invalid_columns.csv](https://github.com/Breeding-Insight/bi-api/files/9748499/BI_1183_invalid_columns.csv)

Result: PASS - Error showing unrecognized columns

* [BI_1183_invalid_data.csv](https://github.com/Breeding-Insight/bi-api/files/9748500/BI_1183_invalid_data.csv)

Result: FAIL - Error during validation:

java.util.NoSuchElementException: No value present
	at java.base/java.util.Optional.get(Optional.java:141)
	at org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor.validateObservationValue(ExperimentProcessor.java:757)
	at org.breedinginsight.brapps.importer.services.processors.ExperimentProcessor.process(ExperimentProcessor.java:209)
	at org.breedinginsight.brapps.importer.services.processors.ProcessorManager.process(ProcessorManager.java:65)
	at org.breedinginsight.brapps.importer.model.imports.experimentObservation.ExperimentImportService.process(ExperimentImportService.java:71)
	at org.breedinginsight.brapps.importer.services.FileImportService.lambda$processFile$4(FileImportService.java:406)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1771)
	at java.base/java.util.concurrent.CompletableFuture$AsyncSupply.exec(CompletableFuture.java:1763)
	at java.base/java.util.concurrent.ForkJoinTask.doExec(ForkJoinTask.java:290)
	at java.base/java.util.concurrent.ForkJoinPool$WorkQueue.topLevelExec(ForkJoinPool.java:1016)
	at java.base/java.util.concurrent.ForkJoinPool.scan(ForkJoinPool.java:1665)
	at java.base/java.util.concurrent.ForkJoinPool.runWorker(ForkJoinPool.java:1598)
	at java.base/java.util.concurrent.ForkJoinWorkerThread.run(ForkJoinWorkerThread.java:183)

Traits used: bi_ontology_template_v11_2021-12-01-test-ontology-with-method-desc.xls

Pushed fix for failing cases

@nickpalladino nickpalladino changed the base branch from future/1.0 to develop October 14, 2022 18:45
try {
traits = ontologyService.getTraitsByProgramId(program.getId(), true);
} catch (DoesNotExistException e) {
log.error(e.getMessage());
Copy link
Member

Choose a reason for hiding this comment

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

Can you add the exception e as a second parameter to this log statement (that way the stack trace will be printed too)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, pushed changes.

break;
case DATE:
if (!validDateValue(value)) {
addRowError(columnHeader, "Incorrect date format (YYYY-MM-DD) detected", validationErrors, row);
Copy link
Member

Choose a reason for hiding this comment

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

This error message is a little confusing. What about "Incorrect date format detected. Expected YYYY-MM-DD"?

Copy link
Member Author

Choose a reason for hiding this comment

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

Sure, pushed changes.

}

private boolean validNumericRange(BigDecimal value, Scale validValues) {
if (value.compareTo(BigDecimal.valueOf(validValues.getValidValueMin())) >= 0 &&
Copy link
Member

Choose a reason for hiding this comment

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

This code will throw a NullPointerException if validValues.getValidValueMin or validValues.getValidValueMax are null

Copy link
Member Author

Choose a reason for hiding this comment

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

Thanks for spotting that, pushed changes.

@nickpalladino nickpalladino merged commit 15797c9 into develop Oct 25, 2022
@nickpalladino nickpalladino deleted the feature/BI-1183 branch October 25, 2022 19:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants