Lines 36-41
use C4::ClassSource;
Link Here
|
36 |
use C4::Charset; |
36 |
use C4::Charset; |
37 |
use C4::Linker; |
37 |
use C4::Linker; |
38 |
use C4::OAI::Sets; |
38 |
use C4::OAI::Sets; |
|
|
39 |
use Koha::Search; |
40 |
use Koha::Utils; |
39 |
|
41 |
|
40 |
use vars qw($VERSION @ISA @EXPORT); |
42 |
use vars qw($VERSION @ISA @EXPORT); |
41 |
|
43 |
|
Lines 87-93
BEGIN {
Link Here
|
87 |
|
89 |
|
88 |
&GetAuthorisedValueDesc |
90 |
&GetAuthorisedValueDesc |
89 |
&GetMarcStructure |
91 |
&GetMarcStructure |
90 |
&GetMarcFromKohaField |
|
|
91 |
&GetFrameworkCode |
92 |
&GetFrameworkCode |
92 |
&TransformKohaToMarc |
93 |
&TransformKohaToMarc |
93 |
&PrepHostMarcField |
94 |
&PrepHostMarcField |
Lines 131-137
BEGIN {
Link Here
|
131 |
&TransformHtmlToMarc2 |
132 |
&TransformHtmlToMarc2 |
132 |
&TransformHtmlToMarc |
133 |
&TransformHtmlToMarc |
133 |
&TransformHtmlToXml |
134 |
&TransformHtmlToXml |
134 |
&GetNoZebraIndexes |
|
|
135 |
prepare_host_field |
135 |
prepare_host_field |
136 |
); |
136 |
); |
137 |
} |
137 |
} |
Lines 449-455
sub DelBiblio {
Link Here
|
449 |
# the previous version of the record |
449 |
# the previous version of the record |
450 |
$oldRecord = GetMarcBiblio($biblionumber); |
450 |
$oldRecord = GetMarcBiblio($biblionumber); |
451 |
} |
451 |
} |
452 |
ModZebra( $biblionumber, "recordDelete", "biblioserver", $oldRecord, undef ); |
452 |
AddToIndexQueue( $biblionumber, "recordDelete", "biblioserver", $oldRecord, undef ); |
453 |
|
453 |
|
454 |
# delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems |
454 |
# delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems |
455 |
$sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
455 |
$sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
Lines 1158-1182
sub GetUsedMarcStructure($) {
Link Here
|
1158 |
return $sth->fetchall_arrayref( {} ); |
1158 |
return $sth->fetchall_arrayref( {} ); |
1159 |
} |
1159 |
} |
1160 |
|
1160 |
|
1161 |
=head2 GetMarcFromKohaField |
|
|
1162 |
|
1163 |
($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode); |
1164 |
|
1165 |
Returns the MARC fields & subfields mapped to the koha field |
1166 |
for the given frameworkcode |
1167 |
|
1168 |
=cut |
1169 |
|
1170 |
sub GetMarcFromKohaField { |
1171 |
my ( $kohafield, $frameworkcode ) = @_; |
1172 |
return (0, undef) unless $kohafield and defined $frameworkcode; |
1173 |
my $relations = C4::Context->marcfromkohafield; |
1174 |
if ( my $mf = $relations->{$frameworkcode}->{$kohafield} ) { |
1175 |
return @$mf; |
1176 |
} |
1177 |
return (0, undef); |
1178 |
} |
1179 |
|
1180 |
=head2 GetMarcBiblio |
1161 |
=head2 GetMarcBiblio |
1181 |
|
1162 |
|
1182 |
my $record = GetMarcBiblio($biblionumber, [$embeditems]); |
1163 |
my $record = GetMarcBiblio($biblionumber, [$embeditems]); |
Lines 2603-2744
sub TransformMarcToKohaOneField {
Link Here
|
2603 |
} |
2584 |
} |
2604 |
|
2585 |
|
2605 |
|
2586 |
|
2606 |
#" |
|
|
2607 |
|
2608 |
# |
2609 |
# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates |
2610 |
# at the same time |
2611 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2612 |
# the table is emptied by misc/cronjobs/zebraqueue_start.pl script |
2613 |
# =head2 ModZebrafiles |
2614 |
# |
2615 |
# &ModZebrafiles( $dbh, $biblionumber, $record, $folder, $server ); |
2616 |
# |
2617 |
# =cut |
2618 |
# |
2619 |
# sub ModZebrafiles { |
2620 |
# |
2621 |
# my ( $dbh, $biblionumber, $record, $folder, $server ) = @_; |
2622 |
# |
2623 |
# my $op; |
2624 |
# my $zebradir = |
2625 |
# C4::Context->zebraconfig($server)->{directory} . "/" . $folder . "/"; |
2626 |
# unless ( opendir( DIR, "$zebradir" ) ) { |
2627 |
# warn "$zebradir not found"; |
2628 |
# return; |
2629 |
# } |
2630 |
# closedir DIR; |
2631 |
# my $filename = $zebradir . $biblionumber; |
2632 |
# |
2633 |
# if ($record) { |
2634 |
# open( OUTPUT, ">", $filename . ".xml" ); |
2635 |
# print OUTPUT $record; |
2636 |
# close OUTPUT; |
2637 |
# } |
2638 |
# } |
2639 |
|
2640 |
=head2 ModZebra |
2587 |
=head2 ModZebra |
2641 |
|
2588 |
|
2642 |
ModZebra( $biblionumber, $op, $server, $oldRecord, $newRecord ); |
2589 |
This method should not be used. The functionality has been moved to |
2643 |
|
2590 |
Koha::Search::AddToIndexQueue. It is left here as a temporary wrapper |
2644 |
$biblionumber is the biblionumber we want to index |
2591 |
to simplify the migration of custom scripts. |
2645 |
|
|
|
2646 |
$op is specialUpdate or delete, and is used to know what we want to do |
2647 |
|
2648 |
$server is the server that we want to update |
2649 |
|
2650 |
$oldRecord is the MARC::Record containing the previous version of the record. This is used only when |
2651 |
NoZebra=1, as NoZebra indexing needs to know the previous version of a record in order to |
2652 |
do an update. |
2653 |
|
2654 |
$newRecord is the MARC::Record containing the new record. It is usefull only when NoZebra=1, and is used to know what to add to the nozebra database. (the record in mySQL being, if it exist, the previous record, the one just before the modif. We need both : the previous and the new one. |
2655 |
|
2592 |
|
2656 |
=cut |
2593 |
=cut |
2657 |
|
2594 |
|
2658 |
sub ModZebra { |
2595 |
sub ModZebra { |
2659 |
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs |
2596 |
AddToIndexQueue(@_) |
2660 |
my ( $biblionumber, $op, $server, $oldRecord, $newRecord ) = @_; |
|
|
2661 |
my $dbh = C4::Context->dbh; |
2662 |
|
2663 |
# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates |
2664 |
# at the same time |
2665 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2666 |
# the table is emptied by misc/cronjobs/zebraqueue_start.pl script |
2667 |
|
2668 |
if ( C4::Context->preference("NoZebra") ) { |
2669 |
|
2670 |
# lock the nozebra table : we will read index lines, update them in Perl process |
2671 |
# and write everything in 1 transaction. |
2672 |
# lock the table to avoid someone else overwriting what we are doing |
2673 |
$dbh->do('LOCK TABLES nozebra WRITE,biblio WRITE,biblioitems WRITE, systempreferences WRITE, auth_types WRITE, auth_header WRITE, auth_subfield_structure READ'); |
2674 |
my %result; # the result hash that will be built by deletion / add, and written on mySQL at the end, to improve speed |
2675 |
if ( $op eq 'specialUpdate' ) { |
2676 |
|
2677 |
# OK, we have to add or update the record |
2678 |
# 1st delete (virtually, in indexes), if record actually exists |
2679 |
if ($oldRecord) { |
2680 |
%result = _DelBiblioNoZebra( $biblionumber, $oldRecord, $server ); |
2681 |
} |
2682 |
|
2683 |
# ... add the record |
2684 |
%result = _AddBiblioNoZebra( $biblionumber, $newRecord, $server, %result ); |
2685 |
} else { |
2686 |
|
2687 |
# it's a deletion, delete the record... |
2688 |
# warn "DELETE the record $biblionumber on $server".$record->as_formatted; |
2689 |
%result = _DelBiblioNoZebra( $biblionumber, $oldRecord, $server ); |
2690 |
} |
2691 |
|
2692 |
# ok, now update the database... |
2693 |
my $sth = $dbh->prepare("UPDATE nozebra SET biblionumbers=? WHERE server=? AND indexname=? AND value=?"); |
2694 |
foreach my $key ( keys %result ) { |
2695 |
foreach my $index ( keys %{ $result{$key} } ) { |
2696 |
$sth->execute( $result{$key}->{$index}, $server, $key, $index ); |
2697 |
} |
2698 |
} |
2699 |
$dbh->do('UNLOCK TABLES'); |
2700 |
} else { |
2701 |
|
2702 |
# |
2703 |
# we use zebra, just fill zebraqueue table |
2704 |
# |
2705 |
my $check_sql = "SELECT COUNT(*) FROM zebraqueue |
2706 |
WHERE server = ? |
2707 |
AND biblio_auth_number = ? |
2708 |
AND operation = ? |
2709 |
AND done = 0"; |
2710 |
my $check_sth = $dbh->prepare_cached($check_sql); |
2711 |
$check_sth->execute( $server, $biblionumber, $op ); |
2712 |
my ($count) = $check_sth->fetchrow_array; |
2713 |
$check_sth->finish(); |
2714 |
if ( $count == 0 ) { |
2715 |
my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); |
2716 |
$sth->execute( $biblionumber, $server, $op ); |
2717 |
$sth->finish; |
2718 |
} |
2719 |
} |
2720 |
} |
2721 |
|
2722 |
=head2 GetNoZebraIndexes |
2723 |
|
2724 |
%indexes = GetNoZebraIndexes; |
2725 |
|
2726 |
return the data from NoZebraIndexes syspref. |
2727 |
|
2728 |
=cut |
2729 |
|
2730 |
sub GetNoZebraIndexes { |
2731 |
my $no_zebra_indexes = C4::Context->preference('NoZebraIndexes'); |
2732 |
my %indexes; |
2733 |
INDEX: foreach my $line ( split /['"],[\n\r]*/, $no_zebra_indexes ) { |
2734 |
$line =~ /(.*)=>(.*)/; |
2735 |
my $index = $1; # initial ' or " is removed afterwards |
2736 |
my $fields = $2; |
2737 |
$index =~ s/'|"|\s//g; |
2738 |
$fields =~ s/'|"|\s//g; |
2739 |
$indexes{$index} = $fields; |
2740 |
} |
2741 |
return %indexes; |
2742 |
} |
2597 |
} |
2743 |
|
2598 |
|
2744 |
=head2 EmbedItemsInMarcBiblio |
2599 |
=head2 EmbedItemsInMarcBiblio |
Lines 2774-3041
sub EmbedItemsInMarcBiblio {
Link Here
|
2774 |
|
2629 |
|
2775 |
=head1 INTERNAL FUNCTIONS |
2630 |
=head1 INTERNAL FUNCTIONS |
2776 |
|
2631 |
|
2777 |
=head2 _DelBiblioNoZebra($biblionumber,$record,$server); |
|
|
2778 |
|
2779 |
function to delete a biblio in NoZebra indexes |
2780 |
This function does NOT delete anything in database : it reads all the indexes entries |
2781 |
that have to be deleted & delete them in the hash |
2782 |
|
2783 |
The SQL part is done either : |
2784 |
- after the Add if we are modifying a biblio (delete + add again) |
2785 |
- immediatly after this sub if we are doing a true deletion. |
2786 |
|
2787 |
$server can be 'biblioserver' or 'authorityserver' : it indexes biblios or authorities (in the same table, $server being part of the table itself |
2788 |
|
2789 |
=cut |
2790 |
|
2791 |
sub _DelBiblioNoZebra { |
2792 |
my ( $biblionumber, $record, $server ) = @_; |
2793 |
|
2794 |
# Get the indexes |
2795 |
my $dbh = C4::Context->dbh; |
2796 |
|
2797 |
# Get the indexes |
2798 |
my %index; |
2799 |
my $title; |
2800 |
if ( $server eq 'biblioserver' ) { |
2801 |
%index = GetNoZebraIndexes; |
2802 |
|
2803 |
# get title of the record (to store the 10 first letters with the index) |
2804 |
my ( $titletag, $titlesubfield ) = GetMarcFromKohaField( 'biblio.title', '' ); # FIXME: should be GetFrameworkCode($biblionumber) ?? |
2805 |
$title = lc( $record->subfield( $titletag, $titlesubfield ) ); |
2806 |
} else { |
2807 |
|
2808 |
# for authorities, the "title" is the $a mainentry |
2809 |
my ( $auth_type_tag, $auth_type_sf ) = C4::AuthoritiesMarc::get_auth_type_location(); |
2810 |
my $authref = C4::AuthoritiesMarc::GetAuthType( $record->subfield( $auth_type_tag, $auth_type_sf ) ); |
2811 |
warn "ERROR : authtype undefined for " . $record->as_formatted unless $authref; |
2812 |
$title = $record->subfield( $authref->{auth_tag_to_report}, 'a' ); |
2813 |
$index{'mainmainentry'} = $authref->{'auth_tag_to_report'} . 'a'; |
2814 |
$index{'mainentry'} = $authref->{'auth_tag_to_report'} . '*'; |
2815 |
$index{'auth_type'} = "${auth_type_tag}${auth_type_sf}"; |
2816 |
} |
2817 |
|
2818 |
my %result; |
2819 |
|
2820 |
# remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values |
2821 |
$title =~ s/ |,|;|\[|\]|\(|\)|\*|-|'|=//g; |
2822 |
|
2823 |
# limit to 10 char, should be enough, and limit the DB size |
2824 |
$title = substr( $title, 0, 10 ); |
2825 |
|
2826 |
#parse each field |
2827 |
my $sth2 = $dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?'); |
2828 |
foreach my $field ( $record->fields() ) { |
2829 |
|
2830 |
#parse each subfield |
2831 |
next if $field->tag < 10; |
2832 |
foreach my $subfield ( $field->subfields() ) { |
2833 |
my $tag = $field->tag(); |
2834 |
my $subfieldcode = $subfield->[0]; |
2835 |
my $indexed = 0; |
2836 |
|
2837 |
# check each index to see if the subfield is stored somewhere |
2838 |
# otherwise, store it in __RAW__ index |
2839 |
foreach my $key ( keys %index ) { |
2840 |
|
2841 |
# warn "examining $key index : ".$index{$key}." for $tag $subfieldcode"; |
2842 |
if ( $index{$key} =~ /$tag\*/ or $index{$key} =~ /$tag$subfieldcode/ ) { |
2843 |
$indexed = 1; |
2844 |
my $line = lc $subfield->[1]; |
2845 |
|
2846 |
# remove meaningless value in the field... |
2847 |
$line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:/ /g; |
2848 |
|
2849 |
# ... and split in words |
2850 |
foreach ( split / /, $line ) { |
2851 |
next unless $_; # skip empty values (multiple spaces) |
2852 |
# if the entry is already here, do nothing, the biblionumber has already be removed |
2853 |
unless ( defined( $result{$key}->{$_} ) && ( $result{$key}->{$_} =~ /$biblionumber,$title\-(\d);/ ) ) { |
2854 |
|
2855 |
# get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing |
2856 |
$sth2->execute( $server, $key, $_ ); |
2857 |
my $existing_biblionumbers = $sth2->fetchrow; |
2858 |
|
2859 |
# it exists |
2860 |
if ($existing_biblionumbers) { |
2861 |
|
2862 |
# warn " existing for $key $_: $existing_biblionumbers"; |
2863 |
$result{$key}->{$_} = $existing_biblionumbers; |
2864 |
$result{$key}->{$_} =~ s/$biblionumber,$title\-(\d);//; |
2865 |
} |
2866 |
} |
2867 |
} |
2868 |
} |
2869 |
} |
2870 |
|
2871 |
# the subfield is not indexed, store it in __RAW__ index anyway |
2872 |
unless ($indexed) { |
2873 |
my $line = lc $subfield->[1]; |
2874 |
$line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:/ /g; |
2875 |
|
2876 |
# ... and split in words |
2877 |
foreach ( split / /, $line ) { |
2878 |
next unless $_; # skip empty values (multiple spaces) |
2879 |
# if the entry is already here, do nothing, the biblionumber has already be removed |
2880 |
unless ( $result{'__RAW__'}->{$_} =~ /$biblionumber,$title\-(\d);/ ) { |
2881 |
|
2882 |
# get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing |
2883 |
$sth2->execute( $server, '__RAW__', $_ ); |
2884 |
my $existing_biblionumbers = $sth2->fetchrow; |
2885 |
|
2886 |
# it exists |
2887 |
if ($existing_biblionumbers) { |
2888 |
$result{'__RAW__'}->{$_} = $existing_biblionumbers; |
2889 |
$result{'__RAW__'}->{$_} =~ s/$biblionumber,$title\-(\d);//; |
2890 |
} |
2891 |
} |
2892 |
} |
2893 |
} |
2894 |
} |
2895 |
} |
2896 |
return %result; |
2897 |
} |
2898 |
|
2899 |
=head2 _AddBiblioNoZebra |
2900 |
|
2901 |
_AddBiblioNoZebra($biblionumber, $record, $server, %result); |
2902 |
|
2903 |
function to add a biblio in NoZebra indexes |
2904 |
|
2905 |
=cut |
2906 |
|
2907 |
sub _AddBiblioNoZebra { |
2908 |
my ( $biblionumber, $record, $server, %result ) = @_; |
2909 |
my $dbh = C4::Context->dbh; |
2910 |
|
2911 |
# Get the indexes |
2912 |
my %index; |
2913 |
my $title; |
2914 |
if ( $server eq 'biblioserver' ) { |
2915 |
%index = GetNoZebraIndexes; |
2916 |
|
2917 |
# get title of the record (to store the 10 first letters with the index) |
2918 |
my ( $titletag, $titlesubfield ) = GetMarcFromKohaField( 'biblio.title', '' ); # FIXME: should be GetFrameworkCode($biblionumber) ?? |
2919 |
$title = lc( $record->subfield( $titletag, $titlesubfield ) ); |
2920 |
} else { |
2921 |
|
2922 |
# warn "server : $server"; |
2923 |
# for authorities, the "title" is the $a mainentry |
2924 |
my ( $auth_type_tag, $auth_type_sf ) = C4::AuthoritiesMarc::get_auth_type_location(); |
2925 |
my $authref = C4::AuthoritiesMarc::GetAuthType( $record->subfield( $auth_type_tag, $auth_type_sf ) ); |
2926 |
warn "ERROR : authtype undefined for " . $record->as_formatted unless $authref; |
2927 |
$title = $record->subfield( $authref->{auth_tag_to_report}, 'a' ); |
2928 |
$index{'mainmainentry'} = $authref->{auth_tag_to_report} . 'a'; |
2929 |
$index{'mainentry'} = $authref->{auth_tag_to_report} . '*'; |
2930 |
$index{'auth_type'} = "${auth_type_tag}${auth_type_sf}"; |
2931 |
} |
2932 |
|
2933 |
# remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values |
2934 |
$title =~ s/ |\.|,|;|\[|\]|\(|\)|\*|-|'|:|=|\r|\n//g; |
2935 |
|
2936 |
# limit to 10 char, should be enough, and limit the DB size |
2937 |
$title = substr( $title, 0, 10 ); |
2938 |
|
2939 |
#parse each field |
2940 |
my $sth2 = $dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?'); |
2941 |
foreach my $field ( $record->fields() ) { |
2942 |
|
2943 |
#parse each subfield |
2944 |
###FIXME: impossible to index a 001-009 value with NoZebra |
2945 |
next if $field->tag < 10; |
2946 |
foreach my $subfield ( $field->subfields() ) { |
2947 |
my $tag = $field->tag(); |
2948 |
my $subfieldcode = $subfield->[0]; |
2949 |
my $indexed = 0; |
2950 |
|
2951 |
# warn "INDEXING :".$subfield->[1]; |
2952 |
# check each index to see if the subfield is stored somewhere |
2953 |
# otherwise, store it in __RAW__ index |
2954 |
foreach my $key ( keys %index ) { |
2955 |
|
2956 |
# warn "examining $key index : ".$index{$key}." for $tag $subfieldcode"; |
2957 |
if ( $index{$key} =~ /$tag\*/ or $index{$key} =~ /$tag$subfieldcode/ ) { |
2958 |
$indexed = 1; |
2959 |
my $line = lc $subfield->[1]; |
2960 |
|
2961 |
# remove meaningless value in the field... |
2962 |
$line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:|\r|\n/ /g; |
2963 |
|
2964 |
# ... and split in words |
2965 |
foreach ( split / /, $line ) { |
2966 |
next unless $_; # skip empty values (multiple spaces) |
2967 |
# if the entry is already here, improve weight |
2968 |
|
2969 |
# warn "managing $_"; |
2970 |
if ( exists $result{$key}->{$_} && $result{$key}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/ ) { |
2971 |
my $weight = $1 + 1; |
2972 |
$result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g; |
2973 |
$result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; |
2974 |
} else { |
2975 |
|
2976 |
# get the value if it exist in the nozebra table, otherwise, create it |
2977 |
$sth2->execute( $server, $key, $_ ); |
2978 |
my $existing_biblionumbers = $sth2->fetchrow; |
2979 |
|
2980 |
# it exists |
2981 |
if ($existing_biblionumbers) { |
2982 |
$result{$key}->{"$_"} = $existing_biblionumbers; |
2983 |
my $weight = defined $1 ? $1 + 1 : 1; |
2984 |
$result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g; |
2985 |
$result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; |
2986 |
|
2987 |
# create a new ligne for this entry |
2988 |
} else { |
2989 |
|
2990 |
# warn "INSERT : $server / $key / $_"; |
2991 |
$dbh->do( 'INSERT INTO nozebra SET server=' . $dbh->quote($server) . ', indexname=' . $dbh->quote($key) . ',value=' . $dbh->quote($_) ); |
2992 |
$result{$key}->{"$_"} .= "$biblionumber,$title-1;"; |
2993 |
} |
2994 |
} |
2995 |
} |
2996 |
} |
2997 |
} |
2998 |
|
2999 |
# the subfield is not indexed, store it in __RAW__ index anyway |
3000 |
unless ($indexed) { |
3001 |
my $line = lc $subfield->[1]; |
3002 |
$line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:|\r|\n/ /g; |
3003 |
|
3004 |
# ... and split in words |
3005 |
foreach ( split / /, $line ) { |
3006 |
next unless $_; # skip empty values (multiple spaces) |
3007 |
# if the entry is already here, improve weight |
3008 |
my $tmpstr = $result{'__RAW__'}->{"$_"} || ""; |
3009 |
if ( $tmpstr =~ /$biblionumber,\Q$title\E\-(\d+);/ ) { |
3010 |
my $weight = $1 + 1; |
3011 |
$result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; |
3012 |
$result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; |
3013 |
} else { |
3014 |
|
3015 |
# get the value if it exist in the nozebra table, otherwise, create it |
3016 |
$sth2->execute( $server, '__RAW__', $_ ); |
3017 |
my $existing_biblionumbers = $sth2->fetchrow; |
3018 |
|
3019 |
# it exists |
3020 |
if ($existing_biblionumbers) { |
3021 |
$result{'__RAW__'}->{"$_"} = $existing_biblionumbers; |
3022 |
my $weight = ( $1 ? $1 : 0 ) + 1; |
3023 |
$result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; |
3024 |
$result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; |
3025 |
|
3026 |
# create a new ligne for this entry |
3027 |
} else { |
3028 |
$dbh->do( 'INSERT INTO nozebra SET server=' . $dbh->quote($server) . ', indexname="__RAW__",value=' . $dbh->quote($_) ); |
3029 |
$result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-1;"; |
3030 |
} |
3031 |
} |
3032 |
} |
3033 |
} |
3034 |
} |
3035 |
} |
3036 |
return %result; |
3037 |
} |
3038 |
|
3039 |
=head2 _koha_marc_update_bib_ids |
2632 |
=head2 _koha_marc_update_bib_ids |
3040 |
|
2633 |
|
3041 |
|
2634 |
|
Lines 3519-3525
sub ModBiblioMarc {
Link Here
|
3519 |
$sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?"); |
3112 |
$sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?"); |
3520 |
$sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $biblionumber ); |
3113 |
$sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $biblionumber ); |
3521 |
$sth->finish; |
3114 |
$sth->finish; |
3522 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver", $oldRecord, $record ); |
3115 |
AddToIndexQueue( $biblionumber, "specialUpdate", "biblioserver", $oldRecord, $record ); |
3523 |
return $biblionumber; |
3116 |
return $biblionumber; |
3524 |
} |
3117 |
} |
3525 |
|
3118 |
|