Bug 13560

Summary: Add an 'Add' option in MARC modification templates
Product: Koha Reporter: Nicole C. Engard <nengard>
Component: ToolsAssignee: Nick Clemens <nick>
Status: Signed Off --- QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: fridolin.somers, J.P.Knight, katrin.fischer, marjorie.barry-vila, nick, stephane.delaye, victor.grousset
Version: master   
Hardware: All   
OS: All   
See Also: http://bugs.koha-community.org/bugzilla3/show_bug.cgi?id=14098
Whiteboard:
Change sponsored?: Sponsored Patch complexity: Small patch
Bot Control: --- When did the bot last check this:
Who signed the patch off: Text to go in the release notes:
Attachments: add/update on marc mod is only updating
Bug 13560 - need an add option in marc modification templates
Bug 13560 - need an add option in marc modification templates
Bug 13560 - Database changes
Bug 13560 - Unit tests
Bug 13560: Add an 'Add' option for marc modification templates
Bug 13560: Add an 'Add' option for marc modification templates
Bug 13560 - Database changes
Bug 13560 - Unit tests
Bug 13560: Add an 'Add' option for marc modification templates

Description Nicole C. Engard 2015-01-12 16:39:23 UTC
Created attachment 35108 [details]
add/update on marc mod is only updating

Right now the marc modification templates have an add/update option but it's only updating. So let's say I want to add a new 650 (like attached) it's updating all existing 650s to have the value I want to add as a new 650.
Comment 1 Fridolin SOMERS 2017-06-28 16:28:49 UTC
This is an enhancement
Comment 2 Nick Clemens 2017-07-05 16:20:33 UTC Comment hidden (obsolete)
Comment 3 delaye 2017-08-28 13:18:38 UTC
when i use the tool (step 12) i have this message

Software error:

Template process failed: undef error - The method itemnumbers is not covered by tests! at /home/koha/src/C4/Templates.pm line 121.


And when i want add the rule 'Add' in the template(step11)  , koha fix the rule delete
Comment 4 Katrin Fischer 2017-10-07 13:47:40 UTC
I think Update is not quite right as the option actually adds a field when it doesn't exist yet. I have used it to add items with different subfields a lot of times. Maybe it needs a better description - Add or update?
Comment 5 Nick Clemens 2017-10-25 17:04:57 UTC
Created attachment 68540 [details] [review]
Bug 13560 - need an add option in marc modification templates

Add/Update would update a field or create new if it existed, but didn't
allow for creating new if the field existed.

This patchset splits the options to Add & Update so that add will always
add a field and Update will operate as it always has

To test:
1 - Have a record with a known existing field (make a copy)
2 - Define a marc modification template that 'Add/update' on that field
3 - Define an 'Add/Update' on a field that doesn't exist
4 - Batch modify the copy of record using the above template
5 - Verify the existing field was updated
6 - Verify the non-existing field was updated
7 - Apply patch
8 - Make another copy
9 - Modify the copy with the same template as above
10 - Should match initial modification
11 - Add a new rule to add a new field
12 - Modify using the updated template
13 - Ensure your new field is created
14 - Test various options in the modification tool
15 - prove t/db_dependent/MarcModificationTemplates.t
Comment 6 Jon Knight 2017-10-25 18:09:22 UTC
When I try to do step 11 in the test plan, the rule created comes out as "Delete" rather than "Add new".  Similarly, if I try to edit the rule to make it "Add new" it goes back to "Delete" once the "Update action" button is pressed in the "Edit action 3" dialog box.
Comment 7 Victor Grousset/tuxayo 2017-11-06 11:21:55 UTC Comment hidden (obsolete)
Comment 8 Victor Grousset/tuxayo 2018-01-15 13:56:24 UTC Comment hidden (obsolete)
Comment 9 Nick Clemens 2018-01-16 16:27:40 UTC
Created attachment 70562 [details] [review]
Bug 13560 - Database changes
Comment 10 Nick Clemens 2018-01-16 16:27:44 UTC
Created attachment 70563 [details] [review]
Bug 13560 - Unit tests

