koha-cvs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Koha-cvs] CVS: koha/C4 Biblio.pm,1.123,1.124


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/C4 Biblio.pm,1.123,1.124
Date: Wed, 10 Aug 2005 03:21:19 -0700

Update of /cvsroot/koha/koha/C4
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31577/C4

Modified Files:
        Biblio.pm 
Log Message:
continuing the road to zebra :
- the biblio add begins to work.
- the biblio modif begins to work.

(still without doing anything on zebra)
(no new change in updatedatabase)

Index: Biblio.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Biblio.pm,v
retrieving revision 1.123
retrieving revision 1.124
diff -C2 -r1.123 -r1.124
*** Biblio.pm   9 Aug 2005 14:10:28 -0000       1.123
--- Biblio.pm   10 Aug 2005 10:21:15 -0000      1.124
***************
*** 24,27 ****
--- 24,28 ----
  use MARC::Record;
  use MARC::File::USMARC;
+ use MARC::File::XML;
  
  use vars qw($VERSION @ISA @EXPORT);
***************
*** 484,488 ****
        my ($marc) = $sth->fetchrow;
        my $record = MARC::File::USMARC::decode($marc);
-       warn "$biblionumber => $marc = ".$record->as_usmarc();
      return $record;
  }
--- 485,488 ----
***************
*** 951,954 ****
--- 951,955 ----
        my $field; # if tag >=10
        for (my $i=0; $i< @$rtags; $i++) {
+               next unless @$rvalues[$i];
                # rebuild MARC::Record
  #                     warn "0=>"address@hidden@$rsubfields[$i]." = 
"address@hidden": ";
***************
*** 1124,1135 ****
  #
  
! =item ($bibid,$oldbibnum,$oldbibitemnum) = 
NEWnewbibilio($dbh,$MARCRecord,$oldbiblio,$oldbiblioitem);
  
! creates a new biblio from a MARC::Record. The 3rd and 4th parameter are 
hashes and may be ignored. If only 2 params are passed to the sub, the old-db 
hashes
! are builded from the MARC::Record. If they are passed, they are used.
  
  =item NEWnewitem($dbh, $record,$bibid);
  
! adds an item in the db.
  
  =cut
--- 1125,1135 ----
  #
  
! =item ($bibid,$oldbibnum,$oldbibitemnum) = 
NEWnewbibilio($dbh,$MARCRecord,$frameworkcode);
  
! creates a biblio from a MARC::Record.
  
  =item NEWnewitem($dbh, $record,$bibid);
  
! creates an item from a MARC::Record
  
  =cut
***************
*** 1137,1149 ****
  sub NEWnewbiblio {
      my ( $dbh, $record, $frameworkcode ) = @_;
!     my $oldbibnum;
!     my $oldbibitemnum;
      my $olddata = MARCmarc2koha( $dbh, $record,$frameworkcode );
!     $oldbibnum = OLDnewbiblio( $dbh, $olddata );
!       $olddata->{'biblionumber'} = $oldbibnum;
!     $oldbibitemnum = OLDnewbiblioitem( $dbh, $olddata );
  
      # search subtiles, addiauthors and subjects
!     my ( $tagfield, $tagsubfield ) =
        MARCfind_marc_from_kohafield( $dbh, 
"additionalauthors.author",$frameworkcode );
      my @addiauthfields = $record->field($tagfield);
--- 1137,1173 ----
  sub NEWnewbiblio {
      my ( $dbh, $record, $frameworkcode ) = @_;
!     my $biblionumber;
!     my $biblioitemnumber;
      my $olddata = MARCmarc2koha( $dbh, $record,$frameworkcode );
!       $olddata->{frameworkcode} = $frameworkcode;
!     $biblionumber = OLDnewbiblio( $dbh, $olddata );
!       $olddata->{biblionumber} = $biblionumber;
!       # add biblionumber into the MARC record (it's the ID for zebra)
!       my ( $tagfield, $tagsubfield ) =
!                                       MARCfind_marc_from_kohafield( $dbh, 
"biblio.biblionumber",$frameworkcode );
!       # create the field
!       my $newfield;
!       if ($tagfield<10) {
!               $newfield = MARC::Field->new(
!                       $tagfield, $biblionumber,
!               );
!       } else {
!               $newfield = MARC::Field->new(
!                       $tagfield, '', '', "$tagsubfield" => $biblionumber,
!               );
!       }
!       # drop old field (just in case it already exist and create new one...
!       my $old_field = $record->field($tagfield);
!       $record->delete_field($old_field);
!       $record->add_fields($newfield);
! 
!       #create the marc entry, that stores the rax marc record in Koha 3.0
!       $olddata->{marc} = $record->as_usmarc();
!       $olddata->{marcxml} = $record->as_xml();
!       # and create biblioitem, that's all folks !
!     $biblioitemnumber = OLDnewbiblioitem( $dbh, $olddata );
  
      # search subtiles, addiauthors and subjects
!     ( $tagfield, $tagsubfield ) =
        MARCfind_marc_from_kohafield( $dbh, 
"additionalauthors.author",$frameworkcode );
      my @addiauthfields = $record->field($tagfield);
***************
*** 1151,1155 ****
          my @addiauthsubfields = $addiauthfield->subfield($tagsubfield);
          foreach my $subfieldcount ( 0 .. $#addiauthsubfields ) {
!             OLDmodaddauthor( $dbh, $oldbibnum,
                  $addiauthsubfields[$subfieldcount] );
          }
--- 1175,1179 ----
          my @addiauthsubfields = $addiauthfield->subfield($tagsubfield);
          foreach my $subfieldcount ( 0 .. $#addiauthsubfields ) {
!             OLDmodaddauthor( $dbh, $biblionumber,
                  $addiauthsubfields[$subfieldcount] );
          }
***************
*** 1161,1165 ****
          my @subtitlesubfields = $subtitlefield->subfield($tagsubfield);
          foreach my $subfieldcount ( 0 .. $#subtitlesubfields ) {
!             OLDnewsubtitle( $dbh, $oldbibnum,
                  $subtitlesubfields[$subfieldcount] );
          }
--- 1185,1189 ----
          my @subtitlesubfields = $subtitlefield->subfield($tagsubfield);
          foreach my $subfieldcount ( 0 .. $#subtitlesubfields ) {
!             OLDnewsubtitle( $dbh, $biblionumber,
                  $subtitlesubfields[$subfieldcount] );
          }
***************
*** 1175,1239 ****
          }
      }
!     OLDmodsubject( $dbh, $oldbibnum, 1, @subjects );
! 
!     # we must add bibnum and bibitemnum in MARC::Record...
!     # we build the new field with biblionumber and biblioitemnumber
!     # we drop the original field
!     # we add the new builded field.
! # NOTE : Works only if the field is ONLY for biblionumber and biblioitemnumber
!     # (steve and paul : thinks 090 is a good choice)
!     my $sth =
!       $dbh->prepare(
! "select tagfield,tagsubfield from marc_subfield_structure where kohafield=?"
!     );
!     $sth->execute("biblio.biblionumber");
!     ( my $tagfield1, my $tagsubfield1 ) = $sth->fetchrow;
!     $sth->execute("biblioitems.biblioitemnumber");
!     ( my $tagfield2, my $tagsubfield2 ) = $sth->fetchrow;
!       my $newfield;
!       # biblionumber & biblioitemnumber are in different fields
!     if ( $tagfield1 != $tagfield2 ) {
!               # deal with biblionumber
!               if ($tagfield1<10) {
!                       $newfield = MARC::Field->new(
!                               $tagfield1, $oldbibnum,
!                       );
!               } else {
!                       $newfield = MARC::Field->new(
!                               $tagfield1, '', '', "$tagsubfield1" => 
$oldbibnum,
!                       );
!               }
!               # drop old field and create new one...
!               my $old_field = $record->field($tagfield1);
!               $record->delete_field($old_field);
!               $record->add_fields($newfield);
!               # deal with biblioitemnumber
!               if ($tagfield2<10) {
!                       $newfield = MARC::Field->new(
!                               $tagfield2, $oldbibitemnum,
!                       );
!               } else {
!                       $newfield = MARC::Field->new(
!                               $tagfield2, '', '', "$tagsubfield2" => 
$oldbibitemnum,
!                       );
!               }
!               # drop old field and create new one...
!               $old_field = $record->field($tagfield2);
!               $record->delete_field($old_field);
!               $record->add_fields($newfield);
!       # biblionumber & biblioitemnumber are in the same field (can't be <10 
as fields <10 have only 1 value)
!       } else {
!               my $newfield = MARC::Field->new(
!                       $tagfield1, '', '', "$tagsubfield1" => $oldbibnum,
!                       "$tagsubfield2" => $oldbibitemnum
!               );
!               # drop old field and create new one...
!               my $old_field = $record->field($tagfield1);
!               $record->delete_field($old_field);
!               $record->add_fields($newfield);
!       }
! #     warn "REC : ".$record->as_formatted;
!     my $bibid = MARCaddbiblio( $dbh, $record, $oldbibnum, $frameworkcode );
!     return ( $bibid, $oldbibnum, $oldbibitemnum );
  }
  
