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

(-)a/C4/ImportBatch.pm (-7 / +9 lines)
Lines 1559-1565 sub RecordsFromMarcPlugin { Link Here
1559
1559
1560
    # Read input file
1560
    # Read input file
1561
    open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
1561
    open IN, "<$input_file" or die "$0: cannot open input file $input_file: $!\n";
1562
    my ( $text, $marc, @return );
1562
    my ( $text, @return );
1563
    $/ = "\035";
1563
    $/ = "\035";
1564
    while (<IN>) {
1564
    while (<IN>) {
1565
        s/^\s+//;
1565
        s/^\s+//;
Lines 1574-1587 sub RecordsFromMarcPlugin { Link Here
1574
        class  => $plugin_class,
1574
        class  => $plugin_class,
1575
        method => 'to_marc',
1575
        method => 'to_marc',
1576
        params => { data => $text },
1576
        params => { data => $text },
1577
    });
1577
    }) if $plugin_class && $text;
1578
1578
1579
    # Convert to array of MARC records
1579
    # Convert to array of MARC records
1580
    my $marc_type = C4::Context->preference('marcflavour');
1580
    if( $text ) {
1581
    foreach my $blob ( split(/\x1D/, $text) ) {
1581
        my $marc_type = C4::Context->preference('marcflavour');
1582
        next if $blob =~ /^\s*$/;
1582
        foreach my $blob ( split(/\x1D/, $text) ) {
1583
        my ($marcrecord) = MarcToUTF8Record($blob, $marc_type, $encoding);
1583
            next if $blob =~ /^\s*$/;
1584
        push @return, $marcrecord;
1584
            my ($marcrecord) = MarcToUTF8Record($blob, $marc_type, $encoding);
1585
            push @return, $marcrecord;
1586
        }
1585
    }
1587
    }
1586
    return \@return;
1588
    return \@return;
1587
}
1589
}
(-)a/t/db_dependent/ImportBatch.t (+1 lines)
Lines 187-192 subtest "RecordsFromMarcPlugin" => sub { Link Here
187
245,a = Noise in the library|;
187
245,a = Noise in the library|;
188
    close $fh;
188
    close $fh;
189
189
190
    t::lib::Mocks::mock_config( 'enable_plugins', 1 );
190
    my ( $plugin ) = Koha::Plugins->new->GetPlugins({ metadata => { name => 'MarcFieldValues' } });
191
    my ( $plugin ) = Koha::Plugins->new->GetPlugins({ metadata => { name => 'MarcFieldValues' } });
191
    isnt( $plugin, undef, "Plugin found" );
192
    isnt( $plugin, undef, "Plugin found" );
192
    my $records = C4::ImportBatch::RecordsFromMarcPlugin( $name, ref $plugin, 'UTF-8' );
193
    my $records = C4::ImportBatch::RecordsFromMarcPlugin( $name, ref $plugin, 'UTF-8' );
(-)a/tools/stage-marc-import.pl (-5 / +2 lines)
Lines 57-63 my $item_action = $input->param('item_action'); Link Here
57
my $comments                   = $input->param('comments');
57
my $comments                   = $input->param('comments');
58
my $record_type                = $input->param('record_type');
58
my $record_type                = $input->param('record_type');
59
my $encoding                   = $input->param('encoding') || 'UTF-8';
59
my $encoding                   = $input->param('encoding') || 'UTF-8';
60
my $format                     = $input->param('format');
60
my $format                     = $input->param('format') || 'MARC';
61
my $marc_modification_template = $input->param('marc_modification_template_id');
61
my $marc_modification_template = $input->param('marc_modification_template_id');
62
62
63
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
63
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
Lines 93-103 if ($completedJobID) { Link Here
93
        ( $errors, $marcrecords ) = C4::ImportBatch::RecordsFromMARCXMLFile( $file, $encoding);
93
        ( $errors, $marcrecords ) = C4::ImportBatch::RecordsFromMARCXMLFile( $file, $encoding);
94
    } elsif( $format eq 'MARC' ) {
94
    } elsif( $format eq 'MARC' ) {
95
        ( $errors, $marcrecords ) = C4::ImportBatch::RecordsFromISO2709File( $file, $record_type, $encoding );
95
        ( $errors, $marcrecords ) = C4::ImportBatch::RecordsFromISO2709File( $file, $record_type, $encoding );
96
    } elsif( $format ) { # plugin
96
    } else { # plugin based
97
        $errors = [];
97
        $errors = [];
98
        $marcrecords = C4::ImportBatch::RecordsFromMarcPlugin( $file, $format, $encoding );
98
        $marcrecords = C4::ImportBatch::RecordsFromMarcPlugin( $file, $format, $encoding );
99
    } else {
100
        die "No format specified";
101
    }
99
    }
102
    warn "$filename: " . ( join ',', @$errors ) if @$errors;
100
    warn "$filename: " . ( join ',', @$errors ) if @$errors;
103
        # no need to exit if we have no records (or only errors) here
101
        # no need to exit if we have no records (or only errors) here
104
- 

Return to bug 19049