Bug 29560

Summary: Add option to create MARC links when adding items to bundles
Product: Koha Reporter: Martin Renvoize (ashimema) <martin.renvoize>
Component: CatalogingAssignee: Martin Renvoize (ashimema) <martin.renvoize>
Status: Needs documenting --- QA Contact: Kyle M Hall (khall) <kyle>
Severity: enhancement    
Priority: P5 - low CC: julian.maurice, kyle, lucas, m.de.rooy, phil, tuomas.kunttu
Version: Main   
Hardware: All   
OS: All   
See Also: https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=11175
https://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=30793
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
This enhancement to the bundle functionality adds the option to create 773 MARC field links between the bundle host and its constituent parts. **Sponsored by** *PTFS Europe*
Version(s) released in:
24.11.00
Circulation function:
Bug Depends on: 28854    
Bug Blocks: 32802, 37364, 37996    
Attachments: Bug 29560: Add link_marc_host to Koha::Biblio
Bug 29560: Add option to create MARC Links when bundling items
Bug 29560: Add link_marc_host to Koha::Biblio
Bug 29560: Add option to create MARC Links when bundling items
Bug 29560: Add link_marc_host to Koha::Biblio
Bug 29560: Add option to create MARC Links when bundling items
Bug 29560: Add link_marc_host to Koha::Biblio
Bug 29560: Add option to create MARC Links when bundling items
Bug 29560: Add link_marc_host to Koha::Biblio
Bug 29560: Add option to create MARC Links when bundling items
Bug 29560: (follow-up) Split prepare and store logic
Bug 29560: Unit tests
Bug 29560: Add link_marc_host to Koha::Biblio
Bug 29560: Add option to create MARC Links when bundling items
Bug 29560: (follow-up) Split prepare and store logic
Bug 29560: Unit tests
Bug 29560: Unit tests: API
Bug 29560: Add link_marc_host to Koha::Biblio
Bug 29560: Add option to create MARC Links when bundling items
Bug 29560: (follow-up) Split prepare and store logic
Bug 29560: Unit tests
Bug 29560: Unit tests: API
Bug 29560: Add link_marc_host to Koha::Biblio
Bug 29560: Add option to create MARC Links when bundling items
Bug 29560: (follow-up) Split prepare and store logic
Bug 29560: Unit tests
Bug 29560: Unit tests: API
Bug 29560: (follow-up) Clean up trailing comma

Description Martin Renvoize (ashimema) 2021-11-23 11:43:23 UTC
Bug 28854 adds the ability to bundle items together for circulation as collections.

It may be useful to optionally allow the action of adding an item into a bundle to trigger the creation of MARC field links in the constituent items biblio.
Comment 1 Martin Renvoize (ashimema) 2021-11-24 17:34:44 UTC
What I'm thinking is adding a checkbox to the add to bundle modal that allows adding '773' links to the child as it's added to the bundle.
Comment 2 Martin Renvoize (ashimema) 2022-05-18 07:33:55 UTC
Created attachment 135090 [details] [review]
Bug 29560: Add link_marc_host to Koha::Biblio

This patch adds the new `link_marc_host` method to Koha::Biblio to
facilitate adding a host link to the marc record of this biblio.
Comment 3 Martin Renvoize (ashimema) 2022-05-18 07:33:59 UTC
Created attachment 135091 [details] [review]
Bug 29560: Add option to create MARC Links when bundling items

This patch add a checkbox to the 'Add to bundle' modal allowing the user
to optionally add MARC links between the new child record and the
current biblio. For MARC21 this will result in a 773 pointing to the
host from the item record and for UNIMARC a 461 field will be added.
Comment 4 Martin Renvoize (ashimema) 2022-05-18 07:35:52 UTC
Work in progress.. I believe is should all be working as expected but we need to add tests and I'd love some feedback on the implementation with respect to the very similar functions in C4::Biblio for preparing a host link field.
Comment 5 Martin Renvoize (ashimema) 2022-06-20 06:46:26 UTC
Perhaps this could/should also be tied to a preference.. 'BundleContentsFrom' or something that allows the librarian to pick from what data source content lists should be built.. MARC Field or First bundle item perhaps?
Comment 6 Martin Renvoize (ashimema) 2022-07-11 13:30:41 UTC Comment hidden (obsolete)
Comment 7 Martin Renvoize (ashimema) 2022-07-11 13:30:48 UTC Comment hidden (obsolete)
Comment 8 Martin Renvoize (ashimema) 2023-02-02 16:51:38 UTC
Noone interested in this?
Comment 9 Martin Renvoize (ashimema) 2023-09-27 16:07:36 UTC
Created attachment 156299 [details] [review]
Bug 29560: Add link_marc_host to Koha::Biblio

This patch adds the new `link_marc_host` method to Koha::Biblio to
facilitate adding a host link to the marc record of this biblio.
Comment 10 Martin Renvoize (ashimema) 2023-09-27 16:07:39 UTC
Created attachment 156300 [details] [review]
Bug 29560: Add option to create MARC Links when bundling items

