Search in sources :

Example 1 with Note

use of org.folio.inventory.domain.items.Note in project mod-inventory by folio-org.

the class ItemUtil method jsonToItem.

public static Item jsonToItem(JsonObject itemRequest) {
    List<String> formerIds = toListOfStrings(itemRequest.getJsonArray(Item.FORMER_IDS_KEY));
    List<String> statisticalCodeIds = toListOfStrings(itemRequest.getJsonArray(Item.STATISTICAL_CODE_IDS_KEY));
    List<String> yearCaption = toListOfStrings(itemRequest.getJsonArray(Item.YEAR_CAPTION_KEY));
    Status status = converterForClass(Status.class).fromJson(itemRequest.getJsonObject(Item.STATUS_KEY));
    List<String> administrativeNotes = toListOfStrings(itemRequest.getJsonArray(Item.ADMINISTRATIVE_NOTES_KEY));
    List<Note> notes = itemRequest.containsKey(Item.NOTES_KEY) ? JsonArrayHelper.toList(itemRequest.getJsonArray(Item.NOTES_KEY)).stream().map(Note::new).collect(Collectors.toList()) : new ArrayList<>();
    List<CirculationNote> circulationNotes = itemRequest.containsKey(Item.CIRCULATION_NOTES_KEY) ? JsonArrayHelper.toList(itemRequest.getJsonArray(Item.CIRCULATION_NOTES_KEY)).stream().map(CirculationNote::new).collect(Collectors.toList()) : new ArrayList<>();
    List<ElectronicAccess> electronicAccess = itemRequest.containsKey(Item.ELECTRONIC_ACCESS_KEY) ? JsonArrayHelper.toList(itemRequest.getJsonArray(Item.ELECTRONIC_ACCESS_KEY)).stream().map(ElectronicAccess::new).collect(Collectors.toList()) : new ArrayList<>();
    List<String> tags = itemRequest.containsKey(Item.TAGS_KEY) ? getTags(itemRequest) : new ArrayList<>();
    String materialTypeId = getNestedProperty(itemRequest, MATERIAL_TYPE, ID);
    String permanentLocationId = getNestedProperty(itemRequest, PERMANENT_LOCATION, ID);
    String temporaryLocationId = getNestedProperty(itemRequest, TEMPORARY_LOCATION, ID);
    String permanentLoanTypeId = getNestedProperty(itemRequest, PERMANENT_LOAN_TYPE, ID);
    String temporaryLoanTypeId = getNestedProperty(itemRequest, TEMPORARY_LOAN_TYPE, ID);
    return new Item(itemRequest.getString(ID), itemRequest.getString(Item.VERSION_KEY), itemRequest.getString(HOLDINGS_RECORD_ID), itemRequest.getString(Item.TRANSIT_DESTINATION_SERVICE_POINT_ID_KEY), status, materialTypeId, permanentLoanTypeId, null).withHrid(itemRequest.getString(Item.HRID_KEY)).withFormerIds(formerIds).withDiscoverySuppress(itemRequest.getBoolean(Item.DISCOVERY_SUPPRESS_KEY)).withBarcode(itemRequest.getString(BARCODE)).withItemLevelCallNumber(itemRequest.getString(Item.ITEM_LEVEL_CALL_NUMBER_KEY)).withEffectiveShelvingOrder(itemRequest.getString(Item.EFFECTIVE_SHELVING_ORDER_KEY)).withItemLevelCallNumberPrefix(itemRequest.getString(Item.ITEM_LEVEL_CALL_NUMBER_PREFIX_KEY)).withItemLevelCallNumberSuffix(itemRequest.getString(Item.ITEM_LEVEL_CALL_NUMBER_SUFFIX_KEY)).withItemLevelCallNumberTypeId(itemRequest.getString(Item.ITEM_LEVEL_CALL_NUMBER_TYPE_ID_KEY)).withVolume(itemRequest.getString(Item.VOLUME_KEY)).withEnumeration(itemRequest.getString(ENUMERATION)).withChronology(itemRequest.getString(CHRONOLOGY)).withNumberOfPieces(itemRequest.getString(NUMBER_OF_PIECES)).withDescriptionOfPieces(itemRequest.getString(Item.DESCRIPTION_OF_PIECES_KEY)).withNumberOfMissingPieces(itemRequest.getString(Item.NUMBER_OF_MISSING_PIECES_KEY)).withMissingPieces(itemRequest.getString(Item.MISSING_PIECES_KEY)).withMissingPiecesDate(itemRequest.getString(Item.MISSING_PIECES_DATE_KEY)).withItemDamagedStatusId(itemRequest.getString(Item.ITEM_DAMAGED_STATUS_ID_KEY)).withItemDamagedStatusDate(itemRequest.getString(Item.ITEM_DAMAGED_STATUS_DATE_KEY)).withPermanentLocationId(permanentLocationId).withTemporaryLocationId(temporaryLocationId).withTemporaryLoanTypeId(temporaryLoanTypeId).withCopyNumber(itemRequest.getString(Item.COPY_NUMBER_KEY)).withAdministrativeNotes(administrativeNotes).withNotes(notes).withCirculationNotes(circulationNotes).withAccessionNumber(itemRequest.getString(Item.ACCESSION_NUMBER_KEY)).withItemIdentifier(itemRequest.getString(Item.ITEM_IDENTIFIER_KEY)).withYearCaption(yearCaption).withElectronicAccess(electronicAccess).withStatisticalCodeIds(statisticalCodeIds).withPurchaseOrderLineIdentifier(itemRequest.getString(Item.PURCHASE_ORDER_LINE_IDENTIFIER)).withLastCheckIn(LastCheckIn.from(itemRequest.getJsonObject(Item.LAST_CHECK_IN))).withTags(tags);
}
Also used : Status(org.folio.inventory.domain.items.Status) Item(org.folio.inventory.domain.items.Item) ElectronicAccess(org.folio.inventory.domain.sharedproperties.ElectronicAccess) Note(org.folio.inventory.domain.items.Note) CirculationNote(org.folio.inventory.domain.items.CirculationNote) CirculationNote(org.folio.inventory.domain.items.CirculationNote)

Aggregations

CirculationNote (org.folio.inventory.domain.items.CirculationNote)1 Item (org.folio.inventory.domain.items.Item)1 Note (org.folio.inventory.domain.items.Note)1 Status (org.folio.inventory.domain.items.Status)1 ElectronicAccess (org.folio.inventory.domain.sharedproperties.ElectronicAccess)1