/[webpac2]/trunk/lib/WebPAC/Input/ISIS.pm
This is repository of my old source code which isn't updated any more. Go to git.rot13.org for current projects!
ViewVC logotype

Contents of /trunk/lib/WebPAC/Input/ISIS.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 623 - (show annotations)
Sat Aug 26 12:00:25 2006 UTC (17 years, 8 months ago) by dpavlin
File size: 2090 byte(s)
 r876@llin:  dpavlin | 2006-08-25 21:53:19 +0200
 remove OpenIsis support (it was broken for quite some time), make hash_filter chatty (debugging)

1 package WebPAC::Input::ISIS;
2
3 use warnings;
4 use strict;
5
6 use WebPAC::Input;
7 use Biblio::Isis 0.23;
8
9 =head1 NAME
10
11 WebPAC::Input::ISIS - support for CDS/ISIS database files
12
13 =head1 VERSION
14
15 Version 0.06
16
17 =cut
18
19 our $VERSION = '0.06';
20
21
22 =head1 SYNOPSIS
23
24 Open CDS/ISIS, WinISIS or IsisMarc database using C<Biblio::Isis>
25 and read all records to memory.
26
27 my $isis = new WebPAC::Input::ISIS();
28 $isis->open( path => '/path/to/ISIS/ISIS' );
29
30 =head1 FUNCTIONS
31
32 =head2 open_db
33
34 Returns handle to database and size in records
35
36 my ($db,$size) = $isis->open_db(
37 path => '/path/to/LIBRI'
38 filter => sub {
39 my ($l,$field_nr) = @_;
40 # do something with $l which is line of input file
41 return $l;
42 },
43 }
44
45 Options:
46
47 =over 4
48
49 =item path
50
51 path to CDS/ISIS database
52
53 =back
54
55 =cut
56
57 sub open_db {
58 my $self = shift;
59
60 my $arg = {@_};
61
62 my $log = $self->_get_logger();
63
64 $log->info("opening ISIS database '$arg->{path}'");
65
66 $log->debug("using Biblio::Isis");
67 my $isis_db = new Biblio::Isis(
68 isisdb => $arg->{path},
69 include_deleted => 1,
70 hash_filter => $arg->{filter} ? sub { return $arg->{filter}->(@_); } : undef,
71 ) or $log->logdie("can't find database $arg->{path}");
72
73 my $size = $isis_db->count;
74
75 return ($isis_db, $size);
76 }
77
78 =head2 fetch_rec
79
80 Return record with ID C<$mfn> from database
81
82 my $rec = $self->fetch_rec( $db, $mfn, $filter_coderef);
83
84 =cut
85
86 sub fetch_rec {
87 my $self = shift;
88
89 my ($isis_db, $mfn, $filter_coderef) = @_;
90
91 use Data::Dump qw/dump/;
92 warn "fetch_rec filter_coderef = ", dump($filter_coderef), $/;
93
94 my $rec = $isis_db->to_hash({
95 mfn => $mfn,
96 include_subfields => 1,
97 hash_filter => sub {
98 my ($l,$f) = @_;
99 warn "## in hash_filter ($l,$f)\n";
100 my $o = $filter_coderef->($l,$f);
101 warn "## out hash_filter = $o\n";
102 return $o;
103 },
104 });
105
106 return $rec;
107 }
108
109 =head1 AUTHOR
110
111 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
112
113 =head1 COPYRIGHT & LICENSE
114
115 Copyright 2005 Dobrica Pavlinusic, All Rights Reserved.
116
117 This program is free software; you can redistribute it and/or modify it
118 under the same terms as Perl itself.
119
120 =cut
121
122 1; # End of WebPAC::Input::ISIS

  ViewVC Help
Powered by ViewVC 1.1.26