-
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-1209]. Implement API to Send claims for multiple pieces (#…
…1054) * [MODORDERS-1209]. Implement API to Send claims for multiple pieces * [MODORDERS-1209]. Update acq-models & add descriptors * [MODORDERS-1209]. Update service with latest acq-models changes * [MODORDERS-1209]. Add API tests, clean MockServer * [MODORDERS-1209]. Improve claiming result output * [MODORDERS-1209]. Remove logging * [MODORDERS-1209]. Temporary change export type, add logging * [MODORDERS-1209]. Remove temporary change export type, change return results, fix tests * [MODORDERS-1209]. Add sleep 1000 * [MODORDERS-1209]. Change test log level * [MODORDERS-1209]. Fix failing handleGetPieces * [MODORDERS-1209]. Add missing pieceRecord to mockData * [MODORDERS-1209]. Fix handleGetPieceById method * [MODORDERS-1209]. Fix handleGetPieces * [MODORDERS-1209]. Revert handleGetPieces & add try-catch * [MODORDERS-1209]. Remove try-catch, change piece status validation * [MODORDERS-1209]. Update piece mockData with Late status * [MODORDERS-1209]. Update piece status validation * [MODORDERS-1209]. Add more logs * [MODORDERS-1209]. Add more logs * [MODORDERS-1209]. Remove piece from mockData piece collections * [MODORDERS-1209]. Add more logging * [MODORDERS-1209]. Add claimPieceIds to job integration details * [MODORDERS-1209]. Add more logs * [MODORDERS-1209]. Fix MockServer handleGetPieces from interfering * [MODORDERS-1209]. Revert getPiecesByIds * [MODORDERS-1209]. Update tests * [MODORDERS-1209]. Fix sonar * [MODORDERS-1209]. Apply review recommendations * [MODORDERS-1209]. Fix descriptors * [MODORDERS-1209]. Add claimedPieceIds assertion to job creation * [MODORDERS-1209]. Add unit tests, add ClaimingError enum * [MODORDERS-1209]. Fix minor typos * [MODORDERS-1209]. Update descriptors * [MODORDERS-1209]. Remove redundant message * [MODORDERS-1209]. Change log level * [MODORDERS-1209]. Remove old logs, change arg name * [MODORDERS-1209]. Fix sonar issue, change log level * [MODORDERS-1209]. Remove CANNOT_COMPLETE_REQ from onComplete
- Loading branch information
1 parent
8092d97
commit 65197ef
Showing
26 changed files
with
1,546 additions
and
281 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
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,39 @@ | ||
#%RAML 1.0 | ||
title: Claim | ||
baseUri: https://github.com/folio-org/mod-orders | ||
version: v1 | ||
protocols: [ HTTP, HTTPS ] | ||
|
||
documentation: | ||
- title: Pieces Business Logic API | ||
content: <b>API for claiming pieces</b> | ||
|
||
types: | ||
claiming-collection: !include acq-models/mod-orders/schemas/claimingCollection.json | ||
claiming-results: !include acq-models/mod-orders/schemas/claimingResults.json | ||
errors: !include raml-util/schemas/errors.schema | ||
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: | ||
validate: !include raml-util/traits/validation.raml | ||
|
||
resourceTypes: | ||
post-with-200: !include rtypes/post-json-200.raml | ||
|
||
/pieces/claim: | ||
displayName: Claim pieces | ||
description: | | ||
Claim pieces. The endpoint is used to: | ||
- Claims pieces grouped by organizations | ||
- Triggers jobs in mod-data-export per each organization that contains an integration detail | ||
type: | ||
post-with-200: | ||
requestSchema: claiming-collection | ||
responseSchema: claiming-results | ||
requestExample: !include acq-models/mod-orders/examples/claimingCollection.sample | ||
responseExample: !include acq-models/mod-orders/examples/claimingResults.sample | ||
is: [validate] | ||
post: | ||
description: Claim pieces |
17 changes: 17 additions & 0 deletions
17
src/main/java/org/folio/models/claiming/ClaimingError.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,17 @@ | ||
package org.folio.models.claiming; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum ClaimingError { | ||
CANNOT_SEND_CLAIMS_PIECE_IDS_ARE_EMPTY("Cannot send claims, piece ids are empty"), | ||
CANNOT_FIND_PIECES_WITH_LATE_STATUS_TO_PROCESS("Cannot find pieces with LATE status to process"), | ||
CANNOT_RETRIEVE_CONFIG_ENTRIES("Cannot retrieve config entries"), | ||
CANNOT_GROUP_PIECES_BY_VENDOR_MESSAGE("Cannot group pieces by vendor"), | ||
CANNOT_CREATE_JOBS_AND_UPDATE_PIECES("Cannot create jobs and update pieces"), | ||
CANNOT_FIND_A_PIECE_BY_ID("Cannot find a piece by '%s' id"); | ||
|
||
private final String value; | ||
} |
14 changes: 14 additions & 0 deletions
14
src/main/java/org/folio/models/claiming/IntegrationDetailField.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,14 @@ | ||
package org.folio.models.claiming; | ||
|
||
import lombok.AllArgsConstructor; | ||
import lombok.Getter; | ||
|
||
@Getter | ||
@AllArgsConstructor | ||
public enum IntegrationDetailField { | ||
EXPORT_TYPE_SPECIFIC_PARAMETERS("exportTypeSpecificParameters"), | ||
VENDOR_EDI_ORDERS_EXPORT_CONFIG("vendorEdiOrdersExportConfig"), | ||
CLAIM_PIECE_IDS("claimPieceIds"); | ||
|
||
private final String value; | ||
} |
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,46 @@ | ||
package org.folio.rest.impl; | ||
|
||
import io.vertx.core.AsyncResult; | ||
import io.vertx.core.Context; | ||
import io.vertx.core.Future; | ||
import io.vertx.core.Handler; | ||
import io.vertx.core.Vertx; | ||
import org.folio.rest.annotations.Validate; | ||
import org.folio.rest.core.models.RequestContext; | ||
import org.folio.rest.jaxrs.model.ClaimingCollection; | ||
import org.folio.rest.jaxrs.resource.PiecesClaim; | ||
import org.folio.service.pieces.PiecesClaimingService; | ||
import org.folio.spring.SpringContextUtil; | ||
import org.springframework.beans.factory.annotation.Autowired; | ||
|
||
import javax.ws.rs.core.Response; | ||
import java.util.Map; | ||
|
||
import static org.folio.orders.utils.ResourcePathResolver.PIECES_CLAIMING_BUSINESS; | ||
import static org.folio.orders.utils.ResourcePathResolver.resourceByIdPath; | ||
import static org.folio.rest.RestConstants.OKAPI_URL; | ||
|
||
public class PiecesClaimingApi extends BaseApi implements PiecesClaim { | ||
|
||
@Autowired | ||
private PiecesClaimingService pieceClaimingService; | ||
|
||
public PiecesClaimingApi() { | ||
SpringContextUtil.autowireDependencies(this, Vertx.currentContext()); | ||
} | ||
|
||
@Override | ||
@Validate | ||
public void postPiecesClaim(ClaimingCollection claimingCollection, Map<String, String> okapiHeaders, | ||
Handler<AsyncResult<Response>> asyncResultHandler, Context vertxContext) { | ||
var requestContext = new RequestContext(vertxContext, okapiHeaders); | ||
pieceClaimingService.sendClaims(claimingCollection, requestContext) | ||
.onSuccess(claimingResults -> { | ||
var okapiUrl = okapiHeaders.get(OKAPI_URL); | ||
var url = resourceByIdPath(PIECES_CLAIMING_BUSINESS); | ||
var response = buildResponseWithLocation(okapiUrl, url, claimingResults); | ||
asyncResultHandler.handle(Future.succeededFuture(response)); | ||
}) | ||
.onFailure(t -> handleErrorResponse(asyncResultHandler, t)); | ||
} | ||
} |
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.