/[cvs]/nfo/perl/libs/Data/Storage/Handler/Tangram.pm
ViewVC logotype

Annotation of /nfo/perl/libs/Data/Storage/Handler/Tangram.pm

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1.1 - (hide annotations)
Thu Oct 10 03:44:07 2002 UTC (21 years, 9 months ago) by cvsjoko
Branch: MAIN
+ new

1 cvsjoko 1.1 #################################
2     #
3     # $Id$
4     #
5     # $Log$
6     #
7     #################################
8    
9     package Data::Storage::Handler::Tangram;
10    
11     use strict;
12     use warnings;
13    
14     use base ("Data::Storage::Handler::Abstract");
15    
16     use Tangram;
17     use Data::Dumper;
18    
19     # get logger instance
20     my $logger = Log::Dispatch::Config->instance;
21    
22    
23     our $metainfo = {
24     'disconnectMethod' => 'disconnect',
25     };
26    
27     sub connect {
28    
29     my $self = shift;
30    
31     my $dsn = shift;
32     $dsn ||= $self->{dbi}->{dsn};
33    
34     $logger->debug( __PACKAGE__ . "->connect($dsn)" );
35    
36     #my $storage = Tangram::Relational->connect( $schema, $dsn );
37     #my $storage = Tangram::mysql->connect( $schema, $dsn );
38     #$storage = Tangram::Relational->connect( Project->schema, $dsn );
39    
40     # if (!testDsn($dsn)) {
41     # croak("Database at \"$dsn\" is not available");
42     # return;
43     # }
44    
45    
46     require 'OSA/tsobj.pm';
47     tsobj::initSchema();
48     #sleep 1;
49     my $schema = tsobj::getSchema();
50     $self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn );
51    
52     #$self->{STORAGEHANDLE_UNDERLYING} = $self->getUnderlyingStorage();
53     #$self->{STORAGEHANDLE_UNDERLYING}->_configureCOREHANDLE();
54     #$self->_configureUnderlyingStorage;
55     $self->configureCOREHANDLE();
56    
57     }
58    
59     sub getChildNodes {
60    
61     my $self = shift;
62     my @nodes;
63    
64     # create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE
65     #my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} });
66     #my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} );
67     my $storage = $self->_getSubLayerHandle();
68     #$storage->_configureCOREHANDLE();
69    
70     #if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) {
71     if (my $result = $storage->sendCommand( 'SHOW TABLES;' ) ) {
72     while ( my $row = $result->_getNextEntry() ) {
73     push @nodes, $row;
74     }
75     }
76    
77     $storage->disconnect();
78    
79     return \@nodes;
80    
81     }
82    
83    
84     sub _getSubLayerHandle {
85    
86     my $self = shift;
87    
88     use Data::Dumper;
89     #print Dumper($self);
90    
91     # hack, make more generic!
92     if (!$self->{STORAGE_SUBLAYER}) {
93     my $loc = new Data::Storage::Locator( type => "DBI", dbi => $self->{dbi}, COREHANDLE => $self->{COREHANDLE}->{db} );
94     $self->{STORAGE_SUBLAYER} = new Data::Storage( $loc, { protected => 1 } );
95     #$self->{STORAGE_UNDER_THE_HOOD}->{STORAGEHANDLE}->_configureCOREHANDLE();
96     #$self->{STORAGE_UNDER_THE_HOOD}->_configureCOREHANDLE();
97     }
98    
99     #print Dumper($self->{STORAGE_UNDER_THE_HOOD});
100    
101     return $self->{STORAGE_SUBLAYER};
102    
103     }
104    
105     sub _configureUnderlyingStorage {
106    
107     my $self = shift;
108     $self->_configureCOREHANDLE_DBI();
109     return;
110    
111     foreach my $key (keys %{$self->{dbi}}) {
112     my $val = $self->{dbi}->{$key};
113     print "entry: $key; $val", "\n";
114     $self->{COREHANDLE}->{db}->{$key} = $val;
115     }
116     #print Dumper($self->{COREHANDLE}->{db});
117     }
118    
119    
120     sub configureCOREHANDLE {
121    
122     my $self = shift;
123    
124     $logger->debug( __PACKAGE__ . "->_configureCOREHANDLE" );
125    
126     #my $subLayer = $self->_getSubLayerHandle();
127    
128     # apply configured modifications
129     if (exists $self->{dbi}->{trace_level} && exists $self->{dbi}->{trace_file}) {
130     $self->{COREHANDLE}->{db}->trace($self->{dbi}->{trace_level}, $self->{dbi}->{trace_file});
131     }
132     if (exists $self->{dbi}->{RaiseError}) {
133     $self->{COREHANDLE}->{db}->{RaiseError} = $self->{dbi}->{RaiseError};
134     }
135     if (exists $self->{dbi}->{PrintError}) {
136     $self->{COREHANDLE}->{db}->{PrintError} = $self->{dbi}->{PrintError};
137     }
138     if (exists $self->{dbi}->{HandleError}) {
139     $self->{COREHANDLE}->{db}->{HandleError} = $self->{dbi}->{HandleError};
140     }
141    
142     }
143    
144     1;

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed