3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.5 2002/11/17 06:35:18 joko |
7 |
|
# + locator metadata can now be reached via ->{locator} |
8 |
|
# - getChildNodes is now wrapped via COREHANDLE |
9 |
|
# |
10 |
# Revision 1.4 2002/10/25 11:44:44 joko |
# Revision 1.4 2002/10/25 11:44:44 joko |
11 |
# + sub _initSchema |
# + sub _initSchema |
12 |
# + sub existsChildNode |
# + sub existsChildNode |
52 |
$logger->debug( __PACKAGE__ . "->getNewPerlObjectByPkgName( pkgname $pkgname args $args )" ); |
$logger->debug( __PACKAGE__ . "->getNewPerlObjectByPkgName( pkgname $pkgname args $args )" ); |
53 |
my $evstring = "use $pkgname;"; |
my $evstring = "use $pkgname;"; |
54 |
eval($evstring); |
eval($evstring); |
55 |
$@ && $logger->error( __PACKAGE__ . ':' . __LINE__ . " Error in eval: " . $@ ); |
$@ && $logger->error( __PACKAGE__ . ':' . __LINE__ . " Error in eval $evstring: " . $@ ); |
56 |
return $pkgname->new($args); |
return $pkgname->new($args); |
57 |
} |
} |
58 |
|
|
60 |
my $self = shift; |
my $self = shift; |
61 |
$logger->debug( __PACKAGE__ . "->_initSchema()" ); |
$logger->debug( __PACKAGE__ . "->_initSchema()" ); |
62 |
#if (!$self->{schema_tangram}) { |
#if (!$self->{schema_tangram}) { |
63 |
my $obj = getNewPerlObjectByPkgName($self->{schema}, { EXPORT_OBJECTS => $self->{classnames} } ); |
my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } ); |
64 |
$self->{schema_tangram} = $obj->getSchema(); |
$self->{schema_tangram} = $obj->getSchema(); |
65 |
#} |
#} |
66 |
if (!$self->{schema_tangram}) { |
if (!$self->{schema_tangram}) { |
75 |
my $self = shift; |
my $self = shift; |
76 |
|
|
77 |
my $dsn = shift; |
my $dsn = shift; |
78 |
$dsn ||= $self->{dbi}->{dsn}; |
$dsn ||= $self->{locator}->{dbi}->{dsn}; |
79 |
|
|
80 |
$logger->debug( __PACKAGE__ . "->connect( dsn $dsn )" ); |
$logger->debug( __PACKAGE__ . "->connect( dsn $dsn )" ); |
81 |
|
|
98 |
#$self->_configureUnderlyingStorage; |
#$self->_configureUnderlyingStorage; |
99 |
$self->configureCOREHANDLE(); |
$self->configureCOREHANDLE(); |
100 |
|
|
101 |
|
$self->{locator}->{status}->{connected} = 1; |
102 |
|
|
103 |
return 1; |
return 1; |
104 |
|
|
105 |
} |
} |
115 |
#my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} }); |
#my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} }); |
116 |
#my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} ); |
#my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} ); |
117 |
my $storage = $self->_getSubLayerHandle(); |
my $storage = $self->_getSubLayerHandle(); |
118 |
|
@nodes = @{$storage->getChildNodes()}; |
119 |
#$storage->_configureCOREHANDLE(); |
#$storage->_configureCOREHANDLE(); |
120 |
|
#print "getchildnodes\n"; |
121 |
|
#print Dumper($self); |
122 |
#if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
#if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
|
if (my $result = $storage->sendCommand( 'SHOW TABLES;' ) ) { |
|
|
while ( my $row = $result->_getNextEntry() ) { |
|
|
push @nodes, $row; |
|
|
} |
|
|
} |
|
123 |
|
|
124 |
$storage->disconnect(); |
$storage->disconnect(); |
125 |
|
|
135 |
my $nodename = shift; |
my $nodename = shift; |
136 |
$logger->debug( __PACKAGE__ . "->getChildNode( nodename $nodename )" ); |
$logger->debug( __PACKAGE__ . "->getChildNode( nodename $nodename )" ); |
137 |
$self->getChildNodes() unless $self->{meta}->{childnodes}; |
$self->getChildNodes() unless $self->{meta}->{childnodes}; |
138 |
|
#print Dumper($self->{meta}->{childnodes}); |
139 |
return grep $nodename, @{$self->{meta}->{childnodes}}; |
return grep $nodename, @{$self->{meta}->{childnodes}}; |
140 |
} |
} |
141 |
|
|
158 |
return; |
return; |
159 |
} |
} |
160 |
|
|
161 |
|
$self->{locator}->{status}->{integrity} = 1; |
162 |
return 1; |
return 1; |
163 |
|
|
164 |
} |
} |
170 |
|
|
171 |
$logger->debug( __PACKAGE__ . "->_getSubLayerHandle()" ); |
$logger->debug( __PACKAGE__ . "->_getSubLayerHandle()" ); |
172 |
|
|
|
use Data::Dumper; |
|
173 |
#print Dumper($self); |
#print Dumper($self); |
174 |
#exit; |
|
|
|
|
175 |
# hack, make more generic! |
# hack, make more generic! |
176 |
if (!$self->{dataStorageLayer}) { |
if (!$self->{dataStorageLayer}) { |
177 |
$logger->debug( __PACKAGE__ . "->_getSubLayerHandle() creating new dataStorageLayer" ); |
$logger->debug( __PACKAGE__ . "->_getSubLayerHandle() creating new dataStorageLayer" ); |
178 |
#my $loc = Data::Storage::Locator->new( type => "DBI", dbi => $self->{dbi}, COREHANDLE => $self->{COREHANDLE}->{db} ); |
#my $loc = Data::Storage::Locator->new( type => "DBI", dbi => $self->{dbi}, COREHANDLE => $self->{COREHANDLE}->{db} ); |
179 |
my $loc = Data::Storage::Locator->new( type => "DBI", dbi => $self->{dbi} ); |
my $loc = Data::Storage::Locator->new( { type => "DBI", dbi => $self->{locator}->{dbi} } ); |
180 |
$self->{dataStorageLayer} = Data::Storage->new( $loc, { protected => 1 } ); |
$self->{dataStorageLayer} = Data::Storage->new( $loc, { protected => 1 } ); |
181 |
#$self->{STORAGE_UNDER_THE_HOOD}->{STORAGEHANDLE}->_configureCOREHANDLE(); |
#$self->{STORAGE_UNDER_THE_HOOD}->{STORAGEHANDLE}->_configureCOREHANDLE(); |
182 |
#$self->{STORAGE_UNDER_THE_HOOD}->_configureCOREHANDLE(); |
#$self->{STORAGE_UNDER_THE_HOOD}->_configureCOREHANDLE(); |
232 |
|
|
233 |
sub deploySchema { |
sub deploySchema { |
234 |
my $self = shift; |
my $self = shift; |
235 |
#my $dsn = $self->{locator}->{dbi}->{dsn}; |
my $args = shift; |
236 |
my $dsn = $self->{dbi}->{dsn}; |
|
237 |
|
my $dsn = $self->{locator}->{dbi}->{dsn}; |
238 |
|
#my $dsn = $self->{dbi}->{dsn}; |
239 |
|
|
240 |
$logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" ); |
$logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" ); |
241 |
|
|
242 |
my $ok; |
my $ok; |
243 |
|
# TODO: is this DBI->connect okay here like it is? regarding errors.....??? |
244 |
if ( my $dbh = DBI->connect($dsn, '', '', { |
if ( my $dbh = DBI->connect($dsn, '', '', { |
245 |
PrintError => 0, |
PrintError => 0, |
246 |
} ) ) { |
} ) ) { |
256 |
sub retreatSchema { |
sub retreatSchema { |
257 |
|
|
258 |
my $self = shift; |
my $self = shift; |
259 |
#my $dsn = $self->{locator}->{dbi}->{dsn}; |
my $dsn = $self->{locator}->{dbi}->{dsn}; |
260 |
my $dsn = $self->{dbi}->{dsn}; |
#my $dsn = $self->{dbi}->{dsn}; |
261 |
|
|
262 |
$logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" ); |
$logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" ); |
263 |
|
|