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

(-)a/C4/AuthoritiesMarc.pm (-14 / +26 lines)
Lines 266-275 sub SearchAuthorities { Link Here
266
        
266
        
267
        ##Here we have to extract MARC record and $authid from ZEBRA AUTHORITIES
267
        ##Here we have to extract MARC record and $authid from ZEBRA AUTHORITIES
268
        my $rec=$oAResult->record($counter);
268
        my $rec=$oAResult->record($counter);
269
        my $marcdata=$rec->raw();
270
        my $authrecord;
271
        my $separator=C4::Context->preference('authoritysep');
269
        my $separator=C4::Context->preference('authoritysep');
272
        $authrecord = MARC::File::USMARC::decode($marcdata);
270
        my $authrecord = C4::Search::new_record_from_zebra(
271
            'authorityserver',
272
            $rec->raw()
273
        );
274
275
        if ( !defined $authrecord or !defined $authrecord->field('001') ) {
276
            $counter++;
277
            next;
278
        }
279
273
        my $authid=$authrecord->field('001')->data();
280
        my $authid=$authrecord->field('001')->data();
274
        my %newline;
281
        my %newline;
275
        $newline{authid} = $authid;
282
        $newline{authid} = $authid;
Lines 847-861 sub FindDuplicateAuthority { Link Here
847
    my $query='at:'.$authtypecode.' ';
854
    my $query='at:'.$authtypecode.' ';
848
    my $filtervalues=qr([\001-\040\!\'\"\`\#\$\%\&\*\+,\-\./:;<=>\?\@\(\)\{\[\]\}_\|\~]);
855
    my $filtervalues=qr([\001-\040\!\'\"\`\#\$\%\&\*\+,\-\./:;<=>\?\@\(\)\{\[\]\}_\|\~]);
849
    if ($record->field($auth_tag_to_report)) {
856
    if ($record->field($auth_tag_to_report)) {
850
      foreach ($record->field($auth_tag_to_report)->subfields()) {
857
        foreach ($record->field($auth_tag_to_report)->subfields()) {
851
        $_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
858
            $_->[1]=~s/$filtervalues/ /g; $query.= " $op he:\"".$_->[1]."\"" if ($_->[0]=~/[A-z]/);
852
      }
859
        }
853
    }
860
    }
854
    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
861
    my ($error, $results, $total_hits) = C4::Search::SimpleSearch( $query, 0, 1, [ "authorityserver" ] );
855
    # there is at least 1 result => return the 1st one
862
    # there is at least 1 result => return the 1st one
856
    if (!defined $error && @{$results} ) {
863
    if (!defined $error && @{$results} ) {
857
      my $marcrecord = MARC::File::USMARC::decode($results->[0]);
864
        my $marcrecord = C4::Search::new_record_from_zebra(
858
      return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
865
            'authorityserver',
866
            $results->[0]
867
        );
868
        return $marcrecord->field('001')->data,BuildSummary($marcrecord,$marcrecord->field('001')->data,$authtypecode);
859
    }
869
    }
860
    # no result, returns nothing
870
    # no result, returns nothing
861
    return;
871
    return;
Lines 1452-1464 sub merge { Link Here
1452
    }
1462
    }
1453
    my $z=0;
1463
    my $z=0;
1454
    while ( $z<$count ) {
1464
    while ( $z<$count ) {
1455
        my $rec;
1465
        my $marcrecordzebra = C4::Search::new_record_from_zebra(
1456
        $rec=$oResult->record($z);
1466
            'biblioserver',
1457
        my $marcdata = $rec->raw();
1467
            $oResult->record($z)->raw()
1458
        my $marcrecordzebra= MARC::Record->new_from_usmarc($marcdata);
1468
        );
1459
        my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' );
1469
        my ( $biblionumbertagfield, $biblionumbertagsubfield ) = &GetMarcFromKohaField( "biblio.biblionumber", '' );
1460
        my $i = ($biblionumbertagfield < 10) ? $marcrecordzebra->field($biblionumbertagfield)->data : $marcrecordzebra->subfield($biblionumbertagfield, $biblionumbertagsubfield);
1470
        my $i = ($biblionumbertagfield < 10)
1461
        my $marcrecorddb=GetMarcBiblio($i);
1471
            ? $marcrecordzebra->field( $biblionumbertagfield )->data
1472
            : $marcrecordzebra->subfield( $biblionumbertagfield, $biblionumbertagsubfield );
1473
        my $marcrecorddb = GetMarcBiblio($i);
1462
        push @reccache, $marcrecorddb;
1474
        push @reccache, $marcrecorddb;
1463
        $z++;
1475
        $z++;
1464
    }
1476
    }
(-)a/C4/Context.pm (-23 / +27 lines)
Lines 706-713 sub Zconn { Link Here
706
        $context->{"Zconn"}->{$server}->destroy() if defined($context->{"Zconn"}->{$server});
706
        $context->{"Zconn"}->{$server}->destroy() if defined($context->{"Zconn"}->{$server});
707
707
708
        $context->{"Zconn"}->{$server} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
708
        $context->{"Zconn"}->{$server} = &_new_Zconn($server,$async,$auth,$piggyback,$syntax);
709
        $context->{ Zconn }->{ $server }->option(
710
            preferredRecordSyntax => C4::Context->preference("marcflavour") );
711
        return $context->{"Zconn"}->{$server};
709
        return $context->{"Zconn"}->{$server};
712
    }
710
    }
713
}
711
}
Lines 731-744 sub _new_Zconn { Link Here
731
729
732
    my $tried=0; # first attempt
730
    my $tried=0; # first attempt
733
    my $Zconn; # connection object
731
    my $Zconn; # connection object
734
    $server = "biblioserver" unless $server;
732
    my $elementSetName;
735
    $syntax = "usmarc" unless $syntax;
733
    my $index_mode;
734
735
    $server //= "biblioserver";
736
    $syntax //= "XML";
737
738
    if ( $server eq 'biblioserver' ) {
739
        $index_mode = $context->{'config'}->{'zebra_bib_index_mode'} // 'grs1';
740
    } elsif ( $server eq 'authorityserver' ) {
741
        $index_mode = $context->{'config'}->{'zebra_auth_index_mode'} // 'dom';
742
    }
743
744
    if ( $index_mode eq 'grs1' ) {
745
746
        $elementSetName = 'F';
747
        $syntax = ( $context->preference("marcflavour") eq 'UNIMARC' )
748
                ? 'unimarc'
749
                : 'usmarc';
750
751
    } else {
752
753
        $elementSetName = 'marcxml';
754
        $syntax = 'XML';
755
    }
736
756
737
    my $host = $context->{'listen'}->{$server}->{'content'};
757
    my $host = $context->{'listen'}->{$server}->{'content'};
738
    my $servername = $context->{"config"}->{$server};
758
    my $servername = $context->{"config"}->{$server};
739
    my $user = $context->{"serverinfo"}->{$server}->{"user"};
759
    my $user = $context->{"serverinfo"}->{$server}->{"user"};
740
    my $password = $context->{"serverinfo"}->{$server}->{"password"};
760
    my $password = $context->{"serverinfo"}->{$server}->{"password"};
741
 $auth = 1 if($user && $password);   
761
    $auth = 1 if($user && $password);
742
    retry:
762
    retry:
743
    eval {
763
    eval {
744
        # set options
764
        # set options
Lines 750-756 sub _new_Zconn { Link Here
750
        $o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"});
770
        $o->option(cqlfile=> $context->{"server"}->{$server}->{"cql2rpn"});
751
        $o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"});
771
        $o->option(cclfile=> $context->{"serverinfo"}->{$server}->{"ccl2rpn"});
752
        $o->option(preferredRecordSyntax => $syntax);
772
        $o->option(preferredRecordSyntax => $syntax);
753
        $o->option(elementSetName => "F"); # F for 'full' as opposed to B for 'brief'
773
        $o->option(elementSetName => $elementSetName);
754
        $o->option(databaseName => ($servername?$servername:"biblios"));
774
        $o->option(databaseName => ($servername?$servername:"biblios"));
755
775
756
        # create a new connection object
776
        # create a new connection object
Lines 765-787 sub _new_Zconn { Link Here
765
        }
785
        }
766
786
767
    };
787
    };
768
#     if ($@) {
788
769
#         # Koha manages the Zebra server -- this doesn't work currently for me because of permissions issues
770
#         # Also, I'm skeptical about whether it's the best approach
771
#         warn "problem with Zebra";
772
#         if ( C4::Context->preference("ManageZebra") ) {
773
#             if ($@->code==10000 && $tried==0) { ##No connection try restarting Zebra
774
#                 $tried=1;
775
#                 warn "trying to restart Zebra";
776
#                 my $res=system("zebrasrv -f $ENV{'KOHA_CONF'} >/koha/log/zebra-error.log");
777
#                 goto "retry";
778
#             } else {
779
#                 warn "Error ", $@->code(), ": ", $@->message(), "\n";
780
#                 $Zconn="error";
781
#                 return $Zconn;
782
#             }
783
#         }
784
#     }
785
    return $Zconn;
789
    return $Zconn;
786
}
790
}
787
791
(-)a/C4/Installer/PerlDependencies.pm (-2 / +2 lines)
Lines 462-468 our $PERL_DEPS = { Link Here
462
    'MARC::Record' => {
462
    'MARC::Record' => {
463
        'usage'    => 'Core',
463
        'usage'    => 'Core',
464
        'required' => '1',
464
        'required' => '1',
465
        'min_ver'  => '2'
465
        'min_ver'  => '2.0.6'
466
    },
466
    },
467
    'Locale::Currency::Format' => {
467
    'Locale::Currency::Format' => {
468
        'usage'    => 'Core',
468
        'usage'    => 'Core',
Lines 487-493 our $PERL_DEPS = { Link Here
487
    'MARC::File::XML' => {
487
    'MARC::File::XML' => {
488
        'usage'    => 'Core',
488
        'usage'    => 'Core',
489
        'required' => '1',
489
        'required' => '1',
490
        'min_ver'  => '0.88'
490
        'min_ver'  => '1.0.1'
491
    },
491
    },
492
    'XML::SAX::Writer' => {
492
    'XML::SAX::Writer' => {
493
        'usage'    => 'Core',
493
        'usage'    => 'Core',
(-)a/C4/Matcher.pm (-1 / +1 lines)
Lines 696-702 sub get_matches { Link Here
696
    if ($self->{'record_type'} eq 'biblio') {
696
    if ($self->{'record_type'} eq 'biblio') {
697
        require C4::Biblio;
697
        require C4::Biblio;
698
        foreach my $marcblob (keys %matches) {
698
        foreach my $marcblob (keys %matches) {
699
            my $target_record = MARC::Record->new_from_usmarc($marcblob);
699
            my $target_record = C4::Search::new_record_from_zebra('biblioserver',$marcblob);
700
            my $record_number;
700
            my $record_number;
701
            my $result = C4::Biblio::TransformMarcToKoha(C4::Context->dbh, $target_record, '');
701
            my $result = C4::Biblio::TransformMarcToKoha(C4::Context->dbh, $target_record, '');
702
            $record_number = $result->{'biblionumber'};
702
            $record_number = $result->{'biblionumber'};
(-)a/C4/Search.pm (-35 / +86 lines)
Lines 144-151 sub FindDuplicate { Link Here
144
    my @results;
144
    my @results;
145
    if (!defined $error) {
145
    if (!defined $error) {
146
        foreach my $possible_duplicate_record (@{$searchresults}) {
146
        foreach my $possible_duplicate_record (@{$searchresults}) {
147
            my $marcrecord =
147
            my $marcrecord = new_record_from_zebra(
148
            MARC::Record->new_from_usmarc($possible_duplicate_record);
148
                'biblioserver',
149
                $possible_duplicate_record
150
            );
151
149
            my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
152
            my $result = TransformMarcToKoha( $dbh, $marcrecord, '' );
150
153
151
            # FIXME :: why 2 $biblionumber ?
154
            # FIXME :: why 2 $biblionumber ?
Lines 289-298 sub SimpleSearch { Link Here
289
            }
292
            }
290
293
291
            for my $j ( $first_record .. $last_record ) {
294
            for my $j ( $first_record .. $last_record ) {
292
                my $record =
295
                my $record = eval {
293
                  $tmpresults[ $i - 1 ]->record( $j - 1 )->raw()
296
                  $tmpresults[ $i - 1 ]->record( $j - 1 )->raw()
294
                  ;    # 0 indexed
297
                  ;    # 0 indexed
295
                push @{$results}, $record;
298
                };
299
                push @{$results}, $record if defined $record;
296
            }
300
            }
297
        }
301
        }
298
    );
302
    );
Lines 446-451 sub getRecords { Link Here
446
                else {
450
                else {
447
                    $times = $size;
451
                    $times = $size;
448
                }
452
                }
453
449
                for ( my $j = $offset ; $j < $times ; $j++ ) {
454
                for ( my $j = $offset ; $j < $times ; $j++ ) {
450
                    my $records_hash;
455
                    my $records_hash;
451
                    my $record;
456
                    my $record;
Lines 488-494 sub getRecords { Link Here
488
                    # not an index scan
493
                    # not an index scan
489
                    else {
494
                    else {
490
                        $record = $results[ $i - 1 ]->record($j)->raw();
495
                        $record = $results[ $i - 1 ]->record($j)->raw();
491
492
                        # warn "RECORD $j:".$record;
496
                        # warn "RECORD $j:".$record;
493
                        $results_hash->{'RECORDS'}[$j] = $record;
497
                        $results_hash->{'RECORDS'}[$j] = $record;
494
                    }
498
                    }
Lines 503-541 sub getRecords { Link Here
503
                      $size > $facets_maxrecs ? $facets_maxrecs : $size;
507
                      $size > $facets_maxrecs ? $facets_maxrecs : $size;
504
                    for my $facet (@$facets) {
508
                    for my $facet (@$facets) {
505
                        for ( my $j = 0 ; $j < $jmax ; $j++ ) {
509
                        for ( my $j = 0 ; $j < $jmax ; $j++ ) {
506
                            my $render_record =
510
507
                              $results[ $i - 1 ]->record($j)->render();
511
                            my $marc_record = new_record_from_zebra (
512
                                    'biblioserver',
513
                                    $results[ $i - 1 ]->record($j)->raw()
514
                            );
515
516
                            if ( ! defined $marc_record ) {
517
                                warn "ERROR DECODING RECORD - $@: " .
518
                                    $results[ $i - 1 ]->record($j)->raw();
519
                                next;
520
                            }
521
508
                            my @used_datas = ();
522
                            my @used_datas = ();
523
509
                            foreach my $tag ( @{ $facet->{tags} } ) {
524
                            foreach my $tag ( @{ $facet->{tags} } ) {
510
525
511
                                # avoid first line
526
                                # avoid first line
512
                                my $tag_num = substr( $tag, 0, 3 );
527
                                my $tag_num = substr( $tag, 0, 3 );
513
                                my $letters = substr( $tag, 3 );
528
                                my $subfield_letters = substr( $tag, 3 );
514
                                my $field_pattern =
529
                                # Removed when as_string fixed
515
                                  '\n' . $tag_num . ' ([^z][^\n]+)';
530
                                my @subfields = $subfield_letters =~ /./sg;
516
                                $field_pattern = '\n' . $tag_num . ' ([^\n]+)'
531
517
                                  if ( int($tag_num) < 10 );
532
                                my @fields = $marc_record->field($tag_num);
518
                                my @field_tokens =
533
                                foreach my $field (@fields) {
519
                                  ( $render_record =~ /$field_pattern/g );
534
                                    my $data = $field->as_string( $subfield_letters, $facet->{sep} );
520
                                foreach my $field_token (@field_tokens) {
535
521
                                    my @subf = ( $field_token =~
522
                                          /\$([a-zA-Z0-9]) ([^\$]+)/g );
523
                                    my @values;
524
                                    for ( my $i = 0 ; $i < @subf ; $i += 2 ) {
525
                                        if ( $letters =~ $subf[$i] ) {
526
                                            my $value = $subf[ $i + 1 ];
527
                                            $value =~ s/^ *//;
528
                                            $value =~ s/ *$//;
529
                                            push @values, $value;
530
                                        }
531
                                    }
532
                                    my $data = join( $facet->{sep}, @values );
533
                                    unless ( $data ~~ @used_datas ) {
536
                                    unless ( $data ~~ @used_datas ) {
534
                                        $facets_counter->{ $facet->{idx} }
535
                                          ->{$data}++;
536
                                        push @used_datas, $data;
537
                                        push @used_datas, $data;
538
                                        $facets_counter->{ $facet->{idx} }->{$data}++;
537
                                    }
539
                                    }
538
                                }    # fields
540
                                } # fields
539
                            }    # field codes
541
                            }    # field codes
540
                        }    # records
542
                        }    # records
541
                        $facets_info->{ $facet->{idx} }->{label_value} =
543
                        $facets_info->{ $facet->{idx} }->{label_value} =
Lines 1700-1715 sub searchResults { Link Here
1700
        $times = $hits;	 # FIXME: if $hits is undefined, why do we want to equal it?
1702
        $times = $hits;	 # FIXME: if $hits is undefined, why do we want to equal it?
1701
    }
1703
    }
1702
1704
1703
	my $marcflavour = C4::Context->preference("marcflavour");
1705
    my $marcflavour = C4::Context->preference("marcflavour");
1704
    # We get the biblionumber position in MARC
1706
    # We get the biblionumber position in MARC
1705
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber','');
1707
    my ($bibliotag,$bibliosubf)=GetMarcFromKohaField('biblio.biblionumber','');
1706
1708
1707
    # loop through all of the records we've retrieved
1709
    # loop through all of the records we've retrieved
1708
    for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
1710
    for ( my $i = $offset ; $i <= $times - 1 ; $i++ ) {
1709
        my $marcrecord = eval { MARC::File::USMARC::decode( $marcresults->[$i] ); };
1711
1710
        if ( $@ ) {
1712
        my $marcrecord;
1711
            warn "ERROR DECODING RECORD - $@: " . $marcresults->[$i];
1713
        if ($scan) {
1712
            next;
1714
            # For Scan searches we built USMARC data
1715
            $marcrecord = MARC::Record->new_from_usmarc( $marcresults->[$i]);
1716
        } else {
1717
            # Normal search, render from Zebra's output
1718
            $marcrecord = new_record_from_zebra(
1719
                'biblioserver',
1720
                $marcresults->[$i]
1721
            );
1722
1723
            if ( ! defined $marcrecord ) {
1724
                warn "ERROR DECODING RECORD - $@: " . $marcresults->[$i];
1725
                next;
1726
            }
1713
        }
1727
        }
1714
1728
1715
        my $fw = $scan
1729
        my $fw = $scan
Lines 2379-2384 sub _ZOOM_event_loop { Link Here
2379
    }
2393
    }
2380
}
2394
}
2381
2395
2396
=head2 new_record_from_zebra
2397
2398
Given raw data from a Zebra result set, return a MARC::Record object
2399
2400
This helper function is needed to take into account all the involved
2401
system preferences and configuration variables to properly create the
2402
MARC::Record object.
2403
2404
If we are using GRS-1, then the raw data we get from Zebra should be USMARC
2405
data. If we are using DOM, then it has to be MARCXML.
2406
2407
=cut
2408
2409
sub new_record_from_zebra {
2410
2411
    my $server   = shift;
2412
    my $raw_data = shift;
2413
    # Set the default indexing modes
2414
    my $index_mode = ( $server eq 'biblioserver' )
2415
                        ? C4::Context->config('zebra_bib_index_mode') // 'grs1'
2416
                        : C4::Context->config('zebra_auth_index_mode') // 'dom';
2417
2418
    my $marc_record =  eval {
2419
        if ( $index_mode eq 'dom' ) {
2420
            MARC::Record->new_from_xml( $raw_data, 'UTF-8' );
2421
        } else {
2422
            MARC::Record->new_from_usmarc( $raw_data );
2423
        }
2424
    };
2425
2426
    if ($@) {
2427
        return;
2428
    } else {
2429
        return $marc_record;
2430
    }
2431
2432
}
2382
2433
2383
END { }    # module clean-up code here (global destructor)
2434
END { }    # module clean-up code here (global destructor)
2384
2435
(-)a/C4/XISBN.pm (-1 / +1 lines)
Lines 67-73 sub _get_biblio_from_xisbn { Link Here
67
    my ( $errors, $results, $total_hits ) = C4::Search::SimpleSearch( "nb=$xisbn", 0, 1 );
67
    my ( $errors, $results, $total_hits ) = C4::Search::SimpleSearch( "nb=$xisbn", 0, 1 );
68
    return unless ( !$errors && scalar @$results );
68
    return unless ( !$errors && scalar @$results );
69
69
70
    my $record = MARC::Record::new_from_usmarc( $results->[0] );
70
    my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[0] );
71
    my $biblionumber = C4::Biblio::get_koha_field_from_marc('biblio', 'biblionumber', $record, '');
71
    my $biblionumber = C4::Biblio::get_koha_field_from_marc('biblio', 'biblionumber', $record, '');
72
    return unless $biblionumber;
72
    return unless $biblionumber;
73
73
(-)a/acqui/neworderbiblio.pl (-1 / +1 lines)
Lines 111-117 if (defined $error) { Link Here
111
my @results;
111
my @results;
112
112
113
foreach my $result ( @{$marcresults} ) {
113
foreach my $result ( @{$marcresults} ) {
114
    my $marcrecord = MARC::File::USMARC::decode( $result );
114
    my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $result );
115
    my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
115
    my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
116
116
117
    $biblio->{booksellerid} = $booksellerid;
117
    $biblio->{booksellerid} = $booksellerid;
(-)a/catalogue/search.pl (-1 / +4 lines)
Lines 660-666 for (my $i=0;$i<@servers;$i++) { Link Here
660
    elsif ($server =~/authorityserver/) { # this is the local authority server
660
    elsif ($server =~/authorityserver/) { # this is the local authority server
661
        my @inner_sup_results_array;
661
        my @inner_sup_results_array;
662
        for my $sup_record ( @{$results_hashref->{$server}->{"RECORDS"}} ) {
662
        for my $sup_record ( @{$results_hashref->{$server}->{"RECORDS"}} ) {
663
            my $marc_record_object = MARC::Record->new_from_usmarc($sup_record);
663
            my $marc_record_object = C4::Search::new_record_from_zebra(
664
                'authorityserver',
665
                $sup_record
666
            );
664
            # warn "Authority Found: ".$marc_record_object->as_formatted();
667
            # warn "Authority Found: ".$marc_record_object->as_formatted();
665
            push @inner_sup_results_array, {
668
            push @inner_sup_results_array, {
666
                'title' => $marc_record_object->field(100)->subfield('a'),
669
                'title' => $marc_record_object->field(100)->subfield('a'),
(-)a/cataloguing/value_builder/marc21_linking_section.pl (-1 / +1 lines)
Lines 231-237 sub plugin { Link Here
231
              my @arrayresults;
231
              my @arrayresults;
232
              my @field_data = ($search);
232
              my @field_data = ($search);
233
            for ( my $i = 0 ; $i < $resultsperpage ; $i++ ) {
233
            for ( my $i = 0 ; $i < $resultsperpage ; $i++ ) {
234
                      my $record = MARC::Record::new_from_usmarc( $results->[$i] );
234
                  my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] );
235
                  my $rechash = TransformMarcToKoha( $dbh, $record );
235
                  my $rechash = TransformMarcToKoha( $dbh, $record );
236
                    my $pos;
236
                    my $pos;
237
                       my $countitems = $rechash->{itembumber} ? 1 : 0;
237
                       my $countitems = $rechash->{itembumber} ? 1 : 0;
(-)a/cataloguing/value_builder/unimarc_field_4XX.pl (-1 / +1 lines)
Lines 390-396 sub plugin { Link Here
390
             $i++
390
             $i++
391
           )
391
           )
392
         {
392
         {
393
            my $record = MARC::Record::new_from_usmarc( $results->[$i] );
393
            my $record = C4::Search::new_record_from_zebra( 'biblioserver', $results->[$i] );
394
            my $rechash = TransformMarcToKoha( $dbh, $record );
394
            my $rechash = TransformMarcToKoha( $dbh, $record );
395
            my $pos;
395
            my $pos;
396
            my $countitems;
396
            my $countitems;
(-)a/circ/circulation.pl (-1 / +1 lines)
Lines 309-315 if ($barcode) { Link Here
309
            foreach my $hit ( @{$results} ) {
309
            foreach my $hit ( @{$results} ) {
310
                my $chosen =
310
                my $chosen =
311
                  TransformMarcToKoha( C4::Context->dbh,
311
                  TransformMarcToKoha( C4::Context->dbh,
312
                    MARC::Record->new_from_usmarc($hit) );
312
                    C4::Search::new_record_from_zebra('biblioserver',$hit) );
313
313
314
                # offer all barcodes individually
314
                # offer all barcodes individually
315
                foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode}) ) {
315
                foreach my $barcode ( sort split(/\s*\|\s*/, $chosen->{barcode}) ) {
(-)a/labels/label-item-search.pl (-1 / +1 lines)
Lines 125-131 if ($show_results) { Link Here
125
    for ( my $i = 0 ; $i < $hits ; $i++ ) {
125
    for ( my $i = 0 ; $i < $hits ; $i++ ) {
126
        my @row_data= ();
126
        my @row_data= ();
127
        #DEBUG Notes: Decode the MARC record from each resulting MARC record...
127
        #DEBUG Notes: Decode the MARC record from each resulting MARC record...
128
        my $marcrecord = MARC::File::USMARC::decode( $marcresults->[$i] );
128
        my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $marcresults->[$i] );
129
        #DEBUG Notes: Transform it to Koha form...
129
        #DEBUG Notes: Transform it to Koha form...
130
        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
130
        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
131
        #DEBUG Notes: Stuff the bib into @biblio_data...
131
        #DEBUG Notes: Stuff the bib into @biblio_data...
(-)a/misc/migration_tools/bulkmarcimport.pl (-1 / +1 lines)
Lines 240-246 RECORD: while ( ) { Link Here
240
        die "unable to search the database for duplicates : $error" if ( defined $error );
240
        die "unable to search the database for duplicates : $error" if ( defined $error );
241
        $debug && warn "$query $server : $totalhits";
241
        $debug && warn "$query $server : $totalhits";
242
        if ( $results && scalar(@$results) == 1 ) {
242
        if ( $results && scalar(@$results) == 1 ) {
243
            my $marcrecord = MARC::File::USMARC::decode( $results->[0] );
243
            my $marcrecord = C4::Search::new_record_from_zebra( $server, $results->[0] );
244
            SetUTF8Flag($marcrecord);
244
            SetUTF8Flag($marcrecord);
245
            $id = GetRecordId( $marcrecord, $tagid, $subfieldid );
245
            $id = GetRecordId( $marcrecord, $tagid, $subfieldid );
246
            if ( $authorities && $marcFlavour ) {
246
            if ( $authorities && $marcFlavour ) {
(-)a/serials/subscription-bib-search.pl (-1 / +1 lines)
Lines 113-119 if ( $op eq "do_search" && $query ) { Link Here
113
113
114
    for ( my $i = 0 ; $i < $total ; $i++ ) {
114
    for ( my $i = 0 ; $i < $total ; $i++ ) {
115
        my %resultsloop;
115
        my %resultsloop;
116
        my $marcrecord = MARC::File::USMARC::decode( $marcrecords->[$i] );
116
        my $marcrecord = C4::Search::new_record_from_zebra( 'biblioserver', $marcrecords->[$i] );
117
        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
117
        my $biblio = TransformMarcToKoha( C4::Context->dbh, $marcrecord, '' );
118
118
119
        #build the hash for the template.
119
        #build the hash for the template.
(-)a/t/db_dependent/Search.t (-3 / +42 lines)
Lines 358-363 sub run_marc21_search_tests { Link Here
358
        getRecords('au:Lessig', 'au:Lessig', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
358
        getRecords('au:Lessig', 'au:Lessig', [], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
359
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords title search for 'Australia' matched right number of records");
359
    is($results_hashref->{biblioserver}->{hits}, 4, "getRecords title search for 'Australia' matched right number of records");
360
360
361
if ( $indexing_mode eq 'dom' ) {
362
    ( undef, $results_hashref, $facets_loop ) =
363
        getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
364
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Efectos del ambiente/ &&
365
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies' &&
366
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/
367
        , "Simple relevance sorting in getRecords matches old behavior");
368
369
    ( undef, $results_hashref, $facets_loop ) =
370
        getRecords('salud', 'salud', [ 'author_az' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
371
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/ &&
372
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[6],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ &&
373
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'World health statistics 2009^ien'
374
        , "Simple ascending author sorting in getRecords matches old behavior");
375
376
    ( undef, $results_hashref, $facets_loop ) =
377
        getRecords('salud', 'salud', [ 'author_za' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
378
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' &&
379
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[12],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/ &&
380
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/la enfermedad laboral\^ies$/
381
        , "Simple descending author sorting in getRecords matches old behavior");
382
383
    ( undef, $results_hashref, $facets_loop ) =
384
        getRecords('salud', 'salud', [ 'pubdate_asc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
385
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies' &&
386
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() =~ m/seguridad e higiene del trabajo\^ies$/ &&
387
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() =~ m/^Indicadores de resultados identificados/
388
        , "Simple ascending publication date sorting in getRecords matches old behavior");
389
390
    ( undef, $results_hashref, $facets_loop ) =
391
        getRecords('salud', 'salud', [ 'pubdate_dsc' ], [ 'biblioserver' ], '38', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
392
    ok(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper() =~ m/^Estado de salud/ &&
393
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[7],'UTF-8')->title_proper() eq 'World health statistics 2009^ien' &&
394
        MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[18],'UTF-8')->title_proper() eq 'Manual de higiene industrial^ies'
395
        , "Simple descending publication date sorting in getRecords matches old behavior");
396
397
} elsif ( $indexing_mode eq 'grs1' ){
361
    ( undef, $results_hashref, $facets_loop ) =
398
    ( undef, $results_hashref, $facets_loop ) =
362
        getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
399
        getRecords('salud', 'salud', [], [ 'biblioserver' ], '19', 0, undef, \%branches, \%itemtypes, 'ccl', undef);
363
    ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() =~ m/^Efectos del ambiente/ &&
400
    ok(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper() =~ m/^Efectos del ambiente/ &&
Lines 392-405 sub run_marc21_search_tests { Link Here
392
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[7])->title_proper() eq 'World health statistics 2009^ien' &&
429
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[7])->title_proper() eq 'World health statistics 2009^ien' &&
393
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() eq 'Manual de higiene industrial^ies'
430
        MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[18])->title_proper() eq 'Manual de higiene industrial^ies'
394
        , "Simple descending publication date sorting in getRecords matches old behavior");
431
        , "Simple descending publication date sorting in getRecords matches old behavior");
432
}
395
433
434
TODO: {
435
    local $TODO = "Switch relevance search to MARCXML too";
396
    ( undef, $results_hashref, $facets_loop ) =
436
    ( undef, $results_hashref, $facets_loop ) =
397
        getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, undef, 1);
437
        getRecords('books', 'books', [ 'relevance' ], [ 'biblioserver' ], '20', 0, undef, \%branches, \%itemtypes, undef, 1);
398
    $record = MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0]);
438
    $record = MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0]);
399
    is($record->title_proper(), 'books', "Scan returned requested item");
439
    is($record->title_proper(), 'books', "Scan returned requested item");
400
    is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term");
440
    is($record->subfield('100', 'a'), 2, "Scan returned correct number of records matching term");
401
402
    # Time to test buildQuery and searchResults too.
441
    # Time to test buildQuery and searchResults too.
442
}
403
443
404
    my ( $query, $simple_query, $query_cgi,
444
    my ( $query, $simple_query, $query_cgi,
405
    $query_desc, $limit, $limit_cgi, $limit_desc,
445
    $query_desc, $limit, $limit_cgi, $limit_desc,
Lines 543-549 sub run_marc21_search_tests { Link Here
543
        is(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
583
        is(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
544
    } else {
584
    } else {
545
        local $TODO = "Query weighting does not behave exactly the same in DOM vs. GRS";
585
        local $TODO = "Query weighting does not behave exactly the same in DOM vs. GRS";
546
        is(MARC::Record::new_from_usmarc($results_hashref->{biblioserver}->{RECORDS}->[0])->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
586
        is(MARC::Record::new_from_xml($results_hashref->{biblioserver}->{RECORDS}->[0],'UTF-8')->title_proper(), 'Salud y seguridad de los trabajadores del sector salud: manual para gerentes y administradores^ies', "Weighted query returns best match first");
547
    }
587
    }
548
588
549
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = 0;
589
    $QueryStemming = $QueryWeightFields = $QueryFuzzy = $QueryRemoveStopwords = 0;
550
- 

Return to bug 11096