use of org.folio.rest.core.exceptions.ErrorCodes.MISSING_INSTANCE_STATUS in project mod-orders by folio-org.
the class InventoryManager method createInstanceRecord.
public CompletableFuture<String> createInstanceRecord(Title title, RequestContext requestContext) {
JsonObject lookupObj = new JsonObject();
CompletableFuture<Void> instanceTypeFuture = getEntryId(INSTANCE_TYPES, MISSING_INSTANCE_TYPE, requestContext).thenAccept(lookupObj::mergeIn);
CompletableFuture<Void> statusFuture = getEntryId(INSTANCE_STATUSES, MISSING_INSTANCE_STATUS, requestContext).thenAccept(lookupObj::mergeIn);
CompletableFuture<Void> contributorNameTypeIdFuture = verifyContributorNameTypesExist(title.getContributors(), requestContext);
return allOf(instanceTypeFuture, statusFuture, contributorNameTypeIdFuture).thenApply(v -> buildInstanceRecordJsonObject(title, lookupObj)).thenCompose(instanceJson -> createInstance(instanceJson, requestContext));
}
use of org.folio.rest.core.exceptions.ErrorCodes.MISSING_INSTANCE_STATUS in project mod-orders by folio-org.
the class InventoryManager method createInstanceRecord.
/**
* Creates Instance Record in Inventory and returns its Id.
*
* @param compPOL PO line to create Instance Record for
* @return id of newly created Instance Record
*/
private CompletableFuture<String> createInstanceRecord(CompositePoLine compPOL, RequestContext requestContext) {
logger.debug("Start processing instance record");
JsonObject lookupObj = new JsonObject();
CompletableFuture<Void> instanceTypeFuture = getEntryId(INSTANCE_TYPES, MISSING_INSTANCE_TYPE, requestContext).thenAccept(lookupObj::mergeIn);
CompletableFuture<Void> statusFuture = getEntryId(INSTANCE_STATUSES, MISSING_INSTANCE_STATUS, requestContext).thenAccept(lookupObj::mergeIn);
CompletableFuture<Void> contributorNameTypeIdFuture = verifyContributorNameTypesExist(compPOL.getContributors(), requestContext);
return CompletableFuture.allOf(instanceTypeFuture, statusFuture, contributorNameTypeIdFuture).thenApply(v -> buildInstanceRecordJsonObject(compPOL, lookupObj)).thenCompose(instanceRecJson -> {
logger.debug("Instance record to save : {}", instanceRecJson);
RequestEntry requestEntry = new RequestEntry(INVENTORY_LOOKUP_ENDPOINTS.get(INSTANCES));
return restClient.post(requestEntry, instanceRecJson, PostResponseType.UUID, String.class, requestContext);
});
}
Aggregations