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

(-)a/misc/bin/connexion_import_daemon.pl (-23 / +34 lines)
Lines 30-36 GetOptions( Link Here
30
    'help|?'        => \$help,
30
    'help|?'        => \$help,
31
);
31
);
32
32
33
if($help || !$config){
33
if ( $help || !$config ) {
34
    print <<EOF
34
    print <<EOF
35
$0 --config=my.conf
35
$0 --config=my.conf
36
Parameters :
36
Parameters :
Lines 55-65 Config file format: Link Here
55
  password - koha user password, authentication
55
  password - koha user password, authentication
56
  match          - marc_matchers.code: ISBN or ISSN
56
  match          - marc_matchers.code: ISBN or ISSN
57
  overlay_action - import_batches.overlay_action: replace, create_new or ignore
57
  overlay_action - import_batches.overlay_action: replace, create_new or ignore
58
  overlay_framework - if overlaying records - move to a new framework, if blank will use default
59
                      if not included it will use the framework of the existing record
58
  nomatch_action - import_batches.nomatch_action: create_new or ignore
60
  nomatch_action - import_batches.nomatch_action: create_new or ignore
59
  item_action    - import_batches.item_action:    always_add,
61
  item_action    - import_batches.item_action:    always_add,
60
                      add_only_for_matches, add_only_for_new or ignore
62
                      add_only_for_matches, add_only_for_new or ignore
61
  import_mode    - stage or direct
63
  import_mode    - stage or direct
62
  framework      - to be used if import_mode is direct
64
  framework      - to be used if import_mode is direct, if blank, will use default
63
  connexion_user      - User sent from connexion client
65
  connexion_user      - User sent from connexion client
64
  connexion_password  - Password sent from connexion client
66
  connexion_password  - Password sent from connexion client
65
67
Lines 69-75 Config file format: Link Here
69
  All process related parameters (all but ip and port) have default values as
71
  All process related parameters (all but ip and port) have default values as
70
  per Koha import process.
72
  per Koha import process.
71
EOF
73
EOF
72
;
74
        ;
73
    exit;
75
    exit;
74
}
76
}
75
77
Lines 353-381 sub handle_request { Link Here
353
    }
355
    }
354
356
355
    my $base_url = $self->{koha};
357
    my $base_url = $self->{koha};
356
    my $resp = $ua->post( $base_url.IMPORT_SVC_URI,
358
    my $resp = $ua->post(
357
                              {'nomatch_action' => $self->{params}->{nomatch_action},
359
        $base_url . IMPORT_SVC_URI,
358
                               'overlay_action' => $self->{params}->{overlay_action},
360
        {
359
                               'match'          => $self->{params}->{match},
361
            'nomatch_action'    => $self->{params}->{nomatch_action},
360
                               'import_mode'    => $self->{params}->{import_mode},
362
            'overlay_action'    => $self->{params}->{overlay_action},
361
                               'framework'      => $self->{params}->{framework},
363
            'match'             => $self->{params}->{match},
362
                               'item_action'    => $self->{params}->{item_action},
364
            'import_mode'       => $self->{params}->{import_mode},
363
                               'xml'            => $data});
365
            'framework'         => $self->{params}->{framework},
366
            'overlay_framework' => $self->{params}->{overlay_framework},
367
            'item_action'       => $self->{params}->{item_action},
368
            'xml'               => $data
369
        }
370
    );
364
371
365
    my $status = $resp->code;
372
    my $status = $resp->code;
366
    if ($status == HTTP_UNAUTHORIZED || $status == HTTP_FORBIDDEN) {
373
    if ( $status == HTTP_UNAUTHORIZED || $status == HTTP_FORBIDDEN ) {
367
        my $user = $self->{user};
374
        my $user     = $self->{user};
368
        my $password = $self->{password};
375
        my $password = $self->{password};
369
        $resp = $ua->post( $base_url.AUTH_URI, { userid => $user, password => $password } );
376
        $resp = $ua->post( $base_url . AUTH_URI, { userid => $user, password => $password } );
370
        $resp = $ua->post( $base_url.IMPORT_SVC_URI,
377
        $resp = $ua->post(
371
                              {'nomatch_action' => $self->{params}->{nomatch_action},
378
            $base_url . IMPORT_SVC_URI,
372
                               'overlay_action' => $self->{params}->{overlay_action},
379
            {
373
                               'match'          => $self->{params}->{match},
380
                'nomatch_action'    => $self->{params}->{nomatch_action},
374
                               'import_mode'    => $self->{params}->{import_mode},
381
                'overlay_action'    => $self->{params}->{overlay_action},
375
                               'framework'      => $self->{params}->{framework},
382
                'match'             => $self->{params}->{match},
376
                               'item_action'    => $self->{params}->{item_action},
383
                'import_mode'       => $self->{params}->{import_mode},
377
                               'xml'            => $data})
384
                'framework'         => $self->{params}->{framework},
378
          if $resp->is_success;
385
                'overlay_framework' => $self->{params}->{overlay_framework},
386
                'item_action'       => $self->{params}->{item_action},
387
                'xml'               => $data
388
            }
389
        ) if $resp->is_success;
379
    }
390
    }
