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

(-)a/Koha/Z3950Server.pm (+46 lines)
Line 0 Link Here
1
package Koha::Z3950Server;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use base qw(Koha::Object);
25
26
=head1 NAME
27
28
Koha::Z3950Server - Koha Z3950Server Object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 _type
37
38
Return type of Object relating to Schema ResultSet
39
40
=cut
41
42
sub _type {
43
    return 'Z3950server';
44
}
45
46
1;
(-)a/Koha/Z3950Servers.pm (+58 lines)
Line 0 Link Here
1
package Koha::Z3950Servers;
2
3
# This file is part of Koha.
4
#
5
# Koha is free software; you can redistribute it and/or modify it under the
6
# terms of the GNU General Public License as published by the Free Software
7
# Foundation; either version 3 of the License, or (at your option) any later
8
# version.
9
#
10
# Koha is distributed in the hope that it will be useful, but WITHOUT ANY
11
# WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
12
# A PARTICULAR PURPOSE.  See the GNU General Public License for more details.
13
#
14
# You should have received a copy of the GNU General Public License along
15
# with Koha; if not, write to the Free Software Foundation, Inc.,
16
# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
17
18
use Modern::Perl;
19
20
use Carp;
21
22
use Koha::Database;
23
24
use Koha::Z3950Server;
25
26
use base qw(Koha::Objects);
27
28
=head1 NAME
29
30
Koha::Z3950Servers - Koha Z3950Server Object set class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
Return type of object, relating to Schema ResultSet
41
42
=cut
43
44
sub _type {
45
    return 'Z3950server';
46
}
47
48
=head3 object_class
49
50
Return object class
51
52
=cut
53
54
sub object_class {
55
    return 'Koha::Z3950Server';
56
}
57
58
1;
(-)a/authorities/authorities-home.pl (-10 / +2 lines)
Lines 37-42 use Koha::Authority::Types; Link Here
37
use Koha::SearchEngine::Search;
37
use Koha::SearchEngine::Search;
38
use Koha::SearchEngine::QueryBuilder;
38
use Koha::SearchEngine::QueryBuilder;
39
use Koha::Token;
39
use Koha::Token;
40
use Koha::Z3950Servers;
40
41
41
my $query = new CGI;
42
my $query = new CGI;
42
my $dbh   = C4::Context->dbh;
43
my $dbh   = C4::Context->dbh;
Lines 214-229 if ( $op eq '' ) { Link Here
214
215
215
}
216
}
216
217
217
my $schema = Koha::Database->new()->schema();
218
my $servers = Koha::Z3950Servers->search();
218
my $servers = $schema->resultset('Z3950server')->search(
219
        {
220
            recordtype => 'biblio',
221
            servertype => ['zed', 'sru'],
222
        },
223
        {   result_class => 'DBIx::Class::ResultClass::HashRefInflator',
224
            order_by     => ['rank', 'servername'],
225
        },
226
);
227
219
228
$template->param(
220
$template->param(
229
    servers => $servers,
221
    servers => $servers,
(-)a/cataloguing/addbooks.pl (-10 / +2 lines)
Lines 37-42 use C4::Search; Link Here
37
use Koha::BiblioFrameworks;
37
use Koha::BiblioFrameworks;
38
use Koha::SearchEngine::Search;
38
use Koha::SearchEngine::Search;
39
use Koha::SearchEngine::QueryBuilder;
39
use Koha::SearchEngine::QueryBuilder;
40
use Koha::Z3950Servers;
40
41
41
my $input = new CGI;
42
my $input = new CGI;
42
43
Lines 133-148 for my $resultsbr (@resultsbr) { Link Here
133
    };
134
    };
134
}
135
}
135
136
136
my $schema = Koha::Database->new()->schema();
137
my $servers = Koha::Z3950Servers->search();
137
my $servers = $schema->resultset('Z3950server')->search(
138
        {
139
            recordtype => 'biblio',
140
            servertype => ['zed', 'sru'],
141
        },
142
        {   result_class => 'DBIx::Class::ResultClass::HashRefInflator',
143
            order_by     => ['rank', 'servername'],
144
        },
145
);
146
138
147
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
139
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
148
$template->param(
140
$template->param(
(-)a/t/db_dependent/Koha/Z3950Servers.t (-1 / +61 lines)
Line 0 Link Here
0
- 
1
#!/usr/bin/perl
2
3
# Copyright 2015 Koha Development team
4
#
5
# This file is part of Koha
6
#
7
# Koha is free software; you can redistribute it and/or modify it
8
# under the terms of the GNU General Public License as published by
9
# the Free Software Foundation; either version 3 of the License, or
10
# (at your option) any later version.
11
#
12
# Koha is distributed in the hope that it will be useful, but
13
# WITHOUT ANY WARRANTY; without even the implied warranty of
14
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15
# GNU General Public License for more details.
16
#
17
# You should have received a copy of the GNU General Public License
18
# along with Koha; if not, see <http://www.gnu.org/licenses>.
19
20
use Modern::Perl;
21
22
use Test::More tests => 4;
23
24
use Koha::Z3950Server;
25
use Koha::Z3950Servers;
26
use Koha::Database;
27
28
use t::lib::TestBuilder;
29
30
my $schema = Koha::Database->new->schema;
31
$schema->storage->txn_begin;
32
33
my $builder = t::lib::TestBuilder->new;
34
my $nb_of_z39s = Koha::Z3950Servers->search->count;
35
my $new_z39_1 = Koha::Z3950Server->new({
36
    host => 'my_host1.org',
37
    port => '32',
38
    db => 'db1',
39
    servername => 'my_test_1',
40
    servertype => 'zed',
41
    recordtype => 'biblio',
42
})->store;
43
my $new_z39_2 = Koha::Z3950Server->new({
44
    host => 'my_host2.org',
45
    port => '64',
46
    db => 'db2',
47
    servername => 'my_test_2',
48
    servertype => 'zed',
49
    recordtype => 'authority',
50
})->store;
51
52
like( $new_z39_1->id, qr|^\d+$|, 'Adding a new z39 server should have set the id');
53
is( Koha::Z3950Servers->search->count, $nb_of_z39s + 2, 'The 2 z39 servers should have been added' );
54
55
my $retrieved_z39_1 = Koha::Z3950Servers->find( $new_z39_1->id );
56
is( $retrieved_z39_1->servername, $new_z39_1->servername, 'Find a z39 server by id should return the correct z39 server' );
57
58
$retrieved_z39_1->delete;
59
is( Koha::Z3950Servers->search->count, $nb_of_z39s + 1, 'Delete should have deleted the z39 server' );
60
61
$schema->storage->txn_rollback;

Return to bug 20047