Backup-Omni

 view release on metacpan or  search on metacpan

lib/Backup/Omni/Session/Messages.pm  view on Meta::CPAN


}

sub prev {
    my $self = shift;

    my $pos = $self->cur_pos;

    $pos--;

    if ($pos < 0) {

        $self->cur_pos(0);
        return undef;

    } else {

        $self->cur_pos($pos);
        return $self->{results}->[$pos];

    }

}

sub first {
    my $self = shift;

    $self->cur_pos(0);

    return $self->{results}->[0];

}

sub last {
    my $self = shift;

    my $end = scalar(@{$self->{results}}) - 1;

    $self->cur_pos($end);
    
    return $self->{results}->[$end];

}

# ----------------------------------------------------------------------
# Private Methods
# ----------------------------------------------------------------------

sub init {
    my $class = shift;

    my $self = $class->SUPER::init(@_);

    my $command = sprintf(COMMAND, OMNIDB, $self->session, $self->report);
    my @result = `$command`;
    my $rc = $?;

    unless (grep(/Normal/, @result)) {

        $self->throw_msg(
            'backup.omni.session.messages',
            'noresults',
            $self->session
        );

    }

    $self->{cur_pos} = 0;
    $self->{results} = \@result;
    
    return $self;

}

1;

__END__

=head1 NAME

Backup::Omni::Session::Messages - Returns the messages of a given session

=head1 SYNOPSIS

 use Backup::Omni::Session::Messages;

 my $messages = Backup::Omni::Session::Messages->new(
     -session => '2013/01/28-1'
 );

 while (my $message = $messaages->next) {

     printf("%s\n", $message);

 }

=head1 DESCRIPTION

This module will return the messages for a session id. It runs the omnidb 
command with the appropiate options. If any errors are encounterd, 
an exception is thrown.

=head1 METHODS

=head2 new

This method will initialze the object. It takes one mandatory parameter and
one optional parameter.

=over 4

=item B<-session>

The session id of the desired session.

=item B<-report>

Optional, returns the type of message. This can be one of the following:

  warning
  minor 



( run in 0.631 second using v1.01-cache-2.11-cpan-5b529ec07f3 )