--- 1199,1204 ----
          }
      }
!     OLDmodsubject( $dbh, $biblionumber, 1, @subjects );
!     return ( $biblionumber, $biblioitemnumber );
  }
  
***************
*** 1244,1253 ****
        return 1;
  }
  sub NEWmodbiblio {
!       my ($dbh,$record,$bibid,$frameworkcode) address@hidden;
        $frameworkcode="" unless $frameworkcode;
!       &MARCmodbiblio($dbh,$bibid,$record,$frameworkcode,0);
        my $oldbiblio = MARCmarc2koha($dbh,$record,$frameworkcode);
!       my $oldbiblionumber = OLDmodbiblio($dbh,$oldbiblio);
        OLDmodbibitem($dbh,$oldbiblio);
        # now, modify addi authors, subject, addititles.
--- 1209,1225 ----
        return 1;
  }
+ 
  sub NEWmodbiblio {
!       my ($dbh,$record,$biblionumber,$frameworkcode) address@hidden;
        $frameworkcode="" unless $frameworkcode;
! #     &MARCmodbiblio($dbh,$bibid,$record,$frameworkcode,0);
        my $oldbiblio = MARCmarc2koha($dbh,$record,$frameworkcode);
!       
!       $oldbiblio->{frameworkcode} = $frameworkcode;
!       #create the marc entry, that stores the rax marc record in Koha 3.0
!       $oldbiblio->{marc} = $record->as_usmarc();
!       $oldbiblio->{marcxml} = $record->as_xml();
!       
!       OLDmodbiblio($dbh,$oldbiblio);
        OLDmodbibitem($dbh,$oldbiblio);
        # now, modify addi authors, subject, addititles.
***************
*** 1257,1261 ****
                my @addiauthsubfields = $addiauthfield->subfield($tagsubfield);
                foreach my $subfieldcount (0..$#addiauthsubfields) {
!                       
OLDmodaddauthor($dbh,$oldbiblionumber,$addiauthsubfields[$subfieldcount]);
                }
        }
