Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/main/java/org/breedinginsight/daos/impl/TraitDAOImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -165,9 +165,17 @@ private List<Trait> fetchTraitsFullByProgramId(UUID programId) {
return new ArrayList<>();
}

String brapiProgramDbId;

try {
brapiProgramDbId = brAPIDAOUtil.getBrAPIProgramDbId(programId);
} catch (ApiException e) {
throw new InternalServerException(String.format("While fetching traits, unable to retrieve brapi programDbId using bi program ID [%s]", programId), e);
}

// Get brapi variables
VariableQueryParams variablesRequest = new VariableQueryParams();
variablesRequest.externalReferenceSource(referenceSource);
variablesRequest.programDbId(brapiProgramDbId);

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.

since traits are now fetched only by programDbId, any variable with a NULL program_id will trigger the throw at line 211 for the whole program. The only way I can see that happening is if the ProdServer migration runs first and the old bi-api creates a trait before this version is deployed. Will these three PRs always be deployed together? If not, it might be worth falling back to the exref lookup for any trait IDs missing from the result.

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.

Yes, the plan is deploy all of these PRs together.

I think this release will be major enough we can take down the sites for a bit of time so that corner case cannot happen. @nickpalladino can give his two cents.

Another option is to make programDbId mandatory for the prod server side, which would mean a failure if it's not submitted in a creation request. That said, none of the other cache entities have program as non null so I think it's relatively safe to move forward.

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.

Thanks, the coordinated deployment addresses the rollout concern.

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.

sounds good

variablesRequest.pageSize(10000);

ApiResponse<BrAPIObservationVariableListResponse> brApiVariables;
Expand Down Expand Up @@ -354,6 +362,14 @@ public List<Trait> createTraitsBrAPI(List<Trait> traits, User actingUser, Progra

//TODO: Pass ontology reference

String brapiProgramDbId;

try {
brapiProgramDbId = brAPIDAOUtil.getBrAPIProgramDbId(program.getId());
} catch (ApiException e) {
throw new InternalServerException(String.format("While creating traits, unable to fetch brapi programDbId using bi program with id [%s]", program.getId()), e);
}

// Convert our traits into BrAPI traits
List<BrAPIObservationVariable> brApiVariables = new ArrayList<>();
for (Trait trait: traits) {
Expand Down Expand Up @@ -419,7 +435,8 @@ public List<Trait> createTraitsBrAPI(List<Trait> traits, User actingUser, Progra
.defaultValue(trait.getDefaultValue())
.synonyms(trait.getSynonyms())
.institution(program.getName())
.commonCropName(program.getSpecies().getCommonName());
.commonCropName(program.getSpecies().getCommonName())
.programDbId(brapiProgramDbId);
if (trait.getTags() != null) brApiVariable.putAdditionalInfoItem(TAGS_KEY, trait.getTags());
if (trait.getFullName() != null) brApiVariable.putAdditionalInfoItem(FULLNAME_KEY, trait.getFullName());

Expand Down
Loading