Added the export method.

Basic tests for the export method.  Need to check the CSV file
to make sure it's created correctly.
This commit is contained in:
Colin Kuskie 2008-02-16 17:11:10 +00:00
parent c3e9e5f5c3
commit 6415b9186f
2 changed files with 41 additions and 1 deletions

View file

@ -4,6 +4,8 @@ use strict;
use Class::InsideOut qw{ :std };
use Carp qw(croak);
use WebGUI::Text;
use WebGUI::Storage;
=head1 NAME
@ -102,6 +104,30 @@ sub delete {
#-------------------------------------------------------------------
=head2 export ( )
Creates a tab deliniated file containing all the information from
the tax table. Returns a temporary WebGUI::Storage object containing
the file. The file will be named "siteTaxData.csv".
=cut
sub export {
my $self = shift;
my $taxIterator = $self->getItems;
my @columns = qw{ field value taxRate };
my $taxData = WebGUI::Text::joinCSV(@columns) . "\n";
while (my $taxRow = $taxIterator->hashRef() ) {
my @taxData = @{ $taxRow }{@columns};
$taxData .= WebGUI::Text::joinCSV(@taxData) . "\n";
}
my $storage = WebGUI::Storage->createTemp($self->session);
$storage->addFileFromScalar('siteTaxData.csv', $taxData);
return $storage;
}
#-------------------------------------------------------------------
=head2 getItems ( )
Returns a WebGUI::SQL::Result object for accessing all of the data in the tax table. This