/[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 726 - (show annotations)
Fri Sep 29 19:52:17 2006 UTC (17 years, 6 months ago) by dpavlin
File size: 2482 byte(s)
 r1045@llin:  dpavlin | 2006-09-29 21:38:42 +0200
 change low-level API to be OO (and remove various ugly cludges).

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

  ViewVC Help
Powered by ViewVC 1.1.26