From 9050b99705eb3c09549968914e2c06285cdfba01 Mon Sep 17 00:00:00 2001 From: Dobrica Pavlinusic Date: Tue, 13 Dec 2016 21:29:06 +0100 Subject: [PATCH] first really working version --- CROSBI.pm | 31 +++++++++++++++++-------------- server.pl | 2 ++ 2 files changed, 19 insertions(+), 14 deletions(-) diff --git a/CROSBI.pm b/CROSBI.pm index f65425a..867ddc5 100644 --- a/CROSBI.pm +++ b/CROSBI.pm @@ -47,8 +47,6 @@ sub usemap {{ my $dbname = 'bibliografija'; -my $dbh = DBI->connect("dbi:Pg:dbname=$dbname", '', '', {AutoCommit => 0}); - sub search { my ( $self, $query ) = @_; @@ -73,6 +71,8 @@ where rad_ustanova.sifra = ? and ( }; + my $dbh = DBI->connect_cached("dbi:Pg:dbname=$dbname", '', '', {AutoCommit => 0}); + my $sth = $dbh->prepare( $sql ); warn "XXX SQL = ",$sql; @@ -146,7 +146,7 @@ sub next_marc { my $id = $row->{id} || die "no id"; my $marc = MARC::Record->new; - $marc->encoding('utf-8'); + $marc->encoding('UTF-8'); my $leader = $marc->leader; @@ -156,12 +156,12 @@ sub next_marc { ## LDR 06 - a - language material ## LDR 07 - a - monographic component part - $leader =~ s/^(....).../$1naa/; + $leader =~ s/^(....)...(.+)/$1naa$2/; ## LDR 17 - Encoding level ; 7 - minimal level, u - unknown ## LDR 18 - i = isbd ; u = unknown - $leader =~ s/^(.{17})/$1uu/; + $leader =~ s/^(.{17})..(.+)/$1uu$2/; $marc->leader( $leader ); warn "# leader [$leader]"; @@ -360,17 +360,20 @@ sub next_marc { ); } - $marc->add_fields(942,' ',' ', - c => 'CLA', - $row->{status_rada} ? ( + my @f942 = ( + c => 'CLA' + ); + if ( $row->{status_rada} ) { + push @f942, ( f => 1, g => $row->{status_rada} - ) : (), - $row->{kategorija} =~ m/Znanstveni/ ? ( - t => '1.01' - ) : $row->{kategorija} =~ m/Strucni/ ? ( - t => '1.04' - ) : (), + ); + } + push @f942, t => '1.01' if $row->{kategorija} =~ m/Znanstveni/; + push @f942, t => '1.01' if $row->{kategorija} =~ m/Strucni/; + + $marc->add_fields(942,' ',' ', + @f942, u => '1', z => join(' - ', $row->{kategorija}, $row->{vrsta_rada}), ); diff --git a/server.pl b/server.pl index d124f46..1ac9edb 100755 --- a/server.pl +++ b/server.pl @@ -12,6 +12,7 @@ use GoogleBooks; use vuFind; use DPLA; use AlephTR; +use CROSBI; use Encode; @@ -25,6 +26,7 @@ my $databases = { 'HATHITRUST' => 'vuFind', 'DPLA' => 'DPLA', 'MKUTUP' => 'AlephTR', + 'CROSBI' => 'CROSBI', }; my $max_records = 10; # XXX configure this -- 2.20.1