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

(-)a/C4/ImportBatch.pm (-1 / +2 lines)
Lines 162-168 sub GetWebserviceBatchId { Link Here
162
    my $dbh = C4::Context->dbh;
162
    my $dbh = C4::Context->dbh;
163
    my $sql = $WEBSERVICE_BASE_QRY;
163
    my $sql = $WEBSERVICE_BASE_QRY;
164
    my @args;
164
    my @args;
165
    foreach my $field (qw(matcher_id overlay_action nomatch_action item_action)) {
165
    $sql .= " AND file_name IS NULL" unless exists $params->{file_name};
166
    foreach my $field (qw(matcher_id overlay_action nomatch_action item_action file_name)) {
166
        if ( my $val = $params->{$field} ) {
167
        if ( my $val = $params->{$field} ) {
167
            $sql .= " AND $field = ?";
168
            $sql .= " AND $field = ?";
168
            push @args, $val;
169
            push @args, $val;
(-)a/misc/bin/connexion_import_daemon.pl (-2 / +44 lines)
Lines 20-25 Link Here
20
use strict;
20
use strict;
21
use warnings;
21
use warnings;
22
22
23
use POSIX qw( strftime );
23
use Getopt::Long qw( GetOptions );
24
use Getopt::Long qw( GetOptions );
24
25
25
my ( $help, $config, $daemon );
26
my ( $help, $config, $daemon );
Lines 143-148 Config file format: Link Here
143
          show up in all catalog searches as soon as the indexing catches up.
144
          show up in all catalog searches as soon as the indexing catches up.
144
      Defaults to `stage`.
145
      Defaults to `stage`.
145
146
147
    import_file_name
148
      Filename string used to distinguish batches in staff client. Supports 2
149
      placeholders:
150
        {TS}
151
          A YYYYMMDDHHmmss timestamp
152
        {0}
153
          A simple incremented count modulo the number of 0's within the
154
          braces, up to 5. For example, {0} = 1 through 9, {00} = 01 through
155
          99, etc. up to 99999.
156
      If no placeholders are used the named batch will be used for all imports
157
      until imported or removed, if any placeholder is used then every import
158
      will be a separate batch. If not supplied the default `(webservice)`
159
      batch will be used.
160
146
    match
161
    match
147
      Which code to use for matching MARC records when deciding whether to add
162
      Which code to use for matching MARC records when deciding whether to add
148
      or replace a record.
163
      or replace a record.
Lines 220-226 Explanation of `import_mode`: Link Here
220
  batch immediately.
235
  batch immediately.
221
- When using `stage`, each request will cause records to be added to an
236
- When using `stage`, each request will cause records to be added to an
222
  existing batch.
237
  existing batch.
223
- The batch name is always `(webservice)`.
238
- The batch name is `(webservice)` unless specified with import_file_name.
224
- If you change `import_mode` from `stage` to `direct` after some records
239
- If you change `import_mode` from `stage` to `direct` after some records
225
  have already been staged, the next request will cause all records in that
240
  have already been staged, the next request will cause all records in that
226
  batch to be imported into the catalog, not just the records from the latest
241
  batch to be imported into the catalog, not just the records from the latest
Lines 332-343 exit; Link Here
332
        $self->{port} = delete( $param{port} )
347
        $self->{port} = delete( $param{port} )
333
            or die "Port not specified";
348
            or die "Port not specified";
334
349
350
        $self->{import_fn_count} = 1;
351
        $self->{import_fn_len} = 1;
352
        $self->{import_file_name} = delete( $param{import_file_name} );
353
        if ( $self->{import_file_name} ) {
354
            if ( $self->{import_file_name} =~ /\{(0+)\}/ ) {
355
                my $len = int(length($1));
356
                if ( $len lt 1 || $len gt 5 ) { $len = 1; }
357
                $self->{import_fn_len} = $len;
358
            }
359
        }
360
335
        $self->{debug} = delete( $param{debug} );
361
        $self->{debug} = delete( $param{debug} );
336
362
337
        my $log_fh;
363
        my $log_fh;
338
        close $self->{log_fh} if $self->{log_fh};
364
        close $self->{log_fh} if $self->{log_fh};
339
        if ( my $logfile = delete $param{log} ) {
365
        if ( my $logfile = delete $param{log} ) {
340
            open( $log_fh, '>>', $logfile ) or die "Cannot open $logfile for write: $!";
366
            open( $log_fh, '>>', $logfile ) or die "Cannot open $logfile for write: $!";
367
            $log_fh->autoflush(1);
341
        } else {
368
        } else {
342
            $log_fh = \*STDERR;
369
            $log_fh = \*STDERR;
343
        }
370
        }
Lines 543-548 exit; Link Here
543
            return $self->error_response("Unauthorized request");
570
            return $self->error_response("Unauthorized request");
544
        }
571
        }
545
572
573
        my $import_fname = "";
574
        if ( $self->{import_file_name} ) {
575
            my $ts = strftime("%Y%m%d%H%M%S", localtime);
576
            my $pad = $self->{import_fn_len};
577
            $import_fname = $self->{import_file_name};
578
579
            $import_fname =~ s/\{TS\}/$ts/g;
580
            $import_fname =~ s/\{0+\}/sprintf("%0${pad}u", $self->{import_fn_count})/eg;
581
582
            $self->{import_fn_count} = $self->{import_fn_count} + 1;
583
            $self->{import_fn_count} = $self->{import_fn_count} % ($self->{import_fn_len} ** 10);
584
        }
585
586
587
546
        my $ua;
588
        my $ua;
547
        if ( $self->{user} ) {
589
        if ( $self->{user} ) {
548
            $user     = $self->{user};
590
            $user     = $self->{user};
Lines 561-566 exit; Link Here
561
            'framework'         => $self->{params}->{framework},
603
            'framework'         => $self->{params}->{framework},
562
            'overlay_framework' => $self->{params}->{overlay_framework},
604
            'overlay_framework' => $self->{params}->{overlay_framework},
563
            'item_action'       => $self->{params}->{item_action},
605
            'item_action'       => $self->{params}->{item_action},
606
            'file_name'         => $import_fname,
564
            'xml'               => $data
607
            'xml'               => $data
565
        };
608
        };
566
609
567
- 

Return to bug 42059