1 %# $Id: full.mc,v 1.28 2007-05-11 13:32:57 mike Exp $
6 my $conn = new ZOOM::Connection("localhost:8018/IR-Explain---1");
7 $conn->option(elementSetName => "zeerex");
8 my $query = cql_target($id);
9 my $rs = $conn->search(new ZOOM::Query::CQL($query));
12 $m->comp("/details/error.mc",
13 title => "Error", message => "No such ID '$id'");
15 my $xc = irspy_xpath_context($rs->record(0));
17 [ Name => "e:databaseInfo/e:title",
18 lang => "en", primary => "true" ],
19 [ Country => "i:status/i:country" ],
20 [ "Last Checked" => "i:status/i:probe[last()]" ],
21 [ Protocol => "e:serverInfo/\@protocol" ],
22 [ Host => "e:serverInfo/e:host" ],
23 [ Port => "e:serverInfo/e:port" ],
24 [ "Database Name" => "e:serverInfo/e:database" ],
25 [ "Type of Library" => "i:status/i:libraryType" ],
26 # [ "Username (if needed)" => "e:serverInfo/e:authentication/e:user" ],
27 # [ "Password (if needed)" => "e:serverInfo/e:authentication/e:password" ],
28 [ "Server ID" => 'i:status/i:serverImplementationId/@value' ],
29 [ "Server Name" => 'i:status/i:serverImplementationName/@value' ],
30 [ "Server Version" => 'i:status/i:serverImplementationVersion/@value' ],
31 [ Description => "e:databaseInfo/e:description",
32 lang => "en", primary => "true" ],
33 [ Author => "e:databaseInfo/e:author" ],
34 [ Contact => "e:databaseInfo/e:contact" ],
35 [ "URL to Hosting Organisation" => "i:status/i:hostURL" ],
36 [ Extent => "e:databaseInfo/e:extent" ],
37 [ History => "e:databaseInfo/e:history" ],
38 [ "Language of Records" => "e:databaseInfo/e:langUsage" ],
39 [ Restrictions => "e:databaseInfo/e:restrictions" ],
40 [ Subjects => "e:databaseInfo/e:subjects" ],
41 [ "Implementation ID" => "i:status/i:implementationId" ],
42 [ "Implementation Name" => "i:status/i:implementationName" ],
43 [ "Implementation Version" => "i:status/i:implementationVersion" ],
44 [ "Reliability/reliability" => \&calc_reliability, $xc ],
45 [ "Services" => \&calc_init_options, $xc ],
46 [ "Bib-1 Use attributes" => \&calc_ap, $xc, "bib-1" ],
47 [ "Dan-1 Use attributes" => \&calc_ap, $xc, "dan-1" ],
48 [ "Operators" => \&calc_boolean, $xc ],
49 [ "Named Result Sets" => \&calc_nrs, $xc ],
50 [ "Record syntaxes" => \&calc_recsyn, $xc ],
51 [ "Explain" => \&calc_explain, $xc ],
53 my $title = $xc->find("e:databaseInfo/e:title");
55 <h2><% xml_encode($title, "") %></h2>
56 <table class="fullrecord" border="1" cellspacing="0" cellpadding="5" width="100%">
58 foreach my $ref (@fields) {
59 my($caption, $xpath, @args) = @$ref;
61 if (ref $xpath && ref($xpath) eq "CODE") {
62 $data = &$xpath(@args);
64 $data = $xc->find($xpath);
69 % $caption =~ s/\/(.*)//;
71 <th><% xml_encode($caption) %><%
72 !defined $help ? "" : $m->comp("/help/link.mc", help =>"info/$help")
74 <td><% xml_encode($data) %></td>
80 <a href="<% xml_encode("http://targettest.indexdata.com/targettest/search/index.zap?" .
82 "target=" . uri_escape_utf8(irspy_identifier2target($id)),
83 "name=" . uri_escape_utf8($title),
84 "attr=" . join(" ", list_ap($xc, "bib-1")),
85 "formats=" . calc_recsyn($xc, " ")))
86 %>">Search this target.</a>
91 sub calc_reliability {
94 my @allpings = $xc->findnodes("i:status/i:probe");
96 return "[untested]" if $nall == 0;
97 my @okpings = $xc->findnodes('i:status/i:probe[@ok = "1"]');
99 return "$nok/$nall = " . int(100*$nok/$nall) . "%";
102 sub calc_init_options {
106 my @nodes = $xc->findnodes('e:configInfo/e:supports/@type');
107 foreach my $node (@nodes) {
108 my $type = $node->value();
109 if ($type =~ s/^z3950_//) {
114 return join(", ", @ops);
120 my @aps = list_ap($xc, $set);
122 return "[none]" if $n == 0;
126 foreach my $ap (@aps) {
127 if (!defined $first) {
128 $first = $last = $ap;
129 } elsif ($ap == $last+1) {
132 # Got a complete range
133 $res .= ", " if $res ne "";
135 $res .= "-$last" if $last > $first;
136 $first = $last = $ap;
141 if (defined $first) {
142 $res .= ", " if $res ne "";
144 $res .= "-$last" if $last > $first;
147 return "$n access points: $res";
153 my $expr = 'e:indexInfo/e:index[@search = "true"]/e:map/e:attr[
154 @set = "'.$set.'" and @type = "1"]';
155 my @nodes = $xc->findnodes($expr);
156 return sort { $a <=> $b } map { $_->findvalue(".") } @nodes;
162 ### Note that we are currently interrogating an IRSpy extension.
163 # The standard ZeeRex record should be extended with a
164 # "supports" type for this.
165 my @nodes = $xc->findnodes('i:status/i:boolean[@ok = "1"]');
166 my $res = join(", ", map { $_->findvalue('@operator') } @nodes);
167 $res = "[none]" if $res eq "";
174 my @nodes = $xc->findnodes('i:status/i:named_resultset[@ok = "1"]');
175 return @nodes ? "Yes" : "No";
180 $sep = ", " if !defined $sep;
182 my @nodes = $xc->findnodes('e:recordInfo/e:recordSyntax');
183 my $res = join($sep, map { $_->findvalue('@name') } @nodes);
184 $res = "[none]" if $res eq "";
191 my @nodes = $xc->findnodes('i:status/i:explain[@ok = "1"]');
192 my $res = join(", ", map { $_->findvalue('@category') } @nodes);
193 $res = "[none]" if $res eq "";