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

use strict;
use warnings;

use lib '/app/tools/common/lib';
use base 'Common::DB::Item';

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

use constant kRoleIDAuthor => 1;

sub GetAllForBooks {
    my ($class) = @_;

    # Return the subset of roles that are appropriate for a book contributor.
    # At this point, we essentially hard-code this to present only 1 - Author.
    # I am not certain that this is the definitive answer, but this interface
    # will keep that abstract in any case...
    #
    $class->SUPER::GetAll( "SELECT * FROM " . kTable . " WHERE contributor_role_id IN (1)" );
}

sub GetAllForBookProducts {
    my ($class) = @_;

    # Return everything BUT author.
    #
    $class->SUPER::GetAll( "SELECT * FROM " . kTable . " WHERE contributor_role_id NOT IN (1)" );
}

sub getAllAsOnixCode {
    my ($class) = @_;

    my $dbo = Common::RSApp->GetClientDB();
    my $sth = $dbo->DoCmd( 'SELECT * FROM ' . kTable );
    return $sth->fetchall_hashref('onix_code');

}

1;