--- 1229,1233 ----
                my @addiauthsubfields = $addiauthfield->subfield($tagsubfield);
                foreach my $subfieldcount (0..$#addiauthsubfields) {
!                       
OLDmodaddauthor($dbh,$biblionumber,$addiauthsubfields[$subfieldcount]);
                }
        }
***************
*** 1266,1273 ****
                # delete & create subtitle again because OLDmodsubtitle can't 
handle new subtitles
                # between 2 modifs
!               $dbh->do("delete from bibliosubtitle where 
biblionumber=$oldbiblionumber");
                foreach my $subfieldcount (0..$#subtitlesubfields) {
                        foreach my $subtit(split 
/\||#/,$subtitlesubfields[$subfieldcount]) {
!                               OLDnewsubtitle($dbh,$oldbiblionumber,$subtit);
                        }
                }
--- 1238,1245 ----
                # delete & create subtitle again because OLDmodsubtitle can't 
handle new subtitles
                # between 2 modifs
!               $dbh->do("delete from bibliosubtitle where 
biblionumber=$biblionumber");
                foreach my $subfieldcount (0..$#subtitlesubfields) {
                        foreach my $subtit(split 
/\||#/,$subtitlesubfields[$subfieldcount]) {
!                               OLDnewsubtitle($dbh,$biblionumber,$subtit);
                        }
                }
***************
*** 1282,1286 ****
                }
        }
!       OLDmodsubject($dbh,$oldbiblionumber,1,@subjects);
        return 1;
  }
--- 1254,1258 ----
                }
        }
!       OLDmodsubject($dbh,$biblionumber,1,@subjects);
        return 1;
  }
***************
*** 1416,1420 ****
      my ( $dbh, $biblio ) = @_;
  
!     #  my $dbh    = &C4Connect;
      my $sth = $dbh->prepare("Select max(biblionumber) from biblio");
      $sth->execute;
--- 1388,1392 ----
      my ( $dbh, $biblio ) = @_;
  
!       $dbh->do('lock tables biblio WRITE');
      my $sth = $dbh->prepare("Select max(biblionumber) from biblio");
      $sth->execute;
