two different crosbi databases searching different tables
[Biblio-Z3950.git] / CROSBI.pm
index a15e70f..b090760 100644 (file)
--- a/CROSBI.pm
+++ b/CROSBI.pm
@@ -58,10 +58,13 @@ sub search {
 
        my $tsquery = join(' & ', split(/\s+/,$query) );
 
+       my $table = lc $self->{database};
+       $table =~ s/^crosbi-//g;
+
        my $sql = qq{
 
 select *
-from casopis
+from $table
 inner join rad_ustanova using (id)
 left outer join rad_napomena using (id)
 left outer join rad_projekt using (id)
@@ -77,11 +80,9 @@ 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;
 
-#-- and naslov like ?
+       my $sth = $dbh->prepare( $sql );
 
        $sth->execute(
                130, # FIXME ustanova
@@ -286,8 +287,18 @@ sub next_marc {
                'a' => $row->{title}
        );
 
+       sub page_range {
+               my ( $prefix, $from, $to ) = @_;
+               my $out;
+               if ( $from ) {
+                       $out = $prefix . $from;
+                       $out .= '-' . $to if $to;
+               }
+               return $out;
+       }
+
        $marc->add_fields(300,' ',' ',
-               a => join(' ', $row->{stranica_prva}, $row->{stranica_zadnja}),
+               a => page_range('',$row->{stranica_prva},$row->{stranica_zadnja}),
                f => 'str.'
        );
 
@@ -344,11 +355,10 @@ sub next_marc {
                ) foreach @a;
        }
 
-
        $marc->add_fields(773,'0',' ',
                t => $row->{casopis},
                x => $row->{issn},
-               g => "$row->{volumen}, ($row->{godina}), str. $row->{stranica_prva}-$row->{stranica_zadnja}",
+               g => "$row->{volumen} ($row->{godina}), $row->{broj} ;" . page_range(' str. ',$row->{stranica_prva}, $row->{stranica_zadnja}),
        );
 
        if ( my $file = $row->{datoteka} ) {