Changeset 36373


Ignore:
Timestamp:
2022-08-16T19:45:27+12:00 (6 weeks ago)
Author:
kjdon
Message:

now I have removed commented out code from last commit

Location:
main/trunk/greenstone2/perllib
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • main/trunk/greenstone2/perllib/extrametautil.pm

    r36372 r36373  
    100100}
    101101
    102 #----------------------------------------------
    103 #### unused below here
    104 
    105 # Unused. Added for symmetry
    106 sub addmetadata_UNUSED {
    107     my ($extrametadata, $filename_re_for_metadata, $value) = @_;   
    108     my $metanames = $extrametadata->{$filename_re_for_metadata};
    109     push(@$metanames, $value);
    110 }
    111 
    112 # Unused. Added for symmetry
    113 sub addmetafile_UNUSED {
    114     my ($extrametafile, $filename_re_for_metadata, $file) = @_;
    115     my $metafiles = $extrametafile->{$filename_re_for_metadata};
    116     push(@$metafiles, $file);
    117 }
    118 
    119 sub addmetadata_for_named_metaname_OLD { # e.g. push(@{$extrametadata->{$filename_re_for_metadata}->{$field_name}}, $value);
    120     my ($extrametadata, $filename_re_for_metadata, $field_name, $value) = @_;
    121     my $metaname_vals = $extrametadata->{$filename_re_for_metadata}->{$field_name};
    122     push(@$metaname_vals, $value);
    123 }
    124 
    125 # Unused. Added for symmetry
    126 sub addmetafile_for_named_file_UNUSED {
    127     my ($extrametafile, $filename_re_for_metadata, $file, $filename_full_path) = @_;
    128     my $metafile_vals = $extrametafile->{$filename_re_for_metadata}->{$file};
    129     push(@$metafile_vals, $filename_full_path);
    130 }
    131 
    132 
    133 #**************** In future, may be useful to expand this utility file
    134 #**************** by having remove methods to mirror the add methods
    135 
    136 
    137 #******************* GET methods
    138 
    139 
    140 sub getmetadata_for_named_metaname_OLD {
    141     my ($extrametadata, $filename_re_for_metadata, $field_name) = @_;
    142     return $extrametadata->{$filename_re_for_metadata}->{$field_name}; # e.g. $extrametadata->{$filename_re_for_metadata}->{$field_name}
    143 }
    144 
    145 # Unused. Added for symmetry
    146 sub getmetafile_for_named_file_UNUSED {
    147     my ($extrametafile, $filename_re_for_metadata, $file) = @_;
    148     return $extrametafile->{$filename_re_for_metadata}->{$file};
    149 }
    150 
    151 
    152 
    153 #******************* SET methods
    154 
    155 # set an individual name-value pair in the metadata hash for a particular file
    156 sub setmetadata_for_named_metaname_OLD {
    157     my ($extrametadata, $filename_re_for_metadata, $field_name, $value) = @_;
    158     $extrametadata->{$filename_re_for_metadata}->{$field_name} = $value;
    159 }
    160 sub setmetafile_UNUSED { # e.g. $extrametafile{$filename_re_for_metadata} = $file;
    161     my ($extrametafile, $filename_re_for_metadata, $file, $filename_full_path) = @_;
    162     $extrametafile->{$filename_re_for_metadata} = $file;
    163 }
    164 
    165 sub setmetafile_for_named_file_OLD {
    166     my ($extrametafile, $filename_re_for_metadata, $file, $filename_full_path) = @_;
    167     $extrametafile->{$filename_re_for_metadata}->{$file} = $filename_full_path;
    168 }
    169 
    170 # Unused. Added for symmetry
    171 sub setmetadata_for_named_pos_UNUSED {
    172     my ($extrametadata, $filename_re_for_metadata, $metaname, $index, $value) = @_;
    173     $extrametadata->{$filename_re_for_metadata}->{$metaname}->[$index] =  $value;
    174 }
    175102
    176103
  • main/trunk/greenstone2/perllib/plugins/EmbeddedMetadataPlugin.pm

    r36372 r36373  
    3030use BaseImporter;
    3131use MetadataRead;
    32 use extrametautil;
    3332use util;
    3433
     
    437436    }
    438437
    439     # Indexing into the extrameta data structures requires the filename's style of slashes to be in URL format
    440     # Then need to convert the filename to a regex, no longer to protect windows directory chars \, but for
    441     # protecting special characters like brackets in the filepath such as "C:\Program Files (x86)\Greenstone".
    442     #print STDERR "file = $file " . &unicode::debug_unicode_string($file);
     438   #print STDERR "file = $file " . &unicode::debug_unicode_string($file);
    443439    $file = &util::raw_filename_to_unicode(&util::filename_head($filename), $file);
    444440
    445441    $self->store_meta_in_extrametadata($file, $exif_metadata, undef, undef, $extrametakeys, $extrametadata, $extrametafile);
    446442
    447     if (0) {
    448     #print STDERR "$file ". &unicode::debug_unicode_string($file);
    449     $file = &util::filepath_to_url_format($file);
    450     #print STDERR "$file " . &unicode::debug_unicode_string($file);
    451     $file = &util::filename_to_regex($file);
    452     #print STDERR "$file ".&unicode::debug_unicode_string($file) ."\n";
    453    
    454     # Associate the metadata now
    455 
    456     if (defined &extrametautil::getmetadata($extrametadata, $file)) {
    457     print STDERR "\n****  EmbeddedMetadataPlugin: Need to merge new metadata with existing stored metadata: file = $file\n" if $verbosity > 3;
    458 
    459     my $file_metadata_table = &extrametautil::getmetadata($extrametadata, $file);
    460 
    461     foreach my $metaname (keys %exif_metadata) {
    462         # will create new entry if one does not already exist
    463         push(@{$file_metadata_table->{$metaname}}, @{$exif_metadata{$metaname}});       
    464     }
    465 
    466     # no need to push $file on to $extrametakeys as it is already in the list
    467     }
    468     else {
    469     &extrametautil::setmetadata($extrametadata, $file, \%exif_metadata);
    470     &extrametautil::addmetakey($extrametakeys, $file);
    471     }
    472     }
     443
    473444}
    474445
  • main/trunk/greenstone2/perllib/plugins/LOMPlugin.pm

    r36372 r36373  
    3232package LOMPlugin;
    3333
    34 use extrametautil;
    3534use ReadTextFile;
    3635use MetadataPass;
     
    177176    }
    178177    $self->{'lom_srcdoc'} = undef; # reset for next file to be processed
    179     # Indexing into the extrameta data structures requires the filename's style of slashes to be in URL format
    180     # Then need to convert the filename to a regex, no longer to protect windows directory chars \, but for
    181     # protecting special characters like brackets in the filepath such as "C:\Program Files (x86)\Greenstone".
    182     if (0) {
    183     $file_re = &util::filepath_to_url_format($file_re);
    184     $file_re = &util::filename_to_regex($file_re);
    185     $self->{'lom_srcdoc'} = undef; # reset for next file to be processed
    186 
    187     &extrametautil::addmetakey($extrametakeys, $file_re);
    188     &extrametautil::setmetadata($extrametadata, $file_re, $self->{'saved_metadata'});
    189     if (defined $lom_srcdoc) {
    190     # copied from oaiplugin
    191     if (!defined &extrametautil::getmetafile($extrametafile, $file_re)) {
    192         &extrametautil::setmetafile($extrametafile, $file_re, {});
    193     }
    194      #maps the file to full path
    195     &extrametautil::setmetafile_for_named_file($extrametafile, $file_re, $file, $filename_full_path);
    196     }
    197     }
     178
    198179    return 1;
    199180}
  • main/trunk/greenstone2/perllib/plugins/MetadataCSVPlugin.pm

    r36372 r36373  
    3535no strict 'refs';
    3636
    37 use extrametautil;
    3837use multiread;
    3938use util;
     
    271270    # Associate the metadata now
    272271    $self->store_meta_in_extrametadata($csv_line_filename, \%csv_line_metadata, $file, $filename_full_path, $extrametakeys, $extrametadata, $extrametafile);
    273     # Indexing into the extrameta data structures requires the filename's style of slashes to be in URL format
    274     # Then need to convert the filename to a regex, no longer to protect windows directory chars \, but for
    275     # protecting special characters like brackets in the filepath such as "C:\Program Files (x86)\Greenstone".
    276 
    277     if (0) {
    278     $csv_line_filename = &util::filepath_to_url_format($csv_line_filename);
    279     $csv_line_filename = &util::filename_to_regex($csv_line_filename);
    280 
    281     if (defined &extrametautil::getmetadata($extrametadata, $csv_line_filename)) { # merge with existing meta   
    282 
    283         my $file_metadata_table = &extrametautil::getmetadata($extrametadata, $csv_line_filename);
    284        
    285         foreach my $metaname (keys %csv_line_metadata) {
    286         # will create new entry if one does not already exist
    287         push(@{$file_metadata_table->{$metaname}}, @{$csv_line_metadata{$metaname}});       
    288         }
    289        
    290         # no need to push $file on to $extrametakeys as it is already in the list
    291     } else { # add as new meta
    292        
    293         &extrametautil::setmetadata($extrametadata, $csv_line_filename, \%csv_line_metadata);
    294         &extrametautil::addmetakey($extrametakeys, $csv_line_filename);
    295     }
    296     # record which file the metadata came from
    297     if (!defined &extrametautil::getmetafile($extrametafile, $csv_line_filename)) {
    298         &extrametautil::setmetafile($extrametafile, $csv_line_filename, {});
    299     }
    300     # maps the file to full path
    301     &extrametautil::setmetafile_for_named_file($extrametafile, $csv_line_filename, $file, $filename_full_path);
    302     }
    303     }
     272
    304273}
    305274
  • main/trunk/greenstone2/perllib/plugins/MetadataRead.pm

    r36372 r36373  
    111111    }
    112112
    113     #if ($srcdoc_exists) { 
    114 #   if (!defined &extrametautil::getmetafile($extrametafile, $filename_for_metadata)) {
    115 #       &extrametautil::setmetafile($extrametafile, $filename_for_metadata, {});
    116 #   }
    117113     if (defined $file && defined $filename_for_metadata) {
    118114     #maps the file to full path
  • main/trunk/greenstone2/perllib/plugins/MetadataXMLPlugin.pm

    r36372 r36373  
    369369        my $filename = $self->{'metadata-filename'};
    370370
    371 #       if (!defined &extrametautil::getmetafile($self->{'metafileref'}, $target)) {
    372 #           &extrametautil::setmetafile($self->{'metafileref'}, $target, {});
    373 #       }
    374 
    375 #       &extrametautil::setmetafile_for_named_file($self->{'metafileref'}, $target, $file, $filename);
    376371        &extrametautil::addmetafile($self->{'metafileref'}, $target, $file, $filename);
    377372    }
  • main/trunk/greenstone2/perllib/plugins/OAIMetadataXMLPlugin.pm

    r36372 r36373  
    126126  {
    127127    # Don't harvest file sets that don't have dc.Identifier set, "dc.Identifier" is usde as the key between Greenstone and OAI Server!
    128     #my $dc_identifier = &extrametautil::getmetadata_for_named_pos($extrametadata, $one_file, "dc.Identifier", 0);
    129128      my $dc_identifier = &extrametautil::getmetadatum_by_index($extrametadata, $one_file, "dc.Identifier", 0);
    130129    next if (!defined($dc_identifier) || $dc_identifier eq "");
     
    200199      }   
    201200     
    202       #&extrametautil::setmetadata_for_named_metaname($extrametadata, $one_file, $field_name, []) if (!defined (&extrametautil::getmetadata_for_named_metaname($extrametadata, $one_file, $field_name)));
    203       #&extrametautil::addmetadata_for_named_metaname($extrametadata, $one_file, $field_name, $value);
    204201      &extrametautil::addmetadatum($extrametadata, $one_file, $field_name, $value);
    205202    }
  • main/trunk/greenstone2/perllib/plugins/OAIPlugin.pm

    r36372 r36373  
    3030#use Devel::Peek;
    3131use Encode;
    32 use extrametautil;
    3332use unicode;
    3433use util;
     
    271270    $self->store_meta_in_extrametadata($filename_for_metadata, $new_metadata, undef, undef, $extrametakeys, $extrametadata, $extrametafile);
    272271    }
    273     # Extrametadata keys should be regular expressions
    274     # Indexing into the extrameta data structures requires the filename's style of slashes to be in URL format
    275     # Then need to convert the filename to a regex, no longer to protect windows directory chars \, but for
    276     # protecting special characters like brackets in the filepath such as "C:\Program Files (x86)\Greenstone".
    277 
    278     if (0) {
    279     $filename_for_metadata = &util::filepath_to_url_format($filename_for_metadata);
    280     $filename_for_metadata = &util::filename_to_regex($filename_for_metadata);
    281 
    282     # Check that we haven't already got some metadata
    283     if (defined &extrametautil::getmetadata($extrametadata, $filename_for_metadata)) {
    284     print STDERR "\n****  OAIPlugin: Need to merge new metadata with existing stored metadata: file = $filename_for_metadata\n" if $verbosity > 3;
    285 
    286     my $file_metadata_table = &extrametautil::getmetadata($extrametadata, $filename_for_metadata);
    287 
    288     foreach my $metaname (keys %{$new_metadata}) {
    289         # will create new entry if one does not already exist
    290         push(@{$file_metadata_table->{$metaname}}, @{$new_metadata->{$metaname}});     
    291     }
    292 
    293     } else {
    294     &extrametautil::setmetadata($extrametadata, $filename_for_metadata, $new_metadata);
    295     &extrametautil::addmetakey($extrametakeys, $filename_for_metadata);
    296     }
    297 
    298     if ($srcdoc_exists) {   
    299 #   if (!defined &extrametautil::getmetafile($extrametafile, $filename_for_metadata)) {
    300 #       &extrametautil::setmetafile($extrametafile, $filename_for_metadata, {});
    301 #   }
    302      #maps the file to full path
    303 #   &extrametautil::setmetafile_for_named_file($extrametafile, $filename_for_metadata, $file, $filename_full_path);
    304     &extrametautil::addmetafile($extrametafile, $filename_for_metadata, $file, $filename_full_path);
    305    
    306     }
    307     } # if 0
    308272
    309273    return 1;
Note: See TracChangeset for help on using the changeset viewer.