source: gsdl/trunk/perllib/classify/AllList.pm@ 18455

Last change on this file since 18455 was 18455, checked in by davidb, 15 years ago

Addition of 'edit_mode' parameter to classify(). This can be either 'add' 'delete' or 'reindex' (should think about renaming the last one to something more appropriate, e.g. update).

  • Property svn:keywords set to Author Date Id Revision
File size: 3.0 KB
Line 
1###########################################################################
2#
3# AllList.pm -- Creates a single list of all documents. Use by the oaiserver.
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) 2005 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 AllList;
27
28use BaseClassifier;
29
30use strict;
31no strict 'refs'; # allow filehandles to be variables and viceversa
32
33sub BEGIN {
34 @AllList::ISA = ('BaseClassifier');
35}
36
37my $arguments =
38 [
39 ];
40
41my $options = { 'name' => "AllList",
42 'desc' => "{AllList.desc}",
43 'abstract' => "yes", # hide from gli
44 'inherits' => "yes" };
45
46sub new {
47 my ($class) = shift (@_);
48 my ($classifierslist,$inputargs,$hashArgOptLists) = @_;
49 push(@$classifierslist, $class);
50
51 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
52 push(@{$hashArgOptLists->{"OptList"}},$options);
53
54 my $self = new BaseClassifier($classifierslist, $inputargs, $hashArgOptLists);
55
56 if ($self->{'info_only'}) {
57 # don't worry about any options etc
58 return bless $self, $class;
59 }
60
61 # Manually set $self parameters.
62 $self->{'list'} = [];
63 $self->{'buttonname'} = "All Documents";
64
65 return bless $self, $class;
66}
67
68sub init {
69 my $self = shift (@_);
70}
71
72sub classify {
73 my $self = shift (@_);
74 my ($doc_obj, $edit_mode) = @_;
75
76 my $doc_OID = $doc_obj->get_OID();
77
78 if ($edit_mode eq "delete") {
79 $self->oid_array_delete($doc_OID,'list');
80 }
81 else {
82 push (@{$self->{'list'}}, $doc_OID);
83 }
84
85 return;
86}
87
88sub get_classify_info {
89 my $self = shift(@_);
90 my ($no_thistype) = @_;
91
92 my %classifyinfo = ('childtype' =>'VList',
93 'Title' =>$self->{'buttonname'},
94 'contains' =>[],
95 'classifyOID' =>"oai");
96 $classifyinfo{'thistype'} = 'Invisible';
97 my @list = @{$self->{'list'}};
98
99 my $seqNo = 0;
100 foreach my $OID (@list) {
101 my $hashref={};
102 $hashref->{'OID'}=$OID;
103
104 my %tempinfo=('childtype'=>'VList',
105 'Title'=>$self->{'buttonname'},
106 'classifyOID' =>"oai.$seqNo",
107 'contains' =>[]);
108
109 push (@{$tempinfo{'contains'}}, $hashref);
110
111 push (@{$classifyinfo{'contains'}}, \%tempinfo);
112 $seqNo ++;
113 }
114
115 return \%classifyinfo;
116}
Note: See TracBrowser for help on using the repository browser.