Bug 20640

Summary: Allow migrating a request between backends
Product: Koha Reporter: Martin Renvoize <martin.renvoize>
Component: ILLAssignee: Martin Renvoize <martin.renvoize>
Status: CLOSED FIXED QA Contact: Katrin Fischer <katrin.fischer>
Severity: enhancement    
Priority: P5 - low CC: joe.mcglynn, josef.moravec, katrin.fischer, magnus, mmg, niamh.walker-headon, nick, paul.thornton
Version: master   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=21459
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
Bug Depends on: 21079, 21835    
Bug Blocks: 22103, 33970, 20600    
Attachments: Bug 20640: Add backend migration support to ILL
Bug 20640: Add backend migration support to ILL
Bug 20640: Add backend migration support to ILL
Commit reflecting changes in:
Bug 20640: Add backend migration support to ILL
Bug 20640: Add backend migration support to ILL
Bug 20640: Add backend migration support to ILL
Bug 20640: Add backend migration support to ILL
Bug 20640: Add backend migration support to ILL
Bug 20640: (follow-up) Degrade gracefully on error
Bug 20640: Add backend migration support to ILL
Bug 20640: (follow-up) Degrade gracefully on error
Bug 20640: (follow-up) Redirect to new request at completion
Bug 20640: (follow-up) Make error message translatable
Bug 20640: Add backend migration support to ILL
Bug 20640: (follow-up) Degrade gracefully on error
Bug 20640: (follow-up) Redirect to new request at completion
Bug 20640: (follow-up) Make error message translatable
Bug 20640: (follow-up) Make error message translatable
Bug 20640: (follow-up) Always send a backend on migrate
Bug 20640: Add backend migration support to ILL
Bug 20640: (follow-up) Degrade gracefully on error
Bug 20640: (follow-up) Redirect to new request at completion
Bug 20640: (follow-up) Make error message translatable
Bug 20640: (follow-up) Always send a backend on migrate

Description Martin Renvoize 2018-04-23 16:05:05 UTC
Currently, once an ILL request has started on a path in one backend it cannot be migrated to another. 

We should allow the status graph to be modified with 'MoveFrom' and 'MoveTo' methods allowing a request to be migrated from one backend to another when both backend support it (and when the request hasn't progressed sufficiently in one backend to prevent cancellation)
Comment 1 Martin Renvoize 2018-04-27 07:51:35 UTC
Created attachment 74903 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.
Comment 2 Martin Renvoize 2018-05-02 08:18:45 UTC
I've added support for this functionality to the Koha2Koha backend (yet to be released publically) and the FreeForm backend. I'm currently working on adding support to the BLDSS backend too. Once these are all in place we can test the core functionality using them.
Comment 3 Martin Renvoize 2018-05-18 12:59:53 UTC
Created attachment 75430 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.
Comment 4 Martin Renvoize 2018-05-18 13:00:32 UTC
Created attachment 75431 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.
Comment 5 Andrew Isherwood 2018-09-07 13:58:42 UTC
Created attachment 78525 [details] [review]
Commit reflecting changes in:

https://bugs.koha-community.org/bugzilla3/attachment.cgi?id=74903&action=diff
Comment 6 Andrew Isherwood 2018-09-07 13:59:05 UTC
Rebased on current master
Comment 7 Andrew Isherwood 2018-09-11 22:45:15 UTC
Comment on attachment 78525 [details] [review]
Commit reflecting changes in:

This patch is just a repeat of the initial patch
Comment 8 Andrew Isherwood 2018-09-27 13:32:09 UTC
Created attachment 79508 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.
Comment 9 Martin Renvoize 2018-09-28 10:54:34 UTC
Created attachment 79571 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.
Comment 10 Martin Renvoize 2018-09-28 10:57:31 UTC
Another rebase.. what fun this is :)
Comment 11 Owen Leonard 2018-09-28 13:08:17 UTC
I'm getting an error when I click the "Switch provider" button:

Duplicate ID at /usr/share/perl5/Exception/Class/Base.pm line 73

I thought it might be a problem with my test data, but after emptying illrequests and illrequestattributes and starting from scratch I still got the error.

Note: You might want to rebase this on Bug 21377 and make it dependent.
Comment 12 Owen Leonard 2018-09-28 13:16:00 UTC
Also: Please add a test plan!
Comment 13 Martin Renvoize 2018-09-28 13:47:59 UTC
Created attachment 79597 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.
Comment 14 Magnus Enger 2018-09-28 14:07:08 UTC
Just as a side note, I have a library that is interested in being able to move things from purchase sugestions to ILL and from ILL to purchase suggestions.
Comment 15 Martin Renvoize 2018-09-28 14:51:36 UTC
(In reply to Magnus Enger from comment #14)
> Just as a side note, I have a library that is interested in being able to
> move things from purchase sugestions to ILL and from ILL to purchase
> suggestions.

I think that'll need to be another bug Magnus.. nice idea though.. feel free to stick a bug in for it and we might get to it at some point.. there's still a big pile in our internal dev queue for ILL ;)
Comment 16 Martin Renvoize 2018-10-11 12:21:50 UTC
Testing

To test this, you must have at least 2 supported backends installed and configured. (Currently, the FreeForm and Koha2Koha backends have both been confirmed to work, and I am currently completing the work on the BLDSS backend).

Once you have two backends installed and working the test plan is:

