View | Details | Raw Unified | Return to bug 7818
Collapse All | Expand All

(-)a/etc/koha-conf.xml (+2 lines)
Lines 285-289 __PAZPAR2_TOGGLE_XML_POST__ Link Here
285
 <pazpar2url>http://__PAZPAR2_HOST__:__PAZPAR2_PORT__/search.pz2</pazpar2url>
285
 <pazpar2url>http://__PAZPAR2_HOST__:__PAZPAR2_PORT__/search.pz2</pazpar2url>
286
 <install_log>__MISC_DIR__/koha-install-log</install_log>
286
 <install_log>__MISC_DIR__/koha-install-log</install_log>
287
 <useldapserver>0</useldapserver><!-- see C4::Auth_with_ldap for extra configs you must add if you want to turn this on -->
287
 <useldapserver>0</useldapserver><!-- see C4::Auth_with_ldap for extra configs you must add if you want to turn this on -->
288
 <zebra_bib_index_mode>__BIB_INDEX_MODE__</zebra_bib_index_mode>
289
 <zebra_auth_index_mode>__AUTH_INDEX_MODE__</zebra_auth_index_mode>
288
</config>
290
</config>
289
</yazgfs>
291
</yazgfs>
(-)a/etc/zebradb/authorities/etc/dom-config.xml (-1 / +1 lines)
Lines 49-54 Authorities DOM config for MARC XML input Link Here
49
    <xslt stylesheet="authority-zebra-indexdefs.xsl"/>
49
    <xslt stylesheet="authority-zebra-indexdefs.xsl"/>
50
  </retrieve>
50
  </retrieve>
51
  <input>
51
  <input>
52
    <xmlreader level="0"/>
52
    <xmlreader level="1"/>
53
  </input>
53
  </input>
54
</dom>
54
</dom>
(-)a/etc/zebradb/biblios/etc/dom-config.xml (-1 / +1 lines)
Lines 49-54 Bibliographic DOM config for MARC XML input Link Here
49
    <xslt stylesheet="biblio-zebra-indexdefs.xsl"/>
49
    <xslt stylesheet="biblio-zebra-indexdefs.xsl"/>
50
  </retrieve>
50
  </retrieve>
51
  <input>
51
  <input>
52
    <xmlreader level="0"/>
52
    <xmlreader level="1"/>
53
  </input>
53
  </input>
