Skip to content

OBPIH-7777 Add validation support for bulk data imports#6019

Open
ewaterman wants to merge 2 commits into
feature/receiving-redesignfrom
ft/OBPIH-7777-import-validation
Open

OBPIH-7777 Add validation support for bulk data imports#6019
ewaterman wants to merge 2 commits into
feature/receiving-redesignfrom
ft/OBPIH-7777-import-validation

Conversation

@ewaterman

Copy link
Copy Markdown
Member

✨ Description of Change

Link to GitHub issue or Jira ticket: https://pihemr.atlassian.net/browse/OBPIH-7777

Description: Add support for validating imported bulk data rows during the new import process (that uses apache POI).

@ewaterman ewaterman self-assigned this Jul 9, 2026
@github-actions github-actions Bot added type: feature A new piece of functionality for the app domain: backend Changes or discussions relating to the backend server labels Jul 9, 2026

errors.add(new BulkDataError(
row: null, // We rely on customValidate to set this later
column: null, // TODO: we can get this from the config using fieldName!

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I'm going to address this TODO in the next (and final?) PR

* A simple configurer of custom validation for use in tests.
* The validation itself is arbitrary. We just define something so that we can make assertions on it.
*/
class BulkDataValidatorConfigurerForTest implements ConfiguresBulkDataValidator<ImportableForTest> {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This class is an example of how we'd add custom validation behaviour to an importer. You create a new ConfiguresBulkDataValidator and override customValidateRow. Then you call errors.addFieldError to add new errors. It works similarly to the new Validator trait that I added a few months ago.

My next PR will make it much clearer how this all ties in together. Essentially to set up a new importer all you need to do is add a component like:

@Component
class ProductImportConfigurer implements ConfiguresBulkDataBinder<Product>,
                                         ConfiguresBulkDataValidator<Product> {

    <...override all the methods to configure the importer...>

}

and then we can start importing Products via the generic import API

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 52.56410% with 37 lines in your changes missing coverage. Please review.
⚠️ Please upload report for BASE (feature/receiving-redesign@a4d0275). Learn more about missing BASE report.

Files with missing lines Patch % Lines
...rg/pih/warehouse/importer/BulkDataValidator.groovy 59.45% 8 Missing and 7 partials ⚠️
...y/org/pih/warehouse/importer/BulkDataErrors.groovy 42.85% 8 Missing ⚠️
...se/importer/BulkDataImportComponentResolver.groovy 20.00% 7 Missing and 1 partial ⚠️
...ehouse/importer/ConfiguresBulkDataValidator.groovy 57.14% 3 Missing and 3 partials ⚠️
Additional details and impacted files
@@                      Coverage Diff                      @@
##             feature/receiving-redesign    #6019   +/-   ##
=============================================================
  Coverage                              ?   11.16%           
  Complexity                            ?     1787           
=============================================================
  Files                                 ?      862           
  Lines                                 ?    48550           
  Branches                              ?    11367           
=============================================================
  Hits                                  ?     5420           
  Misses                                ?    42247           
  Partials                              ?      883           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@jmiranda

Copy link
Copy Markdown
Member

FYI, i'm working on this and will finalize the review tomorrow.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

domain: backend Changes or discussions relating to the backend server type: feature A new piece of functionality for the app

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants