That's it for today
[idzebra-moved-to-github.git] / perl / lib / IDZebra / Resultset.pm
index dd40ad1..bf90d4b 100644 (file)
@@ -34,13 +34,31 @@ sub new {
     $self->{errString}   = $args{errString};
 
     bless ($self, $class);
+
+#    $self->{session}{resultsets}{$args{name}} = $self;
+#    weaken ($self->{session}{resultsets}{$args{name}};
+
     return ($self);
 }
 
-sub DESTROY {
+sub count {
+    my ($self) = @_;
+    return ($self->{recordCount});
+}
+
+sub errCode {
     my ($self) = @_;
+    return ($self->{errCode});
+}
 
-#    print STDERR "Destroy RS\n";
+sub errString {
+    my ($self) = @_;
+    return ($self->{errCode});
+}
+
+# =============================================================================
+sub DESTROY {
+    my ($self) = @_;
 
     # Deleteresultset?
 
@@ -51,6 +69,7 @@ sub DESTROY {
     }
 
     delete($self->{ro});
+#    delete($self->{session}{resultsets}{$self->{name}});
     delete($self->{session});
 }
 # -----------------------------------------------------------------------------
@@ -64,6 +83,8 @@ sub records {
     my $schema       = $args{schema}       ? $args{schema}        : '';
     my $recordSyntax = $args{recordSyntax} ? $args{recordSyntax}  : '';
     
+    my $class        = $args{class}        ? $args{class}         : '';
+    
 
     my $ro = IDZebra::RetrievalObj->new();
     IDZebra::records_retrieve($self->{session}{zh},
@@ -82,7 +103,11 @@ sub records {
     for (my $i=$from; $i<=$to; $i++) {
        my $rec = IDZebra::RetrievalRecord->new();
         IDZebra::record_retrieve($ro, $self->{odr_stream}, $rec, $i-$from+1);
-       push (@res, $rec);
+       if ($class) {
+           
+       } else {
+           push (@res, $rec);
+       }
     }
 
     IDZebra::odr_reset($self->{odr_stream});
@@ -90,6 +115,7 @@ sub records {
     return (@res);
 }
 
+# ============================================================================
 sub sort {
     my ($self, $sortspec, $setname) = @_;
     unless ($setname) {
@@ -102,16 +128,30 @@ sub sort {
     }
 }
 
+# ============================================================================
 __END__
 
 =head1 NAME
 
-IDZebra::Session - 
+IDZebra::Resultset - Representation of Zebra search results
 
 =head1 SYNOPSIS
 
 =head1 DESCRIPTION
 
+The I<Resultset> object represents results of a Zebra search. Contains number of hits, search status, and can be used to sort and retrieve the records.
+
+=head1 PROPERTIES
+
+  $count = $rs->count;
+
+  printf ("RS Status is %d (%s)\n", $rs->errCode, $rs->errString);
+
+I<$rs-E<gt>errCode> is 0, if there were no errors during search.
+
+=head1 RETRIEVING RECORDS
+
+
 =head1 COPYRIGHT
 
 Fill in