Skip to content

Untangle/Hack Pedigree UUID scheme so links work on fe - #553

Open
jloux-brapi wants to merge 4 commits into
feature/BI-2902from
feature/BI-2904
Open

Untangle/Hack Pedigree UUID scheme so links work on fe#553
jloux-brapi wants to merge 4 commits into
feature/BI-2902from
feature/BI-2904

Conversation

@jloux-brapi

@jloux-brapi jloux-brapi commented Sep 1, 2026

Copy link
Copy Markdown
Collaborator

Description

Story: BI-2904

  • Untangled/made a hack to modify germplasm.additionalInfo.male/femaleGermplasmUUID to convert bi-generated ids to the eventually saved brapi germplasmDbIds. This issue was causing links of female/parent Germplasm data table rows to throw and error when clicked, because these IDs are being looked up as brapi germplasmDbIds with the set of changes from feature/BI-2902. This is a rather messy/hacky fix I am using as a stop-gap until we decide to import pedigree after germplasm records are created. A comment explaining this situation has been provided in the code.
  • Added some comments for improvements/edits that will need to be made for the brapi endpoints, linking associated tickets.

Dependencies

epic/BI-2862 branch of brapi-java-prodserver
feature/BI-2905 branch of bi-web

Testing

Full regression for most germplasm features, excluding sample importing, which will be dealt with once develop bi-api code is merged and this ticket

This features include:

  • Importing Germplasm with various use cases, including parent lookups via existing germplasm lookups or via-entry numbers
  • Downloading imported germplasm
  • Viewing imported germplasm in the Germplasm tab, and clicking all associated links in the rows including the GID, both parent links, and Show Details
  • Clicking on existing Germplasm brings up the Pedigree Viewer, where you can click on other germplasm in the hierarchy tree. These should load without error. NOTE: A production bug was discovered clicking back in these scenarios, these changes did not cause this issue)

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 create/modified unit and/or integration tests to cover this change or tests are not applicable
  • I have commented my code, particularly in hard-to-understand areas
  • I have either updated the source of truth or arranged for update with product owner if needed https://breedinginsight.atlassian.net/wiki/spaces/BI/pages/1559953409/Source+of+Truth

…plement stopgap hack

Unit tests made me aware of the use case where rows in a gemrplasm import can reference other rows
in the import as parents, and when this happens, no germplasmDbId will be created until the germplasm is fully imported
because of the way the import is organized.

Until we manage to change this, I've created a stop-gap which will mutate this additional info on the fly from the bi-generated exrefs
to the brapiGermplasmDbIds in the BrAPIGermplasmDAO.processGermplasmForDisplay method.

This will lookup the germplasmDbIds of the pedigree nodes using the exrefs, and will mutate the additional info records for male/female IDs
so that the links still work as expected in the frontend UI
@jloux-brapi jloux-brapi changed the title Add comments to fix during BrAPI endpoint fixing Untangle/Hack Pedigree UUID scheme so links work on fe Sep 4, 2026
@jloux-brapi
jloux-brapi requested a review from humsika September 4, 2026 19:35
@jloux-brapi
jloux-brapi marked this pull request as ready for review September 4, 2026 19:35
private Map<String, String> getPedigreeGermplasmDbIdByBICreatedExRef(List<BrAPIGermplasm> brAPIGermplasm, Program program) throws ApiException {
Map<String, String> germplasmDbIdByGeneratedExRef = new HashMap<>();

for (BrAPIGermplasm germplasm : brAPIGermplasm) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

additionalInfo appears to be nullable, and the existing processing loop below explicitly handles that case. This new helper dereferences it before that normalization occurs, so one germplasm without additionalInfo could fail the entire response. Could we skip parent extraction when additionalInfo is null and also guard against JSON-null parent UUID values?

}
}

List<String> exRefIds = new ArrayList<>(germplasmDbIdByGeneratedExRef.keySet());

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

When no parent UUIDs are present, exRefIds is empty, but this method still sends a BrAPI search containing the program and external-reference source filters. Because the empty ID list does not restrict the search, this may retrieve all matching germplasm for the program even though there is nothing to resolve. Could we return an empty map before making the request?

namePedigreeString = parentNames.get(0);
uuidPedigreeString = additionalInfo.has(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_UUID) ? additionalInfo.get(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_UUID).getAsString() : "";
// Convert the bi-generated additionalInfo parent ID to the brapi germplasmDbId using map from previous step.
uuidPedigreeString = additionalInfo.has(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_UUID) ? pedigreeBrAPIGermplasmDbIdByBICreatedExRef.get(additionalInfo.get(BrAPIAdditionalInfoFields.GERMPLASM_FEMALE_PARENT_UUID).getAsString()) : "";

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

If the BrAPI search does not return one of the requested parent external references, Map.get() returns null. This can serialize pedigreeByUUID as JSON null or produce values such as null/, which BI-Web cannot safely use as a germplasm link. The old implementation did not have this lookup failure mode. Could we validate that every requested parent was resolved, or intentionally use an empty value/GID fallback instead of returning null?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Ultimately we have a huge problem if the search returns empty for a specific exref. In that case, we should probably just throw an error that prevents the page from loading.

GermplasmApi api = brAPIEndpointProvider.get(programDAO.getCoreClient(program.getId()), GermplasmApi.class);


List<BrAPIGermplasm> germplasmSearchedWithExRef = brAPIDAOUtil.searchNoPaging(

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

searchNoPaging() does not iterate additional pages for an asynchronous search result, and the result GET uses the configured 1,000-record page size. If this lookup can return more than 1,000 distinct parents, later mappings may remain unresolved. Can we use the paging-aware search method, or confirm and enforce that this request can never exceed one result page?

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.

2 participants