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

(-)a/Koha/BackgroundJob/ImportKBARTFile.pm (-7 / +9 lines)
Lines 76-84 sub process { Link Here
76
    };
76
    };
77
77
78
    try {
78
    try {
79
        my $column_headers = $args->{column_headers};
79
        my $column_headers       = $args->{column_headers};
80
        my $rows           = $args->{rows};
80
        my $rows                 = $args->{rows};
81
        my $package_id     = $args->{package_id};
81
        my $package_id           = $args->{package_id};
82
        my $create_linked_biblio = $args->{create_linked_biblio};
82
83
83
        if ( scalar( @{$rows} ) == 0 ) {
84
        if ( scalar( @{$rows} ) == 0 ) {
84
            push @messages, {
85
            push @messages, {
Lines 118-124 sub process { Link Here
118
                        };
119
                        };
119
                        $failed_imports++;
120
                        $failed_imports++;
120
                    } else {
121
                    } else {
121
                        my $imported_title = Koha::ERM::EHoldings::Title->new($formatted_title)->store;
122
                        my $imported_title = Koha::ERM::EHoldings::Title->new($formatted_title)
123
                            ->store( { create_linked_biblio => $create_linked_biblio } );
122
                        create_linked_resource(
124
                        create_linked_resource(
123
                            {
125
                            {
124
                                title      => $imported_title,
126
                                title      => $imported_title,
Lines 216-222 sub read_file { Link Here
216
218
217
    my $file_content = defined( $file->{file_content} ) ? decode_base64( $file->{file_content} ) : "";
219
    my $file_content = defined( $file->{file_content} ) ? decode_base64( $file->{file_content} ) : "";
218
    my $delimiter    = $file->{filename} =~ /\.tsv$/    ? "\t"                                   : ",";
220
    my $delimiter    = $file->{filename} =~ /\.tsv$/    ? "\t"                                   : ",";
219
    my $quote_char   = $file->{filename} =~ /\.tsv$/    ? ""                                     : '"';
221
    my $quote_char   = $file->{filename} =~ /\.tsv$/    ? "\""                                   : "\"";
220
222
221
    open my $fh, "<", \$file_content or die;
223
    open my $fh, "<", \$file_content or die;
222
    my $csv = Text::CSV_XS->new(
224
    my $csv = Text::CSV_XS->new(
Lines 422-431 sub is_file_too_large { Link Here
422
    };
424
    };
423
}
425
}
424
426
425
=head3
427
=head3 rescue_EBSCO_files
426
428
427
EBSCO have an incorrect spelling of "preceding_publication_title_id" in all of their KBART files ("preceeding" instead of "preceding").
429
EBSCO have an incorrect spelling of "preceding_publication_title_id" in all of their KBART files ("preceeding" instead of "preceding").
428
This is very annoying because it means all of their KBART files fail to import using the current methodology.
430
This means all of their KBART files fail to import using the current methodology.
429
There is no simple way of finding out who the vendor is before importing so all KBART files from any vendor are going to have to be checked for this spelling and corrected.
431
There is no simple way of finding out who the vendor is before importing so all KBART files from any vendor are going to have to be checked for this spelling and corrected.
430
432
431
=cut
433
=cut
(-)a/Koha/REST/V1/ERM/EHoldings/Titles/Local.pm (-9 / +10 lines)
Lines 272-280 sub import_from_list { Link Here
272
sub import_from_kbart_file {
272
sub import_from_kbart_file {
273
    my $c = shift or return;
273
    my $c = shift or return;
274
274
275
    my $import_data = $c->req->json;
275
    my $import_data          = $c->req->json;
276
    my $file        = $import_data->{file};
276
    my $file                 = $import_data->{file};
277
    my $package_id  = $import_data->{package_id};
277
    my $package_id           = $import_data->{package_id};
278
    my $create_linked_biblio = $import_data->{create_linked_biblio};
278
279
279
    return try {
280
    return try {
280
        my @job_ids;
281
        my @job_ids;
Lines 306-315 sub import_from_kbart_file { Link Here
306
        ) if scalar(@invalid_columns) > 0;
307
        ) if scalar(@invalid_columns) > 0;
307
308
308
        my $params = {
309
        my $params = {
309
            column_headers => $column_headers,
310
            column_headers       => $column_headers,
310
            rows           => $rows,
311
            rows                 => $rows,
311
            package_id     => $package_id,
312
            package_id           => $package_id,
312
            file_name      => $file->{filename}
313
            file_name            => $file->{filename},
314
            create_linked_biblio => $create_linked_biblio
313
        };
315
        };
314
        my $outcome = Koha::BackgroundJob::ImportKBARTFile::is_file_too_large( $params, $max_allowed_packet );
316
        my $outcome = Koha::BackgroundJob::ImportKBARTFile::is_file_too_large( $params, $max_allowed_packet );
315
317
Lines 347-351 sub import_from_kbart_file { Link Here
347
    };
349
    };
348
}
350
}
349
351
350
352
1;
351
1;
(-)a/api/v1/swagger/paths/erm_eholdings_titles.yaml (+2 lines)
Lines 516-521 Link Here
516
              type: object
516
              type: object
517
            package_id:
517
            package_id:
518
              type: string
518
              type: string
519
            create_linked_biblio:
520
              type: boolean
519
          additionalProperties: false
521
          additionalProperties: false
520
    responses:
522
    responses:
521
      201:
523
      201:
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/background_jobs/import_from_kbart_file.inc (-1 / +1 lines)
Lines 1-4 Link Here
1
[% USE Koha %]
1
[% USE Koha %]
2
[% USE raw %]
2
3
3
[% BLOCK report %]
4
[% BLOCK report %]
4
    [% SET report = job.report %]
5
    [% SET report = job.report %]
Lines 90-95 Link Here
90
                }
91
                }
91
            });
92
            });
92
        });
93
        });
