#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2009 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#---------------------------------------------------------------
package BookPub::Catalog::Book::Extended;

# JPK - 'Extended' is pretty vague... This class contains all the OTHER
# stuff we need to edit on the 'edit_book' page.

use strict;
use warnings;

use lib '/app/tools/common/lib';
use lib '/app/tools/bookpub/lib';
use BookPub::Catalog::BookContributorHash;
use BookPub::Catalog::BookSubjectHash;
use Common::RSApp;
use Common::Util;
use Common::Assert;
use Common::FormObject;
use Common::DB::Item::Language;

use base 'BookPub::Catalog::Book';

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

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

    $self->{ContributorHash} = BookPub::Catalog::BookContributorHash->new( bookID => $props->{book_id} );
    $self->{SubjectHash} = BookPub::Catalog::BookSubjectHash->new( bookID => $props->{book_id} );
    $self->{LanguageName} = '';

    if ( $props->{language_code} ) {
        my $lang = Common::DB::Item::Language->Lookup( part1 => $props->{language_code} );
        $self->{LanguageName} = $lang->name();
    }
}

sub _saveBook {
    my ($self) = @_;

    my $dbObj = $self->SUPER::_saveBook();

    $self->{ContributorHash}->save( bookID => $self->BookID() );
    $self->{SubjectHash}->save( bookID => $self->BookID() );

    return $dbObj;
}

###
1;    #
###
