source: main/trunk/model-cols/niupepa/perllib/plugins/AbstractPlugin.pm@ 26201

Last change on this file since 26201 was 26201, checked in by kjdon, 12 years ago

a small subset of niupepa plus all the config files for building and development of the collection

File size: 2.1 KB
Line 
1package AbstractPlugin;
2
3use ReadTextFile;
4use niupepautil;
5use doc;
6
7use strict;
8no strict 'refs'; # allow filehandles to be variables and viceversa
9no strict 'subs';
10
11sub BEGIN {
12 @AbstractPlugin::ISA = ('ReadTextFile');
13}
14
15my $arguments =
16 [
17 { 'name' => "process_exp",
18 'desc' => "{BasePlugin.process_exp}",
19 'type' => "regexp",
20 'deft' => &get_default_process_exp(),
21 'reqd' => "no" } ,
22
23 ];
24
25my $options = { 'name' => "AbstractPlugin",
26 'desc' => "Simple plugin for processing abstracts in niupepa collection",
27 'abstract' => "no",
28 'inherits' => "yes",
29 'args' => $arguments };
30
31sub new {
32 my ($class) = shift (@_);
33 my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
34 push(@$pluginlist, $class);
35
36 push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
37 push(@{$hashArgOptLists->{"OptList"}},$options);
38
39 my $self = new ReadTextFile($pluginlist, $inputargs, $hashArgOptLists);
40
41 return bless $self, $class;
42}
43
44sub get_default_process_exp {
45 my $self = shift (@_);
46
47 return q^(?i)\.abstract$^;
48}
49
50# do plugin specific processing of doc_obj
51sub process {
52 my $self = shift (@_);
53 my ($textref, $pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
54 my $outhandle = $self->{'outhandle'};
55
56 my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
57 # filename is like 01_1_1.abstract, OID is 01_1_1abstract
58 my $OID = $filename_no_path;
59 $OID =~ s/\.//;
60 $doc_obj->set_OID ($OID);
61 print STDERR "set oid $OID\n";
62 my ($full_dir) = $filename_full_path =~ /^(.*?)([^\/\\]*)$/;
63 # set metadata from meta.txt
64 &niupepautil::set_main_metadata($doc_obj, $full_dir, $self->{'verbosity'});
65
66 my $cursection = $doc_obj->get_top_section();
67 #$doc_obj->set_utf8_metadata_element ($cursection, "doctype", "Description");
68
69 my $paper_id = $OID;
70 $paper_id =~ s/abstract//;
71 $doc_obj->set_utf8_metadata_element ($cursection, 'Title', &niupepautil::get_title_string($paper_id));
72
73 # just add the html text as is to the section
74
75 $doc_obj->add_utf8_text($cursection, $$textref);
76
77 return 1;
78}
79
801;
81
Note: See TracBrowser for help on using the repository browser.