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

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

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

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

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

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

sub pageSizePrefName { 'catalog_search_pagesize' }

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

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

    my $collection = RPS::DB::Item::Album->SearchDuplicates(
        catalog_no      => $self->getParam("catalog_no"),
        client_track_id => $self->getParam("client_track_id"),
        client_album_id => $self->getParam("client_album_id"),
        album_title     => $self->getParam("album_title"),
        isrc            => $self->getParam("isrc"),
        digital_upc     => $self->getParam("digital_upc"),
        cd_upc          => $self->getParam("cd_upc"),
        vinyl_upc       => $self->getParam("vinyl_upc"),
        dvd_upc         => $self->getParam("dvd_upc")
    );

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

    $self->{xml}{LabelList} = RPS::LabelList->new();

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

1;
