Bug 17007 - REST API: add route to get biblio
Summary: REST API: add route to get biblio
Status: RESOLVED DUPLICATE of bug 17371
Alias: None
Product: Koha
Classification: Unclassified
Component: Web services (show other bugs)
Version: Main
Hardware: All All
: P3 enhancement (vote)
Assignee: Jiri Kozlovsky
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks: 16652
  Show dependency treegraph
 
Reported: 2016-08-01 00:12 UTC by Jiri Kozlovsky
Modified: 2017-01-15 19:54 UTC (History)
5 users (show)

See Also:
Change sponsored?: Sponsored
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Municipal Libray Ceska Trebova
Version(s) released in:


Attachments
Bug 17007: REST API: add route to get biblio (17.10 KB, patch)
2016-08-01 03:04 UTC, Jiri Kozlovsky
Details | Diff | Splinter Review
Bug 17007: REST API: add route to get biblio (10.56 KB, patch)
2016-08-01 03:29 UTC, Jiri Kozlovsky
Details | Diff | Splinter Review
Bug 17007: REST API: add route to get biblio (9.46 KB, patch)
2016-08-01 03:48 UTC, Jiri Kozlovsky
Details | Diff | Splinter Review
Bug 17007: REST API: add route to get biblio (10.28 KB, patch)
2016-08-01 12:39 UTC, Jiri Kozlovsky
Details | Diff | Splinter Review
Bug 17007: REST API: add route to get biblio (10.28 KB, patch)
2016-08-01 13:03 UTC, Jiri Kozlovsky
Details | Diff | Splinter Review
Bug 17007: REST API: add route to get biblio (11.26 KB, patch)
2016-08-09 09:35 UTC, Lari Taskula
Details | Diff | Splinter Review
Bug 17007: Fix typo in biblio's Swagger definition (1022 bytes, patch)
2016-08-09 10:02 UTC, Lari Taskula
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jiri Kozlovsky 2016-08-01 00:12:41 UTC
Add API route for getting an biblio

GET /api/v1/biblios/{biblionumber} Gets one Biblio
Comment 1 Jiri Kozlovsky 2016-08-01 03:04:58 UTC Comment hidden (obsolete)
Comment 2 Jiri Kozlovsky 2016-08-01 03:29:57 UTC Comment hidden (obsolete)
Comment 3 Jiri Kozlovsky 2016-08-01 03:48:10 UTC Comment hidden (obsolete)
Comment 4 Magnus Enger 2016-08-01 08:34:33 UTC
Does this respect records that are hidden in the OPAC? 
http://manual.koha-community.org/16.05/en/administration.html#OpacHiddenItems
Comment 5 Jiri Kozlovsky 2016-08-01 09:45:14 UTC
(In reply to Magnus Enger from comment #4)
> Does this respect records that are hidden in the OPAC? 
> http://manual.koha-community.org/16.05/en/administration.html#OpacHiddenItems

Good catch! It doesn't respect the OpacHiddenItems syspref. The reason is that Koha::Biblio object class doesn't respect it also. It performs a search in DB given only the biblionumber.

I think we should file a new bug for this in order to preserve single responsibility.

Btw there are some bugs creating new REST API for items, which should respect the OpacHiddenItems, but again, to preserve the single responsibility statement it should be handled from within the middleware - Koha::Items etc.
Comment 6 Jiri Kozlovsky 2016-08-01 10:28:08 UTC
(In reply to Jiri Kozlovsky from comment #5)
> (In reply to Magnus Enger from comment #4)
> > Does this respect records that are hidden in the OPAC? 
> > http://manual.koha-community.org/16.05/en/administration.html#OpacHiddenItems
> I think we should file a new bug for this in order to preserve single
> responsibility.

After thinking this through, I've came up with the idea, that Koha::Biblio's single responsibility is to just retrieve biblios from the DB. So the solution should probably be in the Koha::REST::V1::Biblios, which this patch creates.

After all, even though API is not OPAC & the syspref is described as "Define custom rules to hide specific items from search and view on the OPAC. How to write these rules is documented on the Koha wiki.", I agree with the idea it should be hidden from borrowers, but not from staff. This is why I'm going to implement showing OpacHiddenItems only to staff.

Changing the status to In Discussion.
Comment 7 Jiri Kozlovsky 2016-08-01 12:39:29 UTC Comment hidden (obsolete)
Comment 8 Jiri Kozlovsky 2016-08-01 13:03:20 UTC Comment hidden (obsolete)
Comment 9 Lari Taskula 2016-08-09 09:35:05 UTC
Created attachment 54187 [details] [review]
Bug 17007: REST API: add route to get biblio

This patch adds route to get one biblio from koha.biblios table. On top of this
biblio there is added key "items" with value being array of items belonging to the
requested biblio.

As Magnus Enger pointed out, we should hide all the items defined in the
OpacHiddenItems syspref from all but staff. This patch adds this functionality.

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. Find items which are hidden in OPAC with OpacHiddenItems syspref, note their
record's biblionumber and repeat point 2 with it.
5. Check that if you are logged in as staff, you see all the items (even those
hidden from OPAC)
6. Check that if you are not logged in as staff, you see only the items which are
not hidden from OPAC
7. Run unit tests in t/db_dependent/api/v1/biblios.t

Signed-off-by: Lari Taskula <larit@student.uef.fi>
Comment 10 Lari Taskula 2016-08-09 09:37:00 UTC
(In reply to Jiri Kozlovsky from comment #7)
> Created attachment 53834 [details] [review] [review]
This patch removed commit message from the patch. I added it back from your comment field and merged it together with the original description. Hope it's ok now?
Comment 11 Lari Taskula 2016-08-09 10:02:44 UTC
Created attachment 54193 [details] [review]
Bug 17007: Fix typo in biblio's Swagger definition

By running the test introduced in Bug 17032, we can easily catch issues related
to object definitions in Swagger vs. Koha-object's columns.

This patch fixes a property typo in biblio.json
Comment 12 Jiri Kozlovsky 2016-11-09 20:10:46 UTC
There has been some progress on getting Biblios in bug 17371, which is CRUD and it seems like this bug is subset of 17371, so we could eventually check that problems we have solved here were applied to 17371 and close this one as duplicate?
Comment 13 Jiri Kozlovsky 2017-01-15 19:54:35 UTC
bug 17371 is CRUD for biblios, thus it enables GET, POST & PUT - so after I've moved the OpacHiddenItems there, I'm closing this bug as duplicate

*** This bug has been marked as a duplicate of bug 17371 ***