]> git.evergreen-ils.org Git - working/Evergreen.git/blob - Open-ILS/src/perlmods/OpenILS/Application/Storage.pm
EETS ALIVE!!!!!!!
[working/Evergreen.git] / Open-ILS / src / perlmods / OpenILS / Application / Storage.pm
1 package OpenILS::Application::Storage;
2 use OpenSRF::Application;
3 use base qw/OpenSRF::Application/;
4
5 use OpenSRF::EX qw/:try/;
6 use OpenSRF::Utils::Logger qw/:level/;
7
8 # Pull this in so we can adjust it's @ISA
9 use OpenILS::Application::Storage::CDBI;
10
11 use OpenILS::Application::Storage::FTS;
12
13 # Suck in the method publishing modules
14 use OpenILS::Application::Storage::Publisher;
15
16 # the easy way to get to the logger...
17 my $log = "OpenSRF::Utils::Logger";
18
19 sub DESTROY {};
20
21 sub initialize {
22
23         my $conf = OpenSRF::Utils::SettingsClient->new;
24
25         $log->debug('Initializing ' . __PACKAGE__ . '...', DEBUG);
26
27         my $driver = "OpenILS::Application::Storage::Driver::".
28                 $conf->config_value( apps => storage => app_settings => databases => 'driver');
29
30
31         $log->debug("Attempting to load $driver ...", DEBUG);
32
33         eval "use $driver;";
34         throw OpenILS::EX::PANIC ( "Can't load $driver!  :  $@" ) if ($@);
35
36         $log->debug("$driver loaded successfully", DEBUG);
37
38         @OpenILS::Application::Storage::CDBI::ISA = ( $driver );
39 }
40
41 sub child_init {
42
43         my $conf = OpenSRF::Utils::SettingsClient->new;
44
45         $log->debug('Running child_init for ' . __PACKAGE__ . '...', DEBUG);
46
47         OpenILS::Application::Storage::CDBI->child_init(
48                 $conf->config_value( apps => storage => app_settings => databases => 'database')
49         );
50         
51         return 1 if (OpenILS::Application::Storage::CDBI->db_Main());
52         return 0;
53 }
54
55
56 sub _cdbi2Hash {
57         my $self = shift;
58         my $obj = shift;
59         return { map { ( $_ => $obj->$_ ) } $obj->columns };
60 }
61
62 sub _cdbi_list2AoH {
63         my $self = shift;
64         my @objs = @_;
65         return [ map { _cdbi2oilsHash($_) } @objs ];
66 }
67
68 1;