From 2d4fd97328f0433be4fd027eb7f55919b2665809 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Fri, 17 Dec 2010 15:24:21 +0000 Subject: [PATCH] Simplify sample invocation. Do not attempt to use lib '../lib'. Add dummy deletion code that displays ID of record to be removed. --- samples/zoom/zoom-delete-records | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) diff --git a/samples/zoom/zoom-delete-records b/samples/zoom/zoom-delete-records index 13c07a1..fb5f417 100755 --- a/samples/zoom/zoom-delete-records +++ b/samples/zoom/zoom-delete-records @@ -1,8 +1,7 @@ #!/usr/bin/perl # -# ./zoom-delete-records.pl user=admin,password=fruitbat,localhost:8018/IR-Explain---1 'concat(count(irspy:status/irspy:probe[@ok=1]), "/", count(irspy:status/irspy:probe))' 'count(irspy:status/irspy:probe[@ok=1]) = 0 and count(irspy:status/irspy:probe) >= 10' +# zoom-delete-records user=admin,password=fruitbat,localhost:8018/IR-Explain---1 'concat(count(irspy:status/irspy:probe[@ok=1]), "/", count(irspy:status/irspy:probe))' 'count(irspy:status/irspy:probe[@ok=1]) = 0 and count(irspy:status/irspy:probe) >= 10' -use lib '../lib'; use XML::LibXML; use ZOOM; use strict; @@ -26,6 +25,29 @@ foreach my $i (1 .. $n) { my $val = $xc->findvalue($displayXPath); print "Record $i/$n: $val"; $val = $xc->findvalue($deleteXPath); - print " DELETE" if $val eq "true"; + if ($val eq "true") { + my $id = ZOOM_record_id($rs, $i); + print " DELETE $id"; + #my $p = $conn->package(); + #$p->option(action => "deleteRecord"); + #$p->option(recordIdOpaque => $id); + #$p->send("update"); + #$p->destroy(); + } print "\n"; } + +sub ZOOM_record_id { + my($rs, $i) = @_; + # There is no standard way in Z39.50 to discover the opaque record + # ID of a given record, which is a bit silly as you need this in + # order to update or delete it using Extended Services. So we + # adopt the convention that fetching the record with element-set + # "id" returns the ID. This convention is implemented by the + # IRSpy database, among others. + + my $old = $rs->option(elementSetName => "id"); + my $id = $rs->record($i-1)->render(); + $rs->option(elementSetName => $old); + return $id; +} -- 1.7.10.4