use of org.folio.circulation.domain.RequestLevel in project mod-circulation by folio-org.
the class RequestFromRepresentationService method validateRequestLevel.
private Result<Request> validateRequestLevel(Request request) {
JsonObject representation = request.getRequestRepresentation();
String requestLevelRaw = representation.getString(REQUEST_LEVEL);
RequestLevel requestLevel = RequestLevel.from(requestLevelRaw);
boolean tlrEnabled = request.getTlrSettingsConfiguration().isTitleLevelRequestsFeatureEnabled();
List<RequestLevel> allowedStatuses = tlrEnabled ? List.of(ITEM, TITLE) : List.of(ITEM);
if (!allowedStatuses.contains(requestLevel)) {
String allowedStatusesJoined = allowedStatuses.stream().map(existingLevel -> StringUtils.wrap(existingLevel.getValue(), '"')).collect(Collectors.joining(", "));
return failedValidation("requestLevel must be one of the following: " + allowedStatusesJoined, "requestLevel", requestLevelRaw);
}
return succeeded(request);
}
use of org.folio.circulation.domain.RequestLevel in project mod-circulation by folio-org.
the class RequestScheduledNoticeService method scheduleRequestNotices.
public Result<RequestAndRelatedRecords> scheduleRequestNotices(RequestAndRelatedRecords relatedRecords) {
Request request = relatedRecords.getRequest();
if (request.isClosed()) {
return succeeded(relatedRecords);
}
RequestLevel requestLevel = relatedRecords.getRequest().getRequestLevel();
if (requestLevel == TITLE) {
scheduleTlrRequestNotices(relatedRecords.getRequest());
} else if (requestLevel == ITEM) {
scheduleRequestNotices(relatedRecords.getRequest());
}
return succeeded(relatedRecords);
}
Aggregations