#---------------------------------------------------------------
# ____                   _ _         ____  _
#|  _ \ ___  _   _  __ _| | |_ _   _/ ___|| |__   __ _ _ __ ___
#| |_) / _ \| | | |/ _` | | __| | | \___ \| '_ \ / _` | '__/ _ \
#|  _ < (_) | |_| | (_| | | |_| |_| |___) | | | | (_| | | |  __/
#|_| \_\___/ \__, |\__,_|_|\__|\__, |____/|_| |_|\__,_|_|  \___|
#            |___/             |___/
#
# Copyright (C) 2010 RoyaltyShare, Inc.   All Rights Reserved
#---------------------------------------------------------------
package BookPub::Catalog::Region::RegionWithCountriesList;

use strict;
use warnings;

use lib '/app/tools/bookpub/lib';
use BookPub::Catalog::BookSubject::WithLiteral;
use BookPub::DB::Item::BookSubject;
use BookPub::DB::Item::Region;

use Common::FormObject;
use base 'Common::FormObject::List';

use Data::Dumper;

sub _itemName { 'Region' }

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

    # If a productID is passed in, we will only include regions associated with product_market_price
    # entries for this product.
    if ( $args{productID} ) {
        return BookPub::DB::Item::Region->GetAllByProductID( productID => $args{productID} );
    } else {

        # Otherwise, just return the full list.
        return BookPub::DB::Item::Region->GetAll();
    }
}

sub _getObj {
    my ( $self, $dbItem ) = @_;

    return BookPub::Catalog::Region::RegionWithCountries->new( dbItem => $dbItem );
}
1;