1) Create an ILL request using your prefered, supported, backend
2) Go to the 'Manage request' page for your new request
3) Confirm that a 'Switch provider' button exists
3a) If only one other backend is installed and configured the button will be a button
3b) If multiple backends are installed the button allow dropdown selection of alternate backends
4) Select the backend to migrate to using the 'Switch provider' button.
5) Depending on the backend you have selected to move to, you will be faced with a compatible workflow for migrating the request.. either a new request consisting of the same details as the original request, a search results page from the migrating to backend (with results reflecting a pre-fired search using details from the migrating from request) or a search form pre-filled with the details of the request your migrating from which you can then submit
6) Finally, once you've moved through the steps to create this migrated to request, you should see a new request in your migrated to backend and the original request will be marked as 'Request reverted'.
Comment 17 Martin McGovern 2018-10-18 11:54:07 UTC
Tried to create a Koha request and it throws an error.

Created a Freeform request instead. It throws this error:

DataTables warning: table id=ill-requests - Requested unknown parameter 'metadata_author' for row 0, column 0. For more information about this error, please see http://datatables.net/tn/4
but continues to create the request ok.

It completed the Freeform request.
Switch provider button exists with the other two backends listed on the dropdown.
Tested switching to BLDSS and next screen is presented as expected.
"Request reverted" listed for original request. New request to switched provider listed correctly.

List Requests shows above error also.

Request number on list requests screen is always Nan, whereas correct request number is listed on Manage Request screen.

Created a BLDSS request and switched to Freeform successfully but above error generated on Switch Provider action.
Comment 18 Andrew Isherwood 2018-10-18 12:31:52 UTC
Hi Martin

Thanks very much for this.

The datatables error you're seeing is a known issue. It's due to you not having entered an author for some requests, it's not actually an issue with this bug, bug 21063 fixes it.

The request number being Nan is also fixed with bug 21063 and isn't caused by this bug.

I hope that makes sense, if not, let me know!
Comment 19 PTFS Europe Sandboxes 2018-10-19 07:45:44 UTC
Created attachment 80900 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.

Signed-off-by: Martin McGovern <mmg@interleaf.ie>
Comment 20 Josef Moravec 2018-10-31 16:13:33 UTC
When I click "Switch provider" button, there is error:

DBD::mysql::st execute failed: Duplicate entry '876-article_pages' for key 'PRIMARY' [for Statement "INSERT INTO `illrequestattributes` ( `illrequest_id`, `type`, `value`) VALUES ( ?, ?, ? )" with ParamValues: 0='876', 1='article_pages', 2='pp. 15-19'] at /usr/share/perl5/DBIx/Class/Storage/DBI.pm line 1832.
Duplicate ID
Comment 21 Martin Renvoize 2018-11-01 15:30:11 UTC
Created attachment 81826 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.
Comment 22 Martin Renvoize 2018-11-01 15:30:15 UTC
Created attachment 81827 [details] [review]
Bug 20640: (follow-up) Degrade gracefully on error
Comment 23 Martin Renvoize 2018-11-01 15:31:25 UTC
I've added a more graceful failure mode should a backend fail to load or fail to support the migrate action.
Comment 24 Martin Renvoize 2019-01-11 12:42:26 UTC
Created attachment 83777 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.
Comment 25 Martin Renvoize 2019-01-11 12:42:30 UTC
Created attachment 83778 [details] [review]
Bug 20640: (follow-up) Degrade gracefully on error
Comment 26 Martin Renvoize 2019-01-11 12:42:33 UTC
Created attachment 83779 [details] [review]
Bug 20640: (follow-up) Redirect to new request at completion
Comment 27 Martin Renvoize 2019-01-11 14:51:54 UTC
Created attachment 83797 [details] [review]
Bug 20640: (follow-up) Make error message translatable
Comment 28 Katrin Fischer 2019-01-11 14:56:20 UTC
Created attachment 83798 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 29 Katrin Fischer 2019-01-11 14:56:23 UTC
Created attachment 83799 [details] [review]
Bug 20640: (follow-up) Degrade gracefully on error

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 30 Katrin Fischer 2019-01-11 14:56:27 UTC
Created attachment 83800 [details] [review]
Bug 20640: (follow-up) Redirect to new request at completion

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 31 Katrin Fischer 2019-01-11 14:56:31 UTC
Created attachment 83801 [details] [review]
Bug 20640: (follow-up) Make error message translatable

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 32 Katrin Fischer 2019-01-11 15:02:47 UTC
Found another issue - setting to FQA waiting for news from Martin.
Comment 33 Martin Renvoize 2019-01-11 15:30:53 UTC
Created attachment 83803 [details] [review]
Bug 20640: (follow-up) Make error message translatable
Comment 34 Martin Renvoize 2019-01-11 15:37:32 UTC
Should be ready again for testing now
Comment 35 Martin Renvoize 2019-01-11 16:13:15 UTC
Created attachment 83805 [details] [review]
Bug 20640: (follow-up) Always send a backend on migrate
Comment 36 Katrin Fischer 2019-01-11 16:19:13 UTC
Created attachment 83806 [details] [review]
Bug 20640: Add backend migration support to ILL

- Add core methods required to support the migration of ILL requests
between backends.

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 37 Katrin Fischer 2019-01-11 16:19:17 UTC
Created attachment 83807 [details] [review]
Bug 20640: (follow-up) Degrade gracefully on error

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 38 Katrin Fischer 2019-01-11 16:19:21 UTC
Created attachment 83808 [details] [review]
Bug 20640: (follow-up) Redirect to new request at completion

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 39 Katrin Fischer 2019-01-11 16:19:25 UTC
Created attachment 83809 [details] [review]
Bug 20640: (follow-up) Make error message translatable

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 40 Katrin Fischer 2019-01-11 16:19:29 UTC
Created attachment 83810 [details] [review]
Bug 20640: (follow-up) Always send a backend on migrate

Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
Comment 41 Nick Clemens 2019-01-28 14:12:21 UTC
Awesome work all!

Pushed to master for 19.05
Comment 42 Martin Renvoize 2019-02-01 12:37:14 UTC
This will not be backported to 18.11.x series.