ETLp
view release on metacpan or search on metacpan
lib/ETLp/Audit/FileProcess.pm view on Meta::CPAN
package ETLp::Audit::FileProcess;
use MooseX::Declare;
use DateTime;
class ETLp::Audit::FileProcess with (ETLp::Role::Config, ETLp::Role::Schema,
ETLp::Role::Audit) {
use ETLp::Types;
use Try::Tiny;
use ETLp::Exception;
has 'item' =>
(is => 'ro', isa => 'ETLp::Audit::Item', required => 1, weak_ref => 1);
has 'filename' => (is => 'ro', isa => 'Str', required => 1);
has 'config' => (is => 'ro', isa => 'HashRef', required => 1);
=head2 method_id
Return the primary key of the file process record
=cut
method id {
return $self->{id};
}
=head2 canonical_filename
Returns the canonical filename of the file being processed
=cut
method canonical_filename {
return $self->{canonical_filename};
}
=head2 details
Returns the current record (as a DBIx::Class Row)
=cut
method details {
return $self->EtlpFileProcess->find($self->id);
}
# create a canonical record for the processed file
method _create_canonical_record {
my $now = $self->now;
my $file = $self->EtlpFile->create(
{
canonical_filename => $self->canonical_filename,
date_created => $now,
date_updated => $now,
}
);
return $file->file_id;
}
# Given the filename and format regex, determine the file format
method _get_canonical_filename(Str $filename) {
try {
my $c_regex = $self->config->{config}->{filename_format};
my $canonical_name;
$self->logger->debug("c_regex $c_regex");
$self->logger->debug("filename $filename\n");
if ($filename =~ /$c_regex/) {
$canonical_name = $1;
}
ETLpException->throw(error =>
"Cannot determine canonical name for $filename, regex: $c_regex"
( run in 5.264 seconds using v1.01-cache-2.11-cpan-81fc1098f69 )