<html><head><meta name="color-scheme" content="light dark"></head><body><pre style="word-wrap: break-word; white-space: pre-wrap;">package OpenILS::Utils::OfflineStore;
use strict; use warnings;
use base 'Class::DBI';
use DBI;
use OpenSRF::Utils::Config;

our ($_dsn,$_u,$_p);
sub DBFile {
	my $class = shift;
	my $dsn = shift;
	my $u = shift;
	my $p = shift;
	if ($dsn) {
		$_dsn = $dsn;
		$_u = $u;
		$_p = $p;
	}
	return $_dsn;
}

our $_dbh;
sub db_Main {
	my $self = shift;
	return $_dbh if ($_dbh);

	$_dbh = DBI-&gt;connect($_dsn,$_u,$_p,
		{
			RootClass =&gt; 'DBIx::ContextualFetch' 
		}
	);

	return $_dbh;
}


sub disconnect {
	$_dbh-&gt;disconnect;
	$_dbh = undef;
}


package OpenILS::Utils::OfflineStore::Session;
use base 'OpenILS::Utils::OfflineStore';

sub _create_table {
	my $self = shift;
	$self-&gt;db_Main-&gt;do( &lt;&lt;"	SQL" );

CREATE TABLE session (
	key				TEXT	UNIQUE PRIMARY KEY,
	org				INTEGER	NOT NULL,
	description		TEXT,
	creator			INTEGER NOT NULL,
	create_time		INTEGER NOT NULL,
	in_process		INTEGER NOT NULL DEFAULT 0,
	start_time		INTEGER,
	end_time			INTEGER,
	num_complete	INTEGER NOT NULL DEFAULT 0
);
CREATE INDEX IF NOT EXISTS session_pkey ON session (key);
CREATE INDEX IF NOT EXISTS session_org ON session (org);
CREATE INDEX IF NOT EXISTS session_creation ON session (create_time);

	SQL
}

__PACKAGE__-&gt;table('offline.session');
__PACKAGE__-&gt;columns( Essential =&gt; qw/key org description 
		creator create_time in_process start_time end_time num_complete/);
__PACKAGE__-&gt;has_many(scripts =&gt; 'OpenILS::Utils::OfflineStore::Script');


package OpenILS::Utils::OfflineStore::Script;
use base 'OpenILS::Utils::OfflineStore';

sub _create_table {
	my $self = shift;
	$self-&gt;db_Main-&gt;do( &lt;&lt;"	SQL" );

CREATE TABLE script (
	id		INTEGER	UNIQUE PRIMARY KEY AUTOINCREMENT,
	session		TEXT	NOT NULL,
	requestor	INTEGER	NOT NULL,
	create_time	INTEGER	NOT NULL,
	workstation	TEXT	NOT NULL,
	logfile		TEXT	NOT NULL,
	time_delta	INTEGER	NOT NULL DEFAULT 0,
	count			INTEGER	NOT NULL DEFAULT 0
);
CREATE INDEX IF NOT EXISTS script_pkey ON script (id);
CREATE INDEX IF NOT EXISTS script_ws ON script (workstation);
CREATE INDEX IF NOT EXISTS script_session ON script (session);

	SQL
}

__PACKAGE__-&gt;table('offline.script');
__PACKAGE__-&gt;columns( Essential =&gt; qw/id session requestor create_time workstation logfile time_delta count/);
__PACKAGE__-&gt;has_a(session =&gt; 'OpenILS::Utils::OfflineStore::Session');
__PACKAGE__-&gt;sequence(qw/offline.script_id_seq/);





</pre></body></html>