Search in sources :

Example 1 with Location

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

Example 2 with Location

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);
}
Also used : Assertions.fail(org.junit.jupiter.api.Assertions.fail) Arrays(java.util.Arrays) Location(org.folio.circulation.domain.Location) Response(org.folio.circulation.support.http.client.Response) JsonPropertyFetcher.getDateTimeProperty(org.folio.circulation.support.json.JsonPropertyFetcher.getDateTimeProperty) ZonedDateTime(java.time.ZonedDateTime) APITests(api.support.APITests) RequestBuilder(api.support.builders.RequestBuilder) ItemStatus(org.folio.circulation.domain.ItemStatus) Item(org.folio.circulation.domain.Item) HTTP_OK(java.net.HttpURLConnection.HTTP_OK) IndividualResource(api.support.http.IndividualResource) Address(api.support.builders.Address) Is.is(org.hamcrest.core.Is.is) TextDateTimeMatcher.isEquivalentTo(api.support.matchers.TextDateTimeMatcher.isEquivalentTo) JsonObject(io.vertx.core.json.JsonObject) MatcherAssert.assertThat(org.hamcrest.MatcherAssert.assertThat) Assertions.assertEquals(org.junit.jupiter.api.Assertions.assertEquals) ZoneOffset(java.time.ZoneOffset) JsonObjectArrayPropertyFetcher(org.folio.circulation.support.json.JsonObjectArrayPropertyFetcher) InstanceMapper(org.folio.circulation.storage.mappers.InstanceMapper) lombok.val(lombok.val) UUID(java.util.UUID) ItemResource(api.support.http.ItemResource) Collectors(java.util.stream.Collectors) Collectors.joining(java.util.stream.Collectors.joining) User(org.folio.circulation.domain.User) CallNumberComponents(org.folio.circulation.domain.CallNumberComponents) Test(org.junit.jupiter.api.Test) UserResource(api.support.http.UserResource) List(java.util.List) Stream(java.util.stream.Stream) ClockUtil(org.folio.circulation.support.utils.ClockUtil) ResourceClient(api.support.http.ResourceClient) UUIDMatcher(api.support.matchers.UUIDMatcher) LocalDate(java.time.LocalDate) RequestStatus(org.folio.circulation.domain.RequestStatus) UTC(java.time.ZoneOffset.UTC) AddressExamples(api.support.fixtures.AddressExamples) JsonPropertyFetcher.getNestedStringProperty(org.folio.circulation.support.json.JsonPropertyFetcher.getNestedStringProperty) lombok.val(lombok.val) RequestBuilder(api.support.builders.RequestBuilder) UUID(java.util.UUID) IndividualResource(api.support.http.IndividualResource) Test(org.junit.jupiter.api.Test)

Example 3 with Location

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

Example 4 with Location

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

Example 5 with Location

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

Aggregations

JsonObject (io.vertx.core.json.JsonObject)7 Location (org.folio.circulation.domain.Location)7 Item (org.folio.circulation.domain.Item)4 CallNumberComponents (org.folio.circulation.domain.CallNumberComponents)3 User (org.folio.circulation.domain.User)3 Address (api.support.builders.Address)2 RequestBuilder (api.support.builders.RequestBuilder)2 IndividualResource (api.support.http.IndividualResource)2 ItemResource (api.support.http.ItemResource)2 ZonedDateTime (java.time.ZonedDateTime)2 UUID (java.util.UUID)2 ItemStatus (org.folio.circulation.domain.ItemStatus)2 ServicePoint (org.folio.circulation.domain.ServicePoint)2 InstanceMapper (org.folio.circulation.storage.mappers.InstanceMapper)2 Response (org.folio.circulation.support.http.client.Response)2 APITests (api.support.APITests)1 AddressExamples (api.support.fixtures.AddressExamples)1 ResourceClient (api.support.http.ResourceClient)1 UserResource (api.support.http.UserResource)1 TextDateTimeMatcher.isEquivalentTo (api.support.matchers.TextDateTimeMatcher.isEquivalentTo)1