Changeset 15004

Show
Ignore:
Timestamp:
22.02.2008 11:32:38 (11 years ago)
Author:
davidb
Message:

In response to developing a custom plugin that stores metadata similar to MetadataXMLPlug, some functionality was shifted around so the custom plugin could also access it, and a couple of edits made so the two worked properly side by side.

Location:
gsdl/trunk/perllib
Files:
2 modified

Legend:

Unmodified
Added
Removed
  • gsdl/trunk/perllib/metadatautil.pm

    r13492 r15004  
    112112} 
    113113 
     114 
     115sub store_saved_metadata 
     116{ 
     117    my ($plug,$mname,$mvalue,$md_accumulate) = @_; 
     118 
     119    if (defined $plug->{'saved_metadata'}->{$mname}) { 
     120    if ($md_accumulate) { 
     121        # accumulate mode - add value to existing value(s) 
     122        if (ref ($plug->{'saved_metadata'}->{$mname}) eq "ARRAY") { 
     123        push (@{$plug->{'saved_metadata'}->{$mname}}, $mvalue); 
     124        } else { 
     125        $plug->{'saved_metadata'}->{$mname} =  
     126            [$plug->{'saved_metadata'}->{$mname}, $mvalue]; 
     127        } 
     128    } else { 
     129        # override mode 
     130        $plug->{'saved_metadata'}->{$mname} = $mvalue; 
     131    } 
     132    } else { 
     133    if ($md_accumulate) { 
     134        # accumulate mode - add value into (currently empty) array 
     135        $plug->{'saved_metadata'}->{$mname} = [$mvalue]; 
     136    } else { 
     137        # override mode 
     138        $plug->{'saved_metadata'}->{$mname} = $mvalue; 
     139    } 
     140    } 
     141} 
     142 
     143 
    1141441; 
  • gsdl/trunk/perllib/plugins/MetadataXMLPlug.pm

    r14955 r15004  
    235235 
    236236    if ($element eq "FileSet") { 
    237     push (@{$self->{'metakeysref'}}, @{$self->{'saved_targets'}}); 
    238237    foreach my $target (@{$self->{'saved_targets'}}) { 
    239238        my $file_metadata = $self->{'metadataref'}->{$target}; 
     
    241240        if (!defined $file_metadata) { 
    242241        $self->{'metadataref'}->{$target} = $saved_metadata; 
     242 
     243        # not had target before 
     244        push (@{$self->{'metakeysref'}}, $target); 
    243245        } 
    244246        else { 
    245         $self->combine_metadata_structures($file_metadata,$saved_metadata); 
     247        &metadatautil::combine_metadata_structures($file_metadata,$saved_metadata); 
    246248        } 
    247249    } 
     
    251253    } 
    252254    elsif ($element eq "Metadata") { 
    253     $self->store_saved_metadata($self->{'metadata_name'}, $self->{'metadata_value'}, $self->{'metadata_accumulate'}); 
     255    &metadatautil::store_saved_metadata($self,$self->{'metadata_name'}, $self->{'metadata_value'}, $self->{'metadata_accumulate'}); 
    254256    $self->{'metadata_name'} = ""; 
    255257    } 
     
    280282} 
    281283 
    282 sub combine_metadata_structures 
    283 { 
    284     my $self = shift(@_); 
    285  
    286     my ($mdref1, $mdref2) = @_; 
    287     &metadatautil::combine_metadata_structures($mdref1, $mdref2); 
    288 } 
    289  
    290 sub store_saved_metadata 
    291 { 
    292     my $self = shift(@_); 
    293     my ($mname,$mvalue,$md_accumulate) = @_; 
    294  
    295     if (defined $self->{'saved_metadata'}->{$mname}) { 
    296     if ($md_accumulate) { 
    297         # accumulate mode - add value to existing value(s) 
    298         if (ref ($self->{'saved_metadata'}->{$mname}) eq "ARRAY") { 
    299         push (@{$self->{'saved_metadata'}->{$mname}}, $mvalue); 
    300         } else { 
    301         $self->{'saved_metadata'}->{$mname} =  
    302             [$self->{'saved_metadata'}->{$mname}, $mvalue]; 
    303         } 
    304     } else { 
    305         # override mode 
    306         $self->{'saved_metadata'}->{$mname} = $mvalue; 
    307     } 
    308     } else { 
    309     if ($md_accumulate) { 
    310         # accumulate mode - add value into (currently empty) array 
    311         $self->{'saved_metadata'}->{$mname} = [$mvalue]; 
    312     } else { 
    313         # override mode 
    314         $self->{'saved_metadata'}->{$mname} = $mvalue; 
    315     } 
    316     } 
    317 } 
     284#sub combine_metadata_structures 
     285#{ 
     286#    my $self = shift(@_); 
     287# 
     288#    my ($mdref1, $mdref2) = @_; 
     289#    &metadatautil::combine_metadata_structures($mdref1, $mdref2); 
     290#} 
    318291 
    319292