Ignore:
Timestamp:
2006-09-25T14:17:10+12:00 (18 years ago)
Author:
mdewsnip
Message:

Incremental building and dynamic GDBM updating code, many thanks to John Rowe and John Thompson at DL Consulting Ltd.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/gsdl/perllib/plugins/GAPlug.pm

    r12169 r12844  
    7070    $self->{'metadata_value'} = "";
    7171    $self->{'content'} = "";
     72
     73#    # Currently used to store information for previous values controls. In
     74#    # the next contract I'll move to using information directly from Lucene.
     75#    $self->{'sqlfh'} = 0;
    7276   
    7377    return bless $self, $class;
     
    128132    elsif ($element eq "Metadata") {
    129133    $self->{'doc_obj'}->add_utf8_metadata($self->{'section'}, $self->{'metadata_name'},$self->{'metadata_value'});
     134        # Ensure this value is added to the allvalues database in gseditor.
     135        # Note that the database constraints prevent multiple occurances of the
     136        # same key-value pair.
     137        # We write these out to a file, so they can all be commited in one
     138        # transaction
     139        #if (!$self->{'sqlfh'})
     140        #  {
     141        #    my $sql_file = $ENV{'GSDLHOME'} . "/collect/lld/tmp/gseditor.sql";
     142        #    # If the file doesn't already exist, open it and begin a transaction
     143        #    my $sql_fh;
     144        #    if (!-e $sql_file)
     145        #      {
     146        #        open($sql_fh, ">" . $sql_file);
     147        #        print $sql_fh "BEGIN TRANSACTION;\n";
     148        #      }
     149        #    else
     150        #      {
     151        #        open($sql_fh, ">>" . $sql_file);
     152        #      }
     153        #    print STDERR "Opened SQL log\n";
     154        #    $self->{'sqlfh'} = $sql_fh;
     155        #  }
     156
     157        #my $mvalue = $self->{'metadata_value'};
     158        #$mvalue =~ s/\'/\'\'/g;
     159        #$mvalue =~ s/_claimantsep_/ \& /g;
     160
     161        #my $fh = $self->{'sqlfh'};
     162        #if ($fh)
     163        #  {
     164        #    print $fh "INSERT INTO allvalues (mkey, mvalue) VALUES ('" . $self->{'metadata_name'} . "', '" . $mvalue . "');\n";
     165        #  }
     166
     167        # Clean Up
    130168    $self->{'metadata_name'} = "";
    131169    $self->{'metadata_value'} = "";
     
    135173    $self->{'content'} = "";
    136174    }
    137    
    138175    $self->{'element'} = "";
    139176}
     
    161198sub close_document {
    162199    my $self = shift(@_);
    163    
     200
    164201    # add the associated files
    165202    my $assoc_files =
     
    170207
    171208    my $assoc_filepath=shift (@$assoc_filepath_list);
    172     if (defined ($assoc_filepath)) {
    173     # make absolute rather than relative...
    174     $self->{'filename'} =~ m@^(.*[\\/]archives)@;
    175     $assoc_filepath = "$1/$assoc_filepath/";
    176     } else {
     209
     210    #rint STDERR "Filename is: " . $self->{'filename'} . "\n";
     211    #rint STDERR "Initially my assoc_filepath is: $assoc_filepath\n";
     212    #rint STDERR "Custom archive dir is: " . $self->{'base_dir'} . "\n";
     213    # Correct the assoc filepath if one is defined
     214    if (defined ($assoc_filepath))
     215      {
     216        # Check whether the assoc_filepath already includes the base dir
     217        if (index($assoc_filepath, $self->{'base_dir'}) == -1)
     218          {
     219            # And if not, append it so as to make this absolute
     220            $assoc_filepath = &util::filename_cat($self->{'base_dir'}, $assoc_filepath);
     221          }
     222      }
     223    else
     224      {
    177225    $assoc_filepath = $self->{'filename'};
    178226    $assoc_filepath =~ s/[^\\\/]*$//;
    179     }
     227      }
     228    #rint STDERR "Goned and made it absolute: $assoc_filepath\n";
    180229
    181230    foreach my $assoc_file_info (@$assoc_files) {
    182231    my ($assoc_file, $mime_type, $dir) = split (":", $assoc_file_info);
     232        #rint STDERR "assoc_file: $assoc_file\n";
     233        #rint STDERR "mime_type: $mime_type\n";
     234        #rint STDERR "dir: $dir\n";
    183235    my $real_dir = &util::filename_cat($assoc_filepath, $assoc_file),
    184236    my $assoc_dir = (defined $dir && $dir ne "")
    185237        ? &util::filename_cat($dir, $assoc_file) : $assoc_file;
    186238    $self->{'doc_obj'}->associate_file($real_dir, $assoc_dir, $mime_type);
     239        #rint STDERR "According to me the real assoc_filepath is: $real_dir\n";
    187240    }
    188241    $self->{'doc_obj'}->delete_metadata($self->{'doc_obj'}->get_top_section(), "gsdlassocfile");
Note: See TracChangeset for help on using the changeset viewer.