From: Mike Taylor Date: Wed, 19 Dec 2012 10:04:25 +0000 (+0000) Subject: Resolve X-Git-Url: http://git.indexdata.com/?p=irspy-moved-to-github.git;a=commitdiff_plain;h=08f7276dbdd4b6d3f02cfa3f4b4d06f0af331055;hp=27758ba1f0cb7dbac3c9fe825c08c815f02777a7 Resolve --- diff --git a/.gitignore b/.gitignore index 0b5bd39..d4567d4 100644 --- a/.gitignore +++ b/.gitignore @@ -1,3 +1,4 @@ +MYMETA.yml Makefile blib pm_to_blib diff --git a/Changes b/Changes index 8e20cc8..dc1415c 100644 --- a/Changes +++ b/Changes @@ -24,6 +24,10 @@ Revision history for Perl extension ZOOM::IRSpy. running an XPath with IRSpy-related namespaces established. - Record::Fetch test registers a fail when the syntax actually retrieved does not match that requested. Fixes bug IR-324. + - Add new test, Record::PiggyBack, with support for viewing, + editing and storing results. Fixes bug IR-333. + - IDs used in URLs for full-record links are properly + CQL-quoted. Fixes part of IR-303. 1.02 Wed Jul 7 16:43:36 BST 2010 - Enhance setrlimit program so that it can set maximum diff --git a/MANIFEST b/MANIFEST index 0d2b86b..d2224dc 100644 --- a/MANIFEST +++ b/MANIFEST @@ -32,6 +32,7 @@ lib/ZOOM/IRSpy/Test/Quick.pm lib/ZOOM/IRSpy/Test/Record/Fetch.pm lib/ZOOM/IRSpy/Test/Record/Main.pm lib/ZOOM/IRSpy/Test/Record/OPAC.pm +lib/ZOOM/IRSpy/Test/Record/PiggyBack.pm lib/ZOOM/IRSpy/Test/ResultSet/Main.pm lib/ZOOM/IRSpy/Test/ResultSet/Named.pm lib/ZOOM/IRSpy/Test/Search/Bath.pm diff --git a/lib/ZOOM/IRSpy/Test/Quick.pm b/lib/ZOOM/IRSpy/Test/Quick.pm index c184ccd..a690c9e 100644 --- a/lib/ZOOM/IRSpy/Test/Quick.pm +++ b/lib/ZOOM/IRSpy/Test/Quick.pm @@ -8,7 +8,7 @@ use warnings; use ZOOM::IRSpy::Test; our @ISA = qw(ZOOM::IRSpy::Test); -sub subtests { qw(Ping Record::Fetch) } +sub subtests { qw(Ping Record::PiggyBack) } sub timeout { 20 } diff --git a/lib/ZOOM/IRSpy/Test/Record/PiggyBack.pm b/lib/ZOOM/IRSpy/Test/Record/PiggyBack.pm new file mode 100644 index 0000000..9b62142 --- /dev/null +++ b/lib/ZOOM/IRSpy/Test/Record/PiggyBack.pm @@ -0,0 +1,93 @@ +# See the "Main" test package for documentation + +### Too much common code with OPAC.pm: need to refactor + +package ZOOM::IRSpy::Test::Record::PiggyBack; + +use 5.008; +use strict; +use warnings; + +use ZOOM::IRSpy::Test; +our @ISA = qw(ZOOM::IRSpy::Test); + +my @queries = ( + "\@attr 1=4 mineral", + "\@attr 1=4 computer", + "\@attr 1=44 mineral", # Smithsonian doesn't support AP 4! + "\@attr 1=1016 water", # Connector Framework only does 1016 + ### We can add more queries here + ); + +# We'd like to use this temporary-options hash to set +# preferredRecordSyntax, as well But that doesn't work because the +# same value needs to be in force later on when we make the +# record_immediate() call, otherwise it misses its cache. +my %options = ( + piggyback => 1, + count => 3, +# preferredRecordSyntax => "usmarc" + ); + +sub start { + my $class = shift(); + my($conn) = @_; + + ### It would be better to consult previous tests to find a working RS + $conn->option(preferredRecordSyntax => "usmarc"); + $conn->irspy_search_pqf($queries[0], { queryindex => 0 }, \%options, + ZOOM::Event::ZEND, \&completed_search, + exception => \&completed_search); +} + + +sub completed_search { + my($conn, $task, $udata, $event) = @_; + + if ($event->isa("ZOOM::Exception") && $event->code() == 1005) { + $conn->log("irspy_test", "Piggyback searching not supported"); + $conn->record()->store_result('piggyback', 'ok' => 0); + return ZOOM::IRSpy::Status::TEST_BAD; + } + + my $n = $task->{rs}->size(); + $conn->log("irspy_test", "Piggyback test search (", $task->render_query(), ") ", + ref $event && $event->isa("ZOOM::Exception") ? + "failed: $event" : "found $n records (event=$event)"); + + # remember how often a target record hit a timeout + if (ref $event && $event->isa("ZOOM::Exception")) { + if ($event =~ /Timeout/i) { + $conn->record->zoom_error->{TIMEOUT}++; + $conn->log("irspy_test", "Increase timeout error counter to: " . + $conn->record->zoom_error->{TIMEOUT}); + } + } + + if ($n < 3) { + $task->{rs}->destroy(); + my $qindex = $udata->{queryindex}+1; + my $q = $queries[$qindex]; + return ZOOM::IRSpy::Status::TEST_SKIPPED + if !defined $q || $conn->record->zoom_error->{TIMEOUT} >= $ZOOM::IRSpy::max_timeout_errors; + + $conn->log("irspy_test", "Trying another search ..."); + $conn->irspy_search_pqf($queries[$qindex], { queryindex => $qindex }, \%options, + ZOOM::Event::ZEND, \&completed_search, + exception => \&completed_search); + return ZOOM::IRSpy::Status::TASK_DONE; + } + + # We have a result-set of three of more records, and we requested + # that those records be included in the Search Response using + # piggybacking. Was it done? + my $rec = $task->{rs}->record_immediate(2); + my $ok = defined $rec && $rec->error() == 0; + + $task->{rs}->destroy(); + $conn->record()->store_result('piggyback', 'ok' => $ok); + return $ok ? ZOOM::IRSpy::Status::TEST_GOOD : ZOOM::IRSpy::Status::TEST_BAD; +} + + +1; diff --git a/web/htdocs/details/found.mc b/web/htdocs/details/found.mc index e4312fb..84735fc 100644 --- a/web/htdocs/details/found.mc +++ b/web/htdocs/details/found.mc @@ -124,7 +124,7 @@ push @ids, $id; <% $i %> - "><% xml_encode($title) %> <% xml_encode($reliability, "", { nbsp => 1 }) %> <% xml_encode($host, "") %> diff --git a/web/htdocs/details/full.mc b/web/htdocs/details/full.mc index 546419b..6003fc7 100644 --- a/web/htdocs/details/full.mc +++ b/web/htdocs/details/full.mc @@ -51,6 +51,7 @@ if ($n == 0) { [ "Record syntaxes" => \&calc_recsyn, $xc ], [ "Explain" => \&calc_explain, $xc ], [ "Multiple OPAC records" => \&calc_mor, $xc ], + [ "Piggback searching" => \&calc_piggyback, $xc ], ); my $title = $xc->find("e:databaseInfo/e:title"); @@ -183,6 +184,7 @@ sub calc_boolean { sub calc_nrs { _calc_boolean(@_, 'i:status/i:named_resultset[@ok = "1"]') } sub calc_mor { _calc_boolean(@_, 'i:status/i:multiple_opac[@ok = "1"]') } +sub calc_piggyback { _calc_boolean(@_, 'i:status/i:piggback[@ok = "1"]') } sub _calc_boolean { my($id, $xc, $xpath) = @_; diff --git a/xsl/irspy2zeerex.xsl b/xsl/irspy2zeerex.xsl index 6379a38..3926ad6 100644 --- a/xsl/irspy2zeerex.xsl +++ b/xsl/irspy2zeerex.xsl @@ -165,6 +165,11 @@ + + + + +