Index: /gsdl/trunk/perllib/plugins/AutoExtractMetadata.pm
===================================================================
--- /gsdl/trunk/perllib/plugins/AutoExtractMetadata.pm	(revision 15869)
+++ /gsdl/trunk/perllib/plugins/AutoExtractMetadata.pm	(revision 15869)
@@ -0,0 +1,117 @@
+###########################################################################
+#
+# AutoExtractMetadata.pm -- base plugin for all plugins that want to do metadata extraction from text and/or metadata 
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2008 New Zealand Digital Library Project
+#
+# This program is free software; you can redistribute it and/or modify
+# it under the terms of the GNU General Public License as published by
+# the Free Software Foundation; either version 2 of the License, or
+# (at your option) any later version.
+#
+# This program is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with this program; if not, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+# This plugin uses the supporting Extractors to add metadata extraction 
+# functionality to BasePlugin.
+
+
+package AutoExtractMetadata;
+
+use strict; 
+no strict 'subs';
+no strict 'refs'; # allow filehandles to be variables and viceversa
+
+use BasePlugin;
+use AcronymExtractor;
+use KeyphraseExtractor;
+use EmailAddressExtractor;
+use DateExtractor;
+use GISExtractor;
+
+sub BEGIN {
+    @AutoExtractMetadata::ISA = ( 'BasePlugin', 'AcronymExtractor', 'KeyphraseExtractor', 'EmailAddressExtractor', 'DateExtractor', 'GISExtractor' );
+}
+
+my $arguments = [];
+
+
+my $options = { 'name'     => "AutoExtractMetadata",
+		'desc'     => "{AutoExtractMetadata.desc}",
+		'abstract' => "yes",
+		'inherits' => "no",
+		'args'     => $arguments };
+
+
+sub new {
+
+    # Start the AutoExtractMetadata Constructor
+    my $class = shift (@_);
+    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
+    push(@$pluginlist, $class);
+    
+    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    push(@{$hashArgOptLists->{"OptList"}},$options);
+
+    # load up the options and args for the supporting plugins
+    new AcronymExtractor($pluginlist, $inputargs, $hashArgOptLists);
+    new KeyphraseExtractor($pluginlist, $inputargs, $hashArgOptLists);
+    new EmailAddressExtractor($pluginlist, $inputargs, $hashArgOptLists);
+    new DateExtractor($pluginlist, $inputargs, $hashArgOptLists);
+    new GISExtractor($pluginlist, $inputargs, $hashArgOptLists);
+ 
+    my $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists);
+
+    return bless $self, $class;
+    
+}
+
+sub begin {
+    my $self = shift (@_);
+    my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
+
+    #initialise those extractors that need initialisation
+    $self->initialise_acronym_extractor();
+}
+
+sub end {
+    # potentially called at the end of each plugin pass 
+    # import.pl only has one plugin pass, but buildcol.pl has multiple ones
+
+    my ($self) = @_;
+    # finalise those extractors that need finalisation
+    $self->finalise_acronym_extractor();
+}
+
+# here is where we call methods from the supporting plugins - gis and textextract
+sub auto_extract_metadata {
+    my $self = shift(@_);
+    my ($doc_obj) = @_;
+
+    $self->extract_acronym_metadata($doc_obj);
+    $self->extract_keyphrase_metadata($doc_obj);
+    $self->extract_email_metadata($doc_obj);
+    $self->extract_date_metadata($doc_obj);
+    $self->extract_gis_metadata($doc_obj);
+
+}
+
+sub clean_up_after_doc_obj_processing {
+    my $self = shift(@_);
+
+    $self->SUPER::clean_up_after_doc_obj_processing();
+    $self->GISExtractor::clean_up_temp_files();
+}
+
+1;
