ETLp

 view release on metacpan or  search on metacpan

lib/ETLp/Audit/Item.pm  view on Meta::CPAN

package ETLp::Audit::Item;

use MooseX::Declare;

=head1 NAME

ETLp::Audit::Item - audit the execution of an ETLp job

=head1 DESCRIPTION

This class is used to manage an individual audit item

=cut

class ETLp::Audit::Item with (ETLp::Role::Config, ETLp::Role::Schema,
                              ETLp::Role::Audit)  {

    use DateTime;
    use Try::Tiny;
    use ETLp::Types;
    use ETLp::Audit::FileProcess;
    use DateTime;
    
    has 'job' =>
      (is => 'ro', isa => 'ETLp::Audit::Job', required => 1, weak_ref => 1);
    has 'name'   => (is => 'ro', isa => 'Str',     required => 1);
    has 'phase'  => (is => 'ro', isa => 'Str',     required => 1);
    has 'type'   => (is => 'ro', isa => 'Str',     required => 1);
    has 'config' => (is => 'ro', isa => 'HashRef', required => 1);
    
    method id {
        return $self->{id};
    }
    
=head2 update_message

Sets the item message

=cut

    method update_message(Str $message) {
        my $item = $self->EtlpItem()->find($self->id);
        $item->message($message);
        $self->update($item, $self->now);
    }
    
=head2 update_status

Sets the status of the item

=cut
    
    method update_status(Str $status_name) {
        my $item = $self->EtlpItem()->find($self->id);
        $item->status_id($self->get_status_id($status_name));
        $self->update($item, $self->now);
    }
    
=head2 update

Saves the supplied item to the database

=cut

    method update(ETLp::Schema::Result::EtlpItem $item,
                  DateTime $date) {
        $item->date_updated($date);
        my $job  = $self->EtlpJob->find($self->job->id);
        try {
            $self->schema->txn_do(
                sub {
                    $item->update;
                    $self->job->update($job, $date);
                }
            )
        }
        catch {
            $self->logger->logdie("Cannot update job item record: $_");
        };
    }
    
=head2 create_file_process

Create a file process audit object

=cut

    method create_file_process(Str $filename) {
        my $file_process = ETLp::Audit::FileProcess->new(



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