use of org.folio.circulation.domain.User in project mod-circulation by folio-org.
the class TemplateContextUtil method createStaffSlipContext.
public static JsonObject createStaffSlipContext(Item item, Request request) {
JsonObject staffSlipContext = new JsonObject();
if (item != null) {
JsonObject itemContext = createItemContext(item);
if (item.getLastCheckIn() != null) {
write(itemContext, "lastCheckedInDateTime", item.getLastCheckIn().getDateTime());
}
staffSlipContext.put(ITEM, itemContext);
}
if (request != null) {
staffSlipContext.put(REQUEST, createRequestContext(request));
User requester = request.getRequester();
if (requester != null) {
staffSlipContext.put(REQUESTER, createUserContext(requester, request.getDeliveryAddressTypeId()));
}
}
return staffSlipContext;
}
use of org.folio.circulation.domain.User in project mod-circulation by folio-org.
the class GroupedLoanScheduledNoticeHandler method sendGroupedNotice.
private CompletableFuture<Result<List<ScheduledNoticeContext>>> sendGroupedNotice(List<ScheduledNoticeContext> contexts) {
if (contexts.isEmpty()) {
log.warn("No notices left in the group to process, skipping the group");
return completedFuture(succeeded(contexts));
}
List<ScheduledNoticeContext> relevantContexts = contexts.stream().filter(not(loanScheduledNoticeHandler::isNoticeIrrelevant)).collect(toList());
if (relevantContexts.isEmpty()) {
log.warn("No relevant notices in the group, skipping the group");
return completedFuture(succeeded(contexts));
}
// All the notices have the same properties so we can get any of them
ScheduledNoticeContext contextSample = relevantContexts.get(0);
User user = contextSample.getLoan().getUser();
List<Loan> loans = relevantContexts.stream().map(ScheduledNoticeContext::getLoan).collect(toList());
log.info("Attempting to send a grouped notice for {} scheduled notices", relevantContexts.size());
return patronNoticeService.sendNotice(contextSample.getNotice().getConfiguration(), user.getId(), createMultiLoanNoticeContext(user, loans), buildNoticeLogContext(relevantContexts, user)).thenApply(mapResult(v -> contexts));
}
use of org.folio.circulation.domain.User in project mod-circulation by folio-org.
the class InactiveUserValidatorTests method refuseWhenUserIsNeitherActiveNorInactive.
@Test
void refuseWhenUserIsNeitherActiveNorInactive() {
final User steve = new User(basedUponStevenJones().neitherActiveOrInactive().create());
final InactiveUserValidator validator = forUser(steve.getBarcode());
final Result<LoanAndRelatedRecords> result = validator.refuseWhenUserIsInactive(steve, null);
assertThat(result.failed(), is(true));
}
use of org.folio.circulation.domain.User in project mod-circulation by folio-org.
the class CheckInByBarcodeTests method canCreateStaffSlipContextOnCheckInByBarcode.
@Test
void canCreateStaffSlipContextOnCheckInByBarcode() {
ItemResource item = itemsFixture.basedUponSmallAngryPlanet();
ZonedDateTime requestDate = ZonedDateTime.of(2019, 7, 22, 10, 22, 54, 0, UTC);
IndividualResource servicePoint = servicePointsFixture.cd1();
Address address = SiriusBlack();
IndividualResource requester = usersFixture.steve(builder -> builder.withAddress(address));
final var requestExpiration = java.time.LocalDate.of(2019, 7, 30);
final var holdShelfExpiration = java.time.LocalDate.of(2019, 8, 31);
IndividualResource request = requestsFixture.place(new RequestBuilder().withId(UUID.randomUUID()).open().page().forItem(item).by(requester).withRequestDate(requestDate).fulfilToHoldShelf().withRequestExpiration(requestExpiration).withHoldShelfExpiration(holdShelfExpiration).withPickupServicePointId(servicePoint.getId()).withDeliveryAddressType(addressTypesFixture.home().getId()).withPatronComments("I need the book").withTags(new RequestBuilder.Tags(asList("new", "important"))));
ZonedDateTime checkInDate = ZonedDateTime.of(2019, 7, 25, 14, 23, 41, 0, UTC);
CheckInByBarcodeResponse response = checkInFixture.checkInByBarcode(item, checkInDate, servicePoint.getId());
User requesterUser = new User(requester.getJson());
JsonObject staffSlipContext = response.getStaffSlipContext();
JsonObject userContext = staffSlipContext.getJsonObject("requester");
JsonObject requestContext = staffSlipContext.getJsonObject("request");
assertThat(userContext.getString("firstName"), is(requesterUser.getFirstName()));
assertThat(userContext.getString("lastName"), is(requesterUser.getLastName()));
assertThat(userContext.getString("middleName"), is(requesterUser.getMiddleName()));
assertThat(userContext.getString("barcode"), is(requesterUser.getBarcode()));
assertThat(userContext.getString("addressLine1"), is(address.getAddressLineOne()));
assertThat(userContext.getString("addressLine2"), is(address.getAddressLineTwo()));
assertThat(userContext.getString("city"), is(address.getCity()));
assertThat(userContext.getString("region"), is(address.getRegion()));
assertThat(userContext.getString("postalCode"), is(address.getPostalCode()));
assertThat(userContext.getString("countryId"), is(address.getCountryId()));
assertThat(requestContext.getString("deliveryAddressType"), is(addressTypesFixture.home().getJson().getString("addressType")));
assertThat(requestContext.getString("requestExpirationDate"), isEquivalentTo(ZonedDateTime.of(requestExpiration.atTime(23, 59, 59), ZoneOffset.UTC)));
assertThat(requestContext.getString("holdShelfExpirationDate"), isEquivalentTo(ZonedDateTime.of(holdShelfExpiration.atStartOfDay(), ZoneOffset.UTC)));
assertThat(requestContext.getString("requestID"), is(request.getId()));
assertThat(requestContext.getString("servicePointPickup"), is(servicePoint.getJson().getString("name")));
assertThat(requestContext.getString("patronComments"), is("I need the book"));
}
use of org.folio.circulation.domain.User in project mod-circulation by folio-org.
the class InactiveUserValidatorTests method refuseInactiveUser.
@Test
void refuseInactiveUser() {
final User steve = new User(basedUponStevenJones().inactive().create());
final InactiveUserValidator validator = forUser(steve.getBarcode());
final Result<LoanAndRelatedRecords> result = validator.refuseWhenUserIsInactive(steve, null);
assertThat(result.failed(), is(true));
}
Aggregations