This patch add a checkbox to the 'Add to bundle' modal allowing the user
to optionally add MARC links between the new child record and the
current biblio. For MARC21 this will result in a 773 pointing to the
host from the item record and for UNIMARC a 461 field will be added.
Comment 11 Martin Renvoize (ashimema) 2023-09-27 16:08:06 UTC
Rebased and ready for testing again.
Comment 12 PTFS Europe Sandboxes 2023-11-17 11:32:54 UTC
Created attachment 159081 [details] [review]
Bug 29560: Add link_marc_host to Koha::Biblio

This patch adds the new `link_marc_host` method to Koha::Biblio to
facilitate adding a host link to the marc record of this biblio.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
Comment 13 PTFS Europe Sandboxes 2023-11-17 11:32:56 UTC
Created attachment 159082 [details] [review]
Bug 29560: Add option to create MARC Links when bundling items

This patch add a checkbox to the 'Add to bundle' modal allowing the user
to optionally add MARC links between the new child record and the
current biblio. For MARC21 this will result in a 773 pointing to the
host from the item record and for UNIMARC a 461 field will be added.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
Comment 14 Kyle M Hall (khall) 2023-11-17 18:10:13 UTC
Could we get some unit tests for link_marc_host?
Comment 15 Martin Renvoize (ashimema) 2024-07-10 12:55:33 UTC
Created attachment 168720 [details] [review]
Bug 29560: Add link_marc_host to Koha::Biblio

This patch adds the new `link_marc_host` method to Koha::Biblio to
facilitate adding a host link to the marc record of this biblio.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
Comment 16 Martin Renvoize (ashimema) 2024-07-10 12:55:36 UTC
Created attachment 168721 [details] [review]
Bug 29560: Add option to create MARC Links when bundling items

This patch add a checkbox to the 'Add to bundle' modal allowing the user
to optionally add MARC links between the new child record and the
current biblio. For MARC21 this will result in a 773 pointing to the
host from the item record and for UNIMARC a 461 field will be added.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
Comment 17 Martin Renvoize (ashimema) 2024-07-10 12:55:39 UTC
Created attachment 168722 [details] [review]
Bug 29560: (follow-up) Split prepare and store logic

This allows for future removal of C4::Biblio::prepare_marc_host by
splitting the logic for generating the host field and storing the link
in the child record.
Comment 18 Martin Renvoize (ashimema) 2024-07-10 12:55:41 UTC
Created attachment 168723 [details] [review]
Bug 29560: Unit tests
Comment 19 Martin Renvoize (ashimema) 2024-07-10 12:56:58 UTC
Rebased, a tiny bit of refactoring for thinking about future removal of old code and unit tests added.

Back to signed off and ready for QA.
Comment 20 Kyle M Hall (khall) 2024-07-11 11:22:33 UTC
Can you please address the QA script issue:

 FAIL	Koha/REST/V1/Items.pm
   OK	  critic
   FAIL	  forbidden patterns
		forbidden pattern: Use of $c->validation in API controllers should be avoided (bug 33556) (line 319)

and be able to add a unit test for the rest api change? Thanks!
Comment 21 Martin Renvoize (ashimema) 2024-07-11 13:18:05 UTC
Created attachment 168816 [details] [review]
Bug 29560: Add link_marc_host to Koha::Biblio

This patch adds the new `link_marc_host` method to Koha::Biblio to
facilitate adding a host link to the marc record of this biblio.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
Comment 22 Martin Renvoize (ashimema) 2024-07-11 13:18:08 UTC
Created attachment 168817 [details] [review]
Bug 29560: Add option to create MARC Links when bundling items

This patch add a checkbox to the 'Add to bundle' modal allowing the user
to optionally add MARC links between the new child record and the
current biblio. For MARC21 this will result in a 773 pointing to the
host from the item record and for UNIMARC a 461 field will be added.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
Comment 23 Martin Renvoize (ashimema) 2024-07-11 13:18:11 UTC
Created attachment 168818 [details] [review]
Bug 29560: (follow-up) Split prepare and store logic

This allows for future removal of C4::Biblio::prepare_marc_host by
splitting the logic for generating the host field and storing the link
in the child record.
Comment 24 Martin Renvoize (ashimema) 2024-07-11 13:18:13 UTC
Created attachment 168819 [details] [review]
Bug 29560: Unit tests
Comment 25 Martin Renvoize (ashimema) 2024-07-11 13:18:16 UTC
Created attachment 168820 [details] [review]
Bug 29560: Unit tests: API
Comment 26 Martin Renvoize (ashimema) 2024-07-11 13:34:51 UTC
Created attachment 168821 [details] [review]
Bug 29560: Add link_marc_host to Koha::Biblio

This patch adds the new `link_marc_host` method to Koha::Biblio to
facilitate adding a host link to the marc record of this biblio.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
Comment 27 Martin Renvoize (ashimema) 2024-07-11 13:34:54 UTC
Created attachment 168822 [details] [review]
Bug 29560: Add option to create MARC Links when bundling items

