package Support::ArtistRoleMap::Command::Export;

use Data::Dumper;
use IO::File;
use POSIX qw(tmpnam);

use strict;
use lib '/app/tools/common/lib';
use Common::Log;
use Common::Assert;
use RSApache::Response::DownloadStream;

use lib '/app/tools/support/lib';
use Support::Command;
use Support::ArtistRoleMap::Exporter::Excel;

use base 'Support::Command';

sub cmd  { return 'export_genre_map' }
sub area { return 'cm' }

use constant kTemplate => "/app/tools/support/templates/genre_map/show.xsl";

sub execute {
    my ($self) = @_;

    my $response = $self->SUPER::execute();
    return $response if $response;

    my $excel = Support::ArtistRoleMap::Exporter::Excel->ExportToVariable();

    assert($excel);

    Common::Log::Debug( "RESULT: " . length($excel) . " bytes " );

    $response = RSApache::Response::DownloadStream->new( $excel, "application/octet-stream", "rs_artist_role_map.xls" );

    return $response;
}

1;
