3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.31 2003/04/05 21:24:09 joko |
7 |
|
# modified 'sub getChildNodes': now contains code from 'querySchema' |
8 |
|
# |
9 |
|
# Revision 1.30 2003/03/27 15:31:14 joko |
10 |
|
# fixes to modules regarding new namespace(s) below Data::Mungle::* |
11 |
|
# |
12 |
# Revision 1.29 2003/02/21 01:47:18 joko |
# Revision 1.29 2003/02/21 01:47:18 joko |
13 |
# purged old code |
# purged old code |
14 |
# minor cosmetics |
# minor cosmetics |
133 |
|
|
134 |
use DesignPattern::Object; |
use DesignPattern::Object; |
135 |
use Data::Storage::Result::Tangram; |
use Data::Storage::Result::Tangram; |
136 |
use Data::Compare::Struct qw( isEmpty ); |
use Data::Mungle::Compare::Struct qw( isEmpty ); |
137 |
use Data::Transform::Deep qw( expand ); |
use Data::Mungle::Transform::Deep qw( expand ); |
138 |
|
|
139 |
# get logger instance |
# get logger instance |
140 |
my $logger = Log::Dispatch::Config->instance; |
my $logger = Log::Dispatch::Config->instance; |
234 |
sub getChildNodes { |
sub getChildNodes { |
235 |
|
|
236 |
my $self = shift; |
my $self = shift; |
237 |
my @nodes; |
my $mode = shift; |
238 |
|
$mode ||= 'core'; |
239 |
|
|
240 |
|
$logger->debug( __PACKAGE__ . "->getChildNodes($mode)" ); |
241 |
|
|
242 |
$logger->debug( __PACKAGE__ . "->getChildNodes()" ); |
if ($mode eq 'core') { |
243 |
|
|
244 |
|
my @nodes; |
245 |
|
|
246 |
|
# create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE |
247 |
|
#my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} }); |
248 |
|
#my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} ); |
249 |
|
|
250 |
|
# todo: should we retrieve information from the schema here |
251 |
|
# rather than poorly getting table names from underlying dbi? |
252 |
|
my $storage = $self->_getSubLayerHandle(); |
253 |
|
@nodes = @{$storage->getChildNodes()}; |
254 |
|
#$storage->_configureCOREHANDLE(); |
255 |
|
#print "getchildnodes\n"; |
256 |
|
#print Dumper($self); |
257 |
|
#if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
258 |
|
|
259 |
|
# TODO: REVIEW |
260 |
|
#$storage->disconnect(); |
261 |
|
|
262 |
|
$self->{meta}->{childnodes} = \@nodes; |
263 |
|
|
264 |
# create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE |
return \@nodes; |
|
#my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} }); |
|
|
#my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} ); |
|
265 |
|
|
266 |
# todo: should we retrieve information from the schema here |
} elsif ($mode eq 'root') { |
267 |
# rather than poorly getting table names from underlying dbi? |
|
268 |
my $storage = $self->_getSubLayerHandle(); |
# FIXME: this will return *all* known classes to 'Class::Tangram', |
269 |
@nodes = @{$storage->getChildNodes()}; |
# which might not be what you expect since more than one instance |
270 |
#$storage->_configureCOREHANDLE(); |
# of Tangram may be in memory and Class::Tangram seems to |
271 |
#print "getchildnodes\n"; |
# offer no methods to determine this or filter its result(s) according |
272 |
#print Dumper($self); |
# to a specific database. |
273 |
#if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
my @object_names = Class::Tangram::known_classes(); |
274 |
|
my @concret_names; |
275 |
|
my $o_cnt; |
276 |
|
foreach (sort @object_names) { |
277 |
|
push @concret_names, $_ if (!Class::Tangram::class_is_abstract($_)); |
278 |
|
$o_cnt++; |
279 |
|
} |
280 |
|
|
281 |
# TODO: REVIEW |
my $result = { |
282 |
#$storage->disconnect(); |
all => \@object_names, |
283 |
|
concrete => \@concret_names, |
284 |
|
}; |
285 |
|
return $result; |
286 |
|
|
287 |
$self->{meta}->{childnodes} = \@nodes; |
} |
288 |
|
|
|
return \@nodes; |
|
289 |
|
|
290 |
} |
} |
291 |
|
|
|
|
|
292 |
sub testIntegrity { |
sub testIntegrity { |
293 |
|
|
294 |
my $self = shift; |
my $self = shift; |