use of org.folio.circulation.domain.Location in project mod-circulation by folio-org.
the class ItemSummaryRepresentation method createItemSummary.
public JsonObject createItemSummary(Item item) {
if (item == null || item.isNotFound()) {
return new JsonObject();
}
JsonObject itemSummary = new JsonObject();
write(itemSummary, "id", item.getItemId());
write(itemSummary, "holdingsRecordId", item.getHoldingsRecordId());
write(itemSummary, "instanceId", item.getInstanceId());
write(itemSummary, "title", item.getTitle());
write(itemSummary, "barcode", item.getBarcode());
write(itemSummary, "contributors", mapContributorNamesToJson(item));
write(itemSummary, "callNumber", item.getCallNumber());
write(itemSummary, "enumeration", item.getEnumeration());
write(itemSummary, "chronology", item.getChronology());
write(itemSummary, "volume", item.getVolume());
write(itemSummary, "copyNumber", item.getCopyNumber());
write(itemSummary, CALL_NUMBER_COMPONENTS, createCallNumberComponents(item.getCallNumberComponents()));
JsonObject status = new JsonObject().put("name", item.getStatus().getValue());
if (Objects.nonNull(item.getStatus().getDate())) {
status.put("date", item.getStatus().getDate());
}
write(itemSummary, ItemProperties.STATUS_PROPERTY, status);
write(itemSummary, "inTransitDestinationServicePointId", item.getInTransitDestinationServicePointId());
final ServicePoint inTransitDestinationServicePoint = item.getInTransitDestinationServicePoint();
if (inTransitDestinationServicePoint != null) {
final JsonObject destinationServicePointSummary = new JsonObject();
write(destinationServicePointSummary, "id", inTransitDestinationServicePoint.getId());
write(destinationServicePointSummary, "name", inTransitDestinationServicePoint.getName());
write(itemSummary, "inTransitDestinationServicePoint", destinationServicePointSummary);
}
final Location location = item.getLocation();
if (location != null) {
itemSummary.put("location", new JsonObject().put("name", location.getName()));
}
writeByPath(itemSummary, item.getMaterialTypeName(), "materialType", "name");
return itemSummary;
}
use of org.folio.circulation.domain.Location in project mod-circulation by folio-org.
the class PickSlipsTests method responseContainsPickSlipsWhenServicePointHasManyLocations.
@Test
void responseContainsPickSlipsWhenServicePointHasManyLocations() {
final UUID servicePointId = servicePointsFixture.cd1().getId();
final int numberOfLocations = 100;
IndividualResource location = null;
for (int i = 0; i < numberOfLocations; i++) {
final int currentIndex = i;
location = locationsFixture.basedUponExampleLocation(builder -> builder.withName("Test location " + currentIndex).withCode("LOC_" + currentIndex).withPrimaryServicePoint(servicePointId));
}
val lastLocation = location;
val item = itemsFixture.basedUponSmallAngryPlanet(builder -> builder.withPermanentLocation(lastLocation.getId()).withNoTemporaryLocation());
val james = usersFixture.james();
RequestBuilder pageRequestBuilder = new RequestBuilder().withStatus(RequestStatus.OPEN_NOT_YET_FILLED.getValue()).page().withPickupServicePointId(servicePointId).forItem(item).by(james);
val pageRequest = requestsClient.create(pageRequestBuilder);
val response = ResourceClient.forPickSlips().getById(servicePointId);
assertThat(response.getStatusCode(), is(HTTP_OK));
assertResponseHasItems(response, 1);
assertResponseContains(response, item, pageRequest, james);
}
use of org.folio.circulation.domain.Location in project mod-circulation by folio-org.
the class PatronActionSessionRepository method setInstitutionForLoanItem.
private Loan setInstitutionForLoanItem(Loan loan, Map<String, JsonObject> institutions) {
Item item = loan.getItem();
if (item.isNotFound()) {
return loan;
}
Location oldLocation = item.getLocation();
JsonObject institution = institutions.get(oldLocation.getInstitutionId());
Location locationWithInstitution = oldLocation.withInstitutionRepresentation(institution);
return loan.withItem(item.withLocation(locationWithInstitution));
}
use of org.folio.circulation.domain.Location in project mod-circulation by folio-org.
the class PatronActionSessionRepository method setCampusForLoanItem.
private Loan setCampusForLoanItem(Loan loan, Map<String, JsonObject> campuses) {
Item item = loan.getItem();
if (item.isNotFound()) {
return loan;
}
Location oldLocation = item.getLocation();
JsonObject campus = campuses.get(oldLocation.getCampusId());
Location locationWithCampus = oldLocation.withCampusRepresentation(campus);
return loan.withItem(item.withLocation(locationWithCampus));
}
use of org.folio.circulation.domain.Location in project mod-circulation by folio-org.
the class TemplateContextUtil method createItemContext.
private static JsonObject createItemContext(Item item) {
String contributorNamesToken = item.getContributorNames().collect(joining("; "));
String yearCaptionsToken = String.join("; ", item.getYearCaption());
String copyNumber = item.getCopyNumber() != null ? item.getCopyNumber() : "";
JsonObject itemContext = new JsonObject().put("title", item.getTitle()).put("barcode", item.getBarcode()).put("status", item.getStatus().getValue()).put("primaryContributor", item.getPrimaryContributorName()).put("allContributors", contributorNamesToken).put("enumeration", item.getEnumeration()).put("volume", item.getVolume()).put("chronology", item.getChronology()).put("yearCaption", yearCaptionsToken).put("materialType", item.getMaterialTypeName()).put("loanType", item.getLoanTypeName()).put("copy", copyNumber).put("numberOfPieces", item.getNumberOfPieces()).put("descriptionOfPieces", item.getDescriptionOfPieces());
Location location = item.getLocation();
if (location != null) {
itemContext.put("effectiveLocationSpecific", location.getName()).put("effectiveLocationLibrary", location.getLibraryName()).put("effectiveLocationCampus", location.getCampusName()).put("effectiveLocationInstitution", location.getInstitutionName());
}
CallNumberComponents callNumberComponents = item.getCallNumberComponents();
if (callNumberComponents != null) {
itemContext.put("callNumber", callNumberComponents.getCallNumber()).put("callNumberPrefix", callNumberComponents.getPrefix()).put("callNumberSuffix", callNumberComponents.getSuffix());
}
return itemContext;
}
Aggregations