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

(-)a/Koha/FieldMapping.pm (-44 lines)
Lines 1-44 Link Here
1
package Koha::FieldMapping;
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::FieldMapping - Koha Field Mapping Object class
29
30
=head1 API
31
32
=head2 Class Methods
33
34
=cut
35
36
=head3 type
37
38
=cut
39
40
sub _type {
41
    return 'Fieldmapping';
42
}
43
44
1;
(-)a/Koha/FieldMappings.pm (-50 lines)
Lines 1-50 Link Here
1
package Koha::FieldMappings;
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::FieldMapping;
25
26
use base qw(Koha::Objects);
27
28
=head1 NAME
29
30
Koha::FieldMappings - Koha Field Mapping Object set class
31
32
=head1 API
33
34
=head2 Class Methods
35
36
=cut
37
38
=head3 type
39
40
=cut
41
42
sub _type {
43
    return 'Fieldmapping';
44
}
45
46
sub object_class {
47
    return 'Koha::FieldMapping';
48
}
49
50
1;
(-)a/Koha/Manual.pm (-1 lines)
Lines 79-85 our $mapping = { Link Here
79
    'admin/didyoumean'                         => '/administration.html#did-you-mean?',
79
    'admin/didyoumean'                         => '/administration.html#did-you-mean?',
80
    'admin/edi_accounts'                       => '/administration.html#edi-accounts',
80
    'admin/edi_accounts'                       => '/administration.html#edi-accounts',
81
    'admin/edi_ean_accounts'                   => '/administration.html#library-eans',
81
    'admin/edi_ean_accounts'                   => '/administration.html#library-eans',
82
    'admin/fieldmapping'                       => '/administration.html#keywords-to-marc-mapping',
83
    'admin/item_circulation_alerts'            => '/administration.html#item-circulation-alerts',
82
    'admin/item_circulation_alerts'            => '/administration.html#item-circulation-alerts',
84
    'admin/items_search_fields'                => '/administration.html#item-search-fields',
83
    'admin/items_search_fields'                => '/administration.html#item-search-fields',
85
    'admin/itemtypes'                          => '/administration.html#item-types',
84
    'admin/itemtypes'                          => '/administration.html#item-types',
(-)a/admin/fieldmapping.pl (-70 lines)
Lines 1-70 Link Here
1
#!/usr/bin/perl
2
# Copyright 2009 SARL BibLibre
3
# Copyright 2017 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
use CGI qw ( -utf8 );
22
use C4::Auth;
23
use C4::Biblio;
24
use C4::Output;
25
26
use Koha::BiblioFrameworks;
27
use Koha::FieldMappings;
28
29
my $query = new CGI;
30
31
my $frameworkcode = $query->param('framework') || "";
32
my $field         = $query->param('fieldname');
33
my $fieldcode     = $query->param('marcfield');
34
my $subfieldcode  = $query->param('marcsubfield');
35
my $op            = $query->param('op') || q{};
36
my $id            = $query->param('id');
37
38
my ( $template, $loggedinuser, $cookie ) = get_template_and_user(
39
    {
40
        template_name   => "admin/fieldmapping.tt",
41
        query           => $query,
42
        type            => "intranet",
43
        authnotrequired => 0,
44
        flagsrequired   => { parameters => 'manage_keywords2marc_mappings' },
45
        debug           => 1,
46
    }
47
);
48
49
# FIXME Add exceptions
50
if ( $op eq "delete" and $id ) {
51
    Koha::FieldMappings->find($id)->delete;
52
} elsif ( $field and $fieldcode ) {
53
    my $params = { frameworkcode => $frameworkcode, field => $field, fieldcode => $fieldcode, subfieldcode => $subfieldcode };
54
    my $exists = Koha::FieldMappings->search( $params )->count;;
55
    unless ( $exists ) {
56
        Koha::FieldMapping->new( $params )->store;
57
    }
58
}
59
60
my $fields = Koha::FieldMappings->search({ frameworkcode => $frameworkcode });
61
62
my $frameworks = Koha::BiblioFrameworks->search({}, { order_by => ['frameworktext'] });
63
my $framework  = $frameworks->search( { frameworkcode => $frameworkcode } )->next;
64
$template->param(
65
    frameworks => $frameworks,
66
    framework  => $framework,
67
    fields     => $fields,
68
);
69
70
output_html_with_http_headers $query, $cookie, $template->output;
(-)a/installer/data/mysql/atomicupdate/bug_11529.perl (+2 lines)
Lines 28-33 if( CheckVersion( $DBversion ) ) { Link Here
28
        $dbh->do( "UPDATE marc_subfield_structure SET kohafield='biblio.part_name' WHERE frameworkcode='' AND tagfield='245' AND tagsubfield='p'" );
28
        $dbh->do( "UPDATE marc_subfield_structure SET kohafield='biblio.part_name' WHERE frameworkcode='' AND tagfield='245' AND tagsubfield='p'" );
29
    }
29
    }
