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

(-)a/C4/Biblio.pm (-3 / +15 lines)
Lines 106-111 use Koha::SearchEngine; Link Here
106
use Koha::SearchEngine::Indexer;
106
use Koha::SearchEngine::Indexer;
107
use Koha::Libraries;
107
use Koha::Libraries;
108
use Koha::Util::MARC;
108
use Koha::Util::MARC;
109
use C4::Linker::Default;
109
110
110
use vars qw($debug $cgi_debug);
111
use vars qw($debug $cgi_debug);
111
112
Lines 461-467 sub BiblioAutoLink { Link Here
461
462
462
=head2 LinkBibHeadingsToAuthorities
463
=head2 LinkBibHeadingsToAuthorities
463
464
464
  my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink, $verbose]);
465
  my $num_headings_changed, %results = LinkBibHeadingsToAuthorities($linker, $marc, $frameworkcode, [$allowrelink, $verbose, $dont_auto_create]);
465
466
466
Links bib headings to authority records by checking
467
Links bib headings to authority records by checking
467
each authority-controlled field in the C<MARC::Record>
468
each authority-controlled field in the C<MARC::Record>
Lines 484-490 sub LinkBibHeadingsToAuthorities { Link Here
484
    my $frameworkcode = shift;
485
    my $frameworkcode = shift;
485
    my $allowrelink = shift;
486
    my $allowrelink = shift;
486
    my $verbose = shift;
487
    my $verbose = shift;
488
    my $dont_auto_create = shift;
487
    my %results;
489
    my %results;
490
    my $linker_default=C4::Linker::Default->new();
488
    if (!$bib) {
491
    if (!$bib) {
489
        carp 'LinkBibHeadingsToAuthorities called on undefined bib record';
492
        carp 'LinkBibHeadingsToAuthorities called on undefined bib record';
490
        return ( 0, {});
493
        return ( 0, {});
Lines 508-514 sub LinkBibHeadingsToAuthorities { Link Here
508
            next;
511
            next;
509
        }
512
        }
510
513
511
        my ( $authid, $fuzzy, $match_count ) = $linker->get_link($heading);
514
        my ( $authid, $fuzzy, $match_count, $status ) = $linker->get_link($heading);
515
        if(defined $status){
516
            if ($status eq 'NO_CONNECTION' or $status eq 'SERVER_NOT_FOUND') {
517
                return 0, { error => $status };
518
            }
519
            elsif($status eq 'Z3950_SEARCH_EMPTY'){
520
                ( $authid, $fuzzy, $status ) = $linker_default->get_link($heading);
521
            }
522
        }
512
        if ($authid) {
523
        if ($authid) {
513
            $results{ $fuzzy ? 'fuzzy' : 'linked' }
524
            $results{ $fuzzy ? 'fuzzy' : 'linked' }
514
              ->{ $heading->display_form() }++;
525
              ->{ $heading->display_form() }++;
Lines 530-538 sub LinkBibHeadingsToAuthorities { Link Here
530
                $results{'fuzzy'}->{ $heading->display_form() }++;
541
                $results{'fuzzy'}->{ $heading->display_form() }++;
531
                push(@{$results{'details'}}, { tag => $field->tag(), authid => $current_link, status => 'UNCHANGED'}) if $verbose;
542
                push(@{$results{'details'}}, { tag => $field->tag(), authid => $current_link, status => 'UNCHANGED'}) if $verbose;
532
            }
543
            }
533
            elsif ( C4::Context->preference('AutoCreateAuthorities') ) {
544
            elsif ( !$dont_auto_create && C4::Context->preference('AutoCreateAuthorities') ) {
534
                if ( _check_valid_auth_link( $current_link, $field ) ) {
545
                if ( _check_valid_auth_link( $current_link, $field ) ) {
535
                    $results{'linked'}->{ $heading->display_form() }++;
546
                    $results{'linked'}->{ $heading->display_form() }++;
547
                    push(@{$results{'details'}}, { tag => $field->tag(), authid => $authid, status => 'UNCHANGED'}) if $verbose;
536
                }
548
                }
537
                elsif ( !$match_count ) {
549
                elsif ( !$match_count ) {
538
                    my $authority_type = Koha::Authority::Types->find( $heading->auth_type() );
550
                    my $authority_type = Koha::Authority::Types->find( $heading->auth_type() );
(-)a/C4/Linker/Z3950Server.pm (+312 lines)
Line 0 Link Here
1
package C4::Linker::Z3950Server;
2
3
# Copyright 2012 Frédérick Capovilla - Libéo
4
#
5
# Koha is free software; you can redistribute it and/or modify it
6
# under the terms of the GNU General Public License as published by
7
# the Free Software Foundation; either version 3 of the License, or
8
# (at your option) any later version.
9
#
10
# Koha is distributed in the hope that it will be useful, but
11
# WITHOUT ANY WARRANTY; without even the implied warranty of
12
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
# GNU General Public License for more details.
14
#
15
# You should have received a copy of the GNU General Public License
16
# along with Koha; if not, see <http://www.gnu.org/licenses>.
17
18
use strict;
19
use warnings;
20
use Carp;
21
use MARC::Field;
22
use MARC::Record;
23
use C4::Context;
24
use C4::Heading;
25
use ZOOM; # For Z39.50 Searches
26
use C4::AuthoritiesMarc; # For Authority addition
27
use C4::Log; # logaction
28
29
use base qw(C4::Linker);
30
31
32
sub get_link {
33
    my $self        = shift;
34
    my $heading     = shift;
35
    my $behavior    = shift || 'default';
36
    my $search_form = $heading->search_form();
37
    my $authid;
38
    my $fuzzy = 0;
39
    my $status = '';
40
41
    if ( $self->{'cache'}->{$search_form}->{'cached'} ) {
42
        $authid = $self->{'cache'}->{$search_form}->{'authid'};
43
        $fuzzy  = $self->{'cache'}->{$search_form}->{'fuzzy'};
44
    }else {
45
        # Look for matching authorities on the Z39.50 server
46
        unless($self->{'local_first'}) {
47
            ($authid, undef, $status) = $self->getZ3950Authority($heading);
48
            if($status eq 'Z3950_SEARCH_ERROR' or
49
               $status eq 'Z3950_QUERY_ERROR' or
50
               $status eq 'NO_CONNECTION' or
51
               $status eq 'SERVER_NOT_FOUND') {
52
                return $authid, $fuzzy, $status;
53
            }
54
        }
55
        if(!$authid) {
56
            # look for matching authorities
57
            my $authorities = $heading->authorities(1);    # $skipmetadata = true
58
59
            if ( $behavior eq 'default' && $#{$authorities} >= 0 ) {
60
                $authid = $authorities->[0]->{'authid'};
61
            }elsif ( $behavior eq 'first' && $#{$authorities} >= 0 ) {
62
                $authid = $authorities->[0]->{'authid'};
63
                $fuzzy  = $#{$authorities} > 0;
64
            }
65
            elsif ( $behavior eq 'last' && $#{$authorities} >= 0 ) {
66
                $authid = $authorities->[ $#{$authorities} ]->{'authid'};
67
                $fuzzy  = $#{$authorities} > 0;
68
            }
69
70
            if ( !defined $authid && $self->{'broader_headings'} ) {
71
                my $field     = $heading->field();
72
                my @subfields = $field->subfields();
73
                if ( scalar @subfields > 1 ) {
74
                    pop @subfields;
75
                    $field->replace_with(
76
                        MARC::Field->new(
77
                            $field->tag,
78
                            $field->indicator(1),
79
                            $field->indicator(2),
80
                            map { $_[0] => $_[1] } @subfields
81
                        )
82
                    );
83
                    ( $authid, $fuzzy ) =
84
                      $self->get_link( C4::Heading->new_from_bib_field($field),
85
                        $behavior );
86
                }
87
            }
88
        }
89
        if($self->{'local_first'} && !$authid) {
90
            ($authid, undef, $status) = $self->getZ3950Authority($heading);
91
        }
92
93
        $self->{'cache'}->{$search_form}->{'cached'} = 1;
94
        $self->{'cache'}->{$search_form}->{'authid'} = $authid;
95
        $self->{'cache'}->{$search_form}->{'fuzzy'}  = $fuzzy;
96
    }
97
    return $self->SUPER::_handle_auth_limit($authid), $fuzzy, $status;
98
}
99
100
sub update_cache {
101
    my $self        = shift;
102
    my $heading     = shift;
103
    my $authid      = shift;
104
    my $search_form = $heading->search_form();
105
    my $fuzzy = 0;
106
107
    $self->{'cache'}->{$search_form}->{'cached'} = 1;
108
    $self->{'cache'}->{$search_form}->{'authid'} = $authid;
109
    $self->{'cache'}->{$search_form}->{'fuzzy'}  = $fuzzy;
110
}
111
sub flip_heading {
112
    my $self    = shift;
113
    my $heading = shift;
114
115
    # TODO: implement
116
}
117
118
119
=head1 getZ3950Authority
120
121
  ($authid, $record, $status) = $self->getZ3950Authority($heading);
122
123
  Do a Z39.50 search for the heading using the $conn ZOOM::Connection object and the $heading Heading.
124
  The column origincode is used to check for duplicates.
125
  FIXME: Use thesaurus in search? As of Koha 3.8, the community stopped using them.
126
127
  RETURNS :
128
  $authid = the ID of the local copy of the authority record that was found. undef if nothing was found.
129
  $record = the MARC record of the found authority.
130
  $status = A string with additional informations on the search status (Z3950_CREATED, Z3950_UPDATED, Z3950_QUERY_ERROR, Z3950_SEARCH_ERROR)
131
132
=cut
133
134
sub getZ3950Authority {
135
    my $self = shift;
136
    my $heading = shift;
137
138
    # Try to find a match on the Z39.50 server if LinkerZ3950Server is set
139
    if(C4::Context->preference('LinkerZ3950Server')) {
140
        unless($self->{'conn'}) {
141
            my $sth = C4::Context->dbh->prepare("select * from z3950servers where servername=?");
142
            $sth->execute(C4::Context->preference('LinkerZ3950Server'));
143
            my $server = $sth->fetchrow_hashref or undef;
144
            $sth->finish;
145
146
            if($server) {
147
                my $options = new ZOOM::Options();
148
                $options->option('cclfile' => C4::Context->ModZebrations('authorityserver')->{"ccl2rpn"});
149
                $options->option('elementSetName', 'F');
150
                $options->option('async', 0);
151
                $options->option('databaseName', $server->{db});
152
                $options->option('user',         $server->{userid}  ) if $server->{userid};
153
                $options->option('password',     $server->{password}) if $server->{password};
154
                $options->option('preferredRecordSyntax', $server->{syntax});
155
                $self->{'conn'} = create ZOOM::Connection($options);
156
                eval{ $self->{'conn'}->connect( $server->{host}, $server->{port} ) };
157
                if($@) {
158
                    return (undef, undef, 'NO_CONNECTION');
159
                }}
160
            else {
161
                return (undef, undef, 'SERVER_NOT_FOUND');
162
            }
163
        }
164
    }
165
    else {
166
        return;
167
    }
168
    my $query =qq(Match-Heading,do-not-truncate,ext="$heading->{'search_form'}");
169
    my $zquery = eval{ new ZOOM::Query::CCL2RPN($query, $self->{'conn'}) };
170
    if($@) {
171
        warn $query . "\n" . $@;
172
        return (undef, undef, 'Z3950_QUERY_ERROR');
173
    }
174
175
    # Try to send the search query to the server.
176
    my $rs = eval{ $self->{'conn'}->search($zquery) };
177
    if($@){
178
        warn $query . "\n" . $@;
179
        return (undef, undef, 'Z3950_SEARCH_EMPTY');
180
    }
181
182
    # If authorities are found, select the first valid one for addition in the local authority table.
183
    my $record;
184
    if($rs->size() != 0) {
185
        $record = MARC::Record::new_from_usmarc($rs->record(0)->raw());
186
    }else{
187
        return (undef, undef, 'Z3950_SEARCH_ERROR');
188
    }
189
    $rs->destroy();
190
    $zquery->destroy();
191
192
    # If a valid authority was found, add it in the local authority database.
193
    if($record) {
194
        my $dbh=C4::Context->dbh;
195
196
        my $authtypecode = C4::AuthoritiesMarc::GuessAuthTypeCode($record);
197
        my $authId;
198
199
        # Use the control number to prevent the creation of duplicate authorities.
200
        my $controlNumber = $record->field('970')->subfield('0');
201
        my $sthExist=$dbh->prepare("SELECT authid FROM auth_header WHERE origincode =?");
202
        $sthExist->execute($controlNumber) or die $sthExist->errstr;
203
        ($authId) = $sthExist->fetchrow;
204
        $sthExist->finish;
205
206
        #------------------------------------------------------------------------------------------
207
        # Corrections and verifications before insertion
208
        my $format;
209
        my $leader='     nz  a22     o  4500';# Leader for incomplete MARC21 record
210
211
        if (uc(C4::Context->preference('marcflavour')) eq 'UNIMARC') {
212
            $format= 'UNIMARCAUTH';
213
        }
214
        else {
215
            $format= 'MARC21';
216
        }
217
218
        if ($format eq "MARC21") {
219
            if (!$record->leader) {
220
                $record->leader($leader);
221
            }
222
            if (!$record->field('003')) {
223
                $record->insert_fields_ordered(
224
                        MARC::Field->new('003',C4::Context->preference('MARCOrgCode'))
225
                        );
226
            }
227
            my $time=POSIX::strftime("%Y%m%d%H%M%S",localtime);
228
            if (!$record->field('005')) {
229
                $record->insert_fields_ordered(
230
                        MARC::Field->new('005',$time.".0")
231
                        );
232
            }
233
            my $date=POSIX::strftime("%y%m%d",localtime);
234
            if (!$record->field('008')) {
235
                # Get a valid default value for field 008
236
                my $default_008 = C4::Context->preference('MARCAuthorityControlField008');
237
                if(!$default_008 or length($default_008)<34) {
238
                    $default_008 = '|| aca||aabn           | a|a     d';
239
            }
240
            else {
241
                    $default_008 = substr($default_008,0,34);
242
                }
243
                $record->insert_fields_ordered( MARC::Field->new('008',$date.$default_008) );
244
            }
245
            if (!$record->field('040')) {
246
                $record->insert_fields_ordered(
247
                    MARC::Field->new('040','','',
248
                        'a' => C4::Context->preference('MARCOrgCode'),
249
                        'c' => C4::Context->preference('MARCOrgCode')
250
                    )
251
                );
252
            }
253
        }
254
        if ($format eq "UNIMARCAUTH") {
255
            $record->leader("     nx  j22             ") unless ($record->leader());
256
            my $date=POSIX::strftime("%Y%m%d",localtime);
257
            if (my $string=$record->subfield('100',"a")){
258
                $string=~s/fre50/frey50/;
259
                $record->field('100')->update('a'=>$string);
260
            }
261
            elsif ($record->field('100')){
262
                $record->field('100')->update('a'=>$date."afrey50      ba0");
263
            } else {
264
                $record->append_fields(
265
                    MARC::Field->new('100',' ',' '
266
                        ,'a'=>$date."afrey50      ba0")
267
                );
268
            }
269
        }
270
        my ($auth_type_tag, $auth_type_subfield) = C4::AuthoritiesMarc::get_auth_type_location($authtypecode);
271
        if (!$authId and $format eq "MARC21") {
272
        # only need to do this fix when modifying an existing authority
273
            C4::AuthoritiesMarc::MARC21::fix_marc21_auth_type_location($record, $auth_type_tag, $auth_type_subfield);
274
        }
275
        if (my $field=$record->field($auth_type_tag)){
276
            $field->update($auth_type_subfield=>$authtypecode);
277
        }
278
        else {
279
            $record->add_fields($auth_type_tag,'','', $auth_type_subfield=>$authtypecode);
280
        }
281
        #------------------------------------------------------------------------------------------
282
        if ($authId) {
283
            my $oldRecord=C4::AuthoritiesMarc::GetAuthority($authId);
284
285
            my $sth=$dbh->prepare("UPDATE auth_header SET authtypecode=?,marc=?,marcxml=? WHERE origincode =?");
286
            eval { $sth->execute($authtypecode,$record->as_usmarc,$record->as_xml_record($format),$controlNumber) or die $sth->errstr; };
287
            $sth->finish;
288
            warn "Problem with authority $controlNumber : Cannot update" if $@;
289
            $dbh->commit unless $dbh->{AutoCommit};
290
            return if $@;
291
292
            C4::Biblio::ModZebra($authId,'linkerUpdate',"authorityserver",$oldRecord,$record);
293
            return ($authId, $record, 'Z3950_UPDATED');
294
        }
295
        else {
296
            my $sth=$dbh->prepare("INSERT INTO auth_header (datecreated,authtypecode,marc,marcxml,origincode) VALUES (NOW(),?,?,?,?)");
297
            eval { $sth->execute($authtypecode,$record->as_usmarc,$record->as_xml_record($format),$controlNumber) or die $sth->errstr; };
298
            $sth->finish;
299
            warn "Problem with authority $controlNumber : Cannot insert" if $@;
300
            my $id = $dbh->{'mysql_insertid'};
301
            $dbh->commit unless $dbh->{AutoCommit};
302
            return if $@;
303
304
            logaction( "AUTHORITIES", "ADD", $id, "authority" ) if C4::Context->preference("AuthoritiesLog");
305
            C4::Biblio::ModZebra($id,'linkerUpdate',"authorityserver",undef,$record);
306
            return ($id, $record, 'Z3950_CREATED');
307
        }
308
    }
309
    return ;
310
}
311
312
1;
(-)a/installer/data/mysql/atomicupdate/Bug11300_LinkerZ3950Server_syspef.sql (+2 lines)
Line 0 Link Here
1
INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, `type` ) VALUES
2
('LinkerZ3950Server','',NULL,'Import authorities from this Z39.50 server when searching for authority links with the Z39.50 Server linker module','free');
(-)a/installer/data/mysql/mandatory/sysprefs.sql (+1 lines)
Lines 300-305 INSERT INTO systempreferences ( `variable`, `value`, `options`, `explanation`, ` Link Here
300
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
300
('LinkerModule','Default','Default|FirstMatch|LastMatch','Chooses which linker module to use (see documentation).','Choice'),
301
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
301
('LinkerOptions','','','A pipe-separated list of options for the linker.','free'),
302
('LinkerRelink','1',NULL,'If ON the authority linker will relink headings that have previously been linked every time it runs.','YesNo'),
302
('LinkerRelink','1',NULL,'If ON the authority linker will relink headings that have previously been linked every time it runs.','YesNo'),
303
('LinkerZ3950Server','',NULL,'Import authorities from this Z39.50 server when searching for authority links with the Z39.50 Server linker module',''),
303
('LoadSearchHistoryToTheFirstLoggedUser', '1', NULL, 'If ON, the next user will automatically get the last searches in his history', 'YesNo'),
304
('LoadSearchHistoryToTheFirstLoggedUser', '1', NULL, 'If ON, the next user will automatically get the last searches in his history', 'YesNo'),
304
('LocalCoverImages','0','1','Display local cover images on intranet details pages.','YesNo'),
305
('LocalCoverImages','0','1','Display local cover images on intranet details pages.','YesNo'),
305
('LocalHoldsPriority',  '0', NULL,  'Enables the LocalHoldsPriority feature',  'YesNo'),
306
('LocalHoldsPriority',  '0', NULL,  'Enables the LocalHoldsPriority feature',  'YesNo'),
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/preferences/authorities.pref (+5 lines)
Lines 73-78 Authorities: Link Here
73
                  Default: default
73
                  Default: default
74
                  FirstMatch: "first match"
74
                  FirstMatch: "first match"
75
                  LastMatch: "last match"
75
                  LastMatch: "last match"
76
                  Z3950Server: "Z39.50 Server"
76
            - linker module for matching headings to authority records.
77
            - linker module for matching headings to authority records.
77
        -
78
        -
78
            - "Set the following options for the authority linker:"
79
            - "Set the following options for the authority linker:"
Lines 100-102 Authorities: Link Here
100
                  yes: Do
101
                  yes: Do
101
                  no: "Don't"
102
                  no: "Don't"
102
            - automatically relink headings that have previously been linked when saving records in the cataloging module.
103
            - automatically relink headings that have previously been linked when saving records in the cataloging module.
104
        -
105
            - pref: LinkerZ3950Server
106
            - class: multi
107
            - Import authorities from this Z39.50 server when searching for authority links with the Z39.50 Server linker module :
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/addbiblio.tt (-2 / +19 lines)
Lines 285-290 function updateHeadingLinks(links) { Link Here
285
        var message = '';
285
        var message = '';
286
        var field_class = 'no_matching_authority_field';
286
        var field_class = 'no_matching_authority_field';
287
        switch(heading.status) {
287
        switch(heading.status) {
288
            case 'Z3950_CREATED':
289
                image = 'approve.gif';
290
                message = _("A matching authority record was found on the Z39.50 server and was imported locally.");
291
                field_color = '#99FF99';
292
                break;
293
            case 'Z3950_UPDATED':
294
                image = 'approve.gif';
295
                message = _("A matching authority record was found on the Z39.50 server and a local authority was updated.");
296
                field_color = '#99FF99';
297
                break;
288
            case 'LOCAL_FOUND':
298
            case 'LOCAL_FOUND':
289
                image = '<i class="fa fa-check matching_authority"</i> ';
299
                image = '<i class="fa fa-check matching_authority"</i> ';
290
                message = _("A matching authority was found in the local database.");
300
                message = _("A matching authority was found in the local database.");
Lines 338-344 function AutomaticLinker() { Link Here
338
    $('#f').find('.tag').each(function() {
348
    $('#f').find('.tag').each(function() {
339
        var empty = true;
349
        var empty = true;
340
        $(this).find('.input_marceditor').each(function() {
350
        $(this).find('.input_marceditor').each(function() {
341
            if($(this).val() != '') {
351
            if(this.value != '') {
342
                empty = false;
352
                empty = false;
343
                return false;
353
                return false;
344
            }
354
            }
Lines 350-357 function AutomaticLinker() { Link Here
350
360
351
    // Get all the form values to post via AJAX
361
    // Get all the form values to post via AJAX
352
    var form_data = {};
362
    var form_data = {};
363
    var i=0;
353
    $('#f').find(':input').each(function(){
364
    $('#f').find(':input').each(function(){
354
        form_data[this.name] = $(this).val();
365
       form_data[this.name] = this.value;
355
    });
366
    });
356
    delete form_data[''];
367
    delete form_data[''];
357
368
Lines 369-374 function AutomaticLinker() { Link Here
369
                case 'UNAUTHORIZED':
380
                case 'UNAUTHORIZED':
370
                    alert(_("Error : You do not have the permissions necessary to use this functionality."));
381
                    alert(_("Error : You do not have the permissions necessary to use this functionality."));
371
                    break;
382
                    break;
383
                case 'SERVER_NOT_FOUND':
384
                    alert(_("Error : The Z39.50 server configured in the 'LinkerZ3950Server' preference was not found in the Z39.50 servers list."));
385
                    break;
386
                case 'NO_CONNECTION':
387
                    alert(_("Error : Could not connect to the Z39.50 server."));
388
                    break;
372
                case 'OK':
389
                case 'OK':
373
                    updateHeadingLinks(json.links);
390
                    updateHeadingLinks(json.links);
374
                    break;
391
                    break;
(-)a/svc/cataloguing/automatic_linker.pl (-9 / +9 lines)
Lines 33-49 my %cookies = CGI::Cookie->fetch; Link Here
33
my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID');
33
my $sessid = $cookies{'CGISESSID'}->value || $input->param('CGISESSID');
34
my ( $auth_status, $auth_sessid ) =
34
my ( $auth_status, $auth_sessid ) =
35
  C4::Auth::check_cookie_auth( $sessid, { editauthorities => 1, editcatalogue => 1 } );
35
  C4::Auth::check_cookie_auth( $sessid, { editauthorities => 1, editcatalogue => 1 } );
36
if ( $auth_status ne "ok" ) {
37
    print to_json( { status => 'UNAUTHORIZED' } );
38
    exit 0;
39
}
40
36
41
# Link the biblio headings to authorities and return a json containing the status of all the links.
37
# Link the biblio headings to authorities and return a json containing the status of all the links.
42
# Example : {"status":"OK","links":[{"authid":"123","status":"LINK_CHANGED","tag":"650"}]}
38
# Example : {"status":"OK","links":[{"authid":"123","status":"LINK_CHANGED","tag":"650"}]}
43
#
39
#
44
# tag = the tag number of the field
40
# tag = the tag number of the field
45
# authid = the value of the $9 subfield for this tag
41
# authid = the value of the $9 subfield for this tag
46
# status = The status of the link (LOCAL_FOUND, NONE_FOUND, MULTIPLE_MATCH, UNCHANGED, CREATED)
42
# status = The status of the link (LOCAL_FOUND, NONE_FOUND, MULTIPLE_MATCH, UNCHANGED, CREATED,3950_CREATED, Z3950_UPDATED)
47
43
48
my $json;
44
my $json;
49
45
Lines 54-61 my ( $headings_changed, $results ) = BiblioAutoLink ( Link Here
54
    $input->param('frameworkcode'),
50
    $input->param('frameworkcode'),
55
    1
51
    1
56
);
52
);
57
53
if(defined $results->{error}) {
58
$json->{status} = 'OK';
54
    $json->{links} = $results->{details} || '';
59
$json->{links} = $results->{details} || '';
55
    $json->{links} = $results->{details} || '';
56
}
57
else{
58
    $json->{status} = 'OK';
59
    $json->{links} = $results->{details} || '';
60
}
60
61
61
print to_json($json);
62
print to_json($json);
62
- 

Return to bug 11300