1 | ###########################################################################
|
---|
2 | #
|
---|
3 | # NPDateList.pm -- classifier plugin for sorting by date
|
---|
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 |
|
---|
26 | # overridden for niupepa as we don't want to include abstracts directly in lists
|
---|
27 |
|
---|
28 | package NPDateList;
|
---|
29 |
|
---|
30 | use DateList;
|
---|
31 |
|
---|
32 | use strict;
|
---|
33 | no strict 'refs'; # allow filehandles to be variables and viceversa
|
---|
34 |
|
---|
35 | sub BEGIN {
|
---|
36 | @NPDateList::ISA = ('DateList');
|
---|
37 | }
|
---|
38 |
|
---|
39 | my $arguments;
|
---|
40 |
|
---|
41 | my $options = { 'name' => "NPDateList",
|
---|
42 | 'desc' => "Niupepa specific DateList",
|
---|
43 | 'abstract' => "no",
|
---|
44 | 'inherits' => "yes" };
|
---|
45 |
|
---|
46 | sub new {
|
---|
47 | my ($class) = shift (@_);
|
---|
48 | my ($classifierslist,$inputargs,$hashArgOptLists) = @_;
|
---|
49 | push(@$classifierslist, $class);
|
---|
50 |
|
---|
51 | if(defined $arguments){ push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});}
|
---|
52 | if(defined $options) { push(@{$hashArgOptLists->{"OptList"}},$options)};
|
---|
53 |
|
---|
54 | my $self = new DateList($classifierslist, $inputargs, $hashArgOptLists);
|
---|
55 |
|
---|
56 | return bless $self, $class;
|
---|
57 | }
|
---|
58 |
|
---|
59 | sub classify {
|
---|
60 | my $self = shift (@_);
|
---|
61 | my ($doc_obj) = @_;
|
---|
62 |
|
---|
63 | # want to ignore abstracts
|
---|
64 | my $doctype = $doc_obj->get_metadata_element($doc_obj->get_top_section(), 'doctype');
|
---|
65 | return if (defined $doctype && $doctype eq 'Description');
|
---|
66 |
|
---|
67 | my $doc_OID = $doc_obj->get_OID();
|
---|
68 | my $date = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), 'Date');
|
---|
69 |
|
---|
70 | # if this document doesn't contain Date element we won't
|
---|
71 | # include it in this classification
|
---|
72 | if (defined $date && $date =~ /\d/) {
|
---|
73 | if (defined $self->{'list'}->{$doc_OID}) {
|
---|
74 | print STDERR "WARNING: DateList::classify called multiple times for $doc_OID\n";
|
---|
75 | }
|
---|
76 | $self->{'list'}->{$doc_OID} = $date;
|
---|
77 | }
|
---|
78 | }
|
---|
79 |
|
---|
80 | 1;
|
---|