***************
*** 1426,1431 ****
      $sth->finish;
      $sth =
!       $dbh->prepare(
! "insert into biblio set biblionumber  = ?, title = ?, author = ?, 
copyrightdate = ?, serial = ?, seriestitle = ?, notes = ?, abstract = ?, 
unititle = ?"
      );
      $sth->execute(
--- 1398,1404 ----
      $sth->finish;
      $sth =
!       $dbh->prepare("insert into biblio set   biblionumber=?, title=?,        
        author=?,       copyrightdate=?,
!                                                                               
        serial=?,               seriestitle=?,  notes=?,        abstract=?,
!                                                                               
        unititle=?"
      );
      $sth->execute(
***************
*** 1434,1443 ****
          $biblio->{'serial'},             $biblio->{'seriestitle'},
          $biblio->{'notes'},  $biblio->{'abstract'},
!               $biblio->{'unititle'},
      );
  
      $sth->finish;
! 
!     #  $dbh->disconnect;
      return ($bibnum);
  }
--- 1407,1415 ----
          $biblio->{'serial'},             $biblio->{'seriestitle'},
          $biblio->{'notes'},  $biblio->{'abstract'},
!               $biblio->{'unititle'}
      );
  
      $sth->finish;
!       $dbh->do('unlock tables');
      return ($bibnum);
  }
***************
*** 1445,1468 ****
  sub OLDmodbiblio {
      my ( $dbh, $biblio ) = @_;
! 
!     #  my $dbh   = C4Connect;
!     my $query;
!     my $sth;
! 
!     $query = "";
!     $sth   =
!       $dbh->prepare(
! "Update biblio set title = ?, author = ?, abstract = ?, copyrightdate = ?, 
seriestitle = ?, serial = ?, unititle = ?, notes = ? where biblionumber = ?"
      );
      $sth->execute(
!         $biblio->{'title'},       $biblio->{'author'},
!         $biblio->{'abstract'},    $biblio->{'copyrightdate'},
!         $biblio->{'seriestitle'}, $biblio->{'serial'},
!         $biblio->{'unititle'},    $biblio->{'notes'},
!         $biblio->{'biblionumber'}
      );
! 
!     $sth->finish;
!     return ( $biblio->{'biblionumber'} );
  }    # sub modbiblio
  
--- 1417,1434 ----
  sub OLDmodbiblio {
      my ( $dbh, $biblio ) = @_;
!     my $sth = $dbh->prepare("Update biblio set        title=?,                
author=?,       abstract=?,     copyrightdate=?,
!                                                                               
                seriestitle=?,  serial=?,       unititle=?,     notes=?,        
frameworkcode=? 
!                                                                               
        where biblionumber = ?"
      );
      $sth->execute(
!               $biblio->{'title'},       $biblio->{'author'},
!               $biblio->{'abstract'},    $biblio->{'copyrightdate'},
!               $biblio->{'seriestitle'}, $biblio->{'serial'},
!               $biblio->{'unititle'},    $biblio->{'notes'},
!               $biblio->{frameworkcode},
!               $biblio->{'biblionumber'}
      );
!       $sth->finish;
!       return ( $biblio->{'biblionumber'} );
  }    # sub modbiblio
  
***************
*** 1569,1613 ****
      my $query;
  
