From 7ed543b8a71874e538b4d3bc90401be5b8b939fe Mon Sep 17 00:00:00 2001 From: Galen Charlton Date: Thu, 3 Jan 2008 12:36:19 -0600 Subject: [PATCH] item rework: moved GetMarcItem Moved this function from an exported function in C4::Biblio to a public but unexported function in C4::Items. Added comment noting that this is used only by additem.pl. Signed-off-by: Chris Cormack Signed-off-by: Joshua Ferraro --- C4/Biblio.pm | 60 ------------------------------------------ C4/Items.pm | 49 ++++++++++++++++++++++++++++++++++ cataloguing/additem.pl | 2 +- 3 files changed, 50 insertions(+), 61 deletions(-) diff --git a/C4/Biblio.pm b/C4/Biblio.pm index d4571d36b8..2c7ee4f704 100755 --- a/C4/Biblio.pm +++ b/C4/Biblio.pm @@ -52,7 +52,6 @@ push @EXPORT, qw( &GetBiblioItemByBiblioNumber &GetBiblioFromItemNumber - &GetMarcItem &GetItem &GetItemInfosOf &GetItemStatus @@ -1754,65 +1753,6 @@ sub GetAuthorisedValueDesc { } } -=head2 GetMarcItem - -=over 4 - -Returns MARC::Record of the item passed in parameter. - -=back - -=cut - -sub GetMarcItem { - my ( $biblionumber, $itemnumber ) = @_; - - # GetMarcItem has been revised so that it does the following: - # 1. Gets the item information from the items table. - # 2. Converts it to a MARC field for storage in the bib record. - # - # The previous behavior was: - # 1. Get the bib record. - # 2. Return the MARC tag corresponding to the item record. - # - # The difference is that one treats the items row as authoritative, - # while the other treats the MARC representation as authoritative - # under certain circumstances. - # - # FIXME - a big one - # - # As of 2007-11-27, this change hopefully does not introduce - # any bugs. However, it does mean that for code that uses - # ModItemInMarconefield to update one subfield (corresponding to - # an items column) is now less efficient. - # - # The API needs to be shifted to the following: - # 1. User updates items record. - # 2. Linked bib is sent for indexing. - # - # The missing step 1.5 is updating the item tag in the bib MARC record - # so that the indexes are updated. Depending on performance considerations, - # this may ultimately mean of of the following: - # a. MARC field for item is updated right away. - # b. MARC field for item is updated only as part of indexing. - # c. MARC field for item is never actually stored in bib record; instead - # it is generated only when needed for indexing, item export, and - # (maybe) OPAC display. - # - - my $itemrecord = GetItem($itemnumber); - - # Tack on 'items.' prefix to column names so that TransformKohaToMarc will work. - # Also, don't emit a subfield if the underlying field is blank. - my $mungeditem = { map { $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () } keys %{ $itemrecord } }; - - my $itemmarc = TransformKohaToMarc($mungeditem); - return $itemmarc; - -} - - - =head2 GetMarcNotes =over 4 diff --git a/C4/Items.pm b/C4/Items.pm index a3c972503e..02aebe111a 100644 --- a/C4/Items.pm +++ b/C4/Items.pm @@ -247,6 +247,55 @@ sub ModDateLastSeen { ModItem({ itemlost => 0, datelastseen => $today->output("iso") }, undef, $itemnumber); } +=head1 LIMITED USE FUNCTIONS + +The following functions, while part of the public API, +are not exported. This is generally because they are +meant to be used by only one script for a specific +purpose, and should not be used in any other context +without careful thought. + +=cut + +=head2 GetMarcItem + +=over 4 + +Returns MARC::Record of the item passed in parameter. +This function is meant for use only in C, +where it is needed to support that script's MARC-like +editor. + +=back + +=cut + +sub GetMarcItem { + my ( $biblionumber, $itemnumber ) = @_; + + # GetMarcItem has been revised so that it does the following: + # 1. Gets the item information from the items table. + # 2. Converts it to a MARC field for storage in the bib record. + # + # The previous behavior was: + # 1. Get the bib record. + # 2. Return the MARC tag corresponding to the item record. + # + # The difference is that one treats the items row as authoritative, + # while the other treats the MARC representation as authoritative + # under certain circumstances. + + my $itemrecord = GetItem($itemnumber); + + # Tack on 'items.' prefix to column names so that TransformKohaToMarc will work. + # Also, don't emit a subfield if the underlying field is blank. + my $mungeditem = { map { $itemrecord->{$_} ne '' ? ("items.$_" => $itemrecord->{$_}) : () } keys %{ $itemrecord } }; + + my $itemmarc = TransformKohaToMarc($mungeditem); + return $itemmarc; + +} + =head1 PRIVATE FUNCTIONS AND VARIABLES The following functions are not meant to be called diff --git a/cataloguing/additem.pl b/cataloguing/additem.pl index e575fa6055..b806a0af17 100755 --- a/cataloguing/additem.pl +++ b/cataloguing/additem.pl @@ -127,7 +127,7 @@ if ($op eq "additem") { } elsif ($op eq "edititem") { #------------------------------------------------------------------------------- # retrieve item if exist => then, it's a modif - $itemrecord = GetMarcItem($biblionumber,$itemnumber); + $itemrecord = C4::Items::GetMarcItem($biblionumber,$itemnumber); $nextop="saveitem"; #------------------------------------------------------------------------------- } elsif ($op eq "delitem") { -- 2.39.5