A mapping to say that a record should be included in a OAI-PMH set if it has the value "PDF" in field 347$b can be defined as: Field = 347 Subfield = b Operator = equals Value = PDF In C4::OAI::Sets::_evalRule, this is the code that picks out the relevant field and subfield: 544 my @subfield_values = $record->subfield($field, $subfield); But this will only return the value from the first field with tag $field, it does not really work in array context. The code works, if your 347$b = PDF occurs as the first 347 field, but not if it occurs in a subsequent field 347. So the code needs to be expanded into something like this: my @subfield_values; my @fields = $record->field($field); foreach my $field ( @fields ) { if ( my $subfield_value = $field->subfield($subfield) ) { push @subfield_values, $subfield_value; } }
Created attachment 98153 [details] [review] Bug 24531 - Test for OAI-PMH sets and repeated fields This patch adds two tests related to OAI-PMH sets. It creates a dummy record with a repeated field, with different values. It then tests if the record is caught by mappings that match the value in the first field, and then if it is caught by mappings that match the second field.
Created attachment 98154 [details] [review] Bug 24531 - Fix OAI-PMH sets for records with repeated fields Currently, an OAI-PMH set mapping will only match if the value it is looking for occurs in the first instance of a repeated field. To test: - Apply the first patch with two new tests - Run something like this: sudo koha-shell -c "prove -v t/db_dependent/OAI/Sets.t" kohadev - Verify that the last test fails - Apply this secind patch - Rerun the test file above - Verify that all tests now pass
Created attachment 98221 [details] [review] Bug 24531 - Test for OAI-PMH sets and repeated fields This patch adds two tests related to OAI-PMH sets. It creates a dummy record with a repeated field, with different values. It then tests if the record is caught by mappings that match the value in the first field, and then if it is caught by mappings that match the second field. Signed-off-by: David Nind <david@davidnind.com>
Created attachment 98222 [details] [review] Bug 24531 - Fix OAI-PMH sets for records with repeated fields Currently, an OAI-PMH set mapping will only match if the value it is looking for occurs in the first instance of a repeated field. To test: - Apply the first patch with two new tests - Run something like this: sudo koha-shell -c "prove -v t/db_dependent/OAI/Sets.t" kohadev - Verify that the last test fails - Apply this secind patch - Rerun the test file above - Verify that all tests now pass Signed-off-by: David Nind <david@davidnind.com>
What if there is repeated subfield with same code in one field? Then only first one is taken into account. I do think we want to count on all of them...
(In reply to Josef Moravec from comment #6) > What if there is repeated subfield with same code in one field? Then only > first one is taken into account. I do think we want to count on all of > them... Gah, how did I miss that? I'll update the patch. Thanks!
Created attachment 98894 [details] [review] Bug 24531 - Test for OAI-PMH sets and repeated fields This patch adds two tests related to OAI-PMH sets. It creates a dummy record with a repeated field, with different values. It then tests if the record is caught by mappings that match the value in the first field, and then if it is caught by mappings that match the second field.
Created attachment 98895 [details] [review] Bug 24531 - Fix OAI-PMH sets for records with repeated fields Currently, an OAI-PMH set mapping will only match if the value it is looking for occurs in the first instance of a repeated field. To test: - Apply the first patch with two new tests - Run something like this: sudo koha-shell -c "prove -v t/db_dependent/OAI/Sets.t" kohadev - Verify that the last test fails - Apply this secind patch - Rerun the test file above - Verify that all tests now pass
Created attachment 98896 [details] [review] Bug 24531 - Test for OAI-PMH sets and repeated fields This patch adds two tests related to OAI-PMH sets. It creates a dummy record with a repeated field, with different values. It then tests if the record is caught by mappings that match the value in the first field, and then if it is caught by mappings that match the second field. Signed-off-by: David Nind <david@davidnind.com>
Created attachment 98897 [details] [review] Bug 24531 - Fix OAI-PMH sets for records with repeated fields Currently, an OAI-PMH set mapping will only match if the value it is looking for occurs in the first instance of a repeated field. To test: - Apply the first patch with two new tests - Run something like this: sudo koha-shell -c "prove -v t/db_dependent/OAI/Sets.t" kohadev - Verify that the last test fails - Apply this secind patch - Rerun the test file above - Verify that all tests now pass Signed-off-by: David Nind <david@davidnind.com>
(In reply to Josef Moravec from comment #6) > What if there is repeated subfield with same code in one field? Then only > first one is taken into account. I do think we want to count on all of > them... I have updated the tests and the code to account for repeated subfields. I reset the status to SO, please reset to NSO if necessary.
Created attachment 98906 [details] [review] Bug 24531: Test for OAI-PMH sets and repeated fields This patch adds two tests related to OAI-PMH sets. It creates a dummy record with a repeated field, with different values. It then tests if the record is caught by mappings that match the value in the first field, and then if it is caught by mappings that match the second field. Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
Created attachment 98907 [details] [review] Bug 24531: Fix OAI-PMH sets for records with repeated fields Currently, an OAI-PMH set mapping will only match if the value it is looking for occurs in the first instance of a repeated field. To test: - Apply the first patch with two new tests - Run something like this: sudo koha-shell -c "prove -v t/db_dependent/OAI/Sets.t" kohadev - Verify that the last test fails - Apply this secind patch - Rerun the test file above - Verify that all tests now pass Signed-off-by: David Nind <david@davidnind.com> Signed-off-by: Josef Moravec <josef.moravec@gmail.com>
(In reply to Magnus Enger from comment #12) > (In reply to Josef Moravec from comment #6) > > What if there is repeated subfield with same code in one field? Then only > > first one is taken into account. I do think we want to count on all of > > them... > > I have updated the tests and the code to account for repeated subfields. I > reset the status to SO, please reset to NSO if necessary. Thanks Magnus, PQA now
Nice work everyone! Pushed to master for 20.05
does not apply to 19.11.x please rebase if needed
(In reply to Joy Nelson from comment #17) > does not apply to 19.11.x > please rebase if needed This patchset fixes the _evaRule sub which was added in Bug 21520. Looking into code I think that in 19.11.x series this bug exist also, but the patch need to be rework because of refactoring made in Bug 21520.
*** Bug 12731 has been marked as a duplicate of this bug. ***
*** Bug 29305 has been marked as a duplicate of this bug. ***