###################################################################
# Copyright (C) 2006 RoyaltyShare, Inc.  All Rights Reserved
# $Id$
###################################################################

package MediaServe::MatchAsset;

use strict;
use warnings;
use Carp;
use IO::Scalar;
use Date::Format;

use lib '/app/tools/common/lib';
use Common::RSDB;
use Common::Email;
use Common::Assert;

use base qw( Common::CronScript );

sub _init {
    my ( $self, %args ) = @_;
    $self->SUPER::_init(%args);

    $self->{_client_id} = $args{client_id};

    return $self;
}

sub _run_options {
    my $self = shift;
    my $options = sprintf( "\n  Client ID: %s", $self->{_client_id} ? $self->{_client_id} : "<undef>" );
    return $options . $self->SUPER::_run_options();
}

sub run_process {
    my $self = shift;

    $self->debug("\nStarting the matching process");

    my @clients = $self->get_client_list();
    $self->debug("   Client List: @clients");

    foreach (@clients) {
        $self->match_assets($_);
    }

}

sub get_client_list {
    my $self = shift;
    assert($self);

    return ( $self->{_client_id} ) if ( $self->{_client_id} );

    my @list;
    foreach ( keys(%Common::RSDB::CLIENT_DB) ) {
        push( @list, $_ ) if ( $_ > 0 );
    }

    return sort { $a <=> $b } @list;
}

sub match_assets {
    my $self      = shift;
    my $client_id = shift;

    assert($self);
    assert($client_id);

    $self->debug("\n**** Matching Assets for Client $client_id ****");
}

1;