This patch add a checkbox to the 'Add to bundle' modal allowing the user
to optionally add MARC links between the new child record and the
current biblio. For MARC21 this will result in a 773 pointing to the
host from the item record and for UNIMARC a 461 field will be added.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>
Comment 28 Martin Renvoize (ashimema) 2024-07-11 13:34:57 UTC
Created attachment 168823 [details] [review]
Bug 29560: (follow-up) Split prepare and store logic

This allows for future removal of C4::Biblio::prepare_marc_host by
splitting the logic for generating the host field and storing the link
in the child record.
Comment 29 Martin Renvoize (ashimema) 2024-07-11 13:34:59 UTC
Created attachment 168824 [details] [review]
Bug 29560: Unit tests
Comment 30 Martin Renvoize (ashimema) 2024-07-11 13:35:02 UTC
Created attachment 168825 [details] [review]
Bug 29560: Unit tests: API
Comment 31 Martin Renvoize (ashimema) 2024-07-11 13:35:59 UTC
Doh.. main moved!

Rebased again
Comment 32 Kyle M Hall (khall) 2024-07-12 10:37:08 UTC
Created attachment 168885 [details] [review]
Bug 29560: Add link_marc_host to Koha::Biblio

This patch adds the new `link_marc_host` method to Koha::Biblio to
facilitate adding a host link to the marc record of this biblio.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 33 Kyle M Hall (khall) 2024-07-12 10:37:26 UTC
Created attachment 168886 [details] [review]
Bug 29560: Add option to create MARC Links when bundling items

This patch add a checkbox to the 'Add to bundle' modal allowing the user
to optionally add MARC links between the new child record and the
current biblio. For MARC21 this will result in a 773 pointing to the
host from the item record and for UNIMARC a 461 field will be added.

Signed-off-by: Tuomas Kunttu <tuomas.kunttu@kouvola.fi>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 34 Kyle M Hall (khall) 2024-07-12 10:37:28 UTC
Created attachment 168887 [details] [review]
Bug 29560: (follow-up) Split prepare and store logic

This allows for future removal of C4::Biblio::prepare_marc_host by
splitting the logic for generating the host field and storing the link
in the child record.

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 35 Kyle M Hall (khall) 2024-07-12 10:37:31 UTC
Created attachment 168888 [details] [review]
Bug 29560: Unit tests

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 36 Kyle M Hall (khall) 2024-07-12 10:37:33 UTC
Created attachment 168889 [details] [review]
Bug 29560: Unit tests: API

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 37 Katrin Fischer 2024-07-15 08:58:49 UTC
FOR THIS PATCH SET:

1) Is the comma here correct/intended?

 $sfd{w} = $host_field->data(),;


FOR OTHER BUGS (if you want):

1) I think we should adjust to also take RDA records using 264 into account here. At least for us these are now the majority of records.

+        # Publication
+        if ( $host_field = $marc_host->field('260') ) {
+            my $s = $host_field->as_string('abc');
+            if ($s) {
+                $sfd{d} = $s;
+            }
+        }


2) This should take $n$p into account as well, as otherwise a multi-part work will not be distinguishable from the title:

+        # Title
+        if ( $host_field = $marc_host->field('245') ) {
+            my $s = $host_field->as_string('ab');
+            if ($s) {
+                $sfd{t} = $s;
+            }
+        }
Comment 38 Katrin Fischer 2024-07-15 09:07:06 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 39 Martin Renvoize (ashimema) 2024-07-15 09:18:17 UTC
(In reply to Katrin Fischer from comment #37)
> FOR THIS PATCH SET:
> 
> 1) Is the comma here correct/intended?
> 
>  $sfd{w} = $host_field->data(),;

That's certainly a typo.

> 
> FOR OTHER BUGS (if you want):
> 
> 1) I think we should adjust to also take RDA records using 264 into account
> here. At least for us these are now the majority of records.
> 
> +        # Publication
> +        if ( $host_field = $marc_host->field('260') ) {
> +            my $s = $host_field->as_string('abc');
> +            if ($s) {
> +                $sfd{d} = $s;
> +            }
> +        }
> 
> 
> 2) This should take $n$p into account as well, as otherwise a multi-part
> work will not be distinguishable from the title:
> 
> +        # Title
> +        if ( $host_field = $marc_host->field('245') ) {
> +            my $s = $host_field->as_string('ab');
> +            if ($s) {
> +                $sfd{t} = $s;
> +            }
> +        }

I'm more than happy to be guided on cataloguing standards.. I'm a mere dev without enough real cataloging knowledge to get this 100% right without guidance :)
Comment 40 Martin Renvoize (ashimema) 2024-07-15 10:24:53 UTC
Created attachment 168968 [details] [review]
Bug 29560: (follow-up) Clean up trailing comma

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 41 Katrin Fischer 2024-07-15 11:45:54 UTC
Follow-up pushed to main.
Comment 42 Katrin Fischer 2024-07-15 15:06:44 UTC
I filed:
Bug 37364 - Improve creation of 773 fields for item bundles regarding MARC21 245 and 264

Removing additional_work_needed.