source: main/trunk/greenstone2/perllib/basebuildproc.pm@ 23160

Last change on this file since 23160 was 23160, checked in by kjdon, 13 years ago

member hash renamed, some tidying up

  • Property svn:keywords set to Author Date Id Revision
File size: 21.9 KB
Line 
1##########################################################################
2#
3# basebuildproc.pm --
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# This document processor outputs a document for indexing (should be
27# implemented by subclass) and storing in the database
28
29package basebuildproc;
30
31eval {require bytes};
32
33use classify;
34use dbutil;
35use doc;
36use docproc;
37use strict;
38no strict 'subs';
39no strict 'refs';
40use util;
41
42BEGIN {
43 @basebuildproc::ISA = ('docproc');
44}
45
46sub new()
47 {
48 my ($class, $collection, $source_dir, $build_dir, $keepold, $verbosity, $outhandle) = @_;
49 my $self = new docproc ();
50
51 # outhandle is where all the debugging info goes
52 # output_handle is where the output of the plugins is piped
53 # to (i.e. mg, database etc.)
54 $outhandle = STDERR unless defined $outhandle;
55
56 $self->{'collection'} = $collection;
57 $self->{'source_dir'} = $source_dir;
58 $self->{'build_dir'} = $build_dir;
59 $self->{'keepold'} = $keepold;
60 $self->{'verbosity'} = $verbosity;
61 $self->{'outhandle'} = $outhandle;
62
63 $self->{'classifiers'} = [];
64 $self->{'mode'} = "text";
65 $self->{'assocdir'} = $build_dir;
66 $self->{'dontdb'} = {};
67 $self->{'store_metadata_coverage'} = "false";
68
69 $self->{'index'} = "section:text";
70 $self->{'indexexparr'} = [];
71
72 $self->{'separate_cjk'} = 0;
73
74 my $found_num_data = 0;
75 my $buildconfigfile = undef;
76
77 if ($keepold) {
78 # For incremental building need to seed num_docs etc from values
79 # stored in build.cfg (if present)
80 $buildconfigfile = &util::filename_cat($build_dir, "build.cfg");
81 if (-e $buildconfigfile) {
82 $found_num_data = 1;
83 }
84 else {
85 # try the index dir
86 $buildconfigfile = &util::filename_cat($ENV{'GSDLCOLLECTDIR'},
87 "index", "build.cfg");
88 if (-e $buildconfigfile) {
89 $found_num_data = 1;
90 }
91 }
92
93 }
94
95 if ($found_num_data)
96 {
97 #print STDERR "Found_Num_Data!\n";
98 my $buildcfg = &colcfg::read_build_cfg($buildconfigfile);
99 $self->{'starting_num_docs'} = $buildcfg->{'numdocs'};
100 #print STDERR "- num_docs: $self->{'starting_num_docs'}\n";
101 $self->{'starting_num_sections'} = $buildcfg->{'numsections'};
102 #print STDERR "- num_sections: $self->{'starting_num_sections'}\n";
103 $self->{'starting_num_bytes'} = $buildcfg->{'numbytes'};
104 #print STDERR "- num_bytes: $self->{'starting_num_bytes'}\n";
105 }
106 else
107 {
108 #print STDERR "NOT Found_Num_Data!\n";
109 $self->{'starting_num_docs'} = 0;
110 $self->{'starting_num_sections'} = 0;
111 $self->{'starting_num_bytes'} = 0;
112 }
113
114 $self->{'output_handle'} = "STDOUT";
115 $self->{'num_docs'} = $self->{'starting_num_docs'};
116 $self->{'num_sections'} = $self->{'starting_num_sections'};
117 $self->{'num_bytes'} = $self->{'starting_num_bytes'};
118
119 $self->{'num_processed_bytes'} = 0;
120 $self->{'store_text'} = 1;
121
122 # what level (section/document) the database - indexer intersection is
123 $self->{'db_level'} = "section";
124 #used by browse interface
125 $self->{'doclist'} = [];
126
127 $self->{'indexing_text'} = 0;
128
129 return bless $self, $class;
130
131}
132
133sub reset {
134 my $self = shift (@_);
135
136 $self->{'num_docs'} = $self->{'starting_num_docs'};
137 $self->{'num_sections'} = $self->{'starting_num_sections'};
138 $self->{'num_bytes'} = $self->{'starting_num_bytes'};
139
140 $self->{'num_processed_bytes'} = 0;
141}
142
143sub zero_reset {
144 my $self = shift (@_);
145
146 $self->{'num_docs'} = 0;
147 $self->{'num_sections'} = 0;
148 # reconstructed docs have no text, just metadata, so we need to
149 # remember how many bytes we had initially
150 #$self->{'num_bytes'} = $self->{'starting_num_bytes'};
151 $self->{'num_bytes'} = 0; # we'll store num bytes in db for reconstructed docs.
152 $self->{'num_processed_bytes'} = 0;
153}
154
155sub is_incremental_capable
156{
157 # By default we return 'no' as the answer
158 # Safer to assume non-incremental to start with, and then override in
159 # inherited classes that are.
160
161 return 0;
162}
163
164sub get_num_docs {
165 my $self = shift (@_);
166
167 return $self->{'num_docs'};
168}
169
170sub get_num_sections {
171 my $self = shift (@_);
172
173 return $self->{'num_sections'};
174}
175
176# num_bytes is the actual number of bytes in the collection
177# this is normally the same as what's processed during text compression
178sub get_num_bytes {
179 my $self = shift (@_);
180
181 return $self->{'num_bytes'};
182}
183
184# num_processed_bytes is the number of bytes actually passed
185# to mg for the current index
186sub get_num_processed_bytes {
187 my $self = shift (@_);
188
189 return $self->{'num_processed_bytes'};
190}
191
192sub set_output_handle {
193 my $self = shift (@_);
194 my ($handle) = @_;
195
196 $self->{'output_handle'} = $handle;
197 binmode($handle,":utf8");
198}
199
200
201sub set_mode {
202 my $self = shift (@_);
203 my ($mode) = @_;
204
205 $self->{'mode'} = $mode;
206}
207
208sub get_mode {
209 my $self = shift (@_);
210
211 return $self->{'mode'};
212}
213
214sub set_assocdir {
215 my $self = shift (@_);
216 my ($assocdir) = @_;
217
218 $self->{'assocdir'} = $assocdir;
219}
220
221sub set_dontdb {
222 my $self = shift (@_);
223 my ($dontdb) = @_;
224
225 $self->{'dontdb'} = $dontdb;
226}
227
228sub set_infodbtype
229{
230 my $self = shift(@_);
231 my $infodbtype = shift(@_);
232 $self->{'infodbtype'} = $infodbtype;
233}
234
235sub set_index {
236 my $self = shift (@_);
237 my ($index, $indexexparr) = @_;
238
239 $self->{'index'} = $index;
240 $self->{'indexexparr'} = $indexexparr if defined $indexexparr;
241}
242
243sub set_index_languages {
244 my $self = shift (@_);
245 my ($lang_meta, $langarr) = @_;
246 $lang_meta =~ s/^ex\.//; # strip ex. if there
247 $self->{'lang_meta'} = $lang_meta;
248 $self->{'langarr'} = $langarr;
249}
250
251sub get_index {
252 my $self = shift (@_);
253
254 return $self->{'index'};
255}
256
257sub set_classifiers {
258 my $self = shift (@_);
259 my ($classifiers) = @_;
260
261 $self->{'classifiers'} = $classifiers;
262}
263
264sub set_indexing_text {
265 my $self = shift (@_);
266 my ($indexing_text) = @_;
267
268 $self->{'indexing_text'} = $indexing_text;
269}
270
271sub get_indexing_text {
272 my $self = shift (@_);
273
274 return $self->{'indexing_text'};
275}
276
277sub set_store_text {
278 my $self = shift (@_);
279 my ($store_text) = @_;
280
281 $self->{'store_text'} = $store_text;
282}
283
284sub set_store_metadata_coverage {
285 my $self = shift (@_);
286 my ($store_metadata_coverage) = @_;
287
288 $self->{'store_metadata_coverage'} = $store_metadata_coverage || "";
289}
290
291sub get_doc_list {
292 my $self = shift(@_);
293
294 return @{$self->{'doclist'}};
295}
296
297# the standard database level is section, but you may want to change it to document
298sub set_db_level {
299 my $self= shift (@_);
300 my ($db_level) = @_;
301
302 $self->{'db_level'} = $db_level;
303}
304
305sub set_sections_index_document_metadata {
306 my $self= shift (@_);
307 my ($index_type) = @_;
308
309 $self->{'sections_index_document_metadata'} = $index_type;
310}
311
312sub set_separate_cjk {
313 my $self = shift (@_);
314 my ($sep_cjk) = @_;
315
316 $self->{'separate_cjk'} = $sep_cjk;
317}
318
319sub process {
320 my $self = shift (@_);
321 my $method = $self->{'mode'};
322
323 $self->$method(@_);
324}
325
326# post process text depending on field. Currently don't do anything here
327# except cjk separation, and only for indexing
328# should only do this for indexed text (if $self->{'indexing_text'}),
329# but currently search term highlighting doesn't work if you do that.
330# once thats fixed up, then fix this.
331sub filter_text {
332 my $self = shift (@_);
333 my ($field, $text) = @_;
334
335 # lets do cjk seg here
336 my $new_text =$text;
337 if ($self->{'separate_cjk'}) {
338 $new_text = &cnseg::segment($text);
339 }
340 return $new_text;
341}
342
343
344sub infodb_metadata_stats
345{
346 my $self = shift (@_);
347 my ($field,$edit_mode) = @_;
348
349 # Keep some statistics relating to metadata sets used and
350 # frequency of particular metadata fields within each set
351
352 # Union of metadata prefixes and frequency of fields
353 # (both scoped for this document alone, and across whole collection)
354
355 if ($field =~ m/^(.+)\.(.*)$/) {
356 my $prefix = $1;
357 my $core_field = $2;
358
359 if (($edit_mode eq "add") || ($edit_mode eq "update")) {
360 $self->{'doc_mdprefix_fields'}->{$prefix}->{$core_field}++;
361 $self->{'mdprefix_fields'}->{$prefix}->{$core_field}++;
362 }
363 else {
364 # delete
365 $self->{'doc_mdprefix_fields'}->{$prefix}->{$core_field}--;
366 $self->{'mdprefix_fields'}->{$prefix}->{$core_field}--;
367 }
368
369 }
370 elsif ($field =~ m/^[[:upper:]]/) {
371 # implicit 'ex' metadata set
372
373 if (($edit_mode eq "add") || ($edit_mode eq "update")) {
374
375 $self->{'doc_mdprefix_fields'}->{'ex'}->{$field}++;
376 $self->{'mdprefix_fields'}->{'ex'}->{$field}++;
377 }
378 else {
379 # delete
380 $self->{'doc_mdprefix_fields'}->{'ex'}->{$field}--;
381 $self->{'mdprefix_fields'}->{'ex'}->{$field}--;
382 }
383 }
384
385}
386
387
388sub infodbedit {
389 my $self = shift (@_);
390 my ($doc_obj, $filename, $edit_mode) = @_;
391
392 # only output this document if it is a "indexed_doc" or "info_doc" (database only) document
393 my $doctype = $doc_obj->get_doc_type();
394 return if ($doctype ne "indexed_doc" && $doctype ne "info_doc");
395 print STDERR "infodbedit, mode=$edit_mode, ".$doc_obj->get_OID()."\n";
396 my $archivedir = "";
397 if (defined $filename)
398 {
399 # doc_obj derived directly from file
400 my ($dir) = $filename =~ /^(.*?)(?:\/|\\)[^\/\\]*$/;
401 $dir = "" unless defined $dir;
402 $dir =~ s/\\/\//g;
403 $dir =~ s/^\/+//;
404 $dir =~ s/\/+$//;
405
406 $archivedir = $dir;
407
408 # resolve the final filenames of the files associated with this document
409 $self->assoc_files ($doc_obj, $archivedir);
410 }
411 else
412 {
413 # doc_obj reconstructed from database (has metadata, doc structure but no text)
414 my $top_section = $doc_obj->get_top_section();
415 $archivedir = $doc_obj->get_metadata_element($top_section,"archivedir");
416 }
417
418 if ($edit_mode eq "delete") {
419 # record this doc so we don't process the reconstructed doc later
420 $self->{'dont_process_reconstructed'}->{$doc_obj->get_OID()} = 1;
421 # we don't need to do anything else for the info database for a deleted document. The infodb starts from scratch each time, so no deletion is necessary
422 return;
423 }
424
425 if ($edit_mode eq "update") {
426 # we don't want to process the reconstructed doc later, but we will process this version now.
427 $self->{'dont_process_reconstructed'}->{$doc_obj->get_OID()} = 1;
428 }
429
430 # rest of code used for add and update. In both cases, we add to the classifiers and to the info database.
431
432 #add this document to the browse structure
433 push(@{$self->{'doclist'}},$doc_obj->get_OID())
434 unless ($doctype eq "classification");
435 $self->{'num_docs'} += 1 unless ($doctype eq "classification");
436
437 if (!defined $filename) {
438 # a reconstructed doc
439 my $num_reconstructed_bytes = $doc_obj->get_metadata_element ($doc_obj->get_top_section (), "total_numbytes");
440 if (defined $num_reconstructed_bytes) {
441 print STDERR "adding numbytes $num_reconstructed_bytes\n";
442 $self->{'num_bytes'} += $num_reconstructed_bytes;
443 }
444 }
445 # classify the document
446 &classify::classify_doc ($self->{'classifiers'}, $doc_obj);
447
448 # now add all the sections to the infodb.
449
450 # is this a paged or a hierarchical document
451 my ($thistype, $childtype) = $self->get_document_type ($doc_obj);
452
453 my $section = $doc_obj->get_top_section ();
454 my $doc_OID = $doc_obj->get_OID();
455 my $first = 1;
456 my $infodb_handle = $self->{'output_handle'};
457
458 $self->{'doc_mdprefix_fields'} = {};
459
460 while (defined $section)
461 {
462 my $section_OID = $doc_OID;
463 if ($section ne "")
464 {
465 $section_OID = $doc_OID . "." . $section;
466 }
467 my %section_infodb = ();
468
469 # update a few statistics
470 $self->{'num_bytes'} += $doc_obj->get_text_length ($section);
471 $self->{'num_sections'} += 1 unless ($doctype eq "classification");
472
473 # output the fact that this document is a document (unless doctype
474 # has been set to something else from within a plugin
475 my $dtype = $doc_obj->get_metadata_element ($section, "doctype");
476 if (!defined $dtype || $dtype !~ /\w/) {
477 $section_infodb{"doctype"} = [ "doc" ];
478 }
479
480 if ($first && defined $filename) {
481 # if we are at the top level of the document, and we are not a reconstructed document, set the total_text_length - used to count bytes when we reconstruct later
482 my $length = $doc_obj->get_total_text_length();
483 $section_infodb{"total_numbytes"} = [ $length ];
484 }
485 # Output whether this node contains text
486 #
487 # If doc_obj reconstructed from database file then no need to
488 # explicitly add <hastxt> as this is preserved as metadata when
489 # the database file is loaded in
490 if (defined $filename)
491 {
492 # doc_obj derived directly from file
493 if ($doc_obj->get_text_length($section) > 0) {
494 $section_infodb{"hastxt"} = [ "1" ];
495 } else {
496 $section_infodb{"hastxt"} = [ "0" ];
497 }
498 }
499
500 # output all the section metadata
501 my $metadata = $doc_obj->get_all_metadata ($section);
502 foreach my $pair (@$metadata) {
503 my ($field, $value) = (@$pair);
504
505 if ($field ne "Identifier" && $field !~ /^gsdl/ &&
506 defined $value && $value ne "") {
507
508 # escape problematic stuff
509 $value =~ s/([^\\])\\([^\\])/$1\\\\$2/g;
510 $value =~ s/\n/\\n/g;
511 $value =~ s/\r/\\r/g;
512 # remove ex. if there
513 $field =~ s/^ex\.//;
514
515 # special case for URL metadata
516 if ($field =~ /^URL$/i) {
517 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, $value, { 'section' => [ $section_OID ] });
518 }
519
520 if (!defined $self->{'dontdb'}->{$field}) {
521 push(@{$section_infodb{$field}}, $value);
522
523 if ($section eq "" && $self->{'store_metadata_coverage'} =~ /^true$/i)
524 {
525 $self->infodb_metadata_stats($field,$edit_mode);
526 }
527 }
528 }
529 }
530
531 if ($section eq "")
532 {
533 my $doc_mdprefix_fields = $self->{'doc_mdprefix_fields'};
534
535 foreach my $prefix (keys %$doc_mdprefix_fields)
536 {
537 push(@{$section_infodb{"metadataset"}}, $prefix);
538
539 foreach my $field (keys %{$doc_mdprefix_fields->{$prefix}})
540 {
541 push(@{$section_infodb{"metadatalist-$prefix"}}, $field);
542
543 my $val = $doc_mdprefix_fields->{$prefix}->{$field};
544 push(@{$section_infodb{"metadatafreq-$prefix-$field"}}, $val);
545 }
546 }
547 }
548
549 # If doc_obj reconstructed from database file then no need to
550 # explicitly add <archivedir> as this is preserved as metadata when
551 # the database file is loaded in
552 if (defined $filename)
553 {
554 # output archivedir if at top level
555 if ($section eq $doc_obj->get_top_section()) {
556 $section_infodb{"archivedir"} = [ $archivedir ];
557 }
558 }
559
560 # output document display type
561 if ($first) {
562 $section_infodb{"thistype"} = [ $thistype ];
563 }
564
565 if ($self->{'db_level'} eq "document") {
566 # doc num is num_docs not num_sections
567 # output the matching document number
568 $section_infodb{"docnum"} = [ $self->{'num_docs'} ];
569 }
570 else {
571 # output a list of children
572 my $children = $doc_obj->get_children ($section);
573 if (scalar(@$children) > 0) {
574 $section_infodb{"childtype"} = [ $childtype ];
575 my $contains = "";
576 foreach my $child (@$children)
577 {
578 $contains .= ";" unless ($contains eq "");
579 if ($child =~ /^.*?\.(\d+)$/)
580 {
581 $contains .= "\".$1";
582 }
583 else
584 {
585 $contains .= "\".$child";
586 }
587 }
588 $section_infodb{"contains"} = [ $contains ];
589 }
590 # output the matching doc number
591 $section_infodb{"docnum"} = [ $self->{'num_sections'} ];
592 }
593
594 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, $section_OID, \%section_infodb);
595
596 # output a database entry for the document number, unless we are incremental
597 unless ($self->is_incremental_capable())
598 {
599 if ($self->{'db_level'} eq "document") {
600 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, $self->{'num_docs'}, { 'section' => [ $doc_OID ] });
601 }
602 else {
603 &dbutil::write_infodb_entry($self->{'infodbtype'}, $infodb_handle, $self->{'num_sections'}, { 'section' => [ $section_OID ] });
604 }
605 }
606
607 $first = 0;
608 $section = $doc_obj->get_next_section($section);
609 last if ($self->{'db_level'} eq "document"); # if no sections wanted, only add the docs
610 } # while defined section
611
612}
613
614
615
616
617sub infodb {
618 my $self = shift (@_);
619 my ($doc_obj, $filename) = @_;
620
621 $self->infodbedit($doc_obj,$filename,"add");
622}
623
624sub infodbreindex {
625 my $self = shift (@_);
626 my ($doc_obj, $filename) = @_;
627
628 $self->infodbedit($doc_obj,$filename,"update");
629}
630
631sub infodbdelete {
632 my $self = shift (@_);
633 my ($doc_obj, $filename) = @_;
634
635 $self->infodbedit($doc_obj,$filename,"delete");
636}
637
638
639sub text {
640 my $self = shift (@_);
641 my ($doc_obj) = @_;
642
643 my $handle = $self->{'outhandle'};
644 print $handle "basebuildproc::text function must be implemented in sub classes\n";
645 die "\n";
646}
647
648sub textreindex
649{
650 my $self = shift @_;
651
652 my $outhandle = $self->{'outhandle'};
653 print $outhandle "basebuildproc::textreindex function must be implemented in sub classes\n";
654 if (!$self->is_incremental_capable()) {
655
656 print $outhandle " This operation is only possible with indexing tools with that support\n";
657 print $outhandle " incremental building\n";
658 }
659 die "\n";
660}
661
662sub textdelete
663{
664 my $self = shift @_;
665
666 my $outhandle = $self->{'outhandle'};
667 print $outhandle "basebuildproc::textdelete function must be implemented in sub classes\n";
668 if (!$self->is_incremental_capable()) {
669
670 print $outhandle " This operation is only possible with indexing tools with that support\n";
671 print $outhandle " incremental building\n";
672 }
673 die "\n";
674}
675
676
677# should the document be indexed - according to the subcollection and language
678# specification.
679sub is_subcollection_doc {
680 my $self = shift (@_);
681 my ($doc_obj) = @_;
682
683 my $indexed_doc = 1;
684 foreach my $indexexp (@{$self->{'indexexparr'}}) {
685 $indexed_doc = 0;
686 my ($field, $exp, $options) = split /\//, $indexexp;
687 if (defined ($field) && defined ($exp)) {
688 my ($bool) = $field =~ /^(.)/;
689 $field =~ s/^.// if $bool eq '!';
690 my @metadata_values;
691 if ($field =~ /^filename$/i) {
692 push(@metadata_values, $doc_obj->get_source_filename());
693 }
694 else {
695 $field =~ s/^ex\.//; #strip ex. if present
696 @metadata_values = @{$doc_obj->get_metadata($doc_obj->get_top_section(), $field)};
697 }
698 next unless @metadata_values;
699 foreach my $metadata_value (@metadata_values) {
700 if ($bool eq '!') {
701 if ($options =~ /^i$/i) {
702 if ($metadata_value !~ /$exp/i) {$indexed_doc = 1; last;}
703 } else {
704 if ($metadata_value !~ /$exp/) {$indexed_doc = 1; last;}
705 }
706 } else {
707 if ($options =~ /^i$/i) {
708 if ($metadata_value =~ /$exp/i) {$indexed_doc = 1; last;}
709 } else {
710 if ($metadata_value =~ /$exp/) {$indexed_doc = 1; last;}
711 }
712 }
713 }
714
715 last if ($indexed_doc == 1);
716 }
717 }
718
719 # if this doc is so far in the sub collection, and we have lang info,
720 # now we check the languages to see if it matches
721 if($indexed_doc && defined $self->{'lang_meta'}) {
722 $indexed_doc = 0;
723 my $field = $doc_obj->get_metadata_element($doc_obj->get_top_section(), $self->{'lang_meta'});
724 if (defined $field) {
725 foreach my $lang (@{$self->{'langarr'}}) {
726 my ($bool) = $lang =~ /^(.)/;
727 if ($bool eq '!') {
728 $lang =~ s/^.//;
729 if ($field !~ /$lang/) {
730 $indexed_doc = 1; last;
731 }
732 } else {
733 if ($field =~ /$lang/) {
734 $indexed_doc = 1; last;
735 }
736 }
737 }
738 }
739 }
740 return $indexed_doc;
741
742}
743
744# use 'Paged' if document has no more than 2 levels
745# and each section at second level has a number for
746# Title metadata
747# also use Paged if gsdlthistype metadata is set to Paged
748sub get_document_type {
749 my $self = shift (@_);
750 my ($doc_obj) = @_;
751
752 my $thistype = "VList";
753 my $childtype = "VList";
754 my $title;
755 my @tmp = ();
756
757 my $section = $doc_obj->get_top_section ();
758
759 my $gsdlthistype = $doc_obj->get_metadata_element ($section, "gsdlthistype");
760 if (defined $gsdlthistype) {
761 if ($gsdlthistype eq "Paged") {
762 $childtype = "Paged";
763 if ($doc_obj->get_text_length ($doc_obj->get_top_section())) {
764 $thistype = "Paged";
765 } else {
766 $thistype = "Invisible";
767 }
768
769 return ($thistype, $childtype);
770 } elsif ($gsdlthistype eq "Hierarchy") {
771 return ($thistype, $childtype); # use VList, VList
772 }
773 }
774 my $first = 1;
775 while (defined $section) {
776 @tmp = split /\./, $section;
777 if (scalar(@tmp) > 1) {
778 return ($thistype, $childtype);
779 }
780 if (!$first) {
781 $title = $doc_obj->get_metadata_element ($section, "Title");
782 if (!defined $title || $title !~ /^\d+$/) {
783 return ($thistype, $childtype);
784 }
785 }
786 $first = 0;
787 $section = $doc_obj->get_next_section($section);
788 }
789 if ($doc_obj->get_text_length ($doc_obj->get_top_section())) {
790 $thistype = "Paged";
791 } else {
792 $thistype = "Invisible";
793 }
794 $childtype = "Paged";
795 return ($thistype, $childtype);
796}
797
798sub assoc_files
799{
800 my $self = shift (@_);
801 my ($doc_obj, $archivedir) = @_;
802 my ($afile);
803
804 foreach my $assoc_file (@{$doc_obj->get_assoc_files()}) {
805 #rint STDERR "Processing associated file - copy " . $assoc_file->[0] . " to " . $assoc_file->[1] . "\n";
806 # if assoc file starts with a slash, we put it relative to the assoc
807 # dir, otherwise it is relative to the HASH... directory
808 if ($assoc_file->[1] =~ m@^[/\\]@) {
809 $afile = &util::filename_cat($self->{'assocdir'}, $assoc_file->[1]);
810 } else {
811 $afile = &util::filename_cat($self->{'assocdir'}, $archivedir, $assoc_file->[1]);
812 }
813 &util::hard_link ($assoc_file->[0], $afile, $self->{'verbosity'});
814 }
815}
816
Note: See TracBrowser for help on using the repository browser.