380
    unless ($resp->is_success) {
391
    unless ($resp->is_success) {
381
        $self->log("Unsuccessful request", $resp->request->as_string, $resp->as_string);
392
        $self->log("Unsuccessful request", $resp->request->as_string, $resp->as_string);
(-)a/misc/cronjobs/import_webservice_batch.pl (-17 / +63 lines)
Lines 22-52 use warnings; Link Here
22
use utf8;
22
use utf8;
23
23
24
use Getopt::Long qw( GetOptions );
24
use Getopt::Long qw( GetOptions );
25
use Pod::Usage   qw( pod2usage );
26
25
use Koha::Script -cron;
27
use Koha::Script -cron;
26
use C4::ImportBatch qw( BatchCommitRecords GetStagedWebserviceBatches );
28
use C4::ImportBatch qw( BatchCommitRecords GetStagedWebserviceBatches );
27
29
28
my ($help, $framework);
30
=head1 NAME
31
32
import_webservice_batch.pl - Find batches staged by webservice and import them.
33
34
=head1 SYNOPSIS
35
36
import_webservice_batch.pl [--framework=<frameworkcode> --overlay_framework=<frameworkcode>]
37
38
Options:
39
40
   --help                   brief help message
41
   --framework              specify frameworkcode for new records
42
   --overlay_framework      specify frameworkcode when overlaying records
43
44
=head1 OPTIONS
45
46
=over 8
47
48
=item B<--help>
49
50
Print a brief help message and exits.
51
52
=item B<--framework>
53
54
Specify frameworkcode for new records. Uses default if not specified.
55
56
=item B<--overlay_framework>
57
58
Specify frameworkcode when overlaying records.  Current framework is preserved if not specified.
59
60
=back
61
62
=head1 DESCRIPTION
63
64
This script is designed to import batches staged by webservices (e.g. connexion).
65
66
=head1 USAGE EXAMPLES
67
68
C<import_webservice_batch.pl> - Imports the batches using default framework
69
70
C<import_webservice_batch.pl> -f=<frameworkcode> Imports the batches adding new records into specified framework, not adjusting framework of matched records
71
72
C<import_webservice_batch.pl> -f=<frameworkcode> -o=<frameworkcode> Imports the batches adding new records into specified framework, overlaying matched records to specified framework
73
74
=cut
75
76
my ( $help, $man, $framework, $overlay_framework );
29
77
30
GetOptions(
78
GetOptions(
31
    'help|?'         => \$help,
79
    'help|?'                => \$help,
32
    'framework=s'    => \$framework,
80
    'man'                   => \$man,
81
    'f|framework=s'         => \$framework,
82
    'o|overlay_framework=s' => \$overlay_framework,
33
);
83
);
34
84
35
if($help){
85
pod2usage(1) if $help;
36
    print <<EOF
86
37
$0 --framework=myframework
87
pod2usage( -verbose => 2 ) if $man;
38
Parameters :
39
--help|? This message
40
--framework default ""
41
EOF
42
;
43
    exit;
44
}
45
88
46
my $batch_ids = GetStagedWebserviceBatches() or exit;
89
my $batch_ids = GetStagedWebserviceBatches() or exit;
47
90
48
$framework ||= '';
91
$framework ||= '';
49
BatchCommitRecords({
92
BatchCommitRecords(
50
    batch_id  => $_,
93
    {
51
    framework => $framework
94
        batch_id          => $_,
52
}) foreach @$batch_ids;
95
        framework         => $framework,
96
        overlay_framework => $overlay_framework,
97
    }
98
) foreach @$batch_ids;
(-)a/svc/import_bib (-7 / +10 lines)
Lines 58-65 sub import_bib { Link Here
58
58
59
    my $result = {};
59
    my $result = {};
60
60
61
    my $import_mode = delete $params->{import_mode} || '';
61
    my $import_mode       = delete $params->{import_mode} || '';
62
    my $framework   = delete $params->{framework}   || '';
62
    my $framework         = delete $params->{framework}   || '';
63
    my $overlay_framework = $params->{overlay_framework};
63
64
64
    if (my $matcher_code = delete $params->{match}) {
65
    if (my $matcher_code = delete $params->{match}) {
65
        $params->{matcher_id} = C4::Matcher::GetMatcherId($matcher_code);
66
        $params->{matcher_id} = C4::Matcher::GetMatcherId($matcher_code);
Lines 92-101 sub import_bib { Link Here
92
    my $number_of_matches =  BatchFindDuplicates($batch_id, $matcher);
93
    my $number_of_matches =  BatchFindDuplicates($batch_id, $matcher);
93
94
94
    # XXX we are ignoring the result of this;
95
    # XXX we are ignoring the result of this;
95
    BatchCommitRecords({
96
    BatchCommitRecords(
96
        batch_id  => $batch_id,
97
        {
97
        framework => $framework
98
            batch_id          => $batch_id,
98
    }) if lc($import_mode) eq 'direct';
99
            framework         => $framework,
100
            overlay_framework => $overlay_framework
101
        }
102
    ) if lc($import_mode) eq 'direct';
99
103
100
    my $dbh = C4::Context->dbh();
104
    my $dbh = C4::Context->dbh();
101
    my $sth = $dbh->prepare("SELECT matched_biblionumber FROM import_biblios WHERE import_record_id =?");
105
    my $sth = $dbh->prepare("SELECT matched_biblionumber FROM import_biblios WHERE import_record_id =?");
102
- 

Return to bug 33418