#------------------------------------------------------------
# Copyright (C) 2008 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package Common::Client::ClientList;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use Common::Assert;
use Common::Client;
use Common::DB::Item::Client;
use Common::FormObject;

use base 'Common::FormObject';

sub _init {
    my ( $self, %args ) = @_;

    $self->SUPER::_init(%args);

    my $collection = $self->_getItemCollection(%args);

    $self->{Client} = [];
    while ( $collection->hasNext() ) {
        push @{ $self->{Client} }, $self->_getObjectFromDBItem( $collection->next() );
    }

    return $self;
}

sub _getItemCollection {
    my ( $self, %args ) = @_;

    my $clients;
    if ( $args{typeMask} ) {
        $clients = Common::DB::Item::Client->GetAllOfType( $args{typeMask} );
    } else {
        $clients = Common::DB::Item::Client->GetAll();
    }

    return $clients;
}

sub _getObjectFromDBItem {
    my ( $self, $dbItem ) = @_;
    return Common::Client->new( _dbItem => $dbItem );
}

###
1;    #
###
