Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[MODORDSTOR-356] - Initial setup of claiming batch job #793

Merged
merged 4 commits into from
Nov 16, 2023
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Date;
import java.util.List;
import java.util.Map;
import java.util.Objects;
Expand Down Expand Up @@ -400,8 +401,9 @@ protected Future<Map<String, List<Piece>>> storeUpdatedPieceRecords(Map<String,
.ofValues(piecesGroupedByPoLine)
.flatMap(List::stream)
.filter(this::isSuccessfullyProcessedPiece)
.map((Piece piece) -> storeUpdatedPieceRecord(piece, requestContext))
.collect(Collectors.toList());
.map(piece -> piece.withStatusUpdatedDate(new Date()))
SerhiiNosko marked this conversation as resolved.
Show resolved Hide resolved
.map(piece -> storeUpdatedPieceRecord(piece, requestContext))
.toList();

return GenericCompositeFuture.join(futures)
.map(v -> piecesGroupedByPoLine);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import static org.folio.orders.utils.HelperUtils.collectResultsOnSuccess;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.concurrent.CompletionException;
Expand Down Expand Up @@ -121,18 +122,23 @@ public Future<Void> updatePieceRecord(Piece piece, RequestContext requestContext
.compose(v -> inventoryManager.updateItemWithPieceFields(piece, requestContext))
.onSuccess(vVoid ->
pieceStorageService.getPieceById(piece.getId(), requestContext).onSuccess(pieceStorage -> {
Piece.ReceivingStatus receivingStatusUpdate = piece.getReceivingStatus();
Piece.ReceivingStatus receivingStatusStorage = pieceStorage.getReceivingStatus();
boolean isReceivingStatusChanged = receivingStatusStorage.compareTo(receivingStatusUpdate) != 0;

if(isReceivingStatusChanged) {
Copy link
Contributor

Choose a reason for hiding this comment

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

let's add info log here that can help us in troubleshooting

Copy link
Contributor Author

Choose a reason for hiding this comment

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

we already have loggin statements in #L138 and #L139

Copy link
Contributor

Choose a reason for hiding this comment

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

basically they are with debug level and basically separate log that include pieceId and both statuses(from and to) would be useful expessionally if we have logic with conditional statements, but it up to you

piece.setStatusUpdatedDate(new Date());
}

pieceStorageService.updatePiece(piece, requestContext)
.onSuccess(ok -> {
promise.complete();
JsonObject messageToEventBus = new JsonObject();
messageToEventBus.put("poLineIdUpdate", piece.getPoLineId());

Piece.ReceivingStatus receivingStatusUpdate = piece.getReceivingStatus();
logger.debug("receivingStatusStorage -- {}", receivingStatusStorage);
logger.debug("receivingStatusUpdate -- {}", receivingStatusUpdate);

if (receivingStatusStorage.compareTo(receivingStatusUpdate) != 0) {
if (isReceivingStatusChanged) {
receiptStatusPublisher.sendEvent(MessageAddress.RECEIPT_STATUS, messageToEventBus, requestContext);
}
})
Expand Down