Changeset 2327
- Timestamp:
- 2001-04-20T11:44:50+12:00 (23 years ago)
- Location:
- trunk/gsdl/perllib
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/gsdl/perllib/doc.pm
r2326 r2327 41 41 # classification 42 42 43 my $OIDcount = 0; 44 43 45 sub new { 44 46 my $class = shift (@_); … … 50 52 'subsections'=>{}, 51 53 'metadata'=>[], 52 'text'=>""}, $class; 54 'text'=>"", 55 'OIDtype'=>"hash"}, $class; 53 56 54 57 $self->set_source_filename ($source_filename) if defined $source_filename; … … 93 96 } 94 97 98 sub set_OIDtype { 99 my $self = shift (@_); 100 my ($type) = @_; 101 102 if ($type eq "incremental") { 103 $self->{'OIDtype'} = $type; 104 } else { 105 $self->{'OIDtype'} = "hash"; 106 } 107 } 95 108 96 109 sub set_source_filename { … … 285 298 } 286 299 300 # calculate OID by hashing the contents of the document 287 301 sub _calc_OID { 288 302 my $self = shift (@_); … … 309 323 # methods dealing with OID, not groups of them. 310 324 311 # if $OID is not provided one is calculated from hashing the 312 # current contents of the document 313 # An OID are actually stored as metadata of the document 325 # if $OID is not provided one is calculated 314 326 sub set_OID { 315 327 my $self = shift (@_); 316 328 my ($OID) = @_; 317 329 318 # if an OID wasn't provided then feed this document to 319 # hashfile.exe 330 # if an OID wasn't provided claculate one 320 331 if (!defined $OID) { 321 332 $OID = "NULL"; 322 333 323 my $filename = $self->get_source_filename(); 324 if (defined($filename) && -e $filename) { 325 326 $OID = $self->_calc_OID ($filename); 327 334 if ($self->{'OIDtype'} eq "incremental") { 335 $OID = "D" . $OIDcount; 336 $OIDcount ++; 337 328 338 } else { 329 330 # this warning causes more confusion than it's worth I think 331 # -- sorry Gordon. 332 # print STDERR "doc::set_OID source filename undefined/non-existant (continuing)\n"; 339 # "hash" OID - feed file to hashfile.exe 340 my $filename = $self->get_source_filename(); 341 if (defined($filename) && -e $filename) { 342 343 $OID = $self->_calc_OID ($filename); 344 345 } else { 346 $filename = &util::get_tmp_filename(); 347 if (!open (OUTFILE, ">$filename")) { 348 print STDERR "doc::set_OID could not write to $filename\n"; 349 } else { 350 $self->output_section('OUTFILE', $self->get_top_section(), 351 undef, 1); 352 close (OUTFILE); 353 } 333 354 334 $filename = &util::get_tmp_filename(); 335 if (!open (OUTFILE, ">$filename")) { 336 print STDERR "doc::set_OID could not write to $filename\n"; 337 } else { 338 $self->output_section('OUTFILE', $self->get_top_section(), 339 undef, 1); 340 close (OUTFILE); 355 $OID = $self->_calc_OID ($filename); 356 &util::rm ($filename); 341 357 } 342 343 $OID = $self->_calc_OID ($filename);344 &util::rm ($filename);345 358 } 346 359 } -
trunk/gsdl/perllib/docproc.pm
r537 r2327 33 33 my $self = {}; 34 34 35 $self->{'OIDtype'} = "hash"; 36 35 37 return bless $self, $class; 36 38 } … … 43 45 } 44 46 47 # OIDtype may be "hash" or "incremental" 48 sub set_OIDtype { 49 my $self = shift (@_); 50 my ($type) = @_; 51 52 if ($type eq "incremental") { 53 $self->{'OIDtype'} = $type; 54 } else { 55 $self->{'OIDtype'} = "hash"; 56 } 57 } 58 59 45 60 1; 46 61 -
trunk/gsdl/perllib/plugins/BasPlug.pm
r2235 r2327 285 285 # create a new document 286 286 my $doc_obj = new doc ($filename, "indexed_doc"); 287 $doc_obj->set_OIDtype ($processor->{'OIDtype'}); 287 288 $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Language", $language); 288 289 $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Encoding", $encoding); -
trunk/gsdl/perllib/plugins/ConvertToPlug.pm
r2241 r2327 265 265 # create a new document 266 266 my $doc_obj = new doc ($conv_filename, "indexed_doc"); 267 267 $doc_obj->set_OIDtype ($processor->{'OIDtype'}); 268 268 $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Language", 269 269 $language); -
trunk/gsdl/perllib/plugins/FOXPlug.pm
r537 r2327 229 229 # create a new document 230 230 my $doc_obj = new doc ($file, "indexed_doc"); 231 $doc_obj->set_OIDtype ($processor->{'OIDtype'}); 231 232 my $section = $doc_obj->get_top_section(); 232 233 -
trunk/gsdl/perllib/plugins/HBPlug.pm
r1424 r2327 227 227 # create a new document 228 228 my $doc_obj = new doc ($file, "indexed_doc"); 229 $doc_obj->set_OIDtype ($processor->{'OIDtype'}); 229 230 230 231 # copy the book cover if it exists -
trunk/gsdl/perllib/plugins/ImagePlug.pm
r2230 r2327 272 272 # create a new document 273 273 my $doc_obj = new doc ($filename, "indexed_doc"); 274 274 $doc_obj->set_OIDtype ($processor->{'OIDtype'}); 275 275 276 #run convert to get the thumbnail and extract size and type info 276 277 my $result = run_convert($self, $filename, $file, $doc_obj); -
trunk/gsdl/perllib/plugins/SplitPlug.pm
r2007 r2327 165 165 # create a new document 166 166 my $doc_obj = new doc ($filename, "indexed_doc"); 167 $doc_obj->set_OIDtype ($processor->{'OIDtype'}); 167 168 $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Language", $language); 168 169 $doc_obj->add_utf8_metadata($doc_obj->get_top_section(), "Encoding", $encoding);
Note:
See TracChangeset
for help on using the changeset viewer.