From 1ef5f4d692dd2c672651aed9897d0e5fb8eb3e24 Mon Sep 17 00:00:00 2001 From: Jiri Kozlovsky Date: Mon, 1 Aug 2016 05:26:51 +0200 Subject: [PATCH] Bug 17007: REST API: add route to get biblio Since there could be performance problems with retrieving all the details from all the items belonging to an biblio, there is now returned only a list of itemnumbers within an "items" key instead of all the item's properties. To obtain specific item's properties, use the provided itemnumber to query REST API for items done by Lari Taskula in bug 16825 To test: 1. Open a browser tab on Koha staff and log in (to create CGISESSID cookie). 2. Send GET request to http://yourlibrary/api/v1/biblios/YYY where YYY is an existing biblionumber. 3. Make sure the returned data is correct. 4. Run unit tests in t/db_dependent/api/v1/biblios.t --- Koha/REST/V1/Biblio.pm | 4 +- api/v1/definitions/biblio.json | 10 +- api/v1/definitions/biblioitems.json | 56 ------------ api/v1/definitions/index.json | 1 - api/v1/definitions/item.json | 177 ------------------------------------ 5 files changed, 11 insertions(+), 237 deletions(-) delete mode 100644 api/v1/definitions/biblioitems.json delete mode 100644 api/v1/definitions/item.json diff --git a/Koha/REST/V1/Biblio.pm b/Koha/REST/V1/Biblio.pm index d7206d7..167b265 100644 --- a/Koha/REST/V1/Biblio.pm +++ b/Koha/REST/V1/Biblio.pm @@ -35,7 +35,9 @@ sub get { return $c->$cb({error => "Biblio not found"}, 404); } - my $items = $biblio->items(); + my $items ||= Koha::Items->search( { biblionumber => $biblionumber }, { + columns => [qw/itemnumber/], + }); $biblio = $biblio->unblessed; $biblio->{items} = $items->unblessed; diff --git a/api/v1/definitions/biblio.json b/api/v1/definitions/biblio.json index 3403e1b..a3b35b7 100644 --- a/api/v1/definitions/biblio.json +++ b/api/v1/definitions/biblio.json @@ -3,7 +3,7 @@ "properties": { "biblionumber": { "type": "string", - "description": "unique identifier assigned to each bibliographic record" + "description": "internal bibliographic record identifier" }, "frameworkcode": { "type": "string", @@ -52,7 +52,13 @@ "items": { "type": "array", "items": { - "$ref": "item.json" + "type": "object", + "properties": { + "itemnumber": { + "type": "string", + "description": "internal item identifier" + } + } } } } diff --git a/api/v1/definitions/biblioitems.json b/api/v1/definitions/biblioitems.json deleted file mode 100644 index f6b3f64..0000000 --- a/api/v1/definitions/biblioitems.json +++ /dev/null @@ -1,56 +0,0 @@ -{ - "type": "object", - "properties": { - "biblionumber": { - "type": "string", - "description": "unique identifier assigned to each bibliographic record" - }, - "frameworkcode": { - "type": "string", - "description": "foreign key from the biblio_framework table to identify which framework was used in cataloging this record" - }, - "author": { - "type": ["string", "null"], - "description": "statement of responsibility from MARC record (100$a in MARC21)" - }, - "title": { - "type": ["string", "null"], - "description": "title (without the subtitle) from the MARC record (245$a in MARC21)" - }, - "untitle": { - "type": ["string", "null"], - "description": "uniform title (without the subtitle) from the MARC record (240$a in MARC21)" - }, - "notes": { - "type": ["string", "null"], - "description": "values from the general notes field in the MARC record (500$a in MARC21) split by bar (|)" - }, - "serial": { - "type": ["boolean", "null"], - "description": "Boolean indicating whether biblio is for a serial" - }, - "seriestitle": { - "type": ["string", "null"], - "description": "Title for describing the series" - }, - "copyrightdate": { - "type": ["string", "null"], - "description": "publication or copyright date from the MARC record" - }, - "timestamp": { - "type": "string", - "description": "date and time this record was last touched" - }, - "datecreated": { - "type": "string", - "description": "the date this record was added to Koha" - }, - "abstract": { - "type": ["string", "null"], - "description": "summary from the MARC record (520$a in MARC21)" - }, - "items": { - "$ref": "biblioitems.json" - } - } -} diff --git a/api/v1/definitions/index.json b/api/v1/definitions/index.json index 3d1a43f..10efd36 100644 --- a/api/v1/definitions/index.json +++ b/api/v1/definitions/index.json @@ -2,7 +2,6 @@ "patron": { "$ref": "patron.json" }, "holds": { "$ref": "holds.json" }, "hold": { "$ref": "hold.json" }, - "item": { "$ref": "item.json" }, "biblio": { "$ref": "biblio.json" }, "error": { "$ref": "error.json" } } diff --git a/api/v1/definitions/item.json b/api/v1/definitions/item.json deleted file mode 100644 index 9c43f85..0000000 --- a/api/v1/definitions/item.json +++ /dev/null @@ -1,177 +0,0 @@ -{ - "type": "object", - "properties": { - "itemnumber": { - "type": "string", - "description": "internally assigned item identifier" - }, - "biblionumber": { - "type": "string", - "description": "internally assigned biblio identifier" - }, - "biblioitemnumber": { - "type": "string", - "description": "internally assigned biblio item identifier" - }, - "barcode": { - "type": ["string", "null"], - "description": "item barcode" - }, - "dateaccessioned": { - "type": ["string", "null"], - "description": "date the item was acquired or added to Koha" - }, - "booksellerid": { - "type": ["string", "null"], - "description": "where the item was purchased" - }, - "homebranch": { - "type": ["string", "null"], - "description": "library that owns this item" - }, - "price": { - "type": ["string", "null"], - "description": "purchase price" - }, - "replacementprice": { - "type": ["string", "null"], - "description": "cost the library charges to replace the item if it has been marked lost" - }, - "replacementpricedate": { - "type": ["string", "null"], - "description": "the date the price is effective from" - }, - "datelastborrowed": { - "type": ["string", "null"], - "description": "the date the item was last checked out/issued" - }, - "datelastseen": { - "type": ["string", "null"], - "description": "the date the item was last see (usually the last time the barcode was scanned or inventory was done)" - }, - "stack": { - "type": ["string", "null"], - "description": "?" - }, - "notforloan": { - "type": "string", - "description": "authorized value defining why this item is not for loan" - }, - "damaged": { - "type": "string", - "description": "authorized value defining this item as damaged" - }, - "itemlost": { - "type": "string", - "description": "authorized value defining this item as lost" - }, - "itemlost_on": { - "type": ["string", "null"], - "description": "the date and time an item was last marked as lost, NULL if not lost" - }, - "withdrawn": { - "type": "string", - "description": "authorized value defining this item as withdrawn" - }, - "withdrawn_on": { - "type": ["string", "null"], - "description": "the date and time an item was last marked as withdrawn, NULL if not withdrawn" - }, - "itemcallnumber": { - "type": ["string", "null"], - "description": "call number for this item" - }, - "coded_location_qualifier": { - "type": ["string", "null"], - "description": "coded location qualifier" - }, - "issues": { - "type": ["string", "null"], - "description": "number of times this item has been checked out/issued" - }, - "renewals": { - "type": ["string", "null"], - "description": "number of times this item has been renewed" - }, - "reserves": { - "type": ["string", "null"], - "description": "number of times this item has been placed on hold/reserved" - }, - "restricted": { - "type": ["string", "null"], - "description": "authorized value defining use restrictions for this item" - }, - "itemnotes": { - "type": ["string", "null"], - "description": "public notes on this item" - }, - "itemnotes_nonpublic": { - "type": ["string", "null"], - "description": "non-public notes on this item" - }, - "holdingbranch": { - "type": ["string", "null"], - "description": "library that is currently in possession item" - }, - "paidfor": { - "type": ["string", "null"], - "description": "?" - }, - "timestamp": { - "type": "string", - "description": "date and time this item was last altered" - }, - "location": { - "type": ["string", "null"], - "description": "authorized value for the shelving location for this item" - }, - "permanent_location": { - "type": ["string", "null"], - "description": "linked to the CART and PROC temporary locations feature, stores the permanent shelving location" - }, - "onloan": { - "type": ["string", "null"], - "description": "defines if item is checked out (NULL for not checked out, and checkout date for checked out)" - }, - "cn_source": { - "type": ["string", "null"], - "description": "classification source used on this item" - }, - "cn_sort": { - "type": ["string", "null"], - "description": "?" - }, - "ccode": { - "type": ["string", "null"], - "description": "authorized value for the collection code associated with this item" - }, - "materials": { - "type": ["string", "null"], - "description": "materials specified" - }, - "uri": { - "type": ["string", "null"], - "description": "URL for the item" - }, - "itype": { - "type": ["string", "null"], - "description": "itemtype defining the type for this item" - }, - "more_subfields_xml": { - "type": ["string", "null"], - "description": "additional 952 subfields in XML format" - }, - "enumchron": { - "type": ["string", "null"], - "description": "serial enumeration/chronology for the item" - }, - "copynumber": { - "type": ["string", "null"], - "description": "copy number" - }, - "stocknumber": { - "type": ["string", "null"], - "description": "inventory number" - } - } -} -- 2.1.4