item rework: moved GetMarcItem
authorGalen Charlton <galen.charlton@liblime.com>
Thu, 3 Jan 2008 18:36:19 +0000 (12:36 -0600)
committerJoshua Ferraro <jmf@liblime.com>
Thu, 3 Jan 2008 22:23:56 +0000 (16:23 -0600)
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 <crc@liblime.com>
Signed-off-by: Joshua Ferraro <jmf@liblime.com>
C4/Biblio.pm
C4/Items.pm
cataloguing/additem.pl

index d4571d3..2c7ee4f 100755 (executable)
@@ -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
index a3c9725..02aebe1 100644 (file)
@@ -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<cataloguing/additem.pl>,
+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
index e575fa6..b806a0a 100755 (executable)
@@ -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") {