-#!/usr/bin/perl
-# ============================================================================
+# $Id: Resultset.pm,v 1.5 2003-03-03 00:45:37 pop Exp $
+#
# Zebra perl API header
# =============================================================================
-use strict;
-use Carp;
-# ============================================================================
package IDZebra::Resultset;
-use IDZebra;
-use IDZebra::Logger qw(:flags :calls);
-use IDZebra::Repository;
-use Scalar::Util qw(weaken);
-our @ISA = qw(IDZebra::Logger);
+use strict;
+use warnings;
+
+BEGIN {
+ use IDZebra;
+ use IDZebra::Logger qw(:flags :calls);
+ use Scalar::Util qw(weaken);
+ use Carp;
+ our $VERSION = do { my @r = (q$Revision: 1.5 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+ our @ISA = qw(IDZebra::Logger);
+}
1;
# -----------------------------------------------------------------------------
my ($proto,$session, %args) = @_;
my $class = ref($proto) || $proto;
my $self = {};
+ bless ($self, $class);
+
$self->{session} = $session;
weaken ($self->{session});
- # Retrieval object
- $self->{ro} = IDZebra::RetrievalObj->new();
$self->{odr_stream} = IDZebra::odr_createmem($IDZebra::ODR_DECODE);
$self->{name} = $args{name};
$self->{errCode} = $args{errCode};
$self->{errString} = $args{errString};
- bless ($self, $class);
-
-# $self->{session}{resultsets}{$args{name}} = $self;
-# weaken ($self->{session}{resultsets}{$args{name}};
-
return ($self);
}
+sub recordCount {
+ my ($self) = @_;
+ return ($self->{recordCount});
+}
sub count {
my ($self) = @_;
return ($self->{recordCount});
$self->{odr_stream} = undef;
}
- delete($self->{ro});
+# delete($self->{ro});
# delete($self->{session}{resultsets}{$self->{name}});
delete($self->{session});
}
--- /dev/null
+# $Id: RetrievalRecord.pm,v 1.1 2003-03-03 00:45:37 pop Exp $
+#
+# Zebra perl API header
+# =============================================================================
+package IDZebra::RetrievalRecord;
+
+use strict;
+use warnings;
+
+BEGIN {
+ use IDZebra;
+ our $VERSION = do { my @r = (q$Revision: 1.1 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+}
+
+# =============================================================================
+# THIS IS Just the documentation, the real code is autogenerated by SWIG in
+# IDZebra.pm
+# =============================================================================
+__END__
+
+=head1 NAME
+
+IDZebra::RetrievalRecord - Structure representing a retrieval record
+
+=head1 SYNOPSIS
+
+=head1 DESCRIPTION
+
+=head1 PROPERTIES
+
+=head1 COPYRIGHT
+
+Fill in
+
+=head1 AUTHOR
+
+Peter Popovics, pop@technomat.hu
+
+=head1 SEE ALSO
+
+IDZebra, IDZebra::Session, IDZebra::Resultset, Zebra documentation
+
+=cut
+
+1;
-# $Id: Session.pm,v 1.7 2003-02-28 20:11:20 pop Exp $
+# $Id: Session.pm,v 1.8 2003-03-03 00:45:37 pop Exp $
#
# Zebra perl API header
# =============================================================================
use strict;
use warnings;
+
BEGIN {
use IDZebra;
+ use Scalar::Util;
use IDZebra::Logger qw(:flags :calls);
use IDZebra::Resultset;
- use Scalar::Util;
- use Carp;
- our $VERSION = do { my @r = (q$Revision: 1.7 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
- our @ISA = qw(IDZebra::Logger);
+ our $VERSION = do { my @r = (q$Revision: 1.8 $ =~ /\d+/g); sprintf "%d."."%02d" x $#r, @r };
+# our @ISA = qw(IDZebra::Logger);
}
1;
return ($self);
}
+sub checkzh {
+ my ($self) = @_;
+ unless (defined($self->{zh})) {
+ croak ("Zebra session is not opened");
+ }
+}
+
sub close {
my ($self) = @_;
# -----------------------------------------------------------------------------
sub group {
my ($self,%args) = @_;
+ $self->checkzh;
if ($#_ > 0) {
$self->{rg} = $self->_makeRecordGroup(%args);
$self->_selectRecordGroup($self->{rg});
sub selectRecordGroup {
my ($self, $groupName) = @_;
+ $self->checkzh;
$self->{rg} = $self->_getRecordGroup($groupName);
$self->_selectRecordGroup($self->{rg});
}
sub databases {
my ($self, @databases) = @_;
+ $self->checkzh;
+
unless ($#_ >0) {
return (keys(%{$self->{databases}}));
}
# -----------------------------------------------------------------------------
sub begin_trans {
my ($self) = @_;
+ $self->checkzh;
IDZebra::begin_trans($self->{zh});
}
sub end_trans {
my ($self) = @_;
+ $self->checkzh;
my $stat = IDZebra::ZebraTransactionStatus->new();
IDZebra::end_trans($self->{zh}, $stat);
return ($stat);
sub begin_read {
my ($self) =@_;
+ $self->checkzh;
return(IDZebra::begin_read($self->{zh}));
}
sub end_read {
my ($self) =@_;
+ $self->checkzh;
IDZebra::end_read($self->{zh});
}
sub shadow_enable {
my ($self, $value) = @_;
+ $self->checkzh;
if ($#_ > 0) { IDZebra::set_shadow_enable($self->{zh},$value); }
return (IDZebra::get_shadow_enable($self->{zh}));
}
sub commit {
my ($self) = @_;
+ $self->checkzh;
if ($self->shadow_enable) {
return(IDZebra::commit($self->{zh}));
}
# -----------------------------------------------------------------------------
sub init {
my ($self) = @_;
+ $self->checkzh;
return(IDZebra::init($self->{zh}));
}
sub compact {
my ($self) = @_;
+ $self->checkzh;
return(IDZebra::compact($self->{zh}));
}
sub update {
my ($self, %args) = @_;
+ $self->checkzh;
my $rg = $self->_update_args(%args);
$self->_selectRecordGroup($rg);
$self->begin_trans;
sub delete {
my ($self, %args) = @_;
+ $self->checkzh;
my $rg = $self->_update_args(%args);
$self->_selectRecordGroup($rg);
$self->begin_trans;
sub show {
my ($self, %args) = @_;
+ $self->checkzh;
my $rg = $self->_update_args(%args);
$self->_selectRecordGroup($rg);
$self->begin_trans;
sub update_record {
my ($self, %args) = @_;
+ $self->checkzh;
return(IDZebra::update_record($self->{zh},
$self->_record_update_args(%args)));
}
sub delete_record {
my ($self, %args) = @_;
+ $self->checkzh;
return(IDZebra::delete_record($self->{zh},
$self->_record_update_args(%args)));
}
$rg->{databaseName} = "Default" unless ($rg->{databaseName});
-# print STDERR "$rectype,$sysno,$match,$fname,$len\n";
unless ($rectype) {
$rectype="";
}
}
my $res = "\0" x 2048;
my $r = IDZebra::cql2pqf($self->{cql_ct}, $cqlquery, $res, 2048);
- unless ($r) {return (undef)};
+ if ($r) {
+ carp ("Error transforming CQL query: '$cqlquery', status:$r");
+ }
$res=~s/\0.+$//g;
- return ($res);
+ return ($res,$r);
}
sub search {
my ($self, %args) = @_;
+ $self->checkzh;
+
if ($args{cqlmap}) { $self->cqlmap($args{cqlmap}); }
my $query;
$query = $args{pqf};
}
elsif ($args{cql}) {
- unless ($query = $self->cql2pqf($args{cql})) {
- croak ("Invalid CQL query: '$args{cql}'");
+ my $cqlstat;
+ ($query, $cqlstat) = $self->cql2pqf($args{cql});
+ unless ($query) {
+ croak ("Failed to transform query: '$args{cql}', ".
+ "status: ($cqlstat)");
}
}
unless ($query) {
sub sortResultsets {
my ($self, $sortspec, $setname, @sets) = @_;
+ $self->checkzh;
+
my @setnames;
my $count = 0;
foreach my $rs (@sets) {