Conversation
| 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); |
There was a problem hiding this comment.
Looks good. I would just delete all of this.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Thanks! I received your full comment in Slack and have implemented your suggestions.
| } | ||
|
|
||
| return (List<U>) updatedObservations; | ||
| return (List<U>) brAPIObservationDAO.updateBrAPIObservation(mutatedObservationByDbId, importContext.getProgram().getId()); |
There was a problem hiding this comment.
and add this
| 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()); |
| 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); |
There was a problem hiding this comment.
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.
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: