#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package RPS::Track::TrackWithCALicenses;
use strict;
use warnings;

use Data::Dumper;

use lib '/app/tools/common/lib';
use Common::RSApp;
use Common::Assert;

use lib '/app/tools/rps/lib';
use RPS::License::CA::TrackLicenseList;
use RPS::Track::TrackSimple;
use base 'RPS::Track::TrackSimple';

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

    # Call the inherited method first.
    #
    $self->SUPER::_initProperties($props);

    # Now add in the license list.
    #
    if ( $props->{track_id} > 0 ) {

        my ($productFilter, $licenseFilter, $statusFilter);
        if ( exists $args{filter} ) {
            $productFilter = exists $args{filter}->{productFilter} && $args{filter}->{productFilter};
            $licenseFilter = exists $args{filter}->{licenseFilter} && $args{filter}->{licenseFilter};
            $statusFilter  = exists $args{filter}->{statusFilter}  && $args{filter}->{statusFilter};
        }

        # !!! Do these license lists _really_ need to have all this loadSub state?
        # !!! Do we _really_ need to spew out the entire publisher block, for example?
        #
        $self->{TrackLicenseList} = RPS::License::CA::TrackLicenseList->new(
            trackID       => $props->{track_id},
            readOnly      => 1,
            loadSubs      => 0,
            productFilter => $productFilter,
            licenseFilter => $licenseFilter,
            statusFilter  => $statusFilter
        );
    }
}

###
1;    # Play nicely.
###

