Skip to content

[BI-2903] Support for program_id in germplasm table - #23

Open
jloux-brapi wants to merge 6 commits into
epic/BI-2862from
feature/BI-2903
Open

[BI-2903] Support for program_id in germplasm table#23
jloux-brapi wants to merge 6 commits into
epic/BI-2862from
feature/BI-2903

Conversation

@jloux-brapi

@jloux-brapijloux-brapi commented Aug 11, 2026

Copy link
Copy Markdown

Description

Story:BI-2903

  • Created a migration script to add program_id column to the germplasm along with a foreign constraint and index to support BI's need to lookup germplasm by program id directly.
  • Entity/model support for the new table schema
  • Updated germplasm GET to support lookups by programDbId and programName, and to look them up utilizing the new column
  • Updated germplasm POST search to support looking up programDbId and programNames utilizing new column
  • Updated germplasm PUT update code to support updating a germplasm with supplied programDbId
  • Updated germplasm POST create to supporting creating a germplasm with supplied programDbId

Dependencies

brapi

Testing

  • Verify happy and unhappy paths for germplasm GET with params programDbId and programName
  • Verify happy and unhappy paths for germplasm POST search with programDbIds and programNames
  • Verify happy and unhappy paths for germplasm PUT update with valid/invalid programDbId present
  • Verify happy and unhappy paths for germplasm POST create with valid/invalid programDbIds present in requested germplasm objects to create

Checklist:

@jloux-brapijloux-brapi changed the title Feature/bi 2903[BI-2903] Support for program_id in germplasm tableAug 12, 2026
Base automatically changed from feature/BI-2996 to epic/BI-2862August 24, 2026 20:41
ADD CONSTRAINT germplasm_program_fk
FOREIGN KEY (program_id)
REFERENCES public.program(id)
ON DELETE CASCADE;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Wonder if we should not cascade, seems the convention for other entities related to program like trials and studies, etc. is no action.

updateSynonymEntities(request.getSynonyms(), entity);
if (request.getTaxonIds() != null)
updateTaxonEntities(request.getTaxonIds(), entity);
if (!foundProgramsByDbId.isEmpty()) {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Not applicable for deltabreed use case but may want to fix for general usage. Since foundProgramsByDbId is shared across germplasm in the batch if some germplasm have a program id and some don't then this could result in a NullPointerException on the UUID.fromString call because request.getProgramDbId() could be null.

Something like this should resolve it:

 if (request.getProgramDbId() != null) {
ProgramEntity program =
foundProgramsByDbId.get(UUID.fromString(request.getProgramDbId()));
entity.setProgram(program);
}

SELECT g.id AS germplasm_id, p.id AS program_id
from germplasm g
JOIN germplasm_external_references gex ON g.id = gex.germplasm_entity_id
JOIN external_reference ex ON ex.id = gex.external_references_id

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Maybe we should also constrain on the germplasm exref source being breedinginsight.org/programs

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

@jloux-brapi@nickpalladino