93
94
</script>
94
</script>
95
[% END %]
95
[% END %]
(-)a/koha-tmpl/intranet-tmpl/prog/js/vue/components/ERM/EHoldingsLocalTitlesKBARTImport.vue (-37 / +49 lines)
Lines 17-62 Link Here
17
                    </ol>
17
                    </ol>
18
                </li>
18
                </li>
19
            </ul>
19
            </ul>
20
            <h3>{{ $__("File") }}:</h3>
20
            <fieldset class="rows" id="package_list">
21
            <div class="file_information">
21
                <h3>{{ $__("Select file for upload") }}:</h3>
22
                <span v-if="!file.filename">
23
                    {{ $__("Select a file") }}
24
                    <input
25
                        type="file"
26
                        @change="selectFile($event)"
27
                        :id="`import_file`"
28
                        :name="`import_file`"
29
                        required
30
                    />
31
                </span>
32
                <ol>
22
                <ol>
33
                    <li v-show="file.filename">
23
                    <li>
34
                        {{ $__("File name") }}:
24
                        <label for="import_file">{{ $__("File") }}:</label>
35
                        <span>{{ file.filename }}</span>
25
                        <input
26
                            type="file"
27
                            @change="selectFile($event)"
28
                            :id="`import_file`"
29
                            :name="`import_file`"
30
                            required
31
                        />
32
                    </li>
33
                    <li>
34
                        <label for="package_id"
35
                            >{{ $__("To the following local package") }}:</label
36
                        >
37
                        <v-select
38
                            id="package_id"
39
                            v-model="package_id"
40
                            label="name"
41
                            :reduce="p => p.package_id"
42
                            :options="packages"
43
                            :clearable="false"
44
                            :required="!package_id"
45
                        >
46
                            <template #search="{ attributes, events }">
47
                                <input
48
                                    :required="!package_id"
49
                                    class="vs__search"
50
                                    v-bind="attributes"
51
                                    v-on="events"
52
                                />
53
                            </template>
54
                        </v-select>
55
                        <span class="required">{{ $__("Required") }}</span>
56
                    </li>
57
                    <li>
58
                        <label for="create_linked_biblio"
59
                            >{{ $__("Create linked biblio record") }}:</label
60
                        >
61
                        <input
62
                            type="checkbox"
63
                            id="create_linked_biblio"
64
                            v-model="create_linked_biblio"
65
                        />
36
                    </li>
66
                    </li>
37
                </ol>
67
                </ol>
38
                <fieldset id="package_list">
68
            </fieldset>
39
                    {{ $__("To the following local package") }}:
40
                    <v-select
41
                        v-model="package_id"
42
                        label="name"
43
                        :reduce="p => p.package_id"
44
                        :options="packages"
45
                        :clearable="false"
46
                        :required="!package_id"
47
                    >
48
                        <template #search="{ attributes, events }">
49
                            <input
50
                                :required="!package_id"
51
                                class="vs__search"
52
                                v-bind="attributes"
53
                                v-on="events"
54
                            />
55
                        </template>
56
                    </v-select>
57
                    <span class="required">{{ $__("Required") }}</span>
58
                </fieldset>
59
            </div>
60
            <fieldset class="action">
69
            <fieldset class="action">
61
                <ButtonSubmit />
70
                <ButtonSubmit />
62
                <a @click="clearForm()" role="button" class="cancel">{{
71
                <a @click="clearForm()" role="button" class="cancel">{{
Lines 81-86 export default { Link Here
81
            },
90
            },
82
            packages: [],
91
            packages: [],
83
            package_id: null,
92
            package_id: null,
93
            create_linked_biblio: false,
84
        }
94
        }
85
    },
95
    },
86
    beforeCreate() {
96
    beforeCreate() {
Lines 113-118 export default { Link Here
113
            const importData = {
123
            const importData = {
114
                file: this.file,
124
                file: this.file,
115
                package_id: this.package_id,
125
                package_id: this.package_id,
126
                create_linked_biblio: this.create_linked_biblio,
116
            }
127
            }
117
            client.localTitles.import_kbart(importData).then(
128
            client.localTitles.import_kbart(importData).then(
118
                success => {
129
                success => {
Lines 162-167 export default { Link Here
162
                file_content: null,
173
                file_content: null,
163
            }
174
            }
164
            this.package_id = null
175
            this.package_id = null
176
            this.create_linked_biblio = false
165
        },
177
        },
166
    },
178
    },
167
    components: {
179
    components: {
(-)a/t/db_dependent/Koha/BackgroundJob/ImportKBARTFile.t (-22 / +7 lines)
Lines 194-200 Nature Astronomy 2397-3366 2017-01 1 1 https://www.nature.com/natastron 4bb Link Here
194
};
194
};
195
195
196
subtest 'process' => sub {
196
subtest 'process' => sub {
197
    plan tests => 12;
197
    plan tests => 13;
198
198
199
    $schema->storage->txn_begin;
199
    $schema->storage->txn_begin;
200
200
Lines 364-389 Nature Astronomy 2397-3366 2017-01 1 1 https://www.nature.com/natastron 4bb Link Here
364
    is( $job4->report->{duplicates_found}, 1, 'One duplicate found' );
364
    is( $job4->report->{duplicates_found}, 1, 'One duplicate found' );
365
    is( $job4->report->{titles_imported},  0, 'No titles were imported' );
365
    is( $job4->report->{titles_imported},  0, 'No titles were imported' );
366
    is( $job4->report->{failed_imports},   1, 'One failure found' );
366
    is( $job4->report->{failed_imports},   1, 'One failure found' );
367
    is_deeply(
367
368
        $job4->messages,
368
    is(
369
        [
369
        index( @{ $job4->messages }[0]->{error_message}, 'No such column \'unknown_field\'' ) > 0, 1,
370
            {
370
        'Error message for an unknown column'
371
                'type'          => 'error',
372
                'title'         => 'Nature Plants',
373
                'error_message' =>
374
                    'DBIx::Class::Row::store_column(): No such column \'unknown_field\' on Koha::Schema::Result::ErmEholdingsTitle at /kohadevbox/koha/Koha/Object.pm line 79
375
',
376
                'code' => 'title_failed'
377
            },
378
            {
379
                'code'          => 'title_already_exists',
380
                'error_message' => undef,
381
                'title'         => 'Nature Astronomy',
382
                'type'          => 'warning'
383
            }
384
        ],
385
        'One duplicate message and one failure message for an incorrect column'
386
    );
371
    );
372
    is( @{ $job4->messages }[1]->{code}, 'title_already_exists', 'Error message for a duplicate title' );
387
373
388
    $schema->storage->txn_rollback;
374
    $schema->storage->txn_rollback;
389
    }
375
}
390
- 

Return to bug 34788