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

use strict;
use warnings;

use lib '/app/tools/common/lib';
use lib '/app/tools/bookpuB/LIB';
use Common::Assert;
use BookPub::DB::Item::Archive::BookSubject;
use base 'BookPub::DB::MetadataItem';

sub _NewArchiveItem {
    my ( $class, %args ) = @_;
    return BookPub::DB::Item::Archive::BookSubject->Create(%args);
}

sub _ArchiveTableName {
    return 'archive_book_subject';
}

use constant kTable => 'book_subject';
use constant kDB    => Common::DB::Item::kClientDB;

sub GetAllByBookID {
    my ( $class, $bookID ) = @_;
    assert($bookID);

    my $sql = "SELECT * FROM " . kTable . " WHERE book_id=$bookID ORDER BY bisac_subject_code";
    return $class->GetAll($sql);
}

sub DeleteAllByBookID {
    my ( $class, $bookID ) = @_;
    assert($bookID);
    my $dbo = Common::RSApp::GetClientDB();
    $dbo->DoCmd( "DELETE FROM " . kTable . " WHERE book_id=$bookID" );
}

1;