!     $biblioitem->{'itemtype'}      = $dbh->quote( $biblioitem->{'itemtype'} );
!     $biblioitem->{'url'}           = $dbh->quote( $biblioitem->{'url'} );
!     $biblioitem->{'isbn'}          = $dbh->quote( $biblioitem->{'isbn'} );
!     $biblioitem->{'issn'}          = $dbh->quote( $biblioitem->{'issn'} );
!     $biblioitem->{'publishercode'} =
!       $dbh->quote( $biblioitem->{'publishercode'} );
!     $biblioitem->{'publicationyear'} =
!       $dbh->quote( $biblioitem->{'publicationyear'} );
!     $biblioitem->{'classification'} =
!       $dbh->quote( $biblioitem->{'classification'} );
!     $biblioitem->{'dewey'}       = $dbh->quote( $biblioitem->{'dewey'} );
!     $biblioitem->{'subclass'}    = $dbh->quote( $biblioitem->{'subclass'} );
!     $biblioitem->{'illus'}       = $dbh->quote( $biblioitem->{'illus'} );
!     $biblioitem->{'pages'}       = $dbh->quote( $biblioitem->{'pages'} );
!     $biblioitem->{'volumeddesc'} = $dbh->quote( $biblioitem->{'volumeddesc'} 
);
!     $biblioitem->{'bnotes'}      = $dbh->quote( $biblioitem->{'bnotes'} );
!     $biblioitem->{'size'}        = $dbh->quote( $biblioitem->{'size'} );
!     $biblioitem->{'place'}       = $dbh->quote( $biblioitem->{'place'} );
! 
!     $query = "Update biblioitems set
! itemtype        = $biblioitem->{'itemtype'},
! url             = $biblioitem->{'url'},
! isbn            = $biblioitem->{'isbn'},
! issn            = $biblioitem->{'issn'},
! publishercode   = $biblioitem->{'publishercode'},
! publicationyear = $biblioitem->{'publicationyear'},
! classification  = $biblioitem->{'classification'},
! dewey           = $biblioitem->{'dewey'},
! subclass        = $biblioitem->{'subclass'},
! illus           = $biblioitem->{'illus'},
! pages           = $biblioitem->{'pages'},
! volumeddesc     = $biblioitem->{'volumeddesc'},
! notes                 = $biblioitem->{'bnotes'},
! size          = $biblioitem->{'size'},
! place         = $biblioitem->{'place'}
! where biblioitemnumber = $biblioitem->{'biblioitemnumber'}";
! 
!     $dbh->do($query);
!     if ( $dbh->errstr ) {
!         warn "$query";
!     }
  }    # sub modbibitem
  
--- 1535,1550 ----
      my $query;
  
!     my $sth = $dbh->prepare("update biblioitems set   itemtype=?,             
        url=?,                          isbn=?, issn=?,
!                                                                               
publishercode=?,        publicationyear=?,      classification=?,       dewey=?,
!                                                                               
subclass=?,                     illus=?,                        pages=?,        
                volumeddesc=?,
!                                                                               
notes=?,                        size=?,                         place=?,        
                marc=?,
!                                                                               
marcxml=?
!                                                       where 
biblioitemnumber=?");
!       $sth->execute(  $biblioitem->{itemtype},                
$biblioitem->{url},             $biblioitem->{isbn},    $biblioitem->{issn},
!                               $biblioitem->{publishercode},   
$biblioitem->{publicationyear}, $biblioitem->{classification},  
$biblioitem->{dewey},
!                               $biblioitem->{subclass},                
$biblioitem->{illus},           $biblioitem->{pages},   
$biblioitem->{volumeddesc},
!                               $biblioitem->{bnotes},                  
$biblioitem->{size},            $biblioitem->{place},   $biblioitem->{marc},
!                                       $biblioitem->{marcxml},                 
$biblioitem->{biblioitemnumber});
! #     warn "MOD : $biblioitem->{biblioitemnumber} = ".$biblioitem->{marc};
  }    # sub modbibitem
  
***************
*** 1650,1654 ****
                                                                        pages   
         = ?,                           notes            = ?,
                                                                        size    
         = ?,                           lccn             = ?,
!                                                                       marc    
         = ?,                           place            = ?"
      );
      $sth->execute(
--- 1587,1592 ----
                                                                        pages   
         = ?,                           notes            = ?,
                                                                        size    
         = ?,                           lccn             = ?,
!                                                                       marc    
         = ?,                           place            = ?,
!                                                                       marcxml 
         = ?"
      );
      $sth->execute(
***************
*** 1663,1667 ****
          $biblioitem->{'pages'},          $biblioitem->{'bnotes'},
          $biblioitem->{'size'},           $biblioitem->{'lccn'},
!         $biblioitem->{'marc'},           $biblioitem->{'place'}
      );
      $sth->finish;
--- 1601,1606 ----
          $biblioitem->{'pages'},          $biblioitem->{'bnotes'},
          $biblioitem->{'size'},           $biblioitem->{'lccn'},
!         $biblioitem->{'marc'},           $biblioitem->{'place'},
!               $biblioitem->{marcxml},
      );
      $sth->finish;
***************
*** 2661,2664 ****
--- 2600,2611 ----
  # $Id$
  # $Log$
+ # Revision 1.124  2005/08/10 10:21:15  tipaul
+ # continuing the road to zebra :
+ # - the biblio add begins to work.
+ # - the biblio modif begins to work.
+ #
+ # (still without doing anything on zebra)
+ # (no new change in updatedatabase)
+ #
  # Revision 1.123  2005/08/09 14:10:28  tipaul
  # 1st commit to go to zebra.




reply via email to

[Prev in Thread] Current Thread [Next in Thread]