#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package RPS::Mechanical::UK::McpsLicenseList;

use strict;
use warnings;

use Data::Dumper;

use lib '/app/tools/rps/lib';
use RPS::DB::Item::McpsLicense;
use RPS::Mechanical::UK::McpsLicense;

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


#
# This class will contain the list of MCPS licenses for a given album
#



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

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

	my $albumID = $args{albumID};

    $self->{McpsLicense} = [];
	if ($albumID)
	{
		my $collection = RPS::DB::Item::McpsLicense->GetMcpsLicensesByAlbumID($albumID);

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

			push @{$self->{McpsLicense}}, RPS::Mechanical::UK::McpsLicense->new(_dbItem => $obj);
		}
	}

    return $self;
}




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



# This is the special sort of list accessor.
#
sub McpsLicense
{
    my ($self, $index, $methodAddressList, $newValue) = @_;

    if (0 == scalar @$methodAddressList)
    {
        if (defined $newValue)
        {
            $self->{McpsLicense}[$index] = $newValue;
        }
		return 1;
    }

	# May need to dynamically add objects to the list...
	#
	if (! defined $self->{McpsLicense}[$index])
	{
		$self->{McpsLicense}[$index] = RPS::Mechanical::UK::McpsLicense->new();
	}


    return $self->{McpsLicense}[$index]->_accessProperty($methodAddressList, $newValue);
}


1;

