[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Koha-cvs] CVS: koha/C4 test.pl,1.1,1.2 Catalogue.pm,1.16,1.17
From: |
Paul POULAIN |
Subject: |
[Koha-cvs] CVS: koha/C4 test.pl,1.1,1.2 Catalogue.pm,1.16,1.17 |
Date: |
Thu, 06 Jun 2002 09:23:39 -0700 |
Update of /cvsroot/koha/koha/C4
In directory usw-pr-cvs1:/tmp/cvs-serv26447/C4
Modified Files:
test.pl Catalogue.pm
Log Message:
today stuff around marc. Will change soon as we will use MARC::record (see
marcpm.sourceforge.net)
Index: test.pl
===================================================================
RCS file: /cvsroot/koha/koha/C4/test.pl,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -r1.1 -r1.2
*** test.pl 4 Jun 2002 16:08:47 -0000 1.1
--- test.pl 6 Jun 2002 16:23:36 -0000 1.2
***************
*** 8,15 ****
$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");
--- 8,15 ----
$dbh->do("delete from marc_subfield_table");
$dbh->do("delete from marc_blob_subfield");
! &addSubfield(1,'001','a',1,'1 - This is a value');
! &addSubfield(1,'001','b',1,'2 - This is another value');
! &addSubfield(1,'001','c',1,"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");
! &addSubfield(1,'001','d',1,"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");
print "change 1\n";
&changeSubfield(1,"1new - this is a changed value");
***************
*** 22,59 ****
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);
--- 22,39 ----
my $x= &findSubfield(1,'001','a','',1);
print "subfieldid : $x\n";
! my $record={};
! #$marcstru->{bibid}=58973; # calculated auto_increment in addMarcBiblio
! $record->{bibid}=58973;
! $record->{tags}->{110}->{1}->{indicator}='##';
! $record->{tags}->{110}->{1}->{subfields}->{a}->{1}='first text';
! $record->{tags}->{110}->{1}->{subfields}->{a}->{2}='second text';
! $record->{tags}->{110}->{1}->{subfields}->{b}->{3}='third text';
! $record->{tags}->{120}->{1}->{indicator}='##';
! $record->{tags}->{120}->{1}->{subfields}->{a}->{1}='last text ??';
! $record->{tags}->{120}->{2}->{indicator}='01';
! $record->{tags}->{120}->{2}->{subfields}->{n}->{1}='no, another text';
! print "NEXT IS :
".nextsubfieldid($record->{tags}->{110}->{1}->{subfields})."\n";
! &addMarcBiblio($record);
Index: Catalogue.pm
===================================================================
RCS file: /cvsroot/koha/koha/C4/Catalogue.pm,v
retrieving revision 1.16
retrieving revision 1.17
diff -C2 -r1.16 -r1.17
*** Catalogue.pm 4 Jun 2002 16:08:47 -0000 1.16
--- Catalogue.pm 6 Jun 2002 16:23:37 -0000 1.17
***************
*** 22,26 ****
@EXPORT = qw(&newBiblio &newBiblioItem &newItem &updateBiblio
&updateBiblioItem
&updateItem &changeSubfield &addSubfield &findSubfield
! &addMarcBiblio
&getorders &bookseller &breakdown &basket &newbasket &bookfunds
--- 22,26 ----
@EXPORT = qw(&newBiblio &newBiblioItem &newItem &updateBiblio
&updateBiblioItem
&updateItem &changeSubfield &addSubfield &findSubfield
! &addMarcBiblio &nextsubfieldid
&getorders &bookseller &breakdown &basket &newbasket &bookfunds
***************
*** 226,232 ****
my ($marcstructure) = @_;
my $dbh=C4Connect;
! my $tags;
! my $i;
! my $j;
# adding main table, and retrieving bibid
$dbh->do("lock tables marc_biblio WRITE");
--- 226,233 ----
my ($marcstructure) = @_;
my $dbh=C4Connect;
! my $tag;
! my $tagorder;
! my $subfield;
! my $subfieldorder;
# adding main table, and retrieving bibid
$dbh->do("lock tables marc_biblio WRITE");
***************
*** 240,257 ****
$dbh->do("unlock tables");
# now, add subfields...
! foreach $tags ($marcstructure->{tags}) {
! foreach $i (keys %{$tags}) {
! foreach $j (keys %{$tags->{$i}->{subfields}}) {
! &addSubfield($marcstructure->{bibid},
! $tags->{$i}->{tag},
! $tags->{$i}->{tagorder},
! $tags->{$i}->{subfields}->{$j}->{mark},
! $tags->{$i}->{subfields}->{$j}->{subfieldorder},
! $tags->{$i}->{subfields}->{$j}->{value}
! );
! print
$tags->{$i}->{tag}."//".$tags->{$i}->{subfields}->{$j}->{value}."\n";
}
}
}
}
--- 241,297 ----
$dbh->do("unlock tables");
# now, add subfields...
! foreach $tag (keys %{$marcstructure->{tags}}) {
! foreach $tagorder (keys %{$marcstructure->{tags}->{$tag}}) {
! foreach $subfield (keys
%{$marcstructure->{tags}->{$tag}->{$tagorder}->{subfields}}) {
! foreach $subfieldorder (keys
%{$marcstructure->{tags}->{$tag}->{$tagorder}->{subfields}->{$subfield}}) {
! &addSubfield($marcstructure->{bibid},
! $tag,
! $tagorder,
! $subfield,
! $subfieldorder,
!
$marcstructure->{tags}->{$tag}->{$tagorder}->{subfields}->{$subfield}->{$subfieldorder}
! );
! # print "$tag / $tagorder / $subfield / $subfieldorder /
".$marcstructure->{tags}->{$tag}->{$tagorder}->{subfields}->{$subfield}->{$subfieldorder}."\n";
! }
}
}
}
+ }
+
+ sub buildPerlmarcstructure {
+ # this function builds perlmarcstructure from the old koha-DB fields
+ my ($biblionumber,$author,$title,$unititle,$notes,$abstract,
+ $serial,$seriestitle,$copyrightdate,$biblioitemnumber,$volume,$number,
+ $classification,$itemtype,$isbn,$issn,
+ $dewey,$subclass,$publicationyear,$publishercode,
+ $volumedate,$illus,$pages,$notes,
+ $size,$place,$lccn) = @_;
+
+ my $tagfield;
+ my $tagsubfield;
+ my $perlmarcstructure={};
+ my $i=0;
+ my $dbh=&C4Connect;
+ my $sth=$dbh->prepare("select tagfield,tagsubfield from
marc_subfield_structure where kohafield=?");
+ $sth->execute("biblionumber");
+ if (($tagfield,$tagsubfield)=$sth->fetchrow) {
+
$i=nextsubfieldid($perlmarcstructure->{tags}->{$tagfield}->{1}->{subfields}->{$tagsubfield});
+ $perlmarcstructure->{tags}->{$i}->{tag}=$tagfield;
+ $perlmarcstructure->{tags}->{$i}->{tagorder}=1;
+ $perlmarcstructure->{tags}->{$i}->{indicator}='##';
+ }
+ }
+
+ sub nextsubfieldid {
+ my $subfieldhash=shift;
+ my $maxsubfieldnumber=0;
+ my $subfield;
+ my $number;
+ foreach $subfield (keys %$subfieldhash) {
+ foreach $number (keys %{$subfieldhash->{$subfield}}) {
+ ($number>$maxsubfieldnumber) && ($maxsubfieldnumber=$number);
+ }
+ }
+ return $maxsubfieldnumber+1;
}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [Koha-cvs] CVS: koha/C4 test.pl,1.1,1.2 Catalogue.pm,1.16,1.17,
Paul POULAIN <=