-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MODORDERS-1237]. Create a new API and wrapper model for Claiming wit…
…h an Organization Id (#1085) * [MODORDERS-1237]. Create a new API and wrapper model for Claiming with an Organization Id * [MODORDERS-1237]. Update acq-models * [MODORDERS-1237]. Add unit tests * [MODORDERS-1237]. Add missing nested test class * [MODORDERS-1237]. Add missing class identifier * [MODORDERS-1237]. Add integration tests * [MODORDERS-1237]. Update acq-models * [MODORDERS-1237]. Add missing module permissions * [MODORDERS-1237]. Update acq-models
- Loading branch information
1 parent
173e518
commit cf17b50
Showing
18 changed files
with
883 additions
and
139 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Submodule acq-models
updated
9 files
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#%RAML 1.0 | ||
title: "Wrapper Pieces" | ||
baseUri: https://github.com/folio-org/mod-orders | ||
version: v4 | ||
|
||
documentation: | ||
- title: "Wrapper Pieces" | ||
content: <b>Read API to manage Wrapper Pieces.</b> | ||
|
||
types: | ||
errors: !include raml-util/schemas/errors.schema | ||
wrapper_piece: !include acq-models/mod-orders-storage/schemas/wrapper_piece.json | ||
wrapper_piece_collection: !include acq-models/mod-orders-storage/schemas/wrapper_piece_collection.json | ||
UUID: | ||
type: string | ||
pattern: ^[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[1-5][0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12}$ | ||
|
||
traits: | ||
orderable: !include raml-util/traits/orderable.raml | ||
pageable: !include raml-util/traits/pageable.raml | ||
searchable: !include raml-util/traits/searchable.raml | ||
|
||
resourceTypes: | ||
collection-get: !include raml-util/rtypes/collection-get.raml | ||
collection-item-get: !include raml-util/rtypes/item-collection-get-with-json-response.raml | ||
|
||
/orders/wrapper-pieces: | ||
type: | ||
collection-get: | ||
exampleCollection: !include acq-models/mod-orders-storage/examples/wrapper_piece_collection.sample | ||
schemaCollection: wrapper_piece_collection | ||
get: | ||
description: Get list of Wrapper Pieces | ||
is: [ | ||
searchable: {description: "with valid searchable fields: for example code", example: "[\"code\", \"MEDGRANT\", \"=\"]"}, | ||
pageable | ||
] | ||
/{id}: | ||
uriParameters: | ||
id: | ||
description: The UUID of a Wrapper Piece | ||
type: UUID | ||
type: | ||
collection-item-get: | ||
exampleItem: !include acq-models/mod-orders-storage/examples/wrapper_piece_get.sample | ||
schema: wrapper_piece |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package org.folio.rest.impl; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Context; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.Vertx; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.folio.rest.core.models.RequestContext; | ||
import org.folio.rest.jaxrs.resource.OrdersWrapperPieces; | ||
import org.folio.service.pieces.WrapperPieceStorageService; | ||
import org.folio.spring.SpringContextUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import javax.ws.rs.core.Response; | ||
import java.util.Map; | ||
|
||
import static io.vertx.core.Future.succeededFuture; | ||
|
||
@Log4j2 | ||
public class WrapperPiecesAPI extends BaseApi implements OrdersWrapperPieces { | ||
|
||
@Autowired | ||
private WrapperPieceStorageService wrapperPieceStorageService; | ||
|
||
public WrapperPiecesAPI() { | ||
SpringContextUtil.autowireDependencies(this, Vertx.currentContext()); | ||
} | ||
|
||
@Override | ||
public void getOrdersWrapperPieces(String query, String totalRecords, int offset, int limit, | ||
Map<String, String> okapiHeaders, Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) { | ||
wrapperPieceStorageService.getWrapperPieces(limit, offset, query, new RequestContext(vertxContext, okapiHeaders)) | ||
.onSuccess(wrapperPieces -> asyncResultHandler.handle(succeededFuture(buildOkResponse(wrapperPieces)))) | ||
.onFailure(fail -> handleErrorResponse(asyncResultHandler, fail)); | ||
} | ||
|
||
@Override | ||
public void getOrdersWrapperPiecesById(String id, Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) { | ||
wrapperPieceStorageService.getWrapperPieceById(id, new RequestContext(vertxContext, okapiHeaders)) | ||
.onSuccess(wrapperPiece -> asyncResultHandler.handle(succeededFuture(buildOkResponse(wrapperPiece)))) | ||
.onFailure(fail -> handleErrorResponse(asyncResultHandler, fail)); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
45 changes: 45 additions & 0 deletions
45
src/main/java/org/folio/service/pieces/WrapperPieceStorageService.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
package org.folio.service.pieces; | ||
|
||
import io.vertx.core.Future; | ||
import lombok.extern.log4j.Log4j2; | ||
import org.folio.rest.core.RestClient; | ||
import org.folio.rest.core.models.RequestContext; | ||
import org.folio.rest.core.models.RequestEntry; | ||
import org.folio.rest.jaxrs.model.WrapperPiece; | ||
import org.folio.rest.jaxrs.model.WrapperPieceCollection; | ||
import org.folio.service.consortium.ConsortiumConfigurationService; | ||
import org.folio.service.consortium.ConsortiumUserTenantsRetriever; | ||
import org.folio.service.settings.SettingsRetriever; | ||
|
||
import static org.folio.orders.utils.ResourcePathResolver.WRAPPER_PIECES_STORAGE; | ||
import static org.folio.orders.utils.ResourcePathResolver.resourcesPath; | ||
|
||
@Log4j2 | ||
public class WrapperPieceStorageService extends PieceStorageService { | ||
|
||
private static final String WRAPPER_PIECES_STORAGE_ENDPOINT = resourcesPath(WRAPPER_PIECES_STORAGE); | ||
private static final String WRAPPER_PIECES_STORAGE_BY_ID_ENDPOINT = WRAPPER_PIECES_STORAGE_ENDPOINT + "/{id}"; | ||
|
||
public WrapperPieceStorageService(ConsortiumConfigurationService consortiumConfigurationService, | ||
ConsortiumUserTenantsRetriever consortiumUserTenantsRetriever, | ||
SettingsRetriever settingsRetriever, RestClient restClient) { | ||
super(consortiumConfigurationService, consortiumUserTenantsRetriever, settingsRetriever, restClient); | ||
} | ||
|
||
public Future<WrapperPieceCollection> getWrapperPieces(int limit, int offset, String query, RequestContext requestContext) { | ||
return getUserTenantsIfNeeded(requestContext) | ||
.map(userTenants -> getQueryForUserTenants(userTenants, query)) | ||
.compose(cql -> getAllWrapperPieces(limit, offset, cql, requestContext)); | ||
} | ||
|
||
private Future<WrapperPieceCollection> getAllWrapperPieces(int limit, int offset, String query, RequestContext requestContext) { | ||
log.debug("getAllWrapperPieces:: limit: {}, offset: {}, query: {}", limit, offset, query); | ||
var requestEntry = new RequestEntry(WRAPPER_PIECES_STORAGE_ENDPOINT).withQuery(query).withOffset(offset).withLimit(limit); | ||
return restClient.get(requestEntry, WrapperPieceCollection.class, requestContext); | ||
} | ||
|
||
public Future<WrapperPiece> getWrapperPieceById(String pieceId, RequestContext requestContext) { | ||
var requestEntry = new RequestEntry(WRAPPER_PIECES_STORAGE_BY_ID_ENDPOINT).withId(pieceId); | ||
return restClient.get(requestEntry, WrapperPiece.class, requestContext); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.