Changeset 17026 for gsdl/trunk/perllib/plugins/BasePlugin.pm
- Timestamp:
- 2008-08-27T20:40:20+12:00 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
gsdl/trunk/perllib/plugins/BasePlugin.pm
r16997 r17026 79 79 80 80 our $oidtype_list = 81 [ { 'name' => "hash", 81 [ { 'name' => "auto", 82 'desc' => "{BasePlugin.OIDtype.auto}" }, 83 { 'name' => "hash", 82 84 'desc' => "{import.OIDtype.hash}" }, 83 85 { 'name' => "assigned", … … 116 118 'list' => $oidtype_list, 117 119 # leave default empty so we can tell if its been set or not - if not set will use option from import.pl 118 #'deft' => "hash",120 'deft' => "auto", 119 121 'reqd' => "no", 120 122 'modegli' => "2" }, … … 282 284 my ($pluginfo, $base_dir, $processor, $maxdocs) = @_; 283 285 286 if ($self->{'OIDtype'} eq "auto") { 287 # hasn't been set in the plugin, use the processor values 288 $self->{'OIDtype'} = $processor->{'OIDtype'}; 289 $self->{'OIDmetadata'} = $processor->{'OIDmetadata'}; 290 } 291 if ($self->{'OIDtype'} eq "hash") { 292 # should we hash on the file or on the doc xml?? 293 $self->{'OIDtype'} = $self->get_oid_hash_type(); 294 if ($self->{'OIDtype'} !~ /^(hash_on_file|hash_on_ga_xml)$/) { 295 $self->{'OIDtype'} = "hash_on_file"; 296 } 297 } 284 298 } 285 299 … … 295 309 296 310 my ($self) = @_; 311 } 312 313 # default hashing type is to hash on the original file (or converted file) 314 # override this to return hash_on_ga_xml for filetypes where hashing on the 315 # file is no good eg video 316 sub get_oid_hash_type { 317 318 my $self = shift (@_); 319 320 return "hash_on_file"; 297 321 } 298 322 … … 715 739 my ($doc_obj, $filename_no_path, $file_encoding) = @_; 716 740 741 717 742 my $top_section = $doc_obj->get_top_section(); 718 743 … … 729 754 $doc_obj->set_utf8_metadata_element($top_section, "SourceFile", $filemeta); 730 755 } 731 756 757 # this should be called by all plugins to set the oid of the doc obj, rather 758 # than calling doc_obj->set_OID directly 732 759 sub add_OID { 733 760 my $self = shift (@_); 734 761 my ($doc_obj) = @_; 735 762 736 # See if a metadata field is specified as the field 737 if ((defined $self->{'use_as_doc_identifier'}) && ($self->{'use_as_doc_identifier'} ne "")) { 738 my $metadata_doc_id = $self->{'use_as_doc_identifier'}; 739 740 # Consider "tidying" up metadata_doc_id to be something 741 # suitable in a URL 742 # Could even support a user specified plugin RE for this. 743 744 my $top_section = $doc_obj->get_top_section(); 745 my $oid = $doc_obj->get_metadata_element($top_section,$metadata_doc_id); 746 $doc_obj->set_OID($oid); 747 } 748 # See if there is a plugin-specific set_OID function... 749 elsif (defined ($self->can('set_OID'))) { 750 # it will need $doc_obj to set the Identifier metadata... 751 $self->set_OID(@_); # pass through any extra arguments supplied 752 } else { 763 $doc_obj->set_OIDtype($self->{'OIDtype'}, $self->{'OIDmetadata'}); 764 765 # see if there is a plugin specific set_OID function 766 if (defined ($self->can('set_OID'))) { 767 $self->set_OID(@_); # pass through doc_obj and any extra arguments 768 } 769 else { 753 770 # use the default set_OID() in doc.pm 754 771 $doc_obj->set_OID(); 755 772 } 756 } 757 758 759 773 774 } 775 760 776 # The BasePlugin read_into_doc_obj() function. This function does all the 761 777 # right things to make general options work for a given plugin. It doesn't do anything with the file other than setting reads in … … 791 807 my $top_section = $doc_obj->get_top_section(); 792 808 793 # this should look at the plugin option too...794 $doc_obj->set_OIDtype ($processor->{'OIDtype'}, $processor->{'OIDmetadata'});795 809 $doc_obj->add_utf8_metadata($top_section, "Plugin", "$self->{'plugin_type'}"); 796 810 $doc_obj->add_utf8_metadata($top_section, "FileSize", (-s $filename_full_path));
Note:
See TracChangeset
for help on using the changeset viewer.