use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RequestScheduledNoticeService method rescheduleRequestNotices.
public Result<RequestAndRelatedRecords> rescheduleRequestNotices(RequestAndRelatedRecords relatedRecords) {
Request request = relatedRecords.getRequest();
scheduledNoticesRepository.deleteByRequestId(request.getId()).thenAccept(r -> r.next(resp -> scheduleRequestNotices(request)));
return succeeded(relatedRecords);
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class TemplateContextUtil method createCheckInContext.
public static JsonObject createCheckInContext(CheckInContext context) {
Item item = context.getItem();
Request firstRequest = context.getHighestPriorityFulfillableRequest();
JsonObject staffSlipContext = createStaffSlipContext(item, firstRequest);
JsonObject itemContext = staffSlipContext.getJsonObject(ITEM);
if (ObjectUtils.allNotNull(item, itemContext)) {
write(itemContext, "lastCheckedInDateTime", ClockUtil.getZonedDateTime());
if (item.getInTransitDestinationServicePoint() != null) {
itemContext.put("fromServicePoint", context.getCheckInServicePoint().getName());
itemContext.put("toServicePoint", item.getInTransitDestinationServicePoint().getName());
}
}
return staffSlipContext;
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RollingLoanPolicyCheckOutDueDateCalculationTests method shouldApplyAlternateScheduleWhenQueuedRequestIsHoldAndRolling.
@Test
void shouldApplyAlternateScheduleWhenQueuedRequestIsHoldAndRolling() {
final Period alternateCheckoutLoanPeriod = Period.from(2, "Weeks");
final ZonedDateTime systemTime = ZonedDateTime.of(2019, 6, 14, 11, 23, 43, 0, UTC);
LoanPolicy loanPolicy = LoanPolicy.from(new LoanPolicyBuilder().rolling(Period.months(1)).withAlternateCheckoutLoanPeriod(alternateCheckoutLoanPeriod).create()).withDueDateSchedules(new FixedDueDateSchedulesBuilder().addSchedule(FixedDueDateSchedule.wholeYear(systemTime.getYear())).create());
Item item = Item.from(new ItemBuilder().checkOut().withId(UUID.randomUUID()).create());
Loan loan = Loan.from(new LoanBuilder().withItemId(UUID.fromString(item.getItemId())).withLoanDate(systemTime).create());
Request requestOne = Request.from(new RequestBuilder().withId(UUID.randomUUID()).withPosition(1).create());
Request requestTwo = Request.from(new RequestBuilder().withId(UUID.randomUUID()).withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).hold().withItemId(UUID.fromString(loan.getItemId())).withPosition(2).create());
RequestQueue requestQueue = new RequestQueue(asList(requestOne, requestTwo));
ZonedDateTime calculatedDueDate = loanPolicy.calculateInitialDueDate(loan, requestQueue).value();
String key = "alternateCheckoutLoanPeriod";
ZonedDateTime expectedDueDate = alternateCheckoutLoanPeriod.addTo(systemTime, () -> errorForLoanPeriod(format("the \"%s\" is not recognized", key)), interval -> errorForLoanPeriod(format("the interval \"%s\" in \"%s\" is not recognized", interval, key)), dur -> errorForLoanPeriod(format("the duration \"%s\" in \"%s\" is invalid", dur, key))).value();
assertThat(calculatedDueDate, is(expectedDueDate));
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RequestRepository method batchUpdate.
CompletableFuture<Result<Collection<Request>>> batchUpdate(Collection<Request> requests) {
if (requests == null || requests.isEmpty()) {
return CompletableFuture.completedFuture(succeeded(requests));
}
ResponseInterpreter<Collection<Request>> interpreter = new ResponseInterpreter<Collection<Request>>().on(201, of(() -> requests)).otherwise(forwardOnFailure());
RequestBatch requestBatch = new RequestBatch(requests);
return requestsBatchStorageClient.post(requestBatch.toJson()).thenApply(interpreter::flatMap);
}
use of org.folio.circulation.domain.Request in project mod-circulation by folio-org.
the class RequestRepository method update.
public CompletableFuture<Result<Request>> update(Request request) {
final JsonObject representation = new StoredRequestRepresentation().storedRequest(request);
final ResponseInterpreter<Request> interpreter = new ResponseInterpreter<Request>().on(204, of(() -> request)).otherwise(forwardOnFailure());
return requestsStorageClient.put(request.getId(), representation).thenApply(interpreter::flatMap);
}
Aggregations