source: trunk/gsdl/perllib/plugins/BasPlug.pm@ 839

Last change on this file since 839 was 839, checked in by davidb, 24 years ago

added extra_metadata function

  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 KB
Line 
1###########################################################################
2#
3# BasPlug.pm -- base class for all the import plugins
4# A component of the Greenstone digital library software
5# from the New Zealand Digital Library Project at the
6# University of Waikato, New Zealand.
7#
8# Copyright (C) 1999 New Zealand Digital Library Project
9#
10# This program is free software; you can redistribute it and/or modify
11# it under the terms of the GNU General Public License as published by
12# the Free Software Foundation; either version 2 of the License, or
13# (at your option) any later version.
14#
15# This program is distributed in the hope that it will be useful,
16# but WITHOUT ANY WARRANTY; without even the implied warranty of
17# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18# GNU General Public License for more details.
19#
20# You should have received a copy of the GNU General Public License
21# along with this program; if not, write to the Free Software
22# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23#
24###########################################################################
25
26package BasPlug;
27
28
29sub new {
30 my ($class) = @_;
31
32 return bless {}, $class;
33}
34
35sub begin {
36 my $self = shift (@_);
37 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
38}
39
40sub end {
41 my ($self) = @_;
42}
43
44# return 1 if this class might recurse using $pluginfo
45sub is_recursive {
46 my $self = shift (@_);
47
48 die "BasPlug::is_recursive function must be implemented in sub classes\n";
49}
50
51# return number of files processed, undef if can't process
52# Note that $base_dir might be "" and that $file might
53# include directories
54sub read {
55 my $self = shift (@_);
56 my ($pluginfo, $base_dir, $file, $metadata, $processor, $maxdocs) = @_;
57
58 die "BasPlug::read function must be implemented in sub classes\n";
59
60 return undef; # will never get here
61}
62
63sub extra_metadata
64{
65 my ($self,$doc_obj,$cursection, $metadata) = @_;
66
67 foreach $field (keys(%$metadata)) {
68 # $metadata->{$field} may be an array reference
69 if (ref ($metadata->{$field}) eq "ARRAY") {
70 map {
71 $doc_obj->add_metadata ($cursection, $field, $_);
72 } @{$metadata->{$field}};
73 } else {
74 $doc_obj->add_metadata ($cursection, $field, $metadata->{$field});
75 }
76 }
77}
78
791;
Note: See TracBrowser for help on using the repository browser.