To test:
1 - apply all patches
2 - update database
3 - prove t/db_dependent/MarcModificationTemplates.t
Comment 11 Nick Clemens 2018-01-16 16:27:48 UTC
Created attachment 70564 [details] [review]
Bug 13560: Add an 'Add' option for marc modification templates

Add/Update would update a field or create new if it existed, but didn't
allow for creating new if the field existed.

This patchset splits the options to 'Add & Update' so that 'Add' will always
add a field and 'Update' will operate as it always has

To test:
1 - Have a record with a known existing field (make a copy)
2 - Define a marc modification template that 'Add/update' on that field
3 - Define an 'Add/Update' on a field that doesn't exist
4 - Batch modify the copy of record using the above template
5 - Verify the existing field was updated
6 - Verify the non-existing field was updated
7 - Apply patch and update database
8 - Make another copy
9 - Modify the copy with the same template as above
10 - Should match initial modification
11 - Add a new rule to add a new field
12 - Modify using the updated template
13 - Ensure your new field is created
14 - Test various options in the modification tool
15 - prove t/db_dependent/MarcModificationTemplates.t
Comment 12 Nick Clemens 2018-01-16 16:28:22 UTC
fixed the conflict, split the patches, added DB update to instructions
Comment 13 Victor Grousset/tuxayo 2018-01-17 13:26:01 UTC Comment hidden (obsolete)
Comment 14 Victor Grousset/tuxayo 2018-01-17 13:29:01 UTC Comment hidden (obsolete)
Comment 15 Victor Grousset/tuxayo 2018-02-01 16:40:08 UTC
Created attachment 71115 [details] [review]
Bug 13560 - Database changes

Signed-off-by: Victor Grousset <victor.grousset@biblibre.com>
Comment 16 Victor Grousset/tuxayo 2018-02-01 16:40:13 UTC
Created attachment 71116 [details] [review]
Bug 13560 - Unit tests

To test:
1 - apply all patches
2 - update database
3 - prove t/db_dependent/MarcModificationTemplates.t

Signed-off-by: Victor Grousset <victor.grousset@biblibre.com>
Comment 17 Victor Grousset/tuxayo 2018-02-01 16:40:18 UTC
Created attachment 71117 [details] [review]
Bug 13560: Add an 'Add' option for marc modification templates

Add/Update would update a field or create new if it existed, but didn't
allow for creating new if the field existed.

This patchset splits the options to 'Add & Update' so that 'Add' will always
add a field and 'Update' will operate as it always has

To test:
1 - Have a record with a known existing field (make a copy)
2 - Define a marc modification template that 'Add/update' on that field
3 - Define an 'Add/Update' on a field that doesn't exist
4 - Batch modify the copy of record using the above template
5 - Verify the existing field was updated
6 - Verify the non-existing field was updated
7 - Apply patch and update database
8 - Make another copy
9 - Modify the copy with the same template as above
10 - Should match initial modification
11 - Add a new rule to add a new field
12 - Modify using the updated template
13 - Ensure your new field is created
14 - Test various options in the modification tool
15 - prove t/db_dependent/MarcModificationTemplates.t

Signed-off-by: Victor Grousset <victor.grousset@biblibre.com>
Comment 18 Victor Grousset/tuxayo 2018-02-01 16:41:12 UTC
I forgot to sign off the first two patches. So here they are.

To no loose my previous comment:

As for step «14 - Test various options in the modification tool»

I only moved one field to another to ensure that the target is overwritten without error. Is that enough?
Comment 19 Victor Grousset/tuxayo 2018-02-22 14:58:23 UTC
(In reply to Nick Clemens on IRC)
> ideally you would test all the options just to ensure I didn't break anything unintentionally, but if any other option worked it would seem features are intact

I tried to play with the copy function, but that failed (even on the 17.11) so due to lack of functional knowledge I can't improvise more than that.

But that doesn't seem a big issue. So this would be reading for being QAed if I understand correctly.