Skip to content

Merge of BI-2093 and BI-2134#376

Merged
davedrp merged 4 commits intodevelopfrom
bug/BI-2093-2
Jul 26, 2024
Merged

Merge of BI-2093 and BI-2134#376
davedrp merged 4 commits intodevelopfrom
bug/BI-2093-2

Conversation

@davedrp
Copy link
Contributor

@davedrp davedrp commented Jul 17, 2024

Description

This is just a merge, but it was originally branched of a pre-BI-2134 branch, it warrants retesting. Here is the original PR

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 tested that my code works with both the brapi-java-server and BreedBase
  • I have create/modified unit tests to cover this change
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to documentation
  • I have run TAF: <please include a link to TAF run>

@davedrp davedrp requested a review from dmeidlin July 17, 2024 19:38
@github-actions github-actions bot added the bug Something isn't working label Jul 17, 2024
@davedrp davedrp changed the title Merge of BI-2093 and BI-2109 Merge of BI-2093 and BI-2134 Jul 22, 2024
Comment on lines +116 to +121
Map<String, BrAPIObservation> mutatedObservationByDbId = new HashMap<>();
List<BrAPIObservation> updatedObservations = new ArrayList<>();
for (U member : members) {
BrAPIObservation observation = (BrAPIObservation) member;
Optional.ofNullable(brAPIObservationDAO.updateBrAPIObservation(observation.getObservationDbId(), observation, importContext.getProgram().getId())).ifPresent(updatedObservations::add);
mutatedObservationByDbId.put(observation.getObservationDbId(), observation);
// Optional.ofNullable(brAPIObservationDAO.updateBrAPIObservation(observation.getObservationDbId(), observation, importContext.getProgram().getId())).ifPresent(updatedObservations::add);
Copy link
Contributor

Choose a reason for hiding this comment

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

Looks good. I would just delete all of this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I may be misunderstanding your comment, but mutatedObservationByDbId is used on line 124. If I delete lines 116-121 it will not be declared or populated.

Copy link
Contributor

Choose a reason for hiding this comment

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

Github doesn't let me compose a suggestion on deleted lines, so I had to put the replacement in my next comment below. The map is defined there.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks! I received your full comment in Slack and have implemented your suggestions.

@davedrp davedrp requested a review from dmeidlin July 25, 2024 14:35
}

return (List<U>) updatedObservations;
return (List<U>) brAPIObservationDAO.updateBrAPIObservation(mutatedObservationByDbId, importContext.getProgram().getId());
Copy link
Contributor

Choose a reason for hiding this comment

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

and add this

Suggested change
return (List<U>) brAPIObservationDAO.updateBrAPIObservation(mutatedObservationByDbId, importContext.getProgram().getId());
Map<String, BrAPIObservation> mutatedObservationByDbId = members.stream().collect(Collectors.toMap(
m -> ((BrAPIObservation) m).getObservationDbId(),
m -> ((BrAPIObservation) m)
));
return (List<U>) brAPIObservationDAO.updateBrAPIObservation(mutatedObservationByDbId, importContext.getProgram().getId());

Comment on lines +116 to +121
Map<String, BrAPIObservation> mutatedObservationByDbId = new HashMap<>();
List<BrAPIObservation> updatedObservations = new ArrayList<>();
for (U member : members) {
BrAPIObservation observation = (BrAPIObservation) member;
Optional.ofNullable(brAPIObservationDAO.updateBrAPIObservation(observation.getObservationDbId(), observation, importContext.getProgram().getId())).ifPresent(updatedObservations::add);
mutatedObservationByDbId.put(observation.getObservationDbId(), observation);
// Optional.ofNullable(brAPIObservationDAO.updateBrAPIObservation(observation.getObservationDbId(), observation, importContext.getProgram().getId())).ifPresent(updatedObservations::add);
Copy link
Contributor

Choose a reason for hiding this comment

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

Github doesn't let me compose a suggestion on deleted lines, so I had to put the replacement in my next comment below. The map is defined there.

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

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants