Ignore:
Timestamp:
2008-08-27T20:40:20+12:00 (16 years ago)
Author:
kjdon
Message:

OID generation modifications: OIDtype and OIDmetadata options now available for plugins as well as import. OIDtype for plugins defaults to auto - if set to auto, then use the values from import. All plugins now call self->add_OID instead of doc_obj->set_OID. This sets the doc_obj OIDtype so that doesn't need to be donein other places any more. all plugins have the get_oid_hash_type method - normally returns hash_on_file, but can be overridden to return hash_on_ga_xml for those plugins that don't want hashing on file (MP3,OggVorbis...)

File:
1 edited

Legend:

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

    r16700 r17026  
    234234    # create a new document
    235235    my $doc_obj = new doc ($filename_full_path, "indexed_doc");
    236     $doc_obj->set_OIDtype ($processor->{'OIDtype'}, $processor->{'OIDmetadata'});
    237236    $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Language", $language);
    238237    $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Encoding", $encoding);
     
    248247    # Calculate a "base" document ID.
    249248    if (!defined $id) {
    250         $doc_obj->set_OID();
    251         $id = $doc_obj->get_OID();
     249        $id = $self->get_base_OID($doc_obj);
    252250    }
    253251   
     
    274272
    275273    # add an OID
    276     $self->set_OID($doc_obj, $id, $segment);
     274    $self->add_OID($doc_obj, $id, $segment);
    277275
    278276    # process the document
     
    288286}
    289287
    290 sub set_OID {
     288sub get_base_OID {
     289    my $self = shift(@_);
     290    my ($doc_obj) = @_;
     291
     292    $self->SUPER::add_OID($doc_obj);
     293    return $doc_obj->get_OID();
     294}
     295
     296sub add_OID {
    291297    my $self = shift (@_);
    292     my ($doc_obj, $id, $segment_number) = @_;
    293    
    294     $doc_obj->set_OID($id . "s" . $segment_number);
    295 }
     298    my ($doc_obj, $id, $segment) = @_;
     299
     300    my $full_id = $id . "s" . $segment;
     301    if ($self->{'OIDtype'} eq "assigned") {
     302    my $identifier = $doc_obj->get_metadata_element ($doc_obj->get_top_section(), $self->{'OIDmetadata'});
     303    if (defined $identifier && $identifier ne "") {
     304        $full_id = $identifier;
     305        $full_id =~ s/\.//; #remove any periods
     306        if ($full_id =~ /^[\d]*$/) {
     307        $full_id = "D" . $full_id;
     308        print STDERR "OID only contains numbers, adding a D\n";
     309        }
     310    }
     311    }
     312    $doc_obj->set_OID($full_id);
     313}
     314
    296315
    2973161;
Note: See TracChangeset for help on using the changeset viewer.