source: main/trunk/greenstone2/perllib/plugins/MetadataRead.pm@ 28782

Last change on this file since 28782 was 24547, checked in by ak19, 13 years ago

Added new abstract plugin MetadataRead that defines can_process_this_file_for_metadata that MetadataPlugin subclasses can inherit (if MetadataRead is listed first in the ISA inheritance list) and which will then override the one defined in BasePlugin. For now committing MARC, ISIS and OAIPlugins which now additionally inherit from MetadataRead. Other metadataPlugins also need to be committed.

File size: 3.1 KB
Line 
1###########################################################################
2#
3# MetadataRead - like a Java interface that defines that a subclass is
4# a Plugin that extracts Metadata
5#
6# A component of the Greenstone digital library software
7# from the New Zealand Digital Library Project at the
8# University of Waikato, New Zealand.
9#
10# Copyright (C) 2008 New Zealand Digital Library Project
11#
12# This program is free software; you can redistribute it and/or modify
13# it under the terms of the GNU General Public License as published by
14# the Free Software Foundation; either version 2 of the License, or
15# (at your option) any later version.
16#
17# This program is distributed in the hope that it will be useful,
18# but WITHOUT ANY WARRANTY; without even the implied warranty of
19# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20# GNU General Public License for more details.
21#
22# You should have received a copy of the GNU General Public License
23# along with this program; if not, write to the Free Software
24# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25#
26###########################################################################
27
28package MetadataRead;
29
30use PrintInfo;
31use strict;
32
33# MetadataRead is an abstract superclass that does not inherit from anything else.
34# It exists solely to define the can_process_this_file_for_metadata() method in
35# such a way that those MetadataPlugins that inherit from MetadataRead don't need
36# to define this method and will always process the files associated with them for
37# metadata and other plugins in the pipeline won't be passed these files anymore.
38
39# MetadataRead defines method can_process_this_file_for_metadata() with identical
40# signature to BasePlugin. (MetadataRead doesn't inherit from BasePlugin, so it's
41# not 'overriding' it.) Subclasses of MetadataRead that want to use this method
42# definition can override their inherited BasePlugin version of the method by
43# listing MetadataRead as the *first* superclass they inherit from in the ISA list.
44# This is the way Perl resolves conflicting method definitions.
45
46my $arguments = [];
47
48my $options = { 'name' => "MetadataRead",
49 'desc' => "{MetadataRead.desc}",
50 'abstract' => "yes",
51 'inherits' => "yes",
52 'args' => $arguments };
53
54
55sub new {
56 my ($class) = shift (@_);
57 my ($pluginlist,$inputargs,$hashArgOptLists,$auxiliary) = @_;
58 push(@$pluginlist, $class);
59
60 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
61 push(@{$hashArgOptLists->{"OptList"}},$options);
62
63 # Like PrintInfo, MetadataRead has no superclass,
64 # so $self is intialised to an empty array.
65 my $self = {};
66 return bless $self, $class;
67
68}
69
70# MetadataPlugins that inherit from MetadataRead will by default
71# process all the metadata in files whose extensions match.
72# Override this method in a subclass to return undef if other
73# files should also be allowed to process the metadata therafter.
74sub can_process_this_file_for_metadata {
75 my $self = shift(@_);
76
77# print STDERR "********* MetadataRead::can_process_this_file_for_metadata() called.\n";
78
79 return $self->can_process_this_file(@_);
80}
81
82
831;
Note: See TracBrowser for help on using the repository browser.