/[webpac2]/trunk/lib/WebPAC/Input/MARC.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/MARC.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 337 - (show annotations)
Sat Dec 31 16:41:35 2005 UTC (18 years, 4 months ago) by dpavlin
File size: 1610 byte(s)
 r343@llin:  dpavlin | 2005-12-31 17:44:58 +0100
 fix clash of $self->{size} from WebPAC::Input and WebPAC::Input::MARC,
 dokument _marc_size property

1 package WebPAC::Input::MARC;
2
3 use warnings;
4 use strict;
5
6 use MARC::Fast;
7
8 =head1 NAME
9
10 WebPAC::Input::MARC - support for MARC database files
11
12 =head1 VERSION
13
14 Version 0.04
15
16 =cut
17
18 our $VERSION = '0.04';
19
20
21 =head1 SYNOPSIS
22
23 Open USMARC, Unimarc or any other file format that has same internal
24 structure using C<MARC::Fast>.
25
26 my $marc = new WebPAC::Input::MARC();
27 $marc->open( path => '/path/to/marc.iso' );
28
29 =head1 FUNCTIONS
30
31 =head2 open_db
32
33 Returns handle to database
34
35 my $db = $open_db(
36 path => '/path/to/marc.iso'
37 }
38
39 =cut
40
41 sub open_db {
42 my $self = shift;
43
44 my $arg = {@_};
45
46 my $log = $self->_get_logger();
47
48 $log->info("opening MARC database '$arg->{path}'");
49
50 my $db = new MARC::Fast( marcdb => $arg->{path});
51 my $db_size = $db->count - 1; # FIXME
52
53 $self->{_marc_size} = $db_size;
54
55 return ($db, $db_size);
56 }
57
58 =head2 fetch_rec
59
60 Return record with ID C<$mfn> from database
61
62 my $rec = $self->fetch_rec( $db, $mfn );
63
64 }
65
66 =cut
67
68 sub fetch_rec {
69 my $self = shift;
70
71 my ($db, $mfn) = @_;
72
73 if ($mfn > $self->{_marc_size}) {
74 $self->_get_logger()->warn("seek beyond database size $self->{_marc_size} to $mfn");
75 } else {
76 my $row = $db->to_hash($mfn);
77 push @{$row->{'000'}}, $mfn;
78 return $row;
79 }
80 }
81
82 =head1 PROPERTIES
83
84 =head2 _marc_size
85
86 Store size of MARC database
87
88 print $self->{_marc_size};
89
90
91
92 =head1 AUTHOR
93
94 Dobrica Pavlinusic, C<< <dpavlin@rot13.org> >>
95
96 =head1 COPYRIGHT & LICENSE
97
98 Copyright 2005 Dobrica Pavlinusic, All Rights Reserved.
99
100 This program is free software; you can redistribute it and/or modify it
101 under the same terms as Perl itself.
102
103 =cut
104
105 1; # End of WebPAC::Input::MARC

  ViewVC Help
Powered by ViewVC 1.1.26