#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::Catalog::Command::SearchDistributionStatus;
use strict;
use warnings;

use lib '/app/tools/rps/lib';
use RPS::LabelList;
use RPS::Catalog::DistributionCache;

use lib '/app/tools/metadata/lib';
use Metadata::Validate::Harness;

use lib '/app/tools/common/lib';
use Common::Assert;
use RSApache::Response::XSLT;

use RPS::SearchCommand;
use base 'RPS::SearchCommand';

sub cmd  { return 'search_no_dr'; }
sub area { return 'catalog'; }

use constant kTemplate => "/app/tools/rps/templates/catalog/index.xsl";
use constant kPageSize => 30;

sub pageSizePrefName  { 'catalog_search_pagesize' };

sub execute
{
    my ($self) = @_;
    my $cmd = $self->getParam("c");
    my $collection;

    assert( $cmd && ($cmd eq 'search_in_queue' || $cmd eq 'search_delivered') );

    my $pagesize = $self->setPagesize();

    if( $cmd eq 'search_in_queue' ) {
        $collection = RPS::DB::Item::Album->GetAllQueuedForDistribution();
    } else {
        $collection = RPS::DB::Item::Album->GetAllDistributed();
    }

    my $response = $self->SUPER::execute(collection => $collection,
                                         xmlClass => 'RPS::Catalog::SearchAlbum',
                                         xmlTag => 'Album',
                                         pageSize => $pagesize );
    return $response if $response;


    return RSApache::Response::XSLT->new($self->{xml}, kTemplate);
}



1;
