| 1 | package ETLp::Audit::Browser::Model::Item; | ||
| 2 | |||
| 3 | use MooseX::Declare; | ||
| 4 | |||
| 5 | class ETLp::Audit::Browser::Model::Item with | ||
| 6 | (ETLp::Role::Config, ETLp::Role::Schema, ETLp::Role::Audit, | ||
| 7 | ETLp::Role::Browser) { | ||
| 8 | |||
| 9 | |||
| 10 | use Data::Dumper | ||
| 11 | |||
| 12 | method get_items (Maybe[Int] :$page?, Maybe[Int] :$item_id?, Maybe[Int] :$job_id?, Maybe[Int] :$status_id?, Maybe[Str] :$item_name?, Maybe[Str] :$filename?) { | ||
| 13 | my $criteria = {}; | ||
| 14 | my $attributes = {}; | ||
| 15 | |||
| 16 | $criteria->{job_id} = $job_id if ($job_id); | ||
| 17 | $criteria->{item_id} = $item_id if ($item_id); | ||
| 18 | $criteria->{status_id} = $status_id if $status_id; | ||
| 19 | $criteria->{item_name} = $item_name if $item_name; | ||
| 20 | |||
| 21 | if ($filename) { | ||
| 22 | $criteria->{'etlp_file_process.filename'} = $filename; | ||
| 23 | $attributes->{join} = 'etlp_file_process'; | ||
| 24 | } | ||
| 25 | |||
| 26 | $attributes->{page} = $page; | ||
| 27 | $attributes->{rows} = $self->pagesize; | ||
| 28 | $attributes->{order_by} = 'date_updated desc, item_id desc'; | ||
| 29 | |||
| 30 | my $items = $self->EtlpItem()->search($criteria, $attributes); | ||
| 31 | return $items; | ||
| 32 | } | ||
| 33 | |||
| 34 | method get_item_name_list(Maybe[Int] $job_id?) { | ||
| 35 | return $self->EtlpItem()->search( | ||
| 36 | { | ||
| 37 | job_id => $job_id | ||
| 38 | }, | ||
| 39 | { | ||
| 40 | select => {distinct => 'item_name'}, | ||
| 41 | as => 'item_name' | ||
| 42 | } | ||
| 43 | ) | ||
| 44 | } | ||
| 45 | } | ||
| 46 | |||
| 47 | =head1 NAME | ||
| 48 | |||
| 49 | ETLp::Audit::Browser::Model::Item - Model Class for interacting | ||
| 50 | with Runtime Item Audit Records | ||
| 51 | |||
| 52 | =head1 SYNOPSIS | ||
| 53 | |||
| 54 | use ETLp::Audit::Browser::Model::Item; | ||
| 55 | |||
| 56 | my $model = ETLp::Audit::Browser::Model::Item->new(); | ||
| 57 | my $items = $model->get_items(page => 1); | ||
| 58 | |||
| 59 | =head1 METHODS | ||
| 60 | |||
| 61 | =head2 get_items | ||
| 62 | |||
| 63 | Returns a resultset on the ep_Item table. It will grab 20 rows at | ||
| 64 | a time, and is ordered by date_updated descending | ||
| 65 | |||
| 66 | =head3 Parameters | ||
| 67 | |||
| 68 | * page. Integer. The page you to fetch. Defaults to one | ||
| 69 | * item_id. Optional. The specific item to fetch | ||
| 70 | * job_id. Optional. The job that created the item | ||
| 71 | * status_id. Optional. Filter on item status | ||
| 72 | * item_name. Optional. Fetch item with the supplied name | ||
| 73 | * filename. Optional. Fetch items that processed the supplied file | ||
| 74 | |||
| 75 | =head3 Returns | ||
| 76 | |||
| 77 | * A DBIx::Class resultset | ||
| 78 | |||
| 79 | =head2 get_item_name_list | ||
| 80 | |||
| 81 | Returns a list of all distinct item names for the supplied process id | ||
| 82 | |||
| 83 | =head3 Parameters | ||
| 84 | |||
| 85 | * job_id. Integer | ||
| 86 | |||
| 87 | Returns | ||
| 88 | |||
| 89 | * A DBIx:Class resultset containing a list of item names | ||
| 90 | |||
| 91 | =head1 LICENSE AND COPYRIGHT | ||
| 92 | |||
| 93 | Copyright 2010 Redbone Systems Ltd | ||
| 94 | |||
| 95 | This program is free software; you can redistribute it and/or modify it | ||
| 96 | under the terms of either: the GNU General Public License as published | ||
| 97 | by the Free Software Foundation; or the Artistic License. | ||
| 98 | |||
| 99 | The terms are in the LICENSE file that accompanies this application | ||
| 100 | |||
| 101 | =cut |