diff --git a/ramls/pieces.raml b/ramls/pieces.raml index ef6e47029..e4b5e2157 100644 --- a/ramls/pieces.raml +++ b/ramls/pieces.raml @@ -11,7 +11,7 @@ documentation: types: piece: !include acq-models/mod-orders-storage/schemas/piece.json piece-collection: !include acq-models/mod-orders-storage/schemas/piece_collection.json - piece-batch-status: !include acq-models/mod-orders/schemas/pieceStatusBatchCollection.json + piece-batch-status-collection: !include acq-models/mod-orders/schemas/pieceStatusBatchCollection.json errors: !include raml-util/schemas/errors.schema UUID: type: string @@ -148,7 +148,7 @@ resourceTypes: description: Batch status update for pieces body: application/json: - type: piece-batch-status + type: piece-batch-status-collection example: strict: false value: !include acq-models/mod-orders/examples/pieceStatusBatchCollection.sample diff --git a/src/main/java/org/folio/rest/impl/PiecesAPI.java b/src/main/java/org/folio/rest/impl/PiecesAPI.java index dd129cb10..fed949a28 100644 --- a/src/main/java/org/folio/rest/impl/PiecesAPI.java +++ b/src/main/java/org/folio/rest/impl/PiecesAPI.java @@ -13,7 +13,7 @@ import org.folio.rest.annotations.Validate; import org.folio.rest.core.models.RequestContext; import org.folio.rest.jaxrs.model.Piece; -import org.folio.rest.jaxrs.model.PieceBatchStatus; +import org.folio.rest.jaxrs.model.PieceBatchStatusCollection; import org.folio.rest.jaxrs.resource.OrdersPieces; import org.folio.rest.jaxrs.resource.OrdersPiecesRequests; import org.folio.service.CirculationRequestsRetriever; @@ -63,9 +63,8 @@ public void postOrdersPieces(boolean createItem, Piece entity, Map> asyncResultHandler, Context vertxContext) { pieceCreateFlowManager.createPiece(entity, createItem, new RequestContext(vertxContext, okapiHeaders)) .onSuccess(piece -> { - if (logger.isInfoEnabled()) { - logger.debug("Successfully created piece: {}", JsonObject.mapFrom(piece) - .encodePrettily()); + if (logger.isDebugEnabled()) { + logger.debug("Successfully created piece: {}", JsonObject.mapFrom(piece).encodePrettily()); } asyncResultHandler.handle(succeededFuture(buildCreatedResponse(piece))); }) @@ -112,9 +111,9 @@ public void getOrdersPiecesRequests(List pieceIds, String status, Map okapiHeaders, + public void putOrdersPiecesBatchStatus(PieceBatchStatusCollection pieceBatchStatusCollection, Map okapiHeaders, Handler> asyncResultHandler, Context vertxContext) { - pieceUpdateFlowManager.updatePiecesStatuses(entity.getPieceIds(), entity.getReceivingStatus(), new RequestContext(vertxContext, okapiHeaders)) + pieceUpdateFlowManager.updatePiecesStatuses(pieceBatchStatusCollection.getPieceIds(), pieceBatchStatusCollection.getReceivingStatus(), new RequestContext(vertxContext, okapiHeaders)) .onSuccess(v -> asyncResultHandler.handle(succeededFuture(buildNoContentResponse()))) .onFailure(t -> handleErrorResponse(asyncResultHandler, t)); } diff --git a/src/main/java/org/folio/service/pieces/flows/update/PieceUpdateFlowManager.java b/src/main/java/org/folio/service/pieces/flows/update/PieceUpdateFlowManager.java index 7bdc38d3d..fde3cb785 100644 --- a/src/main/java/org/folio/service/pieces/flows/update/PieceUpdateFlowManager.java +++ b/src/main/java/org/folio/service/pieces/flows/update/PieceUpdateFlowManager.java @@ -19,7 +19,7 @@ import org.folio.rest.jaxrs.model.CompositePurchaseOrder.WorkflowStatus; import org.folio.rest.jaxrs.model.Location; import org.folio.rest.jaxrs.model.Piece; -import org.folio.rest.jaxrs.model.PieceBatchStatus; +import org.folio.rest.jaxrs.model.PieceBatchStatusCollection; import org.folio.service.ProtectionService; import org.folio.service.orders.PurchaseOrderLineService; import org.folio.service.pieces.PieceService; @@ -89,7 +89,7 @@ public Future updatePiece(Piece pieceToUpdate, boolean createItem, boolean .mapEmpty(); } - public Future updatePiecesStatuses(List pieceIds, PieceBatchStatus.ReceivingStatus receivingStatus, RequestContext requestContext) { + public Future updatePiecesStatuses(List pieceIds, PieceBatchStatusCollection.ReceivingStatus receivingStatus, RequestContext requestContext) { var newStatus = Piece.ReceivingStatus.fromValue(receivingStatus.value()); return pieceStorageService.getPiecesByIds(pieceIds, requestContext) .map(pieces -> pieces.stream().collect(Collectors.groupingBy(Piece::getPoLineId)))