package BookPub::Sale::Match::Staged;

# This class extends the Match logic to look in the 'catalog_import' metadata tables, rather
# than the 'live' tables.
# The point here is to provide a mechanism to detect when staged metadata changes might break existing matches.
# We want to use exactly the same logic to find these potential matches we use for 'real' matches.

use strict;

#use warnings;

use Data::Dumper;
use Encode qw(encode_utf8);

use lib '/app/tools/sale_import/lib';
use lib '/app/tools/bookpub/lib/';
use lib '/app/tools/data_classes/lib';
use lib '/app/tools/common/lib';

use Common::Util qw(clean word_containment);
use Common::RSDB;
use Common::Log;
use Common::Assert;
use Common::DB::Item::OnixCode;

#use Product::ProductAlbum; # require'd in MakeMatch

use BookPub::DB::Item::Product;
use BookPub::DB::Item::BookProduct;
use BookPub::DB::Item::Sale;
use BookPub::DB::Item::BookMatch;
use BookPub::DB::Item::BookFormat;
use BookPub::Sale::Match::Result;
use BookPub::DB::Item::ProductInputMap;
use BookPub::Import::Importer;

use base 'BookPub::Sale::Match';

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

    # Fetch the catalog import id from the Singleton.
    #
    my $catalogImportID = Common::RSApp::GetRAMCache()->{catalogImportID};
    assert( $catalogImportID, "ERROR - catalogImportID not set in singleton!" );

    $args{catalog_import_id} = $catalogImportID;
    return BookPub::DB::Item::BookMatch->GetStagedMatches(%args);
}

1;
