#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------


# The biggest problem with the DB::Item abstraction are complex, multi-table
# queries.  To get around the limitations of the current model, while still 
# maintaining abstraction around the database, I will create a 'custom' DB::Item
# class for each query that produces one of these table-spanning reports.
#
# Basically, these will be classes that 
# - are read-only (save will be unavailable),
# - will override _config to skip the automatic schema parsing scheme,
# - will only support Lookup with the 'hash' arg: in other words, will only
#   support being instantiated as part of a collection.
# - ... and probably a few more hacks to make it all work.


package RPS::DB::Item::ReportQueries;
#
#  This will be the base class for the rest of the reports.
#  We'll 'break' the default behaviours here.
#
use strict;
use warnings;
use lib '/app/tools/common/lib';
use Common::DB::Item;
use Common::DB::ItemCollection;
use Common::Assert;

use base 'Common::DB::Item';
use constant kDB => Common::DB::Item::kClientDB();


# Override save to disable saving.
#
sub save
{
    assert(0, "ERROR : ReportQueries cannot be modified or saved");
}


# Override _init to only allow hash based initialization
#
sub _init
{
	my ($self, %params) = @_;

    assert($params{hash},"ERROR : ReportQueries can only be instantiated as part of a collection");

    return $self->SUPER::_init(%params);
}


1;
