#------------------------------------------------------------
# Copyright (C) 2009 RoyaltyShare, Inc.   All Rights Reserved
#------------------------------------------------------------
package BookPub::Tracker::File::Display;

use strict;
use warnings;

use lib '/app/tools/common/lib';
use Common::Assert;
use RSApache::Message;
use base 'BookPub::Tracker::File';

use lib '/app/tools/bookpub/lib';
use BookPub::DB::Item::File;
use BookPub::DB::Item::Sale;
use BookPub::Tracker::Service::ServiceWithConfig;

sub _initProperties {
    my ( $self, $hrProperties ) = @_;

    $self->SUPER::_initProperties($hrProperties);

    # Fetch the child count
    #
    my $count = 0;
    if ( $hrProperties->{file_id} ) {
        $count = BookPub::DB::Item::File->ChildCount( $hrProperties->{file_id} );
    }
    $self->{HasChild} = $count;

    my $fileName = $hrProperties->{orig_file_name};
    $fileName =~ s/_/ /g;

    if ( $count != 0 || $hrProperties->{generation} != 0 ) {
        my $displayGeneration = $hrProperties->{generation} + 1;
        $fileName .= " (Sp" . $displayGeneration . ")";
    }

    $self->{PrettyFileName} = $fileName;

    return $self;
}

1;
