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.

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