-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CIRC-1785 Add "service point for the effective location" and "Request Date"as staff slip token #1280
base: master
Are you sure you want to change the base?
CIRC-1785 Add "service point for the effective location" and "Request Date"as staff slip token #1280
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -44,6 +44,7 @@ public class TemplateContextUtil { | |
private static final String FEE_CHARGE = "feeCharge"; | ||
private static final String FEE_ACTION = "feeAction"; | ||
private static final String UNLIMITED = "unlimited"; | ||
private static final String PICK_SLIPS_KEY = "pickSlips"; | ||
|
||
private TemplateContextUtil() { | ||
} | ||
|
@@ -108,6 +109,19 @@ public static JsonObject createStaffSlipContext(Request request) { | |
return createStaffSlipContext(request.getItem(), request); | ||
} | ||
|
||
public static JsonObject addPrimaryServicePointNameToStaffSlipContext(JsonObject entries, ServicePoint primaryServicePoint) { | ||
if (entries == null) { | ||
return new JsonObject(); | ||
} | ||
if(primaryServicePoint == null) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Space is missing (different style from line 113) |
||
return entries; | ||
} | ||
entries.getJsonArray(PICK_SLIPS_KEY).stream().forEach(pickSlip -> { | ||
((JsonObject)pickSlip).getJsonObject(ITEM).put("effectiveLocationPrimaryServicePointName", primaryServicePoint.getName()); | ||
}); | ||
return entries; | ||
} | ||
|
||
public static JsonObject createStaffSlipContext( | ||
Item item, Request request) { | ||
|
||
|
@@ -184,6 +198,7 @@ private static JsonObject createItemContext(Item item) { | |
if (location != null) { | ||
itemContext | ||
.put("effectiveLocationSpecific", location.getName()) | ||
.put("effectiveLocationPrimaryServicePointName", location.getPrimaryServicePoint().getName()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this changes the API (and is looks like it does - we're adding another field to the |
||
.put("effectiveLocationLibrary", location.getLibraryName()) | ||
.put("effectiveLocationCampus", location.getCampusName()) | ||
.put("effectiveLocationInstitution", location.getInstitutionName()) | ||
|
@@ -231,6 +246,9 @@ private static JsonObject createRequestContext(Request request) { | |
.map(Request::getPickupServicePoint) | ||
.map(ServicePoint::getName) | ||
.ifPresent(value -> requestContext.put("servicePointPickup", value)); | ||
optionalRequest | ||
.map(Request::getRequestDate) | ||
.ifPresent(value -> write(requestContext, "requestDate", value)); | ||
Comment on lines
+249
to
+251
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I believe this should a part of another PR because it's not required in CIRC-1785, but anyway, is it covered with tests? |
||
optionalRequest | ||
.map(Request::getRequestExpirationDate) | ||
.ifPresent(value -> write(requestContext, "requestExpirationDate", value)); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -104,6 +104,8 @@ private void getMany(RoutingContext routingContext) { | |
.thenComposeAsync(r -> r.after(addressTypeRepository::findAddressTypesForRequests)) | ||
.thenComposeAsync(r -> r.after(servicePointRepository::findServicePointsForRequests)) | ||
.thenApply(flatMapResult(this::mapResultToJson)) | ||
.thenComposeAsync(a -> a.combineAfter(() -> servicePointRepository.getServicePointById(servicePointId), | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If |
||
TemplateContextUtil::addPrimaryServicePointNameToStaffSlipContext)) | ||
.thenApply(r -> r.map(JsonHttpResponse::ok)) | ||
.thenAccept(context::writeResultToHttpResponse); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We now have to follow this doc https://wiki.folio.org/display/DD/Logging when creating new code.
mod-circulation
is still not fully covered with the new-style logging yet, but the new code already needs to meet this criteria. I think it would be nice to at least coveraddPrimaryServicePointNameToStaffSlipContext
method