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

(-)a/misc/migration_tools/rebuild_zebra.pl (-16 / +30 lines)
Lines 168-173 my $dbh = C4::Context->dbh; Link Here
168
my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
168
my ($biblionumbertagfield,$biblionumbertagsubfield) = &GetMarcFromKohaField("biblio.biblionumber","");
169
my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber","");
169
my ($biblioitemnumbertagfield,$biblioitemnumbertagsubfield) = &GetMarcFromKohaField("biblioitems.biblioitemnumber","");
170
170
171
my $marcxml_open = q{<?xml version="1.0" encoding="UTF-8"?>
172
<collection xmlns="http://www.loc.gov/MARC21/slim">
173
};
174
175
my $marcxml_close = q{
176
</collection>
177
};
178
171
# Protect again simultaneous update of the zebra index by using a lock file.
179
# Protect again simultaneous update of the zebra index by using a lock file.
172
# Create our own lock directory if its missing.  This shouild be created
180
# Create our own lock directory if its missing.  This shouild be created
173
# by koha-zebra-ctl.sh or at system installation.  If the desired directory
181
# by koha-zebra-ctl.sh or at system installation.  If the desired directory
Lines 478-487 sub export_marc_records_from_sth { Link Here
478
486
479
    my $num_exported = 0;
487
    my $num_exported = 0;
480
    open my $fh, '>:encoding(UTF-8) ', "$directory/exported_records" or die $!;
488
    open my $fh, '>:encoding(UTF-8) ', "$directory/exported_records" or die $!;
481
    if (include_xml_wrapper($as_xml, $record_type)) {
489
482
        # include XML declaration and root element
490
    print {$fh} $marcxml_open
483
        print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
491
        if include_xml_wrapper($as_xml, $record_type);
484
    }
492
485
    my $i = 0;
493
    my $i = 0;
486
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",'');
494
    my ( $itemtag, $itemsubfield ) = GetMarcFromKohaField("items.itemnumber",'');
487
    while (my ($record_number) = $sth->fetchrow_array) {
495
    while (my ($record_number) = $sth->fetchrow_array) {
Lines 550-556 sub export_marc_records_from_sth { Link Here
550
        }
558
        }
551
    }
559
    }
552
    print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
560
    print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
553
    print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
561
    print {$fh} $marcxml_close
562
        if include_xml_wrapper($as_xml, $record_type);
554
    close $fh;
563
    close $fh;
555
    return $num_exported;
564
    return $num_exported;
556
}
565
}
Lines 560-569 sub export_marc_records_from_list { Link Here
560
569
561
    my $num_exported = 0;
570
    my $num_exported = 0;
562
    open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
571
    open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
563
    if (include_xml_wrapper($as_xml, $record_type)) {
572
564
        # include XML declaration and root element
573
    print {$fh} $marcxml_open
565
        print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
574
        if include_xml_wrapper($as_xml, $record_type);
566
    }
575
567
    my $i = 0;
576
    my $i = 0;
568
577
569
    # Skip any deleted records. We check for this anyway, but this reduces error spam
578
    # Skip any deleted records. We check for this anyway, but this reduces error spam
Lines 592-598 sub export_marc_records_from_list { Link Here
592
        }
601
        }
593
    }
602
    }
594
    print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
603
    print "\nRecords exported: $num_exported\n" if ( $verbose_logging );
595
    print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
604
605
    print {$fh} $marcxml_close
606
        if include_xml_wrapper($as_xml, $record_type);
607
596
    close $fh;
608
    close $fh;
597
    return $num_exported;
609
    return $num_exported;
598
}
610
}
Lines 602-611 sub generate_deleted_marc_records { Link Here
602
614
603
    my $records_deleted = {};
615
    my $records_deleted = {};
604
    open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
616
    open my $fh, '>:encoding(UTF-8)', "$directory/exported_records" or die $!;
605
    if (include_xml_wrapper($as_xml, $record_type)) {
617
606
        # include XML declaration and root element
618
    print {$fh} $marcxml_open
607
        print {$fh} '<?xml version="1.0" encoding="UTF-8"?><collection>';
619
        if include_xml_wrapper($as_xml, $record_type);
608
    }
620
609
    my $i = 0;
621
    my $i = 0;
610
    foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) {
622
    foreach my $record_number (map { $_->{biblio_auth_number} } @$entries ) {
611
        print "\r$i" unless ($i++ %100 or !$verbose_logging);
623
        print "\r$i" unless ($i++ %100 or !$verbose_logging);
Lines 633-639 sub generate_deleted_marc_records { Link Here
633
        $records_deleted->{$record_number} = 1;
645
        $records_deleted->{$record_number} = 1;
634
    }
646
    }
635
    print "\nRecords exported: $i\n" if ( $verbose_logging );
647
    print "\nRecords exported: $i\n" if ( $verbose_logging );
636
    print {$fh} '</collection>' if (include_xml_wrapper($as_xml, $record_type));
648
649
    print {$fh} $marcxml_close
650
        if include_xml_wrapper($as_xml, $record_type);
651
637
    close $fh;
652
    close $fh;
638
    return $records_deleted;
653
    return $records_deleted;
639
654
640
- 

Return to bug 16505