diff --git a/NEWS.md b/NEWS.md index 26af4f1f6..bcb5806a5 100644 --- a/NEWS.md +++ b/NEWS.md @@ -4,8 +4,10 @@ ### New APIs versions * Provides `item-storage v10.1` +* Provides `inventory-hierarchy 0.4` ### Features +* Add location properties and material type id to inventory-hierarchy items-and-holdings response ([MODINVSTOR-1133](https://issues.folio.org/browse/MODINVSTOR-1133)) * Add new field "Display summary" for the item schema ([MODINVSTOR-1154](https://issues.folio.org/browse/MODINVSTOR-1154)) * Add new Identifier type Cancelled LCCN ([MODINVSTOR-1156](https://folio-org.atlassian.net/browse/MODINVSTOR-1156)) diff --git a/descriptors/ModuleDescriptor-template.json b/descriptors/ModuleDescriptor-template.json index 27091885e..3cb20baba 100755 --- a/descriptors/ModuleDescriptor-template.json +++ b/descriptors/ModuleDescriptor-template.json @@ -1212,7 +1212,7 @@ }, { "id": "inventory-hierarchy", - "version": "0.3", + "version": "0.4", "handlers": [ { "methods": ["GET"], diff --git a/ramls/examples/inventory-items-and-holdings.json b/ramls/examples/inventory-items-and-holdings.json index 2b938ad4e..318f21e9c 100644 --- a/ramls/examples/inventory-items-and-holdings.json +++ b/ramls/examples/inventory-items-and-holdings.json @@ -17,16 +17,20 @@ ], "location": { "permanentLocation": { + "id": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231", "name": "Annex", "campusName": "City Campus", "libraryName": "Datalogisk Institut", + "libraryCode": "DI", "institutionName": "Københavns Universitet", "code": "KU/CC/DI/A" }, "temporaryLocation": { + "id": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231", "name": "Annex", "campusName": "City Campus", "libraryName": "Datalogisk Institut", + "libraryCode": "DI", "institutionName": "Københavns Universitet", "code": "KU/CC/DI/A" } @@ -118,23 +122,29 @@ ], "location": { "location": { + "id": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231", "name": "Annex", "campusName": "City Campus", "libraryName": "Datalogisk Institut", + "libraryCode": "DI", "institutionName": "Københavns Universitet", "code": "KU/CC/DI/A" }, "permanentLocation": { + "id": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231", "name": "Annex", "campusName": "City Campus", "libraryName": "Datalogisk Institut", + "libraryCode": "DI", "institutionName": "Københavns Universitet", "code": "KU/CC/DI/A" }, "temporaryLocation": { + "id": "d9cd0bed-1b49-4b5e-a7bd-064b8d177231", "name": "Annex", "campusName": "City Campus", "libraryName": "Datalogisk Institut", + "libraryCode": "DI", "institutionName": "Københavns Universitet", "code": "KU/CC/DI/A" } @@ -163,6 +173,7 @@ "itemDamagedStatus": "Not Damaged", "itemDamagedStatusDate": "2020-07-28T09:34:40.562Z", "materialType": "book", + "materialTypeId": "059f3856-2659-45aa-b35a-e0b10d63141d", "permanentLoanType": "Can circulate", "temporaryLoanType": "Can circulate", "electronicAccess": [ diff --git a/ramls/inventory-hierarchy/inventory-instance-records.json b/ramls/inventory-hierarchy/inventory-instance-records.json index 1ae120866..722092374 100644 --- a/ramls/inventory-hierarchy/inventory-instance-records.json +++ b/ramls/inventory-hierarchy/inventory-instance-records.json @@ -61,6 +61,10 @@ "type": "object", "description": "Permanent shelving location in which an item resides", "properties": { + "id": { + "description": "id of this (shelf) location record as UUID.", + "type": "string" + }, "name": { "description": "Name of the (shelf) location", "type": "string" @@ -73,6 +77,10 @@ "description": "The name of the library, the third-level location unit, this (shelf) location belongs to", "type": "string" }, + "libraryCode": { + "description": "The name of the library, the third-level location unit, this (shelf) location belongs to", + "type": "string" + }, "institutionName": { "description": "The name of the institution, the first-level location unit, this (shelf) location belongs to", "type": "string" @@ -94,6 +102,10 @@ "type": "object", "description": "Temporary location, shelving location, or holding which is a physical place where items are stored, or an Online location", "properties": { + "id": { + "description": "id of this (shelf) location record as UUID.", + "type": "string" + }, "name": { "description": "Name of the (shelf) location", "type": "string" @@ -106,6 +118,10 @@ "description": "The name of the library, the third-level location unit, this (shelf) location belongs to", "type": "string" }, + "libraryCode": { + "description": "The code of the library, the third-level location unit, this (shelf) location belongs to", + "type": "string" + }, "institutionName": { "description": "The name of the institution, the first-level location unit, this (shelf) location belongs to", "type": "string" @@ -120,6 +136,10 @@ "type": "object", "description": "Effective location, shelving location, or holding which is a physical place where items are stored, or an Online location", "properties": { + "id": { + "description": "id of this (shelf) location record as UUID.", + "type": "string" + }, "name": { "description": "Name of the (shelf) location", "type": "string" @@ -132,6 +152,10 @@ "description": "The name of the library, the third-level location unit, this (shelf) location belongs to", "type": "string" }, + "libraryCode": { + "description": "The code of the library, the third-level location unit, this (shelf) location belongs to", + "type": "string" + }, "institutionName": { "description": "The name of the institution, the first-level location unit, this (shelf) location belongs to", "type": "string" @@ -439,6 +463,10 @@ "type": "object", "description": "Current home location for the item", "properties": { + "id": { + "description": "id of this (shelf) location record as UUID.", + "type": "string" + }, "name": { "description": "Name of the (shelf) location", "type": "string" @@ -451,6 +479,10 @@ "description": "The name of the library, the third-level location unit, this (shelf) location belongs to", "type": "string" }, + "libraryCode": { + "description": "The code of the library, the third-level location unit, this (shelf) location belongs to", + "type": "string" + }, "institutionName": { "description": "The name of the institution, the first-level location unit, this (shelf) location belongs to", "type": "string" @@ -465,6 +497,10 @@ "type": "object", "description": "Permanent shelving location in which an item resides", "properties": { + "id": { + "description": "id of this (shelf) location record as UUID.", + "type": "string" + }, "name": { "description": "Name of the (shelf) location", "type": "string" @@ -477,6 +513,10 @@ "description": "The name of the library, the third-level location unit, this (shelf) location belongs to", "type": "string" }, + "libraryCode": { + "description": "The code of the library, the third-level location unit, this (shelf) location belongs to", + "type": "string" + }, "institutionName": { "description": "The name of the institution, the first-level location unit, this (shelf) location belongs to", "type": "string" @@ -491,6 +531,10 @@ "type": "object", "description": "Temporary location, shelving location, or holding which is a physical place where items are stored, or an Online location", "properties": { + "id": { + "description": "id of this (shelf) location record as UUID.", + "type": "string" + }, "name": { "description": "Name of the (shelf) location", "type": "string" @@ -503,6 +547,10 @@ "description": "The name of the library, the third-level location unit, this (shelf) location belongs to", "type": "string" }, + "libraryCode": { + "description": "The code of the library, the third-level location unit, this (shelf) location belongs to", + "type": "string" + }, "institutionName": { "description": "The name of the institution, the first-level location unit, this (shelf) location belongs to", "type": "string" @@ -604,6 +652,10 @@ "description": "Define what type of thing the item is", "type": "string" }, + "materialTypeId": { + "description": "Define what type id of thing the item is", + "type": "string" + }, "permanentLoanType": { "description": "Default loan type for a given item. Loan types are tenant-defined", "type": "string" diff --git a/src/main/resources/templates/db_scripts/inventory-hierarchy/updateRecordsViewFunctionToSupportAdditionalFields.sql b/src/main/resources/templates/db_scripts/inventory-hierarchy/updateRecordsViewFunctionToSupportAdditionalFields.sql new file mode 100644 index 000000000..3dce3e345 --- /dev/null +++ b/src/main/resources/templates/db_scripts/inventory-hierarchy/updateRecordsViewFunctionToSupportAdditionalFields.sql @@ -0,0 +1,265 @@ +drop function if exists ${myuniversity}_${mymodule}.get_items_and_holdings_view; +-- Add support of bound-with items +CREATE OR REPLACE FUNCTION ${myuniversity}_${mymodule}.get_items_and_holdings_view(instanceIds uuid[], + skipSuppressedFromDiscoveryRecords bool DEFAULT TRUE) + RETURNS TABLE + ( + "instanceId" uuid, + "source" varchar, + "modeOfIssuance" varchar, + "natureOfContent" jsonb, + "holdings" jsonb, + "items" jsonb + ) +AS +$BODY$ +WITH + -- Locations + viewLocations(locId, locJsonb, locCampJsonb, locLibJsonb, locInstJsonb) AS ( + SELECT loc.id AS locId, + loc.jsonb AS locJsonb, + locCamp.jsonb AS locCampJsonb, + locLib.jsonb AS locLibJsonb, + locInst.jsonb AS locInstJsonb + FROM location loc + LEFT JOIN locinstitution locInst + ON (loc.jsonb ->> 'institutionId')::uuid = locInst.id + LEFT JOIN loccampus locCamp + ON (loc.jsonb ->> 'campusId')::uuid = locCamp.id + LEFT JOIN loclibrary locLib + ON (loc.jsonb ->> 'libraryId')::uuid = locLib.id + WHERE (loc.jsonb ->> 'isActive')::bool = true + ), + -- Passed instances ids + viewInstances(instId, source, modeOfIssuance, natureOfContent) AS ( + SELECT DISTINCT + instId AS "instanceId", + i.jsonb ->> 'source' AS source, + moi.jsonb ->> 'name' AS modeOfIssuance, + COALESCE(getNatureOfContentName(COALESCE(i.jsonb #> '{natureOfContentTermIds}', '[]'::jsonb)), '[]'::jsonb) AS natureOfContent + FROM UNNEST( $1 ) instId + JOIN instance i + ON i.id = instId + LEFT JOIN mode_of_issuance moi + ON moi.id = nullif(i.jsonb ->> 'modeOfIssuanceId','')::uuid + ), + -- Prepared items and holdings + viewItemsAndHoldings(instId, records) AS ( + SELECT itemAndHoldingsAttrs.instanceId, jsonb_strip_nulls(itemAndHoldingsAttrs.itemsAndHoldings) + FROM (SELECT + i.id AS instanceId, + jsonb_build_object('holdings', + COALESCE(jsonb_agg(DISTINCT + jsonb_build_object('id', hr.id, + 'hrId', hr.jsonb ->> 'hrId', + 'suppressFromDiscovery', + CASE WHEN hr.id IS NOT NULL THEN + COALESCE((i.jsonb ->> 'discoverySuppress')::bool, false) OR + COALESCE((hr.jsonb ->> 'discoverySuppress')::bool, false) + ELSE NULL END::bool, + 'holdingsType', ht.jsonb ->> 'name', + 'formerIds', hr.jsonb -> 'formerIds', + 'location', + CASE WHEN hr.id IS NOT NULL THEN + json_build_object('permanentLocation', + jsonb_build_object('name', COALESCE(holdPermLoc.locJsonb ->> 'discoveryDisplayName', holdPermLoc.locJsonb ->> 'name'), + 'code', holdPermLoc.locJsonb ->> 'code', + 'id', holdPermLoc.locJsonb ->> 'id', + 'campusName', holdPermLoc.locCampJsonb ->> 'name', + 'libraryName', holdPermLoc.locLibJsonb ->> 'name', + 'libraryCode', holdPermLoc.locLibJsonb ->> 'code', + 'institutionName', holdPermLoc.locInstJsonb ->> 'name'), + 'temporaryLocation', + jsonb_build_object('name', COALESCE(holdTempLoc.locJsonb ->> 'discoveryDisplayName', holdTempLoc.locJsonb ->> 'name'), + 'code', holdTempLoc.locJsonb ->> 'code', + 'id', holdTempLoc.locJsonb ->> 'id', + 'campusName', holdTempLoc.locCampJsonb ->> 'name', + 'libraryName', holdTempLoc.locLibJsonb ->> 'name', + 'libraryCode', holdTempLoc.locLibJsonb ->> 'code', + 'institutionName', holdTempLoc.locInstJsonb ->> 'name'), + 'effectiveLocation', + jsonb_build_object('name', COALESCE(holdEffLoc.locJsonb ->> 'discoveryDisplayName', holdEffLoc.locJsonb ->> 'name'), + 'code', holdEffLoc.locJsonb ->> 'code', + 'id', holdEffLoc.locJsonb ->> 'id', + 'campusName', holdEffLoc.locCampJsonb ->> 'name', + 'libraryName', holdEffLoc.locLibJsonb ->> 'name', + 'libraryCode', holdEffLoc.locLibJsonb ->> 'code', + 'institutionName', holdEffLoc.locInstJsonb ->> 'name')) + ELSE NULL END::jsonb, + 'callNumber', json_build_object('prefix', hr.jsonb ->> 'callNumberPrefix', + 'suffix', hr.jsonb ->> 'callNumberSuffix', + 'typeId', hr.jsonb ->> 'callNumberTypeId', + 'typeName', hrcnt.jsonb ->> 'name', + 'callNumber', hr.jsonb ->> 'callNumber'), + 'shelvingTitle', hr.jsonb ->> 'shelvingTitle', + 'acquisitionFormat', hr.jsonb ->> 'acquisitionFormat', + 'acquisitionMethod', hr.jsonb ->> 'acquisitionMethod', + 'receiptStatus', hr.jsonb ->> 'receiptStatus', + 'electronicAccess', + CASE WHEN hr.id IS NOT NULL THEN + COALESCE(getElectronicAccessName(COALESCE(hr.jsonb #> '{electronicAccess}', '[]'::jsonb)), '[]'::jsonb) + ELSE NULL::jsonb END, + 'notes', + CASE WHEN hr.id IS NOT NULL THEN + COALESCE(getHoldingNoteTypeName(hr.jsonb -> 'notes'), '[]'::jsonb) + ELSE NULL END::jsonb, + 'illPolicy', ilp.jsonb ->> 'name', + 'retentionPolicy', hr.jsonb ->> 'retentionPolicy', + 'digitizationPolicy', hr.jsonb ->> 'digitizationPolicy', + 'holdingsStatements', hr.jsonb -> 'holdingsStatements', + 'holdingsStatementsForIndexes', hr.jsonb -> 'holdingsStatementsForIndexes', + 'holdingsStatementsForSupplements', hr.jsonb -> 'holdingsStatementsForSupplements', + 'copyNumber', hr.jsonb ->> 'copyNumber', + 'numberOfItems', hr.jsonb ->> 'numberOfItems', + 'receivingHistory', hr.jsonb -> 'receivingHistory', + 'tags', hr.jsonb -> 'tags', + 'statisticalCodes', + CASE WHEN hr.id IS NOT NULL THEN + COALESCE(getStatisticalCodes(hr.jsonb -> 'statisticalCodeIds'), '[]'::jsonb) + ELSE NULL END ::jsonb)) + FILTER (WHERE hr.id IS NOT NULL), '[]'::jsonb), + 'items', + COALESCE(jsonb_agg(DISTINCT + jsonb_build_object('id', item.id, + 'hrId', item.jsonb ->> 'hrId', + 'holdingsRecordId', (item.jsonb ->> 'holdingsRecordId')::UUID, + 'suppressFromDiscovery', + CASE WHEN item.id IS NOT NULL THEN + COALESCE((i.jsonb ->> 'discoverySuppress')::bool, false) OR + COALESCE((hr.jsonb ->> 'discoverySuppress')::bool, false) OR + COALESCE((item.jsonb ->> 'discoverySuppress')::bool, false) + ELSE NULL END::bool, + 'status', item.jsonb #>> '{status, name}', + 'formerIds', item.jsonb -> 'formerIds', + 'location', + CASE WHEN item.id IS NOT NULL THEN + json_build_object('location', + jsonb_build_object('name', COALESCE(itemEffLoc.locJsonb ->> 'discoveryDisplayName', itemEffLoc.locJsonb ->> 'name'), + 'code', itemEffLoc.locJsonb ->> 'code', + 'id', itemEffLoc.locJsonb ->> 'id', + 'campusName', itemEffLoc.locCampJsonb ->> 'name', + 'libraryName', itemEffLoc.locLibJsonb ->> 'name', + 'libraryCode', itemEffLoc.locLibJsonb ->> 'code', + 'institutionName', itemEffLoc.locInstJsonb ->> 'name'), + 'permanentLocation', + jsonb_build_object('name', COALESCE(itemPermLoc.locJsonb ->> 'discoveryDisplayName', itemPermLoc.locJsonb ->> 'name'), + 'code', itemPermLoc.locJsonb ->> 'code', + 'id', itemPermLoc.locJsonb ->> 'id', + 'campusName', itemPermLoc.locCampJsonb ->> 'name', + 'libraryName', itemPermLoc.locLibJsonb ->> 'name', + 'libraryCode', itemPermLoc.locLibJsonb ->> 'code', + 'institutionName', itemPermLoc.locInstJsonb ->> 'name'), + 'temporaryLocation', + jsonb_build_object('name', COALESCE(itemTempLoc.locJsonb ->> 'discoveryDisplayName', itemTempLoc.locJsonb ->> 'name'), + 'code', itemTempLoc.locJsonb ->> 'code', + 'id', itemTempLoc.locJsonb ->> 'id', + 'campusName', itemTempLoc.locCampJsonb ->> 'name', + 'libraryName', itemTempLoc.locLibJsonb ->> 'name', + 'libraryCode', itemTempLoc.locLibJsonb ->> 'code', + 'institutionName', itemTempLoc.locInstJsonb ->> 'name')) + ELSE NULL END::jsonb, + 'callNumber', item.jsonb -> 'effectiveCallNumberComponents' || + jsonb_build_object('typeName', cnt.jsonb ->> 'name'), + 'accessionNumber', item.jsonb ->> 'accessionNumber', + 'barcode', item.jsonb ->> 'barcode', + 'copyNumber', item.jsonb ->> 'copyNumber', + 'volume', item.jsonb ->> 'volume', + 'enumeration', item.jsonb ->> 'enumeration', + 'chronology', item.jsonb ->>'chronology', + 'yearCaption', item.jsonb -> 'yearCaption', + 'itemIdentifier', item.jsonb ->> 'itemIdentifier', + 'numberOfPieces', item.jsonb ->> 'numberOfPieces', + 'descriptionOfPieces', item.jsonb ->> 'descriptionOfPieces', + 'numberOfMissingPieces', item.jsonb ->> 'numberOfMissingPieces', + 'missingPieces', item.jsonb ->> 'missingPieces', + 'missingPiecesDate', item.jsonb ->> 'missingPiecesDate', + 'itemDamagedStatus', itemDmgStat.jsonb ->> 'name', + 'itemDamagedStatusDate', item.jsonb ->> 'itemDamagedStatusDate', + 'materialType', mt.jsonb ->> 'name', + 'materialTypeId', mt.jsonb ->> 'id', + 'permanentLoanType', plt.jsonb ->> 'name', + 'temporaryLoanType', tlt.jsonb ->> 'name', + 'electronicAccess', + CASE WHEN item.id IS NOT NULL THEN + COALESCE(getElectronicAccessName(COALESCE(item.jsonb #> '{electronicAccess}', '[]'::jsonb)), '[]'::jsonb) + ELSE NULL::jsonb END, + 'notes', + CASE WHEN item.id IS NOT NULL THEN + COALESCE(getItemNoteTypeName(item.jsonb -> 'notes'), '[]'::jsonb) + ELSE NULL END::jsonb, + 'tags', item.jsonb -> 'tags', + 'statisticalCodes', + CASE WHEN item.id IS NOT NULL THEN + COALESCE(getStatisticalCodes(item.jsonb -> 'statisticalCodeIds'), '[]'::jsonb) + ELSE NULL END ::jsonb)) + FILTER (WHERE item.id IS NOT NULL AND NOT ($2 AND COALESCE((item.jsonb ->> 'discoverySuppress')::bool, false))), '[]'::jsonb) + ) itemsAndHoldings + + FROM ${myuniversity}_${mymodule}.holdings_record hr + JOIN ${myuniversity}_${mymodule}.instance i + ON i.id = hr.instanceid + JOIN viewInstances vi + ON vi.instId = i.id + LEFT JOIN ${myuniversity}_${mymodule}.bound_with_part bwp on bwp.holdingsrecordid = hr.id + LEFT JOIN ${myuniversity}_${mymodule}.item item + ON item.holdingsrecordid = hr.id OR item.id = bwp.itemid + -- Item's Effective location relation + LEFT JOIN viewLocations itemEffLoc + ON (item.jsonb ->> 'effectiveLocationId')::uuid = itemEffLoc.locId + -- Item's Permanent location relation + LEFT JOIN viewLocations itemPermLoc + ON (item.jsonb ->> 'permanentLocationId')::uuid = itemPermLoc.locId + -- Item's Temporary location relation + LEFT JOIN viewLocations itemTempLoc + ON (item.jsonb ->> 'temporaryLocationId')::uuid = itemTempLoc.locId + -- Item's Material type relation + LEFT JOIN ${myuniversity}_${mymodule}.material_type mt + ON item.materialtypeid = mt.id + -- Item's Call number type relation + LEFT JOIN ${myuniversity}_${mymodule}.call_number_type cnt + ON (item.jsonb #>> '{effectiveCallNumberComponents, typeId}')::uuid = cnt.id + -- Item's Damaged status relation + LEFT JOIN ${myuniversity}_${mymodule}.item_damaged_status itemDmgStat + ON (item.jsonb ->> 'itemDamagedStatusId')::uuid = itemDmgStat.id + -- Item's Permanent loan type relation + LEFT JOIN ${myuniversity}_${mymodule}.loan_type plt + ON (item.jsonb ->> 'permanentLoanTypeId')::uuid = plt.id + -- Item's Temporary loan type relation + LEFT JOIN ${myuniversity}_${mymodule}.loan_type tlt + ON (item.jsonb ->> 'temporaryLoanTypeId')::uuid = tlt.id + -- Holdings type relation + LEFT JOIN ${myuniversity}_${mymodule}.holdings_type ht + ON ht.id = hr.holdingstypeid + -- Holdings Permanent location relation + LEFT JOIN viewLocations holdPermLoc + ON (hr.jsonb ->> 'permanentLocationId')::uuid = holdPermLoc.locId + -- Holdings Temporary location relation + LEFT JOIN viewLocations holdTempLoc + ON (hr.jsonb ->> 'temporaryLocationId')::uuid = holdTempLoc.locId + -- Holdings Effective location relation + LEFT JOIN viewLocations holdEffLoc + ON (hr.jsonb ->> 'effectiveLocationId')::uuid = holdEffLoc.locId + -- Holdings Call number type relation + LEFT JOIN ${myuniversity}_${mymodule}.call_number_type hrcnt + ON (hr.jsonb ->> 'callNumberTypeId')::uuid = hrcnt.id + -- Holdings Ill policy relation + LEFT JOIN ${myuniversity}_${mymodule}.ill_policy ilp + ON hr.illpolicyid = ilp.id + WHERE true + AND NOT ($2 AND COALESCE((hr.jsonb ->> 'discoverySuppress')::bool, false)) + GROUP BY 1 + ) itemAndHoldingsAttrs + ) +-- Instances with items and holding records +SELECT + vi.instId AS "instanceId", + vi.source AS "source", + vi.modeOfIssuance AS "modeOfIssuance", + vi.natureOfContent AS "natureOfContent", + COALESCE(viah.records -> 'holdings', '[]'::jsonb) AS "holdings", + COALESCE(viah.records -> 'items', '[]'::jsonb) AS "items" +FROM viewInstances vi + LEFT JOIN viewItemsAndHoldings viah + ON viah.instId = vi.instId + +$BODY$ LANGUAGE sql; diff --git a/src/main/resources/templates/db_scripts/schema.json b/src/main/resources/templates/db_scripts/schema.json index 9627fbebd..d979b4b99 100644 --- a/src/main/resources/templates/db_scripts/schema.json +++ b/src/main/resources/templates/db_scripts/schema.json @@ -1147,6 +1147,11 @@ "run": "after", "snippetPath": "addIdentifierTypeCancelledLCCN.sql", "fromModuleVersion": "27.1.0" + }, + { + "run": "after", + "snippetPath": "inventory-hierarchy/updateRecordsViewFunctionToSupportAdditionalFields.sql", + "fromModuleVersion": "27.1.0" } ] } diff --git a/src/test/java/org/folio/rest/api/InventoryHierarchyViewTest.java b/src/test/java/org/folio/rest/api/InventoryHierarchyViewTest.java index 254b27559..88bbac0fc 100644 --- a/src/test/java/org/folio/rest/api/InventoryHierarchyViewTest.java +++ b/src/test/java/org/folio/rest/api/InventoryHierarchyViewTest.java @@ -15,11 +15,16 @@ import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasIdForHoldings; import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasIdForInstance; import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasLocationCodeForItems; +import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasLocationIdForItems; +import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasLocationLibraryCodeForItems; +import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasMaterialTypeIdForItems; import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasPermanentLocationCodeForHoldings; import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasPermanentLocationForHoldings; import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasSourceForInstance; import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasTemporaryLocationCodeForHoldings; import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasTemporaryLocationForHoldings; +import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasTemporaryLocationIdForItems; +import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.hasTemporaryLocationLibraryCodeForItems; import static org.folio.rest.support.matchers.InventoryHierarchyResponseMatchers.isDeleted; import static org.folio.utility.ModuleUtility.getClient; import static org.folio.utility.ModuleUtility.getVertx; @@ -89,6 +94,11 @@ private static void verifyInstancesDataWithoutParameters(List instan allOf( hasCallNumberForItems("item effective call number 1", "item effective call number 2"), hasEffectiveLocationInstitutionNameForItems("Primary Institution"), + hasLocationLibraryCodeForItems("ML", "ML"), + hasTemporaryLocationLibraryCodeForItems("ML", "ML"), + hasLocationIdForItems(MAIN_LIBRARY_LOCATION_ID.toString(), THIRD_FLOOR_LOCATION_ID.toString()), + hasTemporaryLocationIdForItems(MAIN_LIBRARY_LOCATION_ID.toString(), THIRD_FLOOR_LOCATION_ID.toString()), + hasMaterialTypeIdForItems(journalMaterialTypeID, bookMaterialTypeID), hasLocationCodeForItems("TestBaseWI/M", "TestBaseWI/TF"), hasAggregatedNumberOfItems(2) ) diff --git a/src/test/java/org/folio/rest/support/matchers/InventoryHierarchyResponseMatchers.java b/src/test/java/org/folio/rest/support/matchers/InventoryHierarchyResponseMatchers.java index 4281245a3..29a47f9a4 100644 --- a/src/test/java/org/folio/rest/support/matchers/InventoryHierarchyResponseMatchers.java +++ b/src/test/java/org/folio/rest/support/matchers/InventoryHierarchyResponseMatchers.java @@ -170,6 +170,28 @@ public static Matcher hasLocationCodeForItems(String... code) { return hasItemsElement(JsonPointer.from("/location/location/code"), ArrayUtils.toArray(code)); } + public static Matcher hasLocationLibraryCodeForItems(String... code) { + return hasItemsElement(JsonPointer.from("/location/location/libraryCode"), ArrayUtils.toArray(code)); + } + + public static Matcher hasLocationIdForItems(String... locationIds) { + return hasItemsElement(JsonPointer.from("/location/location/id"), ArrayUtils.toArray(locationIds)); + } + + public static Matcher hasTemporaryLocationLibraryCodeForItems(String... libraryCodes) { + return hasItemsElement( + JsonPointer.from("/location/temporaryLocation/libraryCode"), + ArrayUtils.toArray(libraryCodes)); + } + + public static Matcher hasTemporaryLocationIdForItems(String... locationIds) { + return hasItemsElement(JsonPointer.from("/location/temporaryLocation/id"), ArrayUtils.toArray(locationIds)); + } + + public static Matcher hasMaterialTypeIdForItems(String... materialTypeIds) { + return hasItemsElement(JsonPointer.from("/materialTypeId"), ArrayUtils.toArray(materialTypeIds)); + } + public static Matcher hasAggregatedNumberOfHoldings(int size) { return hasHoldingsCount(size); }