30
30
31
    $dbh->do( "DROP TABLE IF EXISTS fieldmapping" );
32
31
    # Always end with this (adjust the bug info)
33
    # Always end with this (adjust the bug info)
32
    SetVersion( $DBversion );
34
    SetVersion( $DBversion );
33
    print "Upgrade to $DBversion done (Bug 11529 - Add medium, subtitle and part information to biblio table)\n";
35
    print "Upgrade to $DBversion done (Bug 11529 - Add medium, subtitle and part information to biblio table)\n";
(-)a/installer/data/mysql/kohastructure.sql (-13 lines)
Lines 3267-3285 CREATE TABLE aqorders_transfers ( Link Here
3267
  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
3267
  CONSTRAINT aqorders_transfers_ordernumber_to FOREIGN KEY (ordernumber_to) REFERENCES aqorders (ordernumber) ON DELETE SET NULL ON UPDATE CASCADE
3268
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3268
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3269
3269
3270
--
3271
-- Table structure for table `fieldmapping`
3272
--
3273
3274
DROP TABLE IF EXISTS `fieldmapping`;
3275
CREATE TABLE `fieldmapping` ( -- koha to keyword mapping
3276
  `id` int(11) NOT NULL auto_increment, -- unique identifier assigned by Koha
3277
  `field` varchar(255) NOT NULL, -- keyword to be mapped to (ex. subtitle)
3278
  `frameworkcode` char(4) NOT NULL default '', -- foreign key from the biblio_framework table to link this mapping to a specific framework
3279
  `fieldcode` char(3) NOT NULL, -- marc field number to map to this keyword
3280
  `subfieldcode` char(1) NOT NULL, -- marc subfield associated with the fieldcode to map to this keyword
3281
  PRIMARY KEY  (`id`)
3282
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
3283
3270
3284
--
3271
--
3285
-- Table structure for table `transport_cost`
3272
-- Table structure for table `transport_cost`
(-)a/installer/data/mysql/ru-RU/marcflavour/marc21/optional/fieldmapping.sql (-3 lines)
Lines 1-3 Link Here
1
INSERT INTO `fieldmapping` (`field`, `frameworkcode`, `fieldcode`, `subfieldcode`) VALUES
2
('subtitle', 'CF',  '245', 'p'),
3
('subtitle', 'SER', '490', 'v');
(-)a/installer/data/mysql/ru-RU/marcflavour/marc21/optional/fieldmapping.txt (-1 lines)
Line 1 Link Here
1
Отображение ключевого слова в МАРК-поле (пока 490^v (SER) и 245^p (CF) в кл.сл. «subtitle»).
(-)a/installer/data/mysql/uk-UA/marcflavour/marc21/optional/fieldmapping.sql (-10 lines)
Lines 1-10 Link Here
1
-- koha to keyword mapping
2
--  id            -- unique identifier assigned by Koha (auto_increment)
3
--  field         -- keyword to be mapped to (ex. subtitle)
4
--  frameworkcode -- foreign key from the biblio_framework table to link this mapping to a specific framework (default '')
5
--  fieldcode     -- marc field number to map to this keyword
6
--  subfieldcode  -- marc subfield associated with the fieldcode to map to this keyword
7
INSERT INTO fieldmapping
8
 ( field,     frameworkcode,  fieldcode, subfieldcode) VALUES
9
 ('subtitle', 'CF',           '245',     'p'),
10
 ('subtitle', 'SER',          '490',     'v');
(-)a/installer/data/mysql/uk-UA/marcflavour/marc21/optional/fieldmapping.txt (-1 lines)
Line 1 Link Here
1
Відображення ключового слова у МАРК-поле (наразі 490^v (SER) та 245^p (CF) у кл.сл. „subtitle“).
(-)a/koha-tmpl/intranet-tmpl/prog/en/includes/admin-menu.inc (-3 lines)
Lines 58-66 Link Here
58
                <li><a href="/cgi-bin/koha/admin/biblio_framework.pl">MARC bibliographic framework</a></li>
58
                <li><a href="/cgi-bin/koha/admin/biblio_framework.pl">MARC bibliographic framework</a></li>
59
                <li><a href="/cgi-bin/koha/admin/koha2marclinks.pl">Koha to MARC mapping</a></li>
59
                <li><a href="/cgi-bin/koha/admin/koha2marclinks.pl">Koha to MARC mapping</a></li>
60
            [% END %]
60
            [% END %]
61
            [% IF ( CAN_user_parameters_manage_keywords2koha_mappings ) %]
62
                <li><a href="/cgi-bin/koha/admin/fieldmapping.pl">Keywords to MARC mapping</a></li>
63
            [% END %]
64
            [% IF ( CAN_user_parameters_manage_marc_frameworks ) %]
61
            [% IF ( CAN_user_parameters_manage_marc_frameworks ) %]
65
                <li><a href="/cgi-bin/koha/admin/checkmarc.pl">MARC bibliographic framework test</a></li>
62
                <li><a href="/cgi-bin/koha/admin/checkmarc.pl">MARC bibliographic framework test</a></li>
66
                <li><a href="/cgi-bin/koha/admin/authtypes.pl">Authority types</a></li>
63
                <li><a href="/cgi-bin/koha/admin/authtypes.pl">Authority types</a></li>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/admin-home.tt (-4 lines)
Lines 117-126 Link Here
117
                        <dt><a href="/cgi-bin/koha/admin/koha2marclinks.pl">Koha to MARC mapping</a></dt>
117
                        <dt><a href="/cgi-bin/koha/admin/koha2marclinks.pl">Koha to MARC mapping</a></dt>
118
                        <dd>Define the mapping between the Koha transactional database (SQL) and the MARC Bibliographic records.</dd>
118
                        <dd>Define the mapping between the Koha transactional database (SQL) and the MARC Bibliographic records.</dd>
119
                    [% END %]
119
                    [% END %]
120
                    [% IF ( CAN_user_parameters_manage_keywords2koha_mappings ) %]
121
                        <dt><a href="/cgi-bin/koha/admin/fieldmapping.pl">Keywords to MARC mapping</a></dt>
122
                        <dd>Define the mapping between keywords and MARC fields. The keywords are used to find some data independently of the framework.</dd>
123
                    [% END %]
124
                    [% IF ( CAN_user_parameters_manage_marc_frameworks ) %]
120
                    [% IF ( CAN_user_parameters_manage_marc_frameworks ) %]
125
                        <dt><a href="/cgi-bin/koha/admin/checkmarc.pl">MARC Bibliographic framework test</a></dt>
121
                        <dt><a href="/cgi-bin/koha/admin/checkmarc.pl">MARC Bibliographic framework test</a></dt>
126
                        <dd>Checks the MARC structure. If you change your MARC Bibliographic framework it's recommended that you run this tool to test for errors in your definition.</dd>
122
                        <dd>Checks the MARC structure. If you change your MARC Bibliographic framework it's recommended that you run this tool to test for errors in your definition.</dd>
(-)a/koha-tmpl/intranet-tmpl/prog/en/modules/admin/fieldmapping.tt (-94 lines)
Lines 1-94 Link Here
1
[% USE raw %]
2
[% USE Asset %]
3
[% SET footerjs = 1 %]
4
[% INCLUDE 'doc-head-open.inc' %]
5
<title>Koha &rsaquo; Administration &rsaquo; Keyword to MARC mapping</title>
6
[% INCLUDE 'doc-head-close.inc' %]
7
</head>
8
9
<body id="admin_fieldmapping" class="admin">
10
[% INCLUDE 'header.inc' %]
11
[% INCLUDE 'prefs-admin-search.inc' %]
12
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; Keyword to MARC mapping</div>
13
14
<div class="main container-fluid">
15
    <div class="row">
16
        <div class="col-sm-10 col-sm-push-2">
17
            <main>
18
19
            <h2>Keyword to MARC mapping</h2>
20
            [% UNLESS ( fields.count ) %]
21
                <div class="dialog message"><p>There are no mappings for the [% IF framework.frameworktext %]<em>[% framework.frameworktext | html %]</em>[% ELSE %]default[% END %] framework. </p></div>
22
            [% END %]
23
			<form method="get" action="/cgi-bin/koha/admin/fieldmapping.pl" id="selectframework">
24
				<label for="framework">Framework:</label>
25
                <select name="framework" id="framework" style="width:20em;">
26
                    <option value="">Default</option>
27
                [% FOREACH f IN frameworks %]
28
                    [% IF f.frameworkcode == framework.frameworkcode %]
29
                    <option selected="selected" value="[% f.frameworkcode | html %]">[% f.frameworktext | html %]</option>
30
                    [% ELSE %]
31
                    <option value="[% f.frameworkcode | html %]">[% f.frameworktext | html %]</option>
32
                    [% END %]
33
                [% END %]
34
                </select>
35
			<input type="submit" value="Go" />
36
			</form>
37
38
39
			<form method="post" action="" id="addfield">
40
                <input type="hidden" name="framework" value="[% framework.frameworkcode | html %]" />
41
				<fieldset class="rows">
42
				<legend>Add a mapping</legend>
43
				<ol>
44
					<li><label for="fieldname">Field name: </label><input type="text" id="fieldname" name="fieldname" /></li>
45
					<li><label for="marcfield">MARC field: </label><input type="text" id="marcfield" name="marcfield" size="3" /></li>
46
					<li><label for="marcsubfield">MARC subfield: </label><input type="text" id="marcsubfield" name="marcsubfield" size="1" /></li>
47
				</ol>
48
				<fieldset class="action">
49
					<input type="submit" value="Submit" />
50
				</fieldset>
51
				</fieldset>
52
			</form>
53
54
                [% IF ( fields.count ) %]
55
                    <table>
56
                    <caption>Mappings for the [% IF framework.frameworktext %]<em>[% framework.frameworktext | html %]</em>[% ELSE %]default[% END %] framework</caption>
57
									<tr>
58
										<th>Field</th>
59
                                        <th>MARC field</th>
60
                                        <th>MARC subfield</th>
61
										<th>&nbsp;</th>
62
									</tr>
63
									[% FOREACH field IN fields %]
64
									<tr>
65
                                        <td>[% field.field | html %]</td>
66
										<td>[% field.fieldcode | html %]</td>
67
										<td>[% field.subfieldcode | html %]</td>
68
                                        <td><a class="btn btn-default btn-xs" href="?op=delete&amp;id=[% field.id | html %]&amp;framework=[% field.frameworkcode | html %]"><i class="fa fa-trash"></i> Delete</a></td>
69
									</tr>
70
									[% END %]
71
								</table>[% END %]
72
73
            </main>
74
        </div> <!-- /.col-sm-10.col-sm-push-2 -->
75
76
        <div class="col-sm-2 col-sm-pull-10">
77
            <aside>
78
                [% INCLUDE 'admin-menu.inc' %]
79
            </aside>
80
        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
81
     </div> <!-- /.row -->
82
[% MACRO jsinclude BLOCK %]
83
    [% Asset.js("js/admin-menu.js") | $raw %]
84
    <script type="text/javascript">
85
    <script>
86
        $(document).ready(function() {
87
            $('#selectframework').find("input:submit").hide();
88
            $('#framework').change(function() {
89
                    $('#selectframework').submit();
90
            });
91
        });
92
    </script>
93
[% END %]
94
[% INCLUDE 'intranet-bottom.inc' %]
(-)a/t/db_dependent/Koha/BiblioUtils.t (-5 lines)
Lines 46-55 $biblio->append_fields( Link Here
46
);
46
);
47
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
47
my ( $biblionumber, $biblioitemnumber ) = AddBiblio( $biblio, '' );
48
48
49
my $field_mappings = Koha::Database->new()->schema()->resultset('Fieldmapping');
50
$field_mappings->delete();
51
$field_mappings->create( { field => 'subtitle', fieldcode => '245', subfieldcode => 'b' } );
52
53
$biblio = Koha::Biblios->find( $biblionumber );
49
$biblio = Koha::Biblios->find( $biblionumber );
54
my @subtitles = $biblio->subtitles();
50
my @subtitles = $biblio->subtitles();
55
is( $subtitles[0], 'Test Record Subtitle', 'Got first subtitle correctly' );
51
is( $subtitles[0], 'Test Record Subtitle', 'Got first subtitle correctly' );
56
- 

Return to bug 11529