koha-cvs
[Top][All Lists]
Advanced

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

[Koha-cvs] CVS: koha/misc rebuildnonmarc.pl,1.3,1.4


From: Paul POULAIN
Subject: [Koha-cvs] CVS: koha/misc rebuildnonmarc.pl,1.3,1.4
Date: Thu, 23 Sep 2004 09:23:58 -0700

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

Modified Files:
        rebuildnonmarc.pl 
Log Message:
fixing a major bug in rebuildnonmarc (calculation of itemnumber was wrong & 
caused SQL bugs everywhere)
improving performance by not rewritting the MARC DB, it's useless

Index: rebuildnonmarc.pl
===================================================================
RCS file: /cvsroot/koha/koha/misc/rebuildnonmarc.pl,v
retrieving revision 1.3
retrieving revision 1.4
diff -C2 -r1.3 -r1.4
*** rebuildnonmarc.pl   13 Aug 2004 16:37:26 -0000      1.3
--- rebuildnonmarc.pl   23 Sep 2004 16:23:55 -0000      1.4
***************
*** 10,13 ****
--- 10,14 ----
  use C4::Context;
  use C4::Biblio;
+ use Time::HiRes qw(gettimeofday);
  
  use Getopt::Long;
***************
*** 38,41 ****
--- 39,46 ----
  my $i=0;
  my $starttime = time();
+ 
+ $|=1; # flushes output
+ my $starttime = gettimeofday;
+ 
  #1st of all, find item MARC tag.
  my ($tagfield,$tagsubfield) = 
&MARCfind_marc_from_kohafield($dbh,"items.itemnumber",'');
***************
*** 51,54 ****
--- 56,62 ----
        my @items;
        my $nbitems=0;
+       print ".";
+       my $timeneeded = gettimeofday - $starttime;
+       print "$i in $timeneeded s\n" unless ($i % 50);
        $i++;
        foreach my $field (@fields) {
***************
*** 59,70 ****
                $nbitems++;
        }
!       print "$bibid\n";
        # now, create biblio and items with NEWnewXX call.
!       NEWmodbiblio($dbh,$record,$bibid) unless $test_parameter;
  #     print "biblio done\n";
        for (my $i=0;$i<=$#items;$i++) {
!               my $tmp = MARCmarc2koha($dbh,$items[$i]) unless 
$test_parameter; # finds the itemnumber
! #             warn "==> ".$items[$i]->as_formatted;
!               NEWmoditem($dbh,$items[$i],$bibid,$tmp->{itemnumber}) unless 
$test_parameter;
  #             print "1 item done\n";
        }
--- 67,80 ----
                $nbitems++;
        }
! #     print "$bibid\n";
        # now, create biblio and items with NEWnewXX call.
!       my $frameworkcode = MARCfind_frameworkcode($dbh,$bibid);
!       localNEWmodbiblio($dbh,$record,$bibid,$frameworkcode) unless 
$test_parameter;
! #     warn 'B=>'.$record->as_formatted;
  #     print "biblio done\n";
        for (my $i=0;$i<=$#items;$i++) {
!               my $tmp = MARCmarc2koha($dbh,$items[$i],$frameworkcode) unless 
$test_parameter; # finds the itemnumber
! #             warn "    I=> ".$items[$i]->as_formatted;
!               localNEWmoditem($dbh,$items[$i],$bibid,$tmp->{itemnumber},0) 
unless $test_parameter;
  #             print "1 item done\n";
        }
***************
*** 73,74 ****
--- 83,132 ----
  my $timeneeded = time() - $starttime;
  print "$i MARC record done in $timeneeded seconds\n";
+ 
+ # modified NEWmodbiblio to jump the MARC part of the biblio modif
+ # highly faster
+ sub localNEWmodbiblio {
+       my ($dbh,$record,$bibid,$frameworkcode) address@hidden;
+       $frameworkcode="" unless $frameworkcode;
+ #     &MARCmodbiblio($dbh,$bibid,$record,$frameworkcode,0);
+       my $oldbiblio = MARCmarc2koha($dbh,$record,$frameworkcode);
+       my $oldbiblionumber = C4::Biblio::OLDmodbiblio($dbh,$oldbiblio);
+       C4::Biblio::OLDmodbibitem($dbh,$oldbiblio);
+       # now, modify addi authors, subject, addititles.
+       my ($tagfield,$tagsubfield) = 
MARCfind_marc_from_kohafield($dbh,"additionalauthors.author",$frameworkcode);
+       my @addiauthfields = $record->field($tagfield);
+       foreach my $addiauthfield (@addiauthfields) {
+               my @addiauthsubfields = $addiauthfield->subfield($tagsubfield);
+               foreach my $subfieldcount (0..$#addiauthsubfields) {
+                       
C4::Biblio::OLDmodaddauthor($dbh,$oldbiblionumber,$addiauthsubfields[$subfieldcount]);
+               }
+       }
+       ($tagfield,$tagsubfield) = 
MARCfind_marc_from_kohafield($dbh,"bibliosubtitle.subtitle",$frameworkcode);
+       my @subtitlefields = $record->field($tagfield);
+       foreach my $subtitlefield (@subtitlefields) {
+               my @subtitlesubfields = $subtitlefield->subfield($tagsubfield);
+               foreach my $subfieldcount (0..$#subtitlesubfields) {
+                       
C4::Biblio::OLDnewsubtitle($dbh,$oldbiblionumber,$subtitlesubfields[$subfieldcount]);
+               }
+       }
+       ($tagfield,$tagsubfield) = 
MARCfind_marc_from_kohafield($dbh,"bibliosubject.subject",$frameworkcode);
+       my @subj = $record->field($tagfield);
+       my @subjects;
+       foreach my $subject (@subj) {
+               my @subjsubfield = $subject->subfield($tagsubfield);
+               foreach my $subfieldcount (0..$#subjsubfield) {
+                       push @subjects,$subjsubfield[$subfieldcount];
+               }
+       }
+       C4::Biblio::OLDmodsubject($dbh,$oldbiblionumber,1,@subjects);
+       return 1;
+ }
+ 
+ sub localNEWmoditem {
+     my ( $dbh, $record, $bibid, $itemnumber, $delete ) = @_;
+ #     warn "NEWmoditem $bibid / $itemnumber / $delete ".$record->as_formatted;
+ #     &MARCmoditem( $dbh, $record, $bibid, $itemnumber, $delete );
+       my $frameworkcode=MARCfind_frameworkcode($dbh,$bibid);
+     my $olditem = MARCmarc2koha( $dbh, $record,$frameworkcode );
+     C4::Biblio::OLDmoditem( $dbh, $olditem );
+ }




reply via email to

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