Search in sources :

Example 1 with ServicePoint

use of org.folio.circulation.domain.ServicePoint 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;
}
Also used : ServicePoint(org.folio.circulation.domain.ServicePoint) JsonObject(io.vertx.core.json.JsonObject) Location(org.folio.circulation.domain.Location)

Example 2 with ServicePoint

use of org.folio.circulation.domain.ServicePoint in project mod-circulation by folio-org.

the class ItemsInTransitReport method writeRequest.

private void writeRequest(Request request, JsonObject itemReport) {
    final JsonObject requestJson = new JsonObject();
    write(requestJson, "requestType", request.getRequestType().value);
    write(requestJson, "requestDate", request.getRequestDate());
    write(requestJson, "requestExpirationDate", request.getRequestExpirationDate());
    write(requestJson, "requestPickupServicePointName", ofNullable(request.getPickupServicePoint()).map(ServicePoint::getName).orElse(null));
    final JsonObject tags = request.asJson().getJsonObject("tags");
    if (tags != null) {
        final JsonArray tagsJson = tags.getJsonArray("tagList");
        write(requestJson, "tags", tagsJson);
    }
    ofNullable(request.getRequester()).map(User::getPatronGroup).ifPresent(pg -> write(requestJson, "requestPatronGroup", pg.getDesc()));
    write(itemReport, "request", requestJson);
}
Also used : ServicePoint(org.folio.circulation.domain.ServicePoint) JsonArray(io.vertx.core.json.JsonArray) JsonObject(io.vertx.core.json.JsonObject)

Example 3 with ServicePoint

use of org.folio.circulation.domain.ServicePoint in project mod-circulation by folio-org.

the class ItemsInTransitReport method writeLastCheckIn.

private void writeLastCheckIn(JsonObject itemReport, LastCheckIn lastCheckIn) {
    final JsonObject lastCheckInJson = new JsonObject();
    write(lastCheckInJson, "dateTime", lastCheckIn.getDateTime());
    final ServicePoint lastCheckInServicePoint = lastCheckIn.getServicePoint();
    if (lastCheckInServicePoint != null) {
        writeServicePoint(lastCheckInJson, lastCheckInServicePoint, "servicePoint");
    }
    write(itemReport, "lastCheckIn", lastCheckInJson);
}
Also used : ServicePoint(org.folio.circulation.domain.ServicePoint) JsonObject(io.vertx.core.json.JsonObject)

Example 4 with ServicePoint

use of org.folio.circulation.domain.ServicePoint in project mod-circulation by folio-org.

the class ItemsInTransitReport method buildEntry.

private JsonObject buildEntry(Item item) {
    if (item == null || item.isNotFound()) {
        return new JsonObject();
    }
    item = ofNullable(item.getHoldingsRecordId()).map(reportContext.getHoldingsRecords()::get).map(Holdings::getInstanceId).map(reportContext.getInstances()::get).map(item::withInstance).orElse(item);
    Loan loan = reportContext.getLoans().get(item.getItemId());
    Request request = reportContext.getRequests().get(item.getItemId());
    Location location = reportContext.getLocations().get(item.getLocationId());
    if (location != null) {
        ServicePoint primaryServicePoint = reportContext.getServicePoints().get(location.getPrimaryServicePointId().toString());
        item = item.withLocation(location.withPrimaryServicePoint(primaryServicePoint));
    }
    ServicePoint inTransitDestinationServicePoint = reportContext.getServicePoints().get(item.getInTransitDestinationServicePointId());
    ServicePoint lastCheckInServicePoint = reportContext.getServicePoints().get(item.getLastCheckInServicePointId().toString());
    item = item.updateLastCheckInServicePoint(lastCheckInServicePoint).updateDestinationServicePoint(inTransitDestinationServicePoint);
    final JsonObject entry = new JsonObject();
    write(entry, "id", item.getItemId());
    write(entry, "title", item.getTitle());
    write(entry, "barcode", item.getBarcode());
    write(entry, "contributors", mapContributorNamesToJson(item));
    write(entry, "callNumber", item.getCallNumber());
    write(entry, "enumeration", item.getEnumeration());
    write(entry, "volume", item.getVolume());
    write(entry, "yearCaption", new JsonArray(item.getYearCaption()));
    writeNamedObject(entry, "status", ofNullable(item.getStatus()).map(ItemStatus::getValue).orElse(null));
    write(entry, "inTransitDestinationServicePointId", item.getInTransitDestinationServicePointId());
    write(entry, "copyNumber", item.getCopyNumber());
    write(entry, "effectiveCallNumberComponents", createCallNumberComponents(item.getCallNumberComponents()));
    if (inTransitDestinationServicePoint != null) {
        writeServicePoint(entry, inTransitDestinationServicePoint, "inTransitDestinationServicePoint");
    }
    if (location != null) {
        writeLocation(entry, location);
    }
    if (request != null) {
        User requester = reportContext.getUsers().get(request.getRequesterId());
        PatronGroup requesterPatronGroup = requester == null ? null : reportContext.getPatronGroups().get(requester.getPatronGroupId());
        if (requesterPatronGroup != null) {
            request = request.withRequester(requester.withPatronGroup(requesterPatronGroup));
        }
        ServicePoint pickupServicePoint = reportContext.getServicePoints().get(request.getPickupServicePointId());
        request = request.withPickupServicePoint(pickupServicePoint);
        writeRequest(request, entry);
    }
    if (loan != null) {
        ServicePoint checkoutServicePoint = reportContext.getServicePoints().get(loan.getCheckoutServicePointId());
        ServicePoint checkInServicePoint = reportContext.getServicePoints().get(loan.getCheckInServicePointId());
        loan = loan.withCheckinServicePoint(checkInServicePoint).withCheckoutServicePoint(checkoutServicePoint);
        writeLoan(entry, loan);
    }
    final LastCheckIn lastCheckIn = item.getLastCheckIn();
    if (lastCheckIn != null) {
        writeLastCheckIn(entry, lastCheckIn);
    }
    return entry;
}
Also used : ServicePoint(org.folio.circulation.domain.ServicePoint) JsonArray(io.vertx.core.json.JsonArray) ItemStatus(org.folio.circulation.domain.ItemStatus) LastCheckIn(org.folio.circulation.domain.LastCheckIn) User(org.folio.circulation.domain.User) Loan(org.folio.circulation.domain.Loan) Holdings(org.folio.circulation.domain.Holdings) Request(org.folio.circulation.domain.Request) JsonObject(io.vertx.core.json.JsonObject) PatronGroup(org.folio.circulation.domain.PatronGroup) Location(org.folio.circulation.domain.Location)

Aggregations

JsonObject (io.vertx.core.json.JsonObject)4 ServicePoint (org.folio.circulation.domain.ServicePoint)4 JsonArray (io.vertx.core.json.JsonArray)2 Location (org.folio.circulation.domain.Location)2 Holdings (org.folio.circulation.domain.Holdings)1 ItemStatus (org.folio.circulation.domain.ItemStatus)1 LastCheckIn (org.folio.circulation.domain.LastCheckIn)1 Loan (org.folio.circulation.domain.Loan)1 PatronGroup (org.folio.circulation.domain.PatronGroup)1 Request (org.folio.circulation.domain.Request)1 User (org.folio.circulation.domain.User)1