#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package Distribution::DistributionProcess::DistributionJobList;

use strict;
use warnings;
use Data::Dumper;

use lib '/app/tools/job/lib';
use Job::Job;

use lib '/app/tools/job/lib';
use Distribution::DB::Item::Job;

use Common::FormObject;
use base 'Common::FormObject';

sub _init {
    my $self = shift;
    my %args = @_;

    $self->SUPER::_init(@_);

    my $distProcessID = $args{distributionProcessID};
    my $clientID      = $args{clientID};

    $self->{Job} = [];

    my $collection = Distribution::DB::Item::Job->GetAllDistributionJobs(
        distribution_process_id => $distProcessID,
        client_id               => $clientID
    );

    while ( $collection->hasNext() ) {
        my $jobDB = $collection->next();

        #		push @{$self->{Job}}, Job::Job->new(_dbItem => $jobObj);
        # !!! This is the preferred interface - It will instantiate the correct
        # subclass of Job.
        Common::Log::Debug( "ID: " . $jobDB->job_id() );
        push @{ $self->{Job} }, Job::Job->CreateFromDBItem($jobDB);
    }

    return $self;
}

sub _listProperties {
    return { Job => 1 };
}

1;