54
</dom>
54
</dom>
(-)a/misc/migration_tools/rebuild_zebra.pl (-20 / +59 lines)
Lines 72-83 if (not $biblios and not $authorities) { Link Here
72
    die $msg;
72
    die $msg;
73
}
73
}
74
74
75
if ($authorities and $as_xml) {
76
    my $msg = "Cannot specify both -a and -x\n";
77
    $msg   .= "Please do '$0 --help' to see usage.\n";
78
    die $msg;
79
}
80
81
if ( !$as_xml and $nosanitize ) {
75
if ( !$as_xml and $nosanitize ) {
82
    my $msg = "Cannot specify both -no_xml and -nosanitize\n";
76
    my $msg = "Cannot specify both -no_xml and -nosanitize\n";
83
    $msg   .= "Please do '$0 --help' to see usage.\n";
77
    $msg   .= "Please do '$0 --help' to see usage.\n";
Lines 117-122 my $biblioserverdir = C4::Context->zebraconfig('biblioserver')->{directory}; Link Here
117
my $authorityserverdir = C4::Context->zebraconfig('authorityserver')->{directory};
111
my $authorityserverdir = C4::Context->zebraconfig('authorityserver')->{directory};
118
112
119
my $kohadir = C4::Context->config('intranetdir');
113
my $kohadir = C4::Context->config('intranetdir');
114
my $bib_index_mode = C4::Context->config('zebra_bib_index_mode') || 'grs1';
115
my $auth_index_mode = C4::Context->config('zebra_auth_index_mode') || 'dom';
116
120
my $dbh = C4::Context->dbh;
117
my $dbh = C4::Context->dbh;
121
my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
118
my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
122
my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber","");
119
my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber","");
Lines 319-329 sub select_all_biblios { Link Here
319
    return $sth;
316
    return $sth;
320
}
317
}
321
318
319
sub include_xml_wrapper {
320
    my $as_xml = shift;
321
    my $record_type = shift;
322
   
323
    return 0 unless $as_xml;
324
    return 1 if $record_type eq 'biblio' and $bib_index_mode eq 'dom';
325
    return 1 if $record_type eq 'authority' and $auth_index_mode eq 'dom';
326
    return 0;
327
328
}
329
322
sub export_marc_records_from_sth {
330
sub export_marc_records_from_sth {
323
    my ($record_type, $sth, $directory, $as_xml, $noxml, $nosanitize) = @_;
331
    my ($record_type, $sth, $directory, $as_xml, $noxml, $nosanitize) = @_;
324
332
325
    my $num_exported = 0;
333
    my $num_exported = 0;
326
    open my $fh, '>:encoding(UTF-8) ', "$directory/exported_records" or die $!;
334
    open my $fh, '>:encoding(UTF-8) ', "$directory/exported_records" or die $!;
335
    if (include_xml_wrapper($as_xml, $record_type)) {
336
        # include XML declaration and root element
337
        print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
338
    }
327
    my $i = 0;
339
    my $i = 0;
328
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",'');
340
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",'');
329
    while (my ($record_number) = $sth->fetchrow_array) {
341
    while (my ($record_number) = $sth->fetchrow_array) {
Lines 358-370 sub export_marc_records_from_sth { Link Here
358
        }
370
        }
359
        my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
371
        my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
360
        if (defined $marc) {
372
        if (defined $marc) {
361
            # FIXME - when more than one record is exported and $as_xml is true,
362
            # the output file is not valid XML - it's just multiple <record> elements
363
            # strung together with no single root element.  zebraidx doesn't seem
364
            # to care, though, at least if you're using the GRS-1 filter.  It does
365
            # care if you're using the DOM filter, which requires valid XML file(s).
366
            eval {
373
            eval {
367
                print {$fh} ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc();
374
                my $rec;
375
                if ($as_xml) {
376
                    $rec = $marc->as_xml_record(C4::Context->preference('marcflavour'));
377
                    $rec =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!;
378
                } else {
379
                    $rec = $marc->as_usmarc();
380
                }
381
                print {$fh} $rec;
368
                $num_exported++;
382
                $num_exported++;
369
            };
383
            };
370
            if ($@) {
384
            if ($@) {
Lines 373-378 sub export_marc_records_from_sth { Link Here
373
        }
387
        }
374
    }
388
    }
375
    print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
389
    print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
390
    print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
376
    close $fh;
391
    close $fh;
377
    return $num_exported;
392
    return $num_exported;
378
}
393
}
Lines 382-387 sub export_marc_records_from_list { Link Here
382
397
383
    my $num_exported = 0;
398
    my $num_exported = 0;
384
    open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
399
    open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
400
    if (include_xml_wrapper($as_xml, $record_type)) {
401
        # include XML declaration and root element
402
        print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
403
    }
385
    my $i = 0;
404
    my $i = 0;
386
405
387
    # Skip any deleted records. We check for this anyway, but this reduces error spam
406
    # Skip any deleted records. We check for this anyway, but this reduces error spam
Lines 393-408 sub export_marc_records_from_list { Link Here
393
        print "\r$i" unless ($i++ %100 or !$verbose_logging);
412
        print "\r$i" unless ($i++ %100 or !$verbose_logging);
394
        my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
413
        my ($marc) = get_corrected_marc_record($record_type, $record_number, $noxml);
395
        if (defined $marc) {
414
        if (defined $marc) {
396
            # FIXME - when more than one record is exported and $as_xml is true,
415
            eval {
397
            # the output file is not valid XML - it's just multiple <record> elements
416
                my $rec;
398
            # strung together with no single root element.  zebraidx doesn't seem
417
                if ($as_xml) {
399
            # to care, though, at least if you're using the GRS-1 filter.  It does
418
                    $rec = $marc->as_xml_record(C4::Context->preference('marcflavour'));
400
            # care if you're using the DOM filter, which requires valid XML file(s).
419
                    $rec =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!;
401
            print {$fh} ($as_xml) ? $marc->as_xml_record(C4::Context->preference('marcflavour')) : $marc->as_usmarc();
420
                } else {
421
                    $rec = $marc->as_usmarc();
422
                }
423
                print {$fh} $rec;
424
                $num_exported++;
425
            };
426
            if ($@) {
427
              warn "Error exporting record $record_number ($record_type) ".($noxml ? "not XML" : "XML");
428
            }
402
            $num_exported++;
429
            $num_exported++;
403
        }
430
        }
404
    }
431
    }
405
    print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
432
    print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
433
    print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
406
    close $fh;
434
    close $fh;
407
    return $num_exported;
435
    return $num_exported;
408
}
436
}
Lines 412-417 sub generate_deleted_marc_records { Link Here
412
440
413
    my $records_deleted = {};
441
    my $records_deleted = {};
414
    open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
442
    open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
443
    if (include_xml_wrapper($as_xml, $record_type)) {
444
        # include XML declaration and root element
445
        print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
446
    }
415
    my $i = 0;
447
    my $i = 0;
416
    foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) {
448
    foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) {
417
        print "\r$i" unless ($i++ %100 or !$verbose_logging);
449
        print "\r$i" unless ($i++ %100 or !$verbose_logging);
Lines 427-437 sub generate_deleted_marc_records { Link Here
427
            fix_unimarc_100($marc);
459
            fix_unimarc_100($marc);
428
        }
460
        }
429
461
430
        print {$fh} ($as_xml) ? $marc->as_xml_record(C4::Context->preference("marcflavour")) : $marc->as_usmarc();
462
        my $rec;
463
        if ($as_xml) {
464
            $rec = $marc->as_xml_record(C4::Context->preference('marcflavour'));
465
            $rec =~ s!<\?xml version="1.0" encoding="UTF-8"\?>\n!!;
466
        } else {
467
            $rec = $marc->as_usmarc();
468
        }
469
        print {$fh} $rec;
431
470
432
        $records_deleted->{$record_number} = 1;
471
        $records_deleted->{$record_number} = 1;
433
    }
472
    }
434
    print "\nRecords exported: $i\n" if ( $verbose_logging );
473
    print "\nRecords exported: $i\n" if ( $verbose_logging );
474
    print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
435
    close $fh;
475
    close $fh;
436
    return $records_deleted;
476
    return $records_deleted;
437
    
477
    
438
- 

Return to bug 7818