[Koha-cvs] CVS: koha/C4 test.pl,NONE,1.1 Catalogue.pm,1.15,1.16

Paul POULAIN tipaul at users.sourceforge.net
Tue Jun 4 18:08:49 CEST 2002


Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv25038/C4

Modified Files:
	Catalogue.pm 
Added Files:
	test.pl 
Log Message:
test.pl, contains a script to test the Catalogue.pm stuff.
Catalogue.pm : marc stuff :
* the 3 xxxSubfield functions works
* the addMarcBiblio function has been added : if you pass it a perlmarcstructure (sample in test.pl and explanation in marc/perlmarcstructure file), it adds a biblio to the marc_schema. The newbiblioitem (old koha-DB) still has to be updated to build the perlmarcstructure internally and call addMarcBiblio function.




--- NEW FILE ---
#!/usr/bin/perl
use strict;
require Exporter;
use C4::Database;
use C4::Catalogue;

my $dbh=&C4Connect;
$dbh->do("delete from marc_subfield_table");
$dbh->do("delete from marc_blob_subfield");
&addSubfield(1,'001','a','1 - This is a value',1);
&addSubfield(1,'001','b','2 - This is another value',1);
&addSubfield(1,'001','c',"3 - This is a value very very long. I try to make it longer than 255 char. I need to add something else. will it be long enough now... I'm not sure. That's why i continue to add a few word to this very important sentence. Now I hope it will be enough... Oh, not it need some more characters. So i add stupid strings : xxxxxxxxxxxxxxx dddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeee rrrrrrrrrrrrrrrrrrr ffffffffffffffffff",1);
&addSubfield(1,'001','d',"4 - This is another value very very long. I try to make it longer than 255 char. I need to add something else. will it be long enough now... I'm not sure. That's why i continue to add a few word to this very important sentence. Now I hope it will be enough... Oh, not it need some more characters. So i add stupid strings : xxxxxxxxxxxxxxx dddddddddddddddddddd eeeeeeeeeeeeeeeeeeeeeee rrrrrrrrrrrrrrrrrrr ffffffffffffffffff",1);
print "change 1\n";
&changeSubfield(1,"1new - this is a changed value");
print "change 2\n";
&changeSubfield(2,"2new - go from short to long subfield... uuuuuuuuuuuuuuuuuuuuuuuu yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy tttttttttttttttttttttttttttttttt rrrrrrrrrrrrrrrrrrrrrr eeeeeeeeeeeeeeeeeeeeeeeee zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ssssssssssssssssssssssssss ddddddddddddddddddddddddddddddd fffffffffffffffffffffffff ggggggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhhhhhhh jjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkk");
print "change 3\n";
&changeSubfield(3,"3new - go from long to short subfield...");
print "change 4\n";
&changeSubfield(4,"4new - stay with blob subfield...uuuuuuuuuuuuuuuuuuuuuuuu yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy tttttttttttttttttttttttttttttttt rrrrrrrrrrrrrrrrrrrrrr eeeeeeeeeeeeeeeeeeeeeeeee zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa aqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq ssssssssssssssssssssssssss ddddddddddddddddddddddddddddddd fffffffffffffffffffffffff ggggggggggggggggggggggggg hhhhhhhhhhhhhhhhhhhhhhhhhh jjjjjjjjjjjjjjjjjjjjjkkkkkkkkkkkkkkkkkkkkkkkk");
my $x= &findSubfield(1,'001','a','',1);
print "subfieldid : $x\n";
my $marcstru={};
$marcstru->{bibid}=58973;
$marcstru->{tags}->{1}->{tag}='110';
$marcstru->{tags}->{1}->{tagorder}=1;
$marcstru->{tags}->{1}->{subfields}->{1}->{mark}='a';
$marcstru->{tags}->{1}->{subfields}->{1}->{subfieldorder}=1;
$marcstru->{tags}->{1}->{subfields}->{1}->{value}='this is a test';
$marcstru->{tags}->{1}->{subfields}->{2}->{mark}='b';
$marcstru->{tags}->{1}->{subfields}->{2}->{subfieldorder}=1;
$marcstru->{tags}->{1}->{subfields}->{2}->{value}='this is another test';

$marcstru->{tags}->{2}->{tag}='220';
$marcstru->{tags}->{2}->{tagorder}=1;
$marcstru->{tags}->{2}->{subfields}->{1}->{mark}='a';
$marcstru->{tags}->{2}->{subfields}->{1}->{subfieldorder}=1;
$marcstru->{tags}->{2}->{subfields}->{1}->{value}='this is a test for 220';
$marcstru->{tags}->{2}->{subfields}->{2}->{mark}='b';
$marcstru->{tags}->{2}->{subfields}->{2}->{subfieldorder}=1;
$marcstru->{tags}->{2}->{subfields}->{2}->{value}='this is another test for 220';
$marcstru->{tags}->{2}->{subfields}->{3}->{mark}='b';
$marcstru->{tags}->{2}->{subfields}->{3}->{subfieldorder}=2;
$marcstru->{tags}->{2}->{subfields}->{3}->{value}='this is a third test for 220';

$marcstru->{tags}->{3}->{tag}='330';
$marcstru->{tags}->{3}->{tagorder}=1;
$marcstru->{tags}->{3}->{subfields}->{1}->{mark}='a';
$marcstru->{tags}->{3}->{subfields}->{1}->{subfieldorder}=1;
$marcstru->{tags}->{3}->{subfields}->{1}->{value}='this is a test for 330';
$marcstru->{tags}->{3}->{subfields}->{2}->{mark}='b';
$marcstru->{tags}->{3}->{subfields}->{2}->{subfieldorder}=1;
$marcstru->{tags}->{3}->{subfields}->{2}->{value}='this is another test for 330';
$marcstru->{tags}->{3}->{subfields}->{3}->{mark}='b';
$marcstru->{tags}->{3}->{subfields}->{3}->{subfieldorder}=2;
$marcstru->{tags}->{3}->{subfields}->{3}->{value}='this is a third test for 330';

&addMarcBiblio($marcstru);

Index: Catalogue.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Catalogue.pm,v
retrieving revision 1.15
retrieving revision 1.16
diff -C2 -r1.15 -r1.16
*** Catalogue.pm	29 May 2002 22:47:20 -0000	1.15
--- Catalogue.pm	4 Jun 2002 16:08:47 -0000	1.16
***************
*** 21,25 ****
  @ISA = qw(Exporter);
  @EXPORT = qw(&newBiblio &newBiblioItem &newItem &updateBiblio &updateBiblioItem
! 	     &updateItem &changeSubfield);
  %EXPORT_TAGS = ( );     # eg: TAG => [ qw!name1 name2! ],
  
--- 21,38 ----
  @ISA = qw(Exporter);
  @EXPORT = qw(&newBiblio &newBiblioItem &newItem &updateBiblio &updateBiblioItem
! 	     &updateItem &changeSubfield &addSubfield &findSubfield 
! 	     &addMarcBiblio
[...1566 lines suppressed...]
+ url         = $website->{'url'}
+ where websitenumber = $website->{'websitenumber'}";
+ 
+     $dbh->do($query);
+     
+     $dbh->disconnect;
+ } # sub updatewebsite
+ 
+ 
+ sub deletewebsite {
+     my ($websitenumber) = @_;
+     my $dbh = C4Connect;
+     my $query = "Delete from websites where websitenumber = $websitenumber";
+     
+     $dbh->do($query);
+     
+     $dbh->disconnect;
+ } # sub deletewebsite
  
  END { }       # module clean-up code here (global destructor)





More information about the Koha-cvs mailing list