|
Lines 39-44
use C4::Linker;
Link Here
|
| 39 |
require C4::Heading; |
39 |
require C4::Heading; |
| 40 |
require C4::Serials; |
40 |
require C4::Serials; |
| 41 |
require C4::Items; |
41 |
require C4::Items; |
|
|
42 |
use Koha::Search; |
| 43 |
use Koha::Utils; |
| 42 |
|
44 |
|
| 43 |
use vars qw($VERSION @ISA @EXPORT); |
45 |
use vars qw($VERSION @ISA @EXPORT); |
| 44 |
|
46 |
|
|
Lines 89-95
BEGIN {
Link Here
|
| 89 |
|
91 |
|
| 90 |
&GetAuthorisedValueDesc |
92 |
&GetAuthorisedValueDesc |
| 91 |
&GetMarcStructure |
93 |
&GetMarcStructure |
| 92 |
&GetMarcFromKohaField |
|
|
| 93 |
&GetFrameworkCode |
94 |
&GetFrameworkCode |
| 94 |
&TransformKohaToMarc |
95 |
&TransformKohaToMarc |
| 95 |
&PrepHostMarcField |
96 |
&PrepHostMarcField |
|
Lines 134-140
BEGIN {
Link Here
|
| 134 |
&TransformHtmlToMarc |
135 |
&TransformHtmlToMarc |
| 135 |
&TransformHtmlToXml |
136 |
&TransformHtmlToXml |
| 136 |
&PrepareItemrecordDisplay |
137 |
&PrepareItemrecordDisplay |
| 137 |
&GetNoZebraIndexes |
|
|
| 138 |
); |
138 |
); |
| 139 |
} |
139 |
} |
| 140 |
|
140 |
|
|
Lines 436-442
sub DelBiblio {
Link Here
|
| 436 |
# the previous version of the record |
436 |
# the previous version of the record |
| 437 |
$oldRecord = GetMarcBiblio($biblionumber); |
437 |
$oldRecord = GetMarcBiblio($biblionumber); |
| 438 |
} |
438 |
} |
| 439 |
ModZebra( $biblionumber, "recordDelete", "biblioserver", $oldRecord, undef ); |
439 |
AddToIndexQueue( $biblionumber, "recordDelete", "biblioserver", $oldRecord, undef ); |
| 440 |
|
440 |
|
| 441 |
# delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems |
441 |
# delete biblioitems and items from Koha tables and save in deletedbiblioitems,deleteditems |
| 442 |
$sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
442 |
$sth = $dbh->prepare("SELECT biblioitemnumber FROM biblioitems WHERE biblionumber=?"); |
|
Lines 540-546
sub LinkBibHeadingsToAuthorities {
Link Here
|
| 540 |
if (defined $current_link && C4::Context->preference('LinkerKeepStale')) { |
540 |
if (defined $current_link && C4::Context->preference('LinkerKeepStale')) { |
| 541 |
$results{'fuzzy'}->{$heading->display_form()}++; |
541 |
$results{'fuzzy'}->{$heading->display_form()}++; |
| 542 |
} elsif (C4::Context->preference('AutoCreateAuthorities')) { |
542 |
} elsif (C4::Context->preference('AutoCreateAuthorities')) { |
| 543 |
my $authtypedata=C4::AuthoritiesMarc::GetAuthType($heading->auth_type()); |
543 |
my $authtypedata=GetAuthType($heading->auth_type()); |
| 544 |
my $marcrecordauth=MARC::Record->new(); |
544 |
my $marcrecordauth=MARC::Record->new(); |
| 545 |
if (C4::Context->preference('marcflavour') eq 'MARC21') { |
545 |
if (C4::Context->preference('marcflavour') eq 'MARC21') { |
| 546 |
$marcrecordauth->leader(' nz a22 o 4500'); |
546 |
$marcrecordauth->leader(' nz a22 o 4500'); |
|
Lines 1107-1128
sub GetUsedMarcStructure($) {
Link Here
|
| 1107 |
return $sth->fetchall_arrayref( {} ); |
1107 |
return $sth->fetchall_arrayref( {} ); |
| 1108 |
} |
1108 |
} |
| 1109 |
|
1109 |
|
| 1110 |
=head2 GetMarcFromKohaField |
|
|
| 1111 |
|
| 1112 |
($MARCfield,$MARCsubfield)=GetMarcFromKohaField($kohafield,$frameworkcode); |
| 1113 |
|
| 1114 |
Returns the MARC fields & subfields mapped to the koha field |
| 1115 |
for the given frameworkcode |
| 1116 |
|
| 1117 |
=cut |
| 1118 |
|
| 1119 |
sub GetMarcFromKohaField { |
| 1120 |
my ( $kohafield, $frameworkcode ) = @_; |
| 1121 |
return 0, 0 unless $kohafield and defined $frameworkcode; |
| 1122 |
my $relations = C4::Context->marcfromkohafield; |
| 1123 |
return ( $relations->{$frameworkcode}->{$kohafield}->[0], $relations->{$frameworkcode}->{$kohafield}->[1] ); |
| 1124 |
} |
| 1125 |
|
| 1126 |
=head2 GetMarcBiblio |
1110 |
=head2 GetMarcBiblio |
| 1127 |
|
1111 |
|
| 1128 |
my $record = GetMarcBiblio($biblionumber, [$embeditems]); |
1112 |
my $record = GetMarcBiblio($biblionumber, [$embeditems]); |
|
Lines 2819-2906
$newRecord is the MARC::Record containing the new record. It is usefull only whe
Link Here
|
| 2819 |
|
2803 |
|
| 2820 |
sub ModZebra { |
2804 |
sub ModZebra { |
| 2821 |
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs |
2805 |
###Accepts a $server variable thus we can use it for biblios authorities or other zebra dbs |
| 2822 |
my ( $biblionumber, $op, $server, $oldRecord, $newRecord ) = @_; |
|
|
| 2823 |
my $dbh = C4::Context->dbh; |
| 2824 |
|
2806 |
|
| 2825 |
# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates |
2807 |
# true ModZebra commented until indexdata fixes zebraDB crashes (it seems they occur on multiple updates |
| 2826 |
# at the same time |
2808 |
# at the same time |
| 2827 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
2809 |
# replaced by a zebraqueue table, that is filled with ModZebra to run. |
| 2828 |
# the table is emptied by misc/cronjobs/zebraqueue_start.pl script |
2810 |
# the table is emptied by misc/cronjobs/zebraqueue_start.pl script |
|
|
2811 |
AddToIndexQueue(@_) |
| 2829 |
|
2812 |
|
| 2830 |
if ( C4::Context->preference("NoZebra") ) { |
|
|
| 2831 |
|
| 2832 |
# lock the nozebra table : we will read index lines, update them in Perl process |
| 2833 |
# and write everything in 1 transaction. |
| 2834 |
# lock the table to avoid someone else overwriting what we are doing |
| 2835 |
$dbh->do('LOCK TABLES nozebra WRITE,biblio WRITE,biblioitems WRITE, systempreferences WRITE, auth_types WRITE, auth_header WRITE, auth_subfield_structure READ'); |
| 2836 |
my %result; # the result hash that will be built by deletion / add, and written on mySQL at the end, to improve speed |
| 2837 |
if ( $op eq 'specialUpdate' ) { |
| 2838 |
|
| 2839 |
# OK, we have to add or update the record |
| 2840 |
# 1st delete (virtually, in indexes), if record actually exists |
| 2841 |
if ($oldRecord) { |
| 2842 |
%result = _DelBiblioNoZebra( $biblionumber, $oldRecord, $server ); |
| 2843 |
} |
| 2844 |
|
| 2845 |
# ... add the record |
| 2846 |
%result = _AddBiblioNoZebra( $biblionumber, $newRecord, $server, %result ); |
| 2847 |
} else { |
| 2848 |
|
| 2849 |
# it's a deletion, delete the record... |
| 2850 |
# warn "DELETE the record $biblionumber on $server".$record->as_formatted; |
| 2851 |
%result = _DelBiblioNoZebra( $biblionumber, $oldRecord, $server ); |
| 2852 |
} |
| 2853 |
|
| 2854 |
# ok, now update the database... |
| 2855 |
my $sth = $dbh->prepare("UPDATE nozebra SET biblionumbers=? WHERE server=? AND indexname=? AND value=?"); |
| 2856 |
foreach my $key ( keys %result ) { |
| 2857 |
foreach my $index ( keys %{ $result{$key} } ) { |
| 2858 |
$sth->execute( $result{$key}->{$index}, $server, $key, $index ); |
| 2859 |
} |
| 2860 |
} |
| 2861 |
$dbh->do('UNLOCK TABLES'); |
| 2862 |
} else { |
| 2863 |
|
| 2864 |
# |
| 2865 |
# we use zebra, just fill zebraqueue table |
| 2866 |
# |
| 2867 |
my $check_sql = "SELECT COUNT(*) FROM zebraqueue |
| 2868 |
WHERE server = ? |
| 2869 |
AND biblio_auth_number = ? |
| 2870 |
AND operation = ? |
| 2871 |
AND done = 0"; |
| 2872 |
my $check_sth = $dbh->prepare_cached($check_sql); |
| 2873 |
$check_sth->execute( $server, $biblionumber, $op ); |
| 2874 |
my ($count) = $check_sth->fetchrow_array; |
| 2875 |
$check_sth->finish(); |
| 2876 |
if ( $count == 0 ) { |
| 2877 |
my $sth = $dbh->prepare("INSERT INTO zebraqueue (biblio_auth_number,server,operation) VALUES(?,?,?)"); |
| 2878 |
$sth->execute( $biblionumber, $server, $op ); |
| 2879 |
$sth->finish; |
| 2880 |
} |
| 2881 |
} |
| 2882 |
} |
| 2883 |
|
| 2884 |
=head2 GetNoZebraIndexes |
| 2885 |
|
| 2886 |
%indexes = GetNoZebraIndexes; |
| 2887 |
|
| 2888 |
return the data from NoZebraIndexes syspref. |
| 2889 |
|
| 2890 |
=cut |
| 2891 |
|
| 2892 |
sub GetNoZebraIndexes { |
| 2893 |
my $no_zebra_indexes = C4::Context->preference('NoZebraIndexes'); |
| 2894 |
my %indexes; |
| 2895 |
INDEX: foreach my $line ( split /['"],[\n\r]*/, $no_zebra_indexes ) { |
| 2896 |
$line =~ /(.*)=>(.*)/; |
| 2897 |
my $index = $1; # initial ' or " is removed afterwards |
| 2898 |
my $fields = $2; |
| 2899 |
$index =~ s/'|"|\s//g; |
| 2900 |
$fields =~ s/'|"|\s//g; |
| 2901 |
$indexes{$index} = $fields; |
| 2902 |
} |
| 2903 |
return %indexes; |
| 2904 |
} |
2813 |
} |
| 2905 |
|
2814 |
|
| 2906 |
=head2 EmbedItemsInMarcBiblio |
2815 |
=head2 EmbedItemsInMarcBiblio |
|
Lines 2935-3202
sub EmbedItemsInMarcBiblio {
Link Here
|
| 2935 |
|
2844 |
|
| 2936 |
=head1 INTERNAL FUNCTIONS |
2845 |
=head1 INTERNAL FUNCTIONS |
| 2937 |
|
2846 |
|
| 2938 |
=head2 _DelBiblioNoZebra($biblionumber,$record,$server); |
|
|
| 2939 |
|
| 2940 |
function to delete a biblio in NoZebra indexes |
| 2941 |
This function does NOT delete anything in database : it reads all the indexes entries |
| 2942 |
that have to be deleted & delete them in the hash |
| 2943 |
|
| 2944 |
The SQL part is done either : |
| 2945 |
- after the Add if we are modifying a biblio (delete + add again) |
| 2946 |
- immediatly after this sub if we are doing a true deletion. |
| 2947 |
|
| 2948 |
$server can be 'biblioserver' or 'authorityserver' : it indexes biblios or authorities (in the same table, $server being part of the table itself |
| 2949 |
|
| 2950 |
=cut |
| 2951 |
|
| 2952 |
sub _DelBiblioNoZebra { |
| 2953 |
my ( $biblionumber, $record, $server ) = @_; |
| 2954 |
|
| 2955 |
# Get the indexes |
| 2956 |
my $dbh = C4::Context->dbh; |
| 2957 |
|
| 2958 |
# Get the indexes |
| 2959 |
my %index; |
| 2960 |
my $title; |
| 2961 |
if ( $server eq 'biblioserver' ) { |
| 2962 |
%index = GetNoZebraIndexes; |
| 2963 |
|
| 2964 |
# get title of the record (to store the 10 first letters with the index) |
| 2965 |
my ( $titletag, $titlesubfield ) = GetMarcFromKohaField( 'biblio.title', '' ); # FIXME: should be GetFrameworkCode($biblionumber) ?? |
| 2966 |
$title = lc( $record->subfield( $titletag, $titlesubfield ) ); |
| 2967 |
} else { |
| 2968 |
|
| 2969 |
# for authorities, the "title" is the $a mainentry |
| 2970 |
my ( $auth_type_tag, $auth_type_sf ) = C4::AuthoritiesMarc::get_auth_type_location(); |
| 2971 |
my $authref = C4::AuthoritiesMarc::GetAuthType( $record->subfield( $auth_type_tag, $auth_type_sf ) ); |
| 2972 |
warn "ERROR : authtype undefined for " . $record->as_formatted unless $authref; |
| 2973 |
$title = $record->subfield( $authref->{auth_tag_to_report}, 'a' ); |
| 2974 |
$index{'mainmainentry'} = $authref->{'auth_tag_to_report'} . 'a'; |
| 2975 |
$index{'mainentry'} = $authref->{'auth_tag_to_report'} . '*'; |
| 2976 |
$index{'auth_type'} = "${auth_type_tag}${auth_type_sf}"; |
| 2977 |
} |
| 2978 |
|
| 2979 |
my %result; |
| 2980 |
|
| 2981 |
# remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values |
| 2982 |
$title =~ s/ |,|;|\[|\]|\(|\)|\*|-|'|=//g; |
| 2983 |
|
| 2984 |
# limit to 10 char, should be enough, and limit the DB size |
| 2985 |
$title = substr( $title, 0, 10 ); |
| 2986 |
|
| 2987 |
#parse each field |
| 2988 |
my $sth2 = $dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?'); |
| 2989 |
foreach my $field ( $record->fields() ) { |
| 2990 |
|
| 2991 |
#parse each subfield |
| 2992 |
next if $field->tag < 10; |
| 2993 |
foreach my $subfield ( $field->subfields() ) { |
| 2994 |
my $tag = $field->tag(); |
| 2995 |
my $subfieldcode = $subfield->[0]; |
| 2996 |
my $indexed = 0; |
| 2997 |
|
| 2998 |
# check each index to see if the subfield is stored somewhere |
| 2999 |
# otherwise, store it in __RAW__ index |
| 3000 |
foreach my $key ( keys %index ) { |
| 3001 |
|
| 3002 |
# warn "examining $key index : ".$index{$key}." for $tag $subfieldcode"; |
| 3003 |
if ( $index{$key} =~ /$tag\*/ or $index{$key} =~ /$tag$subfieldcode/ ) { |
| 3004 |
$indexed = 1; |
| 3005 |
my $line = lc $subfield->[1]; |
| 3006 |
|
| 3007 |
# remove meaningless value in the field... |
| 3008 |
$line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:/ /g; |
| 3009 |
|
| 3010 |
# ... and split in words |
| 3011 |
foreach ( split / /, $line ) { |
| 3012 |
next unless $_; # skip empty values (multiple spaces) |
| 3013 |
# if the entry is already here, do nothing, the biblionumber has already be removed |
| 3014 |
unless ( defined( $result{$key}->{$_} ) && ( $result{$key}->{$_} =~ /$biblionumber,$title\-(\d);/ ) ) { |
| 3015 |
|
| 3016 |
# get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing |
| 3017 |
$sth2->execute( $server, $key, $_ ); |
| 3018 |
my $existing_biblionumbers = $sth2->fetchrow; |
| 3019 |
|
| 3020 |
# it exists |
| 3021 |
if ($existing_biblionumbers) { |
| 3022 |
|
| 3023 |
# warn " existing for $key $_: $existing_biblionumbers"; |
| 3024 |
$result{$key}->{$_} = $existing_biblionumbers; |
| 3025 |
$result{$key}->{$_} =~ s/$biblionumber,$title\-(\d);//; |
| 3026 |
} |
| 3027 |
} |
| 3028 |
} |
| 3029 |
} |
| 3030 |
} |
| 3031 |
|
| 3032 |
# the subfield is not indexed, store it in __RAW__ index anyway |
| 3033 |
unless ($indexed) { |
| 3034 |
my $line = lc $subfield->[1]; |
| 3035 |
$line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:/ /g; |
| 3036 |
|
| 3037 |
# ... and split in words |
| 3038 |
foreach ( split / /, $line ) { |
| 3039 |
next unless $_; # skip empty values (multiple spaces) |
| 3040 |
# if the entry is already here, do nothing, the biblionumber has already be removed |
| 3041 |
unless ( $result{'__RAW__'}->{$_} =~ /$biblionumber,$title\-(\d);/ ) { |
| 3042 |
|
| 3043 |
# get the index value if it exist in the nozebra table and remove the entry, otherwise, do nothing |
| 3044 |
$sth2->execute( $server, '__RAW__', $_ ); |
| 3045 |
my $existing_biblionumbers = $sth2->fetchrow; |
| 3046 |
|
| 3047 |
# it exists |
| 3048 |
if ($existing_biblionumbers) { |
| 3049 |
$result{'__RAW__'}->{$_} = $existing_biblionumbers; |
| 3050 |
$result{'__RAW__'}->{$_} =~ s/$biblionumber,$title\-(\d);//; |
| 3051 |
} |
| 3052 |
} |
| 3053 |
} |
| 3054 |
} |
| 3055 |
} |
| 3056 |
} |
| 3057 |
return %result; |
| 3058 |
} |
| 3059 |
|
| 3060 |
=head2 _AddBiblioNoZebra |
| 3061 |
|
| 3062 |
_AddBiblioNoZebra($biblionumber, $record, $server, %result); |
| 3063 |
|
| 3064 |
function to add a biblio in NoZebra indexes |
| 3065 |
|
| 3066 |
=cut |
| 3067 |
|
| 3068 |
sub _AddBiblioNoZebra { |
| 3069 |
my ( $biblionumber, $record, $server, %result ) = @_; |
| 3070 |
my $dbh = C4::Context->dbh; |
| 3071 |
|
| 3072 |
# Get the indexes |
| 3073 |
my %index; |
| 3074 |
my $title; |
| 3075 |
if ( $server eq 'biblioserver' ) { |
| 3076 |
%index = GetNoZebraIndexes; |
| 3077 |
|
| 3078 |
# get title of the record (to store the 10 first letters with the index) |
| 3079 |
my ( $titletag, $titlesubfield ) = GetMarcFromKohaField( 'biblio.title', '' ); # FIXME: should be GetFrameworkCode($biblionumber) ?? |
| 3080 |
$title = lc( $record->subfield( $titletag, $titlesubfield ) ); |
| 3081 |
} else { |
| 3082 |
|
| 3083 |
# warn "server : $server"; |
| 3084 |
# for authorities, the "title" is the $a mainentry |
| 3085 |
my ( $auth_type_tag, $auth_type_sf ) = C4::AuthoritiesMarc::get_auth_type_location(); |
| 3086 |
my $authref = C4::AuthoritiesMarc::GetAuthType( $record->subfield( $auth_type_tag, $auth_type_sf ) ); |
| 3087 |
warn "ERROR : authtype undefined for " . $record->as_formatted unless $authref; |
| 3088 |
$title = $record->subfield( $authref->{auth_tag_to_report}, 'a' ); |
| 3089 |
$index{'mainmainentry'} = $authref->{auth_tag_to_report} . 'a'; |
| 3090 |
$index{'mainentry'} = $authref->{auth_tag_to_report} . '*'; |
| 3091 |
$index{'auth_type'} = "${auth_type_tag}${auth_type_sf}"; |
| 3092 |
} |
| 3093 |
|
| 3094 |
# remove blancks comma (that could cause problem when decoding the string for CQL retrieval) and regexp specific values |
| 3095 |
$title =~ s/ |\.|,|;|\[|\]|\(|\)|\*|-|'|:|=|\r|\n//g; |
| 3096 |
|
| 3097 |
# limit to 10 char, should be enough, and limit the DB size |
| 3098 |
$title = substr( $title, 0, 10 ); |
| 3099 |
|
| 3100 |
#parse each field |
| 3101 |
my $sth2 = $dbh->prepare('SELECT biblionumbers FROM nozebra WHERE server=? AND indexname=? AND value=?'); |
| 3102 |
foreach my $field ( $record->fields() ) { |
| 3103 |
|
| 3104 |
#parse each subfield |
| 3105 |
###FIXME: impossible to index a 001-009 value with NoZebra |
| 3106 |
next if $field->tag < 10; |
| 3107 |
foreach my $subfield ( $field->subfields() ) { |
| 3108 |
my $tag = $field->tag(); |
| 3109 |
my $subfieldcode = $subfield->[0]; |
| 3110 |
my $indexed = 0; |
| 3111 |
|
| 3112 |
# warn "INDEXING :".$subfield->[1]; |
| 3113 |
# check each index to see if the subfield is stored somewhere |
| 3114 |
# otherwise, store it in __RAW__ index |
| 3115 |
foreach my $key ( keys %index ) { |
| 3116 |
|
| 3117 |
# warn "examining $key index : ".$index{$key}." for $tag $subfieldcode"; |
| 3118 |
if ( $index{$key} =~ /$tag\*/ or $index{$key} =~ /$tag$subfieldcode/ ) { |
| 3119 |
$indexed = 1; |
| 3120 |
my $line = lc $subfield->[1]; |
| 3121 |
|
| 3122 |
# remove meaningless value in the field... |
| 3123 |
$line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:|\r|\n/ /g; |
| 3124 |
|
| 3125 |
# ... and split in words |
| 3126 |
foreach ( split / /, $line ) { |
| 3127 |
next unless $_; # skip empty values (multiple spaces) |
| 3128 |
# if the entry is already here, improve weight |
| 3129 |
|
| 3130 |
# warn "managing $_"; |
| 3131 |
if ( exists $result{$key}->{$_} && $result{$key}->{"$_"} =~ /$biblionumber,\Q$title\E\-(\d+);/ ) { |
| 3132 |
my $weight = $1 + 1; |
| 3133 |
$result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g; |
| 3134 |
$result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; |
| 3135 |
} else { |
| 3136 |
|
| 3137 |
# get the value if it exist in the nozebra table, otherwise, create it |
| 3138 |
$sth2->execute( $server, $key, $_ ); |
| 3139 |
my $existing_biblionumbers = $sth2->fetchrow; |
| 3140 |
|
| 3141 |
# it exists |
| 3142 |
if ($existing_biblionumbers) { |
| 3143 |
$result{$key}->{"$_"} = $existing_biblionumbers; |
| 3144 |
my $weight = defined $1 ? $1 + 1 : 1; |
| 3145 |
$result{$key}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//g; |
| 3146 |
$result{$key}->{"$_"} .= "$biblionumber,$title-$weight;"; |
| 3147 |
|
| 3148 |
# create a new ligne for this entry |
| 3149 |
} else { |
| 3150 |
|
| 3151 |
# warn "INSERT : $server / $key / $_"; |
| 3152 |
$dbh->do( 'INSERT INTO nozebra SET server=' . $dbh->quote($server) . ', indexname=' . $dbh->quote($key) . ',value=' . $dbh->quote($_) ); |
| 3153 |
$result{$key}->{"$_"} .= "$biblionumber,$title-1;"; |
| 3154 |
} |
| 3155 |
} |
| 3156 |
} |
| 3157 |
} |
| 3158 |
} |
| 3159 |
|
| 3160 |
# the subfield is not indexed, store it in __RAW__ index anyway |
| 3161 |
unless ($indexed) { |
| 3162 |
my $line = lc $subfield->[1]; |
| 3163 |
$line =~ s/-|\.|\?|,|;|!|'|\(|\)|\[|\]|{|}|"|<|>|&|\+|\*|\/|=|:|\r|\n/ /g; |
| 3164 |
|
| 3165 |
# ... and split in words |
| 3166 |
foreach ( split / /, $line ) { |
| 3167 |
next unless $_; # skip empty values (multiple spaces) |
| 3168 |
# if the entry is already here, improve weight |
| 3169 |
my $tmpstr = $result{'__RAW__'}->{"$_"} || ""; |
| 3170 |
if ( $tmpstr =~ /$biblionumber,\Q$title\E\-(\d+);/ ) { |
| 3171 |
my $weight = $1 + 1; |
| 3172 |
$result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; |
| 3173 |
$result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; |
| 3174 |
} else { |
| 3175 |
|
| 3176 |
# get the value if it exist in the nozebra table, otherwise, create it |
| 3177 |
$sth2->execute( $server, '__RAW__', $_ ); |
| 3178 |
my $existing_biblionumbers = $sth2->fetchrow; |
| 3179 |
|
| 3180 |
# it exists |
| 3181 |
if ($existing_biblionumbers) { |
| 3182 |
$result{'__RAW__'}->{"$_"} = $existing_biblionumbers; |
| 3183 |
my $weight = ( $1 ? $1 : 0 ) + 1; |
| 3184 |
$result{'__RAW__'}->{"$_"} =~ s/$biblionumber,\Q$title\E\-(\d+);//; |
| 3185 |
$result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-$weight;"; |
| 3186 |
|
| 3187 |
# create a new ligne for this entry |
| 3188 |
} else { |
| 3189 |
$dbh->do( 'INSERT INTO nozebra SET server=' . $dbh->quote($server) . ', indexname="__RAW__",value=' . $dbh->quote($_) ); |
| 3190 |
$result{'__RAW__'}->{"$_"} .= "$biblionumber,$title-1;"; |
| 3191 |
} |
| 3192 |
} |
| 3193 |
} |
| 3194 |
} |
| 3195 |
} |
| 3196 |
} |
| 3197 |
return %result; |
| 3198 |
} |
| 3199 |
|
| 3200 |
=head2 _find_value |
2847 |
=head2 _find_value |
| 3201 |
|
2848 |
|
| 3202 |
($indicators, $value) = _find_value($tag, $subfield, $record,$encoding); |
2849 |
($indicators, $value) = _find_value($tag, $subfield, $record,$encoding); |
|
Lines 3715-3721
sub ModBiblioMarc {
Link Here
|
| 3715 |
$sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?"); |
3362 |
$sth = $dbh->prepare("UPDATE biblioitems SET marc=?,marcxml=? WHERE biblionumber=?"); |
| 3716 |
$sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $biblionumber ); |
3363 |
$sth->execute( $record->as_usmarc(), $record->as_xml_record($encoding), $biblionumber ); |
| 3717 |
$sth->finish; |
3364 |
$sth->finish; |
| 3718 |
ModZebra( $biblionumber, "specialUpdate", "biblioserver", $oldRecord, $record ); |
3365 |
AddToIndexQueue( $biblionumber, "specialUpdate", "biblioserver", $oldRecord, $record ); |
| 3719 |
return $biblionumber; |
3366 |
return $biblionumber; |
| 3720 |
} |
3367 |
} |
| 3721 |
|
3368 |
|