- Timestamp:
- 2018-11-30T22:02:15+13:00 (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
main/trunk/greenstone2/perllib/plugins/GreenstoneSQLPlugin.pm
r32640 r32643 373 373 374 374 print STDERR " GreenstoneSQLPlugin processing doc $oid (reading into docobj from SQL db)\n" 375 if $self->{'verbosity'}; 375 if $self->{'verbosity'}; 376 377 my $build_proc_mode = $self->{'processor'}->get_mode(); # can be "text" as per basebuildproc or infodb 378 if($build_proc_mode =~ m/(delete)$/) { 379 # build_proc_mode could be "(infodb|text)(delete|reindex)" 380 # "...delete" or "...reindex" as per ArchivesInfPlugin 381 # But reindex is implemented as delete for GreenstoneSQLPlugs, so that's all we see here? 382 print STDERR " DOC $oid WAS MARKED FOR DELETION. Won't attempt to retrieve from SQL db.\n" if $self->{'verbosity'}; 383 $self->{'doc_obj'}->set_OID($oid); # oid is all we care about for a doc marked for deletion 384 $self->SUPER::close_document(@_); # at the end of this method, doc will have been deleted 385 return; # oid of doc marked for deletion is not in the SQL db, don't bother looking it up 386 } 387 388 # else, doc denoted by oid was not marked for deletion, look up its oid in db and read it into doc obj 376 389 377 390 if($proc_mode eq "all" || $proc_mode eq "meta_only") { … … 384 397 foreach my $row (@$records) { 385 398 my ($primary_key, $did, $sid, $metaname, $metaval) = @$row; 386 387 # don't allow duplicate toplevel OID, as can happen when a doc has been renamed and requires reindexing388 # TODO: any other meta that should not be duplicated, but can have been changed between rebuilds so that we need to call set_meta instead of add_meta?389 # e.g. FileSize, SourceFile. But Language can be multiple, so gs meta is not guaranteed to be unique either. Whereas of dc metadata we know390 # that some if not all should allow multiple entires for the same meta name, e.g. dc.Author/dc.Creator391 if($sid =~ m@^root@ && $metaname eq "Identifier") {392 # doc_obj's toplevel Identifier metadata is a special case:393 # it should have only one value, so instead of add_meta() that will allow old Identifier meta to linger394 # Need to do set_meta(). We then break out of the loop, to prevent duplicates (older values from DB) to be inserted for Identifier into doc_obj395 # Handles the case where a doc was renamed and rebuilding triggers re-indexing case: old identifier is now overwritten with new one396 $self->{'doc_obj'}->set_OID($oid); # calls doc_obj->set_metadata_element(top_section, Identifier, $oid). Sets OID if one doesn't exist.397 next; # ensures Identifier set only once, and ensure Identifier is set to current docOID for the doc, a.o.t. allowing it to be set to any expired docOID from before a doc got renamed.398 }399 400 # process all other metadata the normal way:401 399 402 400 # get rid of the artificial "root" introduced in section id when saving to sql db … … 450 448 } 451 449 450 451 # setting OID here instead of before reading from SQL db into docobj, will prevent duplicate values for Identifier 452 # since doc::set_OID() calls doc::set_metadata_element() for metadata that can't occur more than once 453 $self->{'doc_obj'}->set_OID($oid); # may only be necessary if doc was marked for deletion so that SUPER::close_document knows 454 # the oid of marked doc to remove from index 455 452 456 # done reading into docobj from SQL db 453 457
Note:
See TracChangeset
for help on using the changeset viewer.