Bugzilla – Attachment 29961 Details for
Bug 12477
We need better ways to manage and update MARC Frameworks
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
DBIC-based framework updater
Frameworks.pm (text/plain), 3.23 KB, created by
David Cook
on 2014-07-23 05:01:26 UTC
(
hide
)
Description:
DBIC-based framework updater
Filename:
MIME Type:
Creator:
David Cook
Created:
2014-07-23 05:01:26 UTC
Size:
3.23 KB
patch
obsolete
>package Koha::Prosentient::Frameworks; > ># This file is part of Koha. ># ># Copyright Prosentient Systems 2014 ># ># Koha is free software; you can redistribute it and/or modify it ># under the terms of the GNU General Public License as published by ># the Free Software Foundation; either version 3 of the License, or ># (at your option) any later version. ># ># Koha is distributed in the hope that it will be useful, but ># WITHOUT ANY WARRANTY; without even the implied warranty of ># MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the ># GNU General Public License for more details. ># ># You should have received a copy of the GNU General Public License ># along with Koha; if not, see <http://www.gnu.org/licenses>. > >use Modern::Perl; > >use base qw(Class::Accessor); >__PACKAGE__->mk_accessors(qw( X )); > >=head1 NAME > >Koha::Prosentient::Frameworks > >=head1 SYNOPSIS > > use Koha::Prosentient::Frameworks; > my $KohaFrameworks = Koha::Prosentient::Frameworks->new(); > >=head1 DESCRIPTION > >This class adds third-party (ie Prosentient) MARC bibliographic framework >management functionality > >=cut > >sub new { > my ($class, $args) = @_; > $args = {} unless defined $args; > return bless ($args, $class); >} > >=head2 UpdateFrameworkStructureFromCanon > > Search the database for framework fields and subfields using a DBIC resultset, > and an arrayref of hashrefs containing a canonical version of the field or subfield > bibliographic framework. > > Resets frameworkcode value in the hashref, as well as other values via a callback function > > Inserts/updates framework fields/subfields using DBIC and callback functions. > >=cut > >sub UpdateFrameworkStructureFromCanon { > my ( $self, $args ) = @_; > > my $canonical_structure = $args->{canonical_structure}; > my $dbic_resultset = $args->{dbic_resultset}; > my $frameworkcodes = $args->{frameworkcodes}; > > my $canon_callback = $args->{canon_callback}; > my $db_insert_callback = $args->{db_insert_callback} // sub { my ( $d_unit ) = @_; $d_unit->insert; }; > my $db_update_callback = $args->{db_update_callback}; > > if ( $canonical_structure && $dbic_resultset ){ > foreach my $frameworkcode (@{$frameworkcodes}){ > #Iterate through canonical structure > foreach my $canon_unit (@{$canonical_structure}){ > $canon_unit->{frameworkcode} = $frameworkcode; > #Reset some attributes for the canon_unit using a callback > if ($canon_callback){ > $canon_callback->({ c_unit => $canon_unit, }); > } > > #Database interaction > my $database_unit = $dbic_resultset->find_or_new($canon_unit,{ key => "primary" }); > if( !$database_unit->in_storage ) { > #The callback will perform the actual insertion > if ($db_insert_callback){ > $db_insert_callback->({ d_unit => $database_unit, }); > } > } elsif ($database_unit->in_storage) { > #The callback will perform the actual update > if ($db_update_callback){ > $db_update_callback->({ d_unit => $database_unit, c_unit => $canon_unit, }); > } > } > } > } > } >} > >1;
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Raw
Actions:
View
Attachments on
bug 12477
:
29316
|
29810
|
29869
| 29961