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

(-)a/Koha/Import/Oaipmh/Authorities.pm (-5 / +5 lines)
Lines 1-4 Link Here
1
package Koha::Import::Oaipmh::Authorities;
1
package Koha::Import::OAI::Authorities;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 16-28 package Koha::Import::Oaipmh::Authorities; Link Here
16
16
17
use Modern::Perl;
17
use Modern::Perl;
18
18
19
use Koha::Import::Oaipmh::Authority;
19
use Koha::Import::OAI::Authority;
20
20
21
use base qw(Koha::Objects);
21
use base qw(Koha::Objects);
22
22
23
=head1 NAME
23
=head1 NAME
24
24
25
Koha::Import::Oaipmh::Authorities
25
Koha::Import::OAI::Authorities
26
26
27
This object represents a collection of OAI-PMH records being imported as authorities
27
This object represents a collection of OAI-PMH records being imported as authorities
28
28
Lines 36-42 This object represents a collection of OAI-PMH records being imported as authori Link Here
36
=cut
36
=cut
37
37
38
sub _type {
38
sub _type {
39
    return 'ImportOaipmhAuthority';
39
    return 'ImportOAIAuthority';
40
}
40
}
41
41
42
=head3 object_class
42
=head3 object_class
Lines 46-51 Koha::Object class Link Here
46
=cut
46
=cut
47
47
48
sub object_class {
48
sub object_class {
49
    return 'Koha::Import::Oaipmh::Authority';
49
    return 'Koha::Import::OAI::Authority';
50
}
50
}
51
1;
51
1;
(-)a/Koha/Import/Oaipmh/Authority.pm (-3 / +3 lines)
Lines 1-4 Link Here
1
package Koha::Import::Oaipmh::Authority;
1
package Koha::Import::OAI::Authority;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 20-26 use base qw(Koha::Object); Link Here
20
20
21
=head1 NAME
21
=head1 NAME
22
22
23
Koha::Import::Oaipmh::Authority
23
Koha::Import::OAI::Authority
24
24
25
This object represents an OAI-PMH record being imported as an authority
25
This object represents an OAI-PMH record being imported as an authority
26
26
Lines 35-41 This object represents an OAI-PMH record being imported as an authority Link Here
35
=cut
35
=cut
36
36
37
sub _type {
37
sub _type {
38
    return 'ImportOaipmhAuthority';
38
    return 'ImportOAIAuthority';
39
}
39
}
40
40
41
1;
41
1;
(-)a/Koha/Import/Oaipmh/Biblio.pm (-3 / +3 lines)
Lines 1-4 Link Here
1
package Koha::Import::Oaipmh::Biblio;
1
package Koha::Import::OAI::Biblio;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 20-26 use base qw(Koha::Object); Link Here
20
20
21
=head1 NAME
21
=head1 NAME
22
22
23
Koha::Import::Oaipmh::Biblio
23
Koha::Import::OAI::Biblio
24
24
25
This object represents an OAI-PMH record being imported as a bibliographic record
25
This object represents an OAI-PMH record being imported as a bibliographic record
26
26
Lines 34-40 This object represents an OAI-PMH record being imported as a bibliographic recor Link Here
34
=cut
34
=cut
35
35
36
sub _type {
36
sub _type {
37
    return 'ImportOaipmhBiblio';
37
    return 'ImportOaiBiblio';
38
}
38
}
39
39
40
1;
40
1;
(-)a/Koha/Import/Oaipmh/Biblios.pm (-5 / +5 lines)
Lines 1-4 Link Here
1
package Koha::Import::Oaipmh::Biblios;
1
package Koha::Import::OAI::Biblios;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 16-28 package Koha::Import::Oaipmh::Biblios; Link Here
16
16
17
use Modern::Perl;
17
use Modern::Perl;
18
18
19
use Koha::Import::Oaipmh::Biblio;
19
use Koha::Import::OAI::Biblio;
20
20
21
use base qw(Koha::Objects);
21
use base qw(Koha::Objects);
22
22
23
=head1 NAME
23
=head1 NAME
24
24
25
Koha::Import::Oaipmh::Biblios
25
Koha::Import::OAI::Biblios
26
26
27
This object represents a collection of OAI-PMH records being imported as bibliographic records
27
This object represents a collection of OAI-PMH records being imported as bibliographic records
28
28
Lines 36-42 This object represents a collection of OAI-PMH records being imported as bibliog Link Here
36
=cut
36
=cut
37
37
38
sub _type {
38
sub _type {
39
    return 'ImportOaipmhBiblio';
39
    return 'ImportOaiBiblio';
40
}
40
}
41
41
42
=head3 object_class
42
=head3 object_class
Lines 46-51 Koha::Object class Link Here
46
=cut
46
=cut
47
47
48
sub object_class {
48
sub object_class {
49
    return 'Koha::Import::Oaipmh::Biblio';
49
    return 'Koha::Import::OAI::Biblio';
50
}
50
}
51
1;
51
1;
(-)a/Koha/OAI/Client/Harvester.pm (-17 / +16 lines)
Lines 36-46 use C4::Log qw( cronlogaction ); Link Here
36
use HTTP::OAI;
36
use HTTP::OAI;
37
use HTTP::OAI::Metadata::OAI_DC;
37
use HTTP::OAI::Metadata::OAI_DC;
38
use Koha::DateUtils qw( dt_from_string );
38
use Koha::DateUtils qw( dt_from_string );
39
use Koha::OaiServers;
39
use Koha::OAIServers;
40
use Koha::Import::Oaipmh::Biblio;
40
use Koha::Import::OAI::Biblio;
41
use Koha::Import::Oaipmh::Biblios;
41
use Koha::Import::OAI::Biblios;
42
use Koha::Import::Oaipmh::Authority;
42
use Koha::Import::OAI::Authority;
43
use Koha::Import::Oaipmh::Authorities;
43
use Koha::Import::OAI::Authorities;
44
use Koha::XSLT::Base;
44
use Koha::XSLT::Base;
45
use MARC::File::XML;
45
use MARC::File::XML;
46
use MARC::Record;
46
use MARC::Record;
Lines 61-79 my $strp = DateTime::Format::Strptime->new( Link Here
61
our $xslt_engine = Koha::XSLT::Base->new;
61
our $xslt_engine = Koha::XSLT::Base->new;
62
62
63
=head2 new
63
=head2 new
64
64
$harvester = Koha::OAI::Client::Harvester->new( { server => $server, days => $days, force => $force, logger => \&logger } );
65
$harvester = Koha::OAI::Client::Harvester->new( { server => $server, verbose => $verbose, days => $days, force => $force } );
66
65
67
New instance of Koha::OAI::Client::Harvester
66
New instance of Koha::OAI::Client::Harvester
68
67
69
C<$server> An OAI repository (Koha::OaiServer)
68
C<$server> An OAI repository (Koha::OAIServer)
70
71
C<$verbose> print log messages to stdout when enabled
72
69
73
C<$days> number of days to harvest from (optional)
70
C<$days> number of days to harvest from (optional)
74
71
75
C<$force> force harvesting (ignore records datestamps)
72
C<$force> force harvesting (ignore records datestamps)
76
73
74
C<$logger> a callback function to handle logs (optional)
75
77
=cut
76
=cut
78
77
79
sub new {
78
sub new {
Lines 250-256 sub processRecord { Link Here
250
    }
249
    }
251
    my $imported_record;
250
    my $imported_record;
252
    if ( $server->recordtype eq "biblio" ) {
251
    if ( $server->recordtype eq "biblio" ) {
253
        $imported_record = Koha::Import::Oaipmh::Biblios->find(
252
        $imported_record = Koha::Import::OAI::Biblios->find(
254
            {
253
            {
255
                repository => $server->endpoint,
254
                repository => $server->endpoint,
256
                identifier => $oai_record->identifier,
255
                identifier => $oai_record->identifier,
Lines 258-264 sub processRecord { Link Here
258
            }
257
            }
259
        );
258
        );
260
    } else {
259
    } else {
261
        $imported_record = Koha::Import::Oaipmh::Authorities->find(
260
        $imported_record = Koha::Import::OAI::Authorities->find(
262
            {
261
            {
263
                repository => $server->endpoint,
262
                repository => $server->endpoint,
264
                identifier => $oai_record->identifier,
263
                identifier => $oai_record->identifier,
Lines 318-324 sub processRecord { Link Here
318
        if ( $server->recordtype eq "biblio" ) {
317
        if ( $server->recordtype eq "biblio" ) {
319
            my ( $biblionumber, $biblioitemnumber ) = AddBiblio($marcrecord);
318
            my ( $biblionumber, $biblioitemnumber ) = AddBiblio($marcrecord);
320
            $self->printlog( $oai_record->identifier . " added, biblionumber: $biblionumber" );
319
            $self->printlog( $oai_record->identifier . " added, biblionumber: $biblionumber" );
321
            Koha::Import::Oaipmh::Biblio->new(
320
            Koha::Import::OAI::Biblio->new(
322
                {
321
                {
323
                    repository   => $server->endpoint,
322
                    repository   => $server->endpoint,
324
                    identifier   => $oai_record->identifier,
323
                    identifier   => $oai_record->identifier,
Lines 330-336 sub processRecord { Link Here
330
        } else {
329
        } else {
331
            my $authid = AddAuthority( $marcrecord, "", GuessAuthTypeCode($marcrecord) );
330
            my $authid = AddAuthority( $marcrecord, "", GuessAuthTypeCode($marcrecord) );
332
            $self->printlog( $oai_record->identifier . " added, authid: $authid" );
331
            $self->printlog( $oai_record->identifier . " added, authid: $authid" );
333
            Koha::Import::Oaipmh::Authority->new(
332
            Koha::Import::OAI::Authority->new(
334
                {
333
                {
335
                    repository => $server->endpoint,
334
                    repository => $server->endpoint,
336
                    identifier => $oai_record->identifier,
335
                    identifier => $oai_record->identifier,
Lines 350-364 sub processRecord { Link Here
350
349
351
=head2 $self->printlog
350
=head2 $self->printlog
352
351
353
This method adds a cronlog and prints to stdout if verbose is enabled
352
This method gives the caller an opportunity to handle log messages
354
353
355
=cut
354
=cut
356
355
357
sub printlog {
356
sub printlog {
358
    my ( $self, $message ) = @_;
357
    my ( $self, $message ) = @_;
358
    return unless $self->{logger};
359
    $message = $self->{server}->servername . ": " . $message;
359
    $message = $self->{server}->servername . ": " . $message;
360
    print $message . "\n" if ( $self->{verbose} );
360
    $self->{logger}->($message);
361
    cronlogaction( { info => $message } );
362
}
361
}
363
362
364
1;
363
1;
(-)a/Koha/OaiServer.pm (-3 / +3 lines)
Lines 1-4 Link Here
1
package Koha::OaiServer;
1
package Koha::OAIServer;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 24-30 use base qw(Koha::Object); Link Here
24
24
25
=head1 NAME
25
=head1 NAME
26
26
27
Koha::OaiServer - Koha OaiServer Object class
27
Koha::OAIServer - Koha OAIServer Object class
28
28
29
=head1 API
29
=head1 API
30
30
Lines 39-45 Return type of Object relating to Schema ResultSet Link Here
39
=cut
39
=cut
40
40
41
sub _type {
41
sub _type {
42
    return 'Oaiserver';
42
    return 'OaiServer';
43
}
43
}
44
44
45
1;
45
1;
(-)a/Koha/OaiServers.pm (-5 / +5 lines)
Lines 1-4 Link Here
1
package Koha::OaiServers;
1
package Koha::OAIServers;
2
2
3
# This file is part of Koha.
3
# This file is part of Koha.
4
#
4
#
Lines 20-32 use Modern::Perl; Link Here
20
20
21
use Koha::Database;
21
use Koha::Database;
22
22
23
use Koha::OaiServer;
23
use Koha::OAIServer;
24
24
25
use base qw(Koha::Objects);
25
use base qw(Koha::Objects);
26
26
27
=head1 NAME
27
=head1 NAME
28
28
29
Koha::OaiServers - Koha OaiServer Object set class
29
Koha::OAIServers - Koha OAIServer Object set class
30
30
31
=head1 API
31
=head1 API
32
32
Lines 41-47 Return type of object, relating to Schema ResultSet Link Here
41
=cut
41
=cut
42
42
43
sub _type {
43
sub _type {
44
    return 'Oaiserver';
44
    return 'OaiServer';
45
}
45
}
46
46
47
=head3 object_class
47
=head3 object_class
Lines 51-57 Return object class Link Here
51
=cut
51
=cut
52
52
53
sub object_class {
53
sub object_class {
54
    return 'Koha::OaiServer';
54
    return 'Koha::OAIServer';
55
}
55
}
56
56
57
1;
57
1;
(-)a/admin/oaiservers.pl (-11 / +11 lines)
Lines 26-32 use C4::Context; Link Here
26
use C4::Auth   qw( get_template_and_user );
26
use C4::Auth   qw( get_template_and_user );
27
use C4::Output qw( output_html_with_http_headers );
27
use C4::Output qw( output_html_with_http_headers );
28
use Koha::Database;
28
use Koha::Database;
29
use Koha::OaiServers;
29
use Koha::OAIServers;
30
30
31
# Initialize CGI, template, database
31
# Initialize CGI, template, database
32
32
Lines 38-50 my $searchfield = ''; Link Here
38
38
39
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
39
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
40
    {
40
    {
41
        template_name => "admin/oaiservers.tt",
41
        template_name => "admin/oai_servers.tt",
42
        query         => $input,
42
        query         => $input,
43
        type          => "intranet",
43
        type          => "intranet",
44
        flagsrequired => { parameters => 'manage_search_targets' },
44
        flagsrequired => { parameters => 'manage_search_targets' },
45
    }
45
    }
46
);
46
);
47
my $script_name = "/cgi-bin/koha/admin/oaiservers.pl";
47
my $script_name = "/cgi-bin/koha/admin/oai_servers.pl";
48
my $path        = C4::Context->config('intrahtdocs') . "/prog/";
48
my $path        = C4::Context->config('intrahtdocs') . "/prog/";
49
49
50
$template->param( script_name => $script_name, xslt_path => $path );
50
$template->param( script_name => $script_name, xslt_path => $path );
Lines 55-61 my $schema = Koha::Database->new()->schema(); Link Here
55
# First process a confirmed delete, or save a validated record
55
# First process a confirmed delete, or save a validated record
56
56
57
if ( $op eq 'cud-delete_confirmed' && $id ) {
57
if ( $op eq 'cud-delete_confirmed' && $id ) {
58
    my $server = Koha::OaiServers->find($id);
58
    my $server = Koha::OAIServers->find($id);
59
    if ($server) {
59
    if ($server) {
60
        $server->delete;
60
        $server->delete;
61
        $template->param( msg_deleted => 1, msg_add => $server->servername );
61
        $template->param( msg_deleted => 1, msg_add => $server->servername );
Lines 69-75 if ( $op eq 'cud-delete_confirmed' && $id ) { Link Here
69
        add_xslt/;
69
        add_xslt/;
70
    my $formdata = _form_data_hashref( $input, \@fields );
70
    my $formdata = _form_data_hashref( $input, \@fields );
71
    if ($id) {
71
    if ($id) {
72
        my $server = Koha::OaiServers->find($id);
72
        my $server = Koha::OAIServers->find($id);
73
        if ($server) {
73
        if ($server) {
74
            $server->set($formdata)->store;
74
            $server->set($formdata)->store;
75
            $template->param( msg_updated => 1, msg_add => $formdata->{servername} );
75
            $template->param( msg_updated => 1, msg_add => $formdata->{servername} );
Lines 78-84 if ( $op eq 'cud-delete_confirmed' && $id ) { Link Here
78
        }
78
        }
79
        $id = 0;
79
        $id = 0;
80
    } else {
80
    } else {
81
        Koha::OaiServer->new($formdata)->store;
81
        Koha::OAIServer->new($formdata)->store;
82
        $template->param( msg_added => 1, msg_add => $formdata->{servername} );
82
        $template->param( msg_added => 1, msg_add => $formdata->{servername} );
83
    }
83
    }
84
} elsif ( $op eq 'search' ) {
84
} elsif ( $op eq 'search' ) {
Lines 91-104 if ( $op eq 'cud-delete_confirmed' && $id ) { Link Here
91
91
92
my $data = [];
92
my $data = [];
93
if ( $op eq 'add' || $op eq 'edit' ) {
93
if ( $op eq 'add' || $op eq 'edit' ) {
94
    $data = ServerSearch( $schema, $id, $searchfield ) if $searchfield || $id;
94
    $data = server_search( $schema, $id, $searchfield ) if $searchfield || $id;
95
    delete $data->[0]->{id}                            if @$data && $op eq 'add';    #cloning record
95
    delete $data->[0]->{id}                             if @$data && $op eq 'add';    #cloning record
96
    $template->param(
96
    $template->param(
97
        add_form => 1, server => @$data ? $data->[0] : undef,
97
        add_form => 1, server => @$data ? $data->[0] : undef,
98
        op => $op, type => $op eq 'add' ? lc $type : ''
98
        op => $op, type => $op eq 'add' ? lc $type : ''
99
    );
99
    );
100
} else {
100
} else {
101
    $data = ServerSearch( $schema, $id, $searchfield );
101
    $data = server_search( $schema, $id, $searchfield );
102
    $template->param(
102
    $template->param(
103
        loop => \@$data, searchfield => $searchfield, id => $id,
103
        loop => \@$data, searchfield => $searchfield, id => $id,
104
        op   => 'list'
104
        op   => 'list'
Lines 108-117 output_html_with_http_headers $input, $cookie, $template->output; Link Here
108
108
109
# End of main code
109
# End of main code
110
110
111
sub ServerSearch {    #find server(s) by id or name
111
sub server_search {    #find server(s) by id or name
112
    my ( $schema, $id, $searchstring ) = @_;
112
    my ( $schema, $id, $searchstring ) = @_;
113
113
114
    return Koha::OaiServers->search(
114
    return Koha::OAIServers->search(
115
        $id ? { id => $id } : { servername => { like => $searchstring . '%' } },
115
        $id ? { id => $id } : { servername => { like => $searchstring . '%' } },
116
    )->unblessed;
116
    )->unblessed;
117
}
117
}
(-)a/installer/data/mysql/atomicupdate/Bug-35659.pl (-10 / +10 lines)
Lines 8-15 return { Link Here
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
8
        my ( $dbh, $out ) = @$args{qw(dbh out)};
9
        $dbh->do(
9
        $dbh->do(
10
            q{
10
            q{
11
            CREATE TABLE IF NOT EXISTS `oaiservers` (
11
            CREATE TABLE IF NOT EXISTS `oai_servers` (
12
              `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
12
              `oai_server_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
13
              `endpoint` varchar(255) NOT NULL COMMENT 'OAI endpoint (host + port + path)',
13
              `endpoint` varchar(255) NOT NULL COMMENT 'OAI endpoint (host + port + path)',
14
              `oai_set` varchar(255) DEFAULT NULL COMMENT 'OAI set to harvest',
14
              `oai_set` varchar(255) DEFAULT NULL COMMENT 'OAI set to harvest',
15
              `servername` longtext NOT NULL COMMENT 'name given to the target by the library',
15
              `servername` longtext NOT NULL COMMENT 'name given to the target by the library',
Lines 20-31 return { Link Here
20
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
20
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
21
        }
21
        }
22
        );
22
        );
23
        say $out "Added new table 'oaiservers'";
23
        say $out "Added new table 'oai_servers'";
24
24
25
        $dbh->do(
25
        $dbh->do(
26
            q{
26
            q{
27
            CREATE TABLE IF NOT EXISTS `import_oaipmh_biblios` (
27
            CREATE TABLE IF NOT EXISTS `import_oai_biblios` (
28
              `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
28
              `import_oai_biblio_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
29
              `biblionumber` int(11) NOT NULL COMMENT 'unique identifier assigned to each koha record',
29
              `biblionumber` int(11) NOT NULL COMMENT 'unique identifier assigned to each koha record',
30
              `identifier` varchar(255) NOT NULL COMMENT 'OAI record identifier',
30
              `identifier` varchar(255) NOT NULL COMMENT 'OAI record identifier',
31
              `repository` varchar(255) NOT NULL COMMENT 'OAI repository',
31
              `repository` varchar(255) NOT NULL COMMENT 'OAI repository',
Lines 34-48 return { Link Here
34
              `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
34
              `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
35
              PRIMARY KEY (id),
35
              PRIMARY KEY (id),
36
              KEY biblionumber (biblionumber),
36
              KEY biblionumber (biblionumber),
37
              CONSTRAINT FK_import_oaipmh_biblios_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE NO ACTION
37
              CONSTRAINT FK_import_oai_biblios_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE NO ACTION
38
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
38
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
39
        }
39
        }
40
        );
40
        );
41
41
42
        $dbh->do(
42
        $dbh->do(
43
            q{
43
            q{
44
            CREATE TABLE IF NOT EXISTS `import_oaipmh_authorities` (
44
            CREATE TABLE IF NOT EXISTS `import_oai_authorities` (
45
              `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
45
              `import_oai_authority_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
46
              `authid` bigint(20) unsigned NOT NULL COMMENT 'unique identifier assigned to each koha record',
46
              `authid` bigint(20) unsigned NOT NULL COMMENT 'unique identifier assigned to each koha record',
47
              `identifier` varchar(255) NOT NULL COMMENT 'OAI record identifier',
47
              `identifier` varchar(255) NOT NULL COMMENT 'OAI record identifier',
48
              `repository` varchar(255) NOT NULL COMMENT 'OAI repository',
48
              `repository` varchar(255) NOT NULL COMMENT 'OAI repository',
Lines 51-61 return { Link Here
51
              `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
51
              `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
52
              PRIMARY KEY (id),
52
              PRIMARY KEY (id),
53
              KEY authid (authid),
53
              KEY authid (authid),
54
              CONSTRAINT FK_import_oaipmh_authorities_1 FOREIGN KEY (authid) REFERENCES auth_header (authid) ON DELETE CASCADE ON UPDATE NO ACTION
54
              CONSTRAINT FK_import_oai_authorities_1 FOREIGN KEY (authid) REFERENCES auth_header (authid) ON DELETE CASCADE ON UPDATE NO ACTION
55
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
55
            ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
56
        }
56
        }
57
        );
57
        );
58
        say $out "Added new tables 'import_oaipmh_biblios' and import_oaipmh_authorities";
58
        say $out "Added new tables 'import_oai_biblios' and import_oai_authorities";
59
59
60
        $dbh->do(
60
        $dbh->do(
61
            q{
61
            q{
(-)a/installer/data/mysql/kohastructure.sql (-11 / +11 lines)
Lines 4833-4845 CREATE TABLE `oai_sets_mappings` ( Link Here
4833
/*!40101 SET character_set_client = @saved_cs_client */;
4833
/*!40101 SET character_set_client = @saved_cs_client */;
4834
4834
4835
--
4835
--
4836
-- Table structure for table `oaiservers`
4836
-- Table structure for table `oai_servers`
4837
--
4837
--
4838
4838
4839
DROP TABLE IF EXISTS `oaiservers`;
4839
DROP TABLE IF EXISTS `oai_servers`;
4840
/*!40101 SET @saved_cs_client     = @@character_set_client */;
4840
/*!40101 SET @saved_cs_client     = @@character_set_client */;
4841
/*!40101 SET character_set_client = utf8 */;
4841
/*!40101 SET character_set_client = utf8 */;
4842
CREATE TABLE `oaiservers` (
4842
CREATE TABLE `oai_servers` (
4843
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4843
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4844
  `endpoint` varchar(255) NOT NULL COMMENT 'OAI endpoint (host + port + path)',
4844
  `endpoint` varchar(255) NOT NULL COMMENT 'OAI endpoint (host + port + path)',
4845
  `oai_set` varchar(255) DEFAULT NULL COMMENT 'OAI set to harvest',
4845
  `oai_set` varchar(255) DEFAULT NULL COMMENT 'OAI set to harvest',
Lines 4851-4863 CREATE TABLE `oaiservers` ( Link Here
4851
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4851
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4852
4852
4853
--
4853
--
4854
-- Table structure for table `import_oaipmh_biblios`
4854
-- Table structure for table `import_oai_biblios`
4855
--
4855
--
4856
4856
4857
DROP TABLE IF EXISTS `import_oaipmh_biblios`;
4857
DROP TABLE IF EXISTS `import_oai_biblios`;
4858
/*!40101 SET @saved_cs_client     = @@character_set_client */;
4858
/*!40101 SET @saved_cs_client     = @@character_set_client */;
4859
/*!40101 SET character_set_client = utf8 */;
4859
/*!40101 SET character_set_client = utf8 */;
4860
CREATE TABLE `import_oaipmh_biblios` (
4860
CREATE TABLE `import_oai_biblios` (
4861
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4861
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4862
  `biblionumber` int(11) NOT NULL COMMENT 'unique identifier assigned to each koha record',
4862
  `biblionumber` int(11) NOT NULL COMMENT 'unique identifier assigned to each koha record',
4863
  `identifier` varchar(255) NOT NULL COMMENT 'OAI record identifier',
4863
  `identifier` varchar(255) NOT NULL COMMENT 'OAI record identifier',
Lines 4867-4883 CREATE TABLE `import_oaipmh_biblios` ( Link Here
4867
  `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
4867
  `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
4868
  PRIMARY KEY (id),
4868
  PRIMARY KEY (id),
4869
  KEY biblionumber (biblionumber),
4869
  KEY biblionumber (biblionumber),
4870
  CONSTRAINT FK_import_oaipmh_biblios_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE NO ACTION
4870
  CONSTRAINT FK_import_oai_biblios_1 FOREIGN KEY (biblionumber) REFERENCES biblio (biblionumber) ON DELETE CASCADE ON UPDATE NO ACTION
4871
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4871
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4872
4872
4873
--
4873
--
4874
-- Table structure for table `import_oaipmh_authorities`
4874
-- Table structure for table `import_oai_authorities`
4875
--
4875
--
4876
4876
4877
DROP TABLE IF EXISTS `import_oaipmh_authorities`;
4877
DROP TABLE IF EXISTS `import_oai_authorities`;
4878
/*!40101 SET @saved_cs_client     = @@character_set_client */;
4878
/*!40101 SET @saved_cs_client     = @@character_set_client */;
4879
/*!40101 SET character_set_client = utf8 */;
4879
/*!40101 SET character_set_client = utf8 */;
4880
CREATE TABLE `import_oaipmh_authorities` (
4880
CREATE TABLE `import_oai_authorities` (
4881
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4881
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'unique identifier assigned by Koha',
4882
  `authid` bigint(20) unsigned NOT NULL COMMENT 'unique identifier assigned to each koha record',
4882
  `authid` bigint(20) unsigned NOT NULL COMMENT 'unique identifier assigned to each koha record',
4883
  `identifier` varchar(255) NOT NULL COMMENT 'OAI record identifier',
4883
  `identifier` varchar(255) NOT NULL COMMENT 'OAI record identifier',
Lines 4887-4893 CREATE TABLE `import_oaipmh_authorities` ( Link Here
4887
  `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
4887
  `last_modified` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
4888
  PRIMARY KEY (id),
4888
  PRIMARY KEY (id),
4889
  KEY authid (authid),
4889
  KEY authid (authid),
4890
  CONSTRAINT FK_import_oaipmh_authorities_1 FOREIGN KEY (authid) REFERENCES auth_header (authid) ON DELETE CASCADE ON UPDATE NO ACTION
4890
  CONSTRAINT FK_import_oai_authorities_1 FOREIGN KEY (authid) REFERENCES auth_header (authid) ON DELETE CASCADE ON UPDATE NO ACTION
4891
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4891
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
4892
4892
4893
--
4893
--
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (-1 / +1 lines)
Lines 149-155 Link Here
149
            [% END %]
149
            [% END %]
150
            [% IF ( CAN_user_parameters_manage_search_targets ) %]
150
            [% IF ( CAN_user_parameters_manage_search_targets ) %]
151
                <li><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></li>
151
                <li><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></li>
152
                <li><a href="/cgi-bin/koha/admin/oaiservers.pl">OAI repositories</a></li>
152
                <li><a href="/cgi-bin/koha/admin/oai_servers.pl">OAI repositories</a></li>
153
            [% END %]
153
            [% END %]
154
            [% IF ( CAN_user_parameters_manage_smtp_servers ) %]
154
            [% IF ( CAN_user_parameters_manage_smtp_servers ) %]
155
                <li><a href="/cgi-bin/koha/admin/smtp_servers.pl">SMTP servers</a></li>
155
                <li><a href="/cgi-bin/koha/admin/smtp_servers.pl">SMTP servers</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/oai-admin-search.inc (-1 / +1 lines)
Lines 3-9 Link Here
3
<div id="header_search" role="tablist">
3
<div id="header_search" role="tablist">
4
    <div class="tab-content">
4
    <div class="tab-content">
5
        <div id="oai_search" role="tabpanel" class="tab-pane active">
5
        <div id="oai_search" role="tabpanel" class="tab-pane active">
6
            <form action="/cgi-bin/koha/admin/oaiservers.pl" method="get">
6
            <form action="/cgi-bin/koha/admin/oai_servers.pl" method="get">
7
                <div class="form-title">
7
                <div class="form-title">
8
                    <label class="control-label" for="searchfield">Search OAI repositories</label>
8
                    <label class="control-label" for="searchfield">Search OAI repositories</label>
9
                </div>
9
                </div>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (-1 / +1 lines)
Lines 249-255 Link Here
249
                    [% IF ( CAN_user_parameters_manage_search_targets ) %]
249
                    [% IF ( CAN_user_parameters_manage_search_targets ) %]
250
                        <dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></dt>
250
                        <dt><a href="/cgi-bin/koha/admin/z3950servers.pl">Z39.50/SRU servers</a></dt>
251
                        <dd>Define which external servers to query for MARC data</dd>
251
                        <dd>Define which external servers to query for MARC data</dd>
252
                        <dt><a href="/cgi-bin/koha/admin/oaiservers.pl">OAI repositories</a></dt>
252
                        <dt><a href="/cgi-bin/koha/admin/oai_servers.pl">OAI repositories</a></dt>
253
                        <dd>Define which OAI repositories to harvest data from</dd>
253
                        <dd>Define which OAI repositories to harvest data from</dd>
254
                    [% END %]
254
                    [% END %]
255
                    [% IF ( CAN_user_parameters_manage_smtp_servers ) %]
255
                    [% IF ( CAN_user_parameters_manage_smtp_servers ) %]
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/oaiservers.tt (-12 / +12 lines)
Lines 15-21 Link Here
15
[% INCLUDE 'doc-head-close.inc' %]
15
[% INCLUDE 'doc-head-close.inc' %]
16
</head>
16
</head>
17
17
18
<body id="admin_oaiservers" class="admin">
18
<body id="admin_oai_servers" class="admin">
19
[% WRAPPER 'header.inc' %]
19
[% WRAPPER 'header.inc' %]
20
    [% INCLUDE 'oai-admin-search.inc' %]
20
    [% INCLUDE 'oai-admin-search.inc' %]
21
[% END %]
21
[% END %]
Lines 28-34 Link Here
28
28
29
        [% IF op == 'edit' || op == 'add' %]
29
        [% IF op == 'edit' || op == 'add' %]
30
            [% WRAPPER breadcrumb_item %]
30
            [% WRAPPER breadcrumb_item %]
31
                <a href="/cgi-bin/koha/admin/oaiservers.pl">OAI repositories</a>
31
                <a href="/cgi-bin/koha/admin/oai_servers.pl">OAI repositories</a>
32
           [% END %]
32
           [% END %]
33
        [% END %]
33
        [% END %]
34
34
Lines 89-95 Link Here
89
89
90
        <li><label for="endpoint" class="required">Endpoint: </label> <input type="text" name="endpoint" id="endpoint" size="30" value="[% server.endpoint | html %]" required="required" /> <span class="required">Required</span>
90
        <li><label for="endpoint" class="required">Endpoint: </label> <input type="text" name="endpoint" id="endpoint" size="30" value="[% server.endpoint | html %]" required="required" /> <span class="required">Required</span>
91
        </li>
91
        </li>
92
        <li><label for="oai_set">Set: </label> <input type="text" name="oai_set" id="oai_set" value="[% server.oai_set | html %]" />
92
        <li><label for="oai_set">[% I18N.tp('OAI', 'Set:') | html %] </label> <input type="text" name="oai_set" id="oai_set" value="[% server.oai_set | html %]" />
93
        </li>
93
        </li>
94
        <li>
94
        <li>
95
            <label for="dataformat">Data format: </label>
95
            <label for="dataformat">Data format: </label>
Lines 115-145 Link Here
115
        </ol>
115
        </ol>
116
        </fieldset>
116
        </fieldset>
117
117
118
        <fieldset class="action"><input type="submit" class="btn btn-primary" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/oaiservers.pl">Cancel</a></fieldset>
118
        <fieldset class="action"><input type="submit" class="btn btn-primary" value="Save" /> <a class="cancel" href="/cgi-bin/koha/admin/oai_servers.pl">Cancel</a></fieldset>
119
    </form>
119
    </form>
120
[% END %]
120
[% END %]
121
121
122
[% IF op == 'list' %]
122
[% IF op == 'list' %]
123
    <div id="toolbar" class="btn-toolbar">
123
    <div id="toolbar" class="btn-toolbar">
124
        <a id="newserver" class="btn btn-default" href="/cgi-bin/koha/admin/oaiservers.pl?op=add"><i class="fa fa-plus"></i> New OAI repository</a>
124
        <a id="newserver" class="btn btn-default" href="/cgi-bin/koha/admin/oai_servers.pl?op=add"><i class="fa fa-plus"></i> New OAI repository</a>
125
    </div>
125
    </div>
126
    <h1>OAI repositories administration</h1>
126
    <h1>OAI repositories administration</h1>
127
    [% IF id %]
127
    [% IF id %]
128
        You searched for record [% id | html %]
128
        <span>You searched for record [% id | html %]</span>
129
    [% ELSIF searchfield %]
129
    [% ELSIF searchfield %]
130
        You searched for [% searchfield | html %]
130
        </span>You searched for [% searchfield | html %]<span>
131
    [% END %]
131
    [% END %]
132
132
133
    <div class="page-section">
133
    <div class="page-section">
134
    <table id="serverst">
134
    <table id="serverst">
135
135
136
        <thead><tr><th>Id</th><th>Repository name</th><th>Endpoint</th><th>Set</th><th>Data format</th><th>Record type</th><th class="noExport">Actions</th>
136
        <thead><tr><th>Id</th><th>Repository name</th><th>Endpoint</th><th>[% tp('OAI', 'Set') | html %]</th><th>Data format</th><th>Record type</th><th class="noExport">Actions</th>
137
        </tr></thead>
137
        </tr></thead>
138
        <tbody>
138
        <tbody>
139
        [% FOREACH loo IN loop %]
139
        [% FOREACH loo IN loop %]
140
            <tr>
140
            <tr>
141
            <td>[% loo.id | html %]</td>
141
            <td>[% loo.id | html %]</td>
142
            <td><a href="/cgi-bin/koha/admin/oaiservers.pl?op=edit&amp;id=[% loo.id | uri %]">[% loo.servername | html %]</a></td><td>[% loo.endpoint | html %]</td><td>[% loo.oai_set | html %]</td>
142
            <td><a href="/cgi-bin/koha/admin/oai_servers.pl?op=edit&amp;id=[% loo.id | uri %]">[% loo.servername | html %]</a></td><td>[% loo.endpoint | html %]</td><td>[% loo.oai_set | html %]</td>
143
            <td>[% loo.dataformat | html %]</td>
143
            <td>[% loo.dataformat | html %]</td>
144
            <td>[% IF ( loo.recordtype == 'biblio' )  %]
144
            <td>[% IF ( loo.recordtype == 'biblio' )  %]
145
                <span>Bibliographic</span>
145
                <span>Bibliographic</span>
Lines 153-163 Link Here
153
                        Actions <b class="caret"></b>
153
                        Actions <b class="caret"></b>
154
                    </a>
154
                    </a>
155
                    <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
155
                    <ul class="dropdown-menu pull-right" role="menu" aria-labelledby="reportactions[% savedreport.id | html %]">
156
                        <li><a href="/cgi-bin/koha/admin/oaiservers.pl?op=edit&amp;id=[% loo.id | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li>
156
                        <li><a href="/cgi-bin/koha/admin/oai_servers.pl?op=edit&amp;id=[% loo.id | uri %]"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Edit</a></li>
157
                        <li><a href="/cgi-bin/koha/admin/oaiservers.pl?op=add&amp;id=[% loo.id | uri %]"><i class="fa fa-copy"></i> Copy</a></li>
157
                        <li><a href="/cgi-bin/koha/admin/oai_servers.pl?op=add&amp;id=[% loo.id | uri %]"><i class="fa fa-copy"></i> Copy</a></li>
158
                        <li>
158
                        <li>
159
                            <a href="#" class="delete" data-formid="server_row_[% loo.id | uri %]" data-servername="[% loo.servername | html %]"><i class="fa fa-trash-can"></i> Delete</a>
159
                            <a href="#" class="delete" data-formid="server_row_[% loo.id | uri %]" data-servername="[% loo.servername | html %]"><i class="fa fa-trash-can"></i> Delete</a>
160
                            <form id="server_row_[% loo.id | uri %]" action="/cgi-bin/koha/admin/oaiservers.pl" method="post">
160
                            <form id="server_row_[% loo.id | uri %]" action="/cgi-bin/koha/admin/oai_servers.pl" method="post">
161
                                [% INCLUDE 'csrf-token.inc' %]
161
                                [% INCLUDE 'csrf-token.inc' %]
162
                                <input type="hidden" name="op" value="cud-delete_confirmed">
162
                                <input type="hidden" name="op" value="cud-delete_confirmed">
163
                                <input type="hidden" name="id" value="[% loo.id | uri %]">
163
                                <input type="hidden" name="id" value="[% loo.id | uri %]">
(-)a/misc/cronjobs/harvest_oai.pl (-4 / +11 lines)
Lines 24-30 use utf8; Link Here
24
use Getopt::Long qw( GetOptions );
24
use Getopt::Long qw( GetOptions );
25
use Koha::Script -cron;
25
use Koha::Script -cron;
26
use Koha::OAI::Client::Harvester;
26
use Koha::OAI::Client::Harvester;
27
use Koha::OaiServers;
27
use Koha::OAIServers;
28
use C4::Log   qw( cronlogaction );
28
use C4::Log   qw( cronlogaction );
29
use Try::Tiny qw( catch try );
29
use Try::Tiny qw( catch try );
30
30
Lines 60-66 if ($help) { Link Here
60
}
60
}
61
61
62
if ($list) {
62
if ($list) {
63
    my $servers = Koha::OaiServers->search( {}, { order_by => { -asc => 'id' } } )->unblessed;
63
    my $servers = Koha::OAIServers->search( {}, { order_by => { -asc => 'id' } } )->unblessed;
64
    print "The following repositories are available: \n\n";
64
    print "The following repositories are available: \n\n";
65
    foreach my $server (@$servers) {
65
    foreach my $server (@$servers) {
66
        print $server->{'id'} . ": "
66
        print $server->{'id'} . ": "
Lines 81-87 if ( !$id ) { Link Here
81
    print $usage . "\n";
81
    print $usage . "\n";
82
}
82
}
83
83
84
my $server = Koha::OaiServers->find($id);
84
my $server = Koha::OAIServers->find($id);
85
85
86
unless ($server) {
86
unless ($server) {
87
    print "OAI Server $id unknown\n";
87
    print "OAI Server $id unknown\n";
Lines 103-110 cronlogaction( { action => 'Start', info => "Starting OAI Harvest" } ); Link Here
103
cronlogaction( { info   => "Command line: $command_line_options" } );
103
cronlogaction( { info   => "Command line: $command_line_options" } );
104
104
105
my $harvester =
105
my $harvester =
106
    Koha::OAI::Client::Harvester->new( { server => $server, verbose => $verbose, days => $days, force => $force } );
106
    Koha::OAI::Client::Harvester->new( { server => $server, days => $days, force => $force, logger => \&logFunction } );
107
$harvester->init();
107
$harvester->init();
108
108
109
cronlogaction( { action => 'End', info => "Ending OAI Harvest" } );
109
cronlogaction( { action => 'End', info => "Ending OAI Harvest" } );
110
111
sub logFunction {
112
    my $message = shift;
113
    print $message . "\n" if ($verbose);
114
    cronlogaction( { info => $message } );
115
}
116
110
exit(0);
117
exit(0);
(-)a/t/db_dependent/Koha/OAIHarvester.t (-5 / +5 lines)
Lines 27-34 use HTTP::OAI::Metadata::OAI_DC; Link Here
27
use HTTP::OAI::Record;
27
use HTTP::OAI::Record;
28
use HTTP::OAI::Encapsulation;
28
use HTTP::OAI::Encapsulation;
29
use Koha::Database;
29
use Koha::Database;
30
use Koha::OaiServer;
30
use Koha::OAIServer;
31
use Koha::OaiServers;
31
use Koha::OAIServers;
32
use Koha::OAI::Client::Harvester;
32
use Koha::OAI::Client::Harvester;
33
33
34
my $schema  = Koha::Database->new->schema;
34
my $schema  = Koha::Database->new->schema;
Lines 36-42 my $builder = t::lib::TestBuilder->new; Link Here
36
36
37
$schema->storage->txn_begin;
37
$schema->storage->txn_begin;
38
38
39
my $new_oai_1 = Koha::OaiServer->new(
39
my $new_oai_1 = Koha::OAIServer->new(
40
    {
40
    {
41
        endpoint   => 'my_host1.org',
41
        endpoint   => 'my_host1.org',
42
        oai_set    => 'set1',
42
        oai_set    => 'set1',
Lines 85-95 $r->header->datestamp('2018-05-10T09:18:13Z'); Link Here
85
$status = $harvester->processRecord($r);
85
$status = $harvester->processRecord($r);
86
is( $status, 'updated', 'When force is not used, record is updated if newer' );
86
is( $status, 'updated', 'When force is not used, record is updated if newer' );
87
87
88
my $imported_record = Koha::Import::Oaipmh::Biblios->find( { identifier => 'oai:myarchive.org:oid-234' } );
88
my $imported_record = Koha::Import::OAI::Biblios->find( { identifier => 'oai:myarchive.org:oid-234' } );
89
my $added_datestamp = $imported_record->datestamp;
89
my $added_datestamp = $imported_record->datestamp;
90
$r->header->datestamp(undef);
90
$r->header->datestamp(undef);
91
$status          = $harvester->processRecord($r);
91
$status          = $harvester->processRecord($r);
92
$imported_record = Koha::Import::Oaipmh::Biblios->find( { identifier => 'oai:myarchive.org:oid-234' } );
92
$imported_record = Koha::Import::OAI::Biblios->find( { identifier => 'oai:myarchive.org:oid-234' } );
93
my $updated_datestamp = $imported_record->datestamp;
93
my $updated_datestamp = $imported_record->datestamp;
94
isnt(
94
isnt(
95
    $added_datestamp, $updated_datestamp,
95
    $added_datestamp, $updated_datestamp,
(-)a/t/db_dependent/Koha/OAIServers.t (-10 / +9 lines)
Lines 23-30 use Test::Exception; Link Here
23
23
24
use t::lib::TestBuilder;
24
use t::lib::TestBuilder;
25
use Koha::Database;
25
use Koha::Database;
26
use Koha::OaiServer;
26
use Koha::OAIServer;
27
use Koha::OaiServers;
27
use Koha::OAIServers;
28
28
29
my $schema  = Koha::Database->new->schema;
29
my $schema  = Koha::Database->new->schema;
30
my $builder = t::lib::TestBuilder->new;
30
my $builder = t::lib::TestBuilder->new;
Lines 32-39 my $builder = t::lib::TestBuilder->new; Link Here
32
subtest 'new, find and delete tests' => sub {
32
subtest 'new, find and delete tests' => sub {
33
    plan tests => 4;
33
    plan tests => 4;
34
    $schema->storage->txn_begin;
34
    $schema->storage->txn_begin;
35
    my $nb_of_oais = Koha::OaiServers->search->count;
35
    my $nb_of_oais = Koha::OAIServers->search->count;
36
    my $new_oai_1  = Koha::OaiServer->new(
36
    my $new_oai_1  = Koha::OAIServer->new(
37
        {
37
        {
38
            endpoint   => 'my_host1.org',
38
            endpoint   => 'my_host1.org',
39
            oai_set    => 'set1',
39
            oai_set    => 'set1',
Lines 42-48 subtest 'new, find and delete tests' => sub { Link Here
42
            recordtype => 'biblio',
42
            recordtype => 'biblio',
43
        }
43
        }
44
    )->store;
44
    )->store;
45
    my $new_oai_2 = Koha::OaiServer->new(
45
    my $new_oai_2 = Koha::OAIServer->new(
46
        {
46
        {
47
            endpoint   => 'my_host2.org',
47
            endpoint   => 'my_host2.org',
48
            oai_set    => 'set2',
48
            oai_set    => 'set2',
Lines 53-68 subtest 'new, find and delete tests' => sub { Link Here
53
    )->store;
53
    )->store;
54
54
55
    like( $new_oai_1->id, qr|^\d+$|, 'Adding a new oai server should have set the id' );
55
    like( $new_oai_1->id, qr|^\d+$|, 'Adding a new oai server should have set the id' );
56
    is( Koha::OaiServers->search->count, $nb_of_oais + 2, 'The 2 oai servers should have been added' );
56
    is( Koha::OAIServers->search->count, $nb_of_oais + 2, 'The 2 oai servers should have been added' );
57
57
58
    my $retrieved_oai_1 = Koha::OaiServers->find( $new_oai_1->id );
58
    my $retrieved_oai_1 = Koha::OAIServers->find( $new_oai_1->id );
59
    is(
59
    is(
60
        $retrieved_oai_1->servername, $new_oai_1->servername,
60
        $retrieved_oai_1->servername, $new_oai_1->servername,
61
        'Find a oai server by id should return the correct oai server'
61
        'Find a oai server by id should return the correct oai server'
62
    );
62
    );
63
63
64
    $retrieved_oai_1->delete;
64
    $retrieved_oai_1->delete;
65
    is( Koha::OaiServers->search->count, $nb_of_oais + 1, 'Delete should have deleted the oai server' );
65
    is( Koha::OAIServers->search->count, $nb_of_oais + 1, 'Delete should have deleted the oai server' );
66
66
67
    $schema->storage->txn_rollback;
67
    $schema->storage->txn_rollback;
68
};
68
};
Lines 72-78 subtest 'Check NOT NULL without default values' => sub { Link Here
72
    $schema->storage->txn_begin;
72
    $schema->storage->txn_begin;
73
    local $SIG{__WARN__} = sub { };    # TODO Needed it for suppressing DBIx warns
73
    local $SIG{__WARN__} = sub { };    # TODO Needed it for suppressing DBIx warns
74
74
75
    my $server = Koha::OaiServer->new(
75
    my $server = Koha::OAIServer->new(
76
        {
76
        {
77
            oai_set    => 'set3',
77
            oai_set    => 'set3',
78
            dataformat => 'marcxml',
78
            dataformat => 'marcxml',
79
- 

Return to bug 35659