#------------------------------------------------------------
# Copyright (C) 2006 RoyaltyShare, Inc.   All Rights Reserved
# $Id$
#------------------------------------------------------------
package Support::DB::Item::DataImportFile;
use strict;
use warnings;

use lib '/app/tools/rps/lib';

use lib '/app/tools/common/lib';
use Common::Assert;

use base 'Common::DB::Item';

use constant kTable => 'data_import_file';
use constant kDB    => Common::DB::Item::kCommonDB();

use constant kFileTypeTemplate   => 1; # input template
use constant kFileTypeExceptions => 2; # exceptions file

use constant kFileStatusAborted     => 0;  # import terminated
use constant kFileStatusUnprocessed => 1;  # file uploaded, but no test or import done yet
use constant kFileStatusTested      => 2;  # ran 'make test'
use constant kFileStatusImported    => 3;  # ran 'make import'
use constant kFileStatusIgnore      => 4;  # do not process

sub GetAll {
    my $class = shift;

    my $sql = "SELECT * FROM " . kTable . " ORDER BY file_id";
    return $class->SUPER::GetAll($sql);
}

sub GetByImportID {
    my ( $class, %args ) = @_;
    my $importID = $args{import_id};
    my $dbo      = Common::RSApp::GetClientDB();
    my $sql = "SELECT * FROM " . kTable . " WHERE import_id=$importID ORDER BY file_id";
    return $class->SUPER::GetAll($sql);
}

1;
