3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.32 2003/04/08 22:52:22 joko |
7 |
|
# modified 'querySchema': better behaviour regarding filtering result |
8 |
|
# |
9 |
|
# Revision 1.31 2003/04/05 21:24:09 joko |
10 |
|
# modified 'sub getChildNodes': now contains code from 'querySchema' |
11 |
|
# |
12 |
# Revision 1.30 2003/03/27 15:31:14 joko |
# Revision 1.30 2003/03/27 15:31:14 joko |
13 |
# fixes to modules regarding new namespace(s) below Data::Mungle::* |
# fixes to modules regarding new namespace(s) below Data::Mungle::* |
14 |
# |
# |
237 |
sub getChildNodes { |
sub getChildNodes { |
238 |
|
|
239 |
my $self = shift; |
my $self = shift; |
240 |
my @nodes; |
my $mode = shift; |
241 |
|
my $filter = shift; |
242 |
|
|
243 |
|
$mode ||= 'core'; |
244 |
|
$filter ||= 'all'; |
245 |
|
|
246 |
|
$logger->debug( __PACKAGE__ . "->getChildNodes($mode)" ); |
247 |
|
|
248 |
$logger->debug( __PACKAGE__ . "->getChildNodes()" ); |
if ($mode eq 'core') { |
249 |
|
|
250 |
# create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE |
my @nodes; |
251 |
#my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} }); |
|
252 |
#my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} ); |
# create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE |
253 |
|
#my $loc = new Data::Storage::Locator( type => "DBI", dbi => { db => $self->{COREHANDLE}->{db} }); |
254 |
# todo: should we retrieve information from the schema here |
#my $loc = new Data::Storage::Locator( type => "DBI", COREHANDLE => $self->{COREHANDLE}->{db} ); |
255 |
# rather than poorly getting table names from underlying dbi? |
|
256 |
my $storage = $self->_getSubLayerHandle(); |
# todo: should we retrieve information from the schema here |
257 |
@nodes = @{$storage->getChildNodes()}; |
# rather than poorly getting table names from underlying dbi? |
258 |
#$storage->_configureCOREHANDLE(); |
my $storage = $self->_getSubLayerHandle(); |
259 |
#print "getchildnodes\n"; |
@nodes = @{$storage->getChildNodes()}; |
260 |
#print Dumper($self); |
#$storage->_configureCOREHANDLE(); |
261 |
#if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
#print "getchildnodes\n"; |
262 |
|
#print Dumper($self); |
263 |
|
#if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { |
264 |
|
|
265 |
|
# TODO: REVIEW |
266 |
|
#$storage->disconnect(); |
267 |
|
|
268 |
|
$self->{meta}->{childnodes} = \@nodes; |
269 |
|
|
270 |
|
return \@nodes; |
271 |
|
|
272 |
# TODO: REVIEW |
} elsif ($mode eq 'root') { |
273 |
#$storage->disconnect(); |
|
274 |
|
# FIXME: this will return *all* known classes to 'Class::Tangram', |
275 |
|
# which might not be what you expect since more than one instance |
276 |
|
# of Tangram may be in memory and Class::Tangram seems to |
277 |
|
# offer no methods to determine this or filter its result(s) according |
278 |
|
# to a specific database. |
279 |
|
my @object_names = Class::Tangram::known_classes(); |
280 |
|
my @concret_names; |
281 |
|
my $o_cnt; |
282 |
|
foreach (sort @object_names) { |
283 |
|
push @concret_names, $_ if (!Class::Tangram::class_is_abstract($_)); |
284 |
|
$o_cnt++; |
285 |
|
} |
286 |
|
|
287 |
|
if ($filter eq 'all') { |
288 |
|
return \@object_names; |
289 |
|
} elsif ($filter eq 'concrete') { |
290 |
|
return \@concret_names; |
291 |
|
} |
292 |
|
|
293 |
$self->{meta}->{childnodes} = \@nodes; |
} |
294 |
|
|
|
return \@nodes; |
|
295 |
|
|
296 |
} |
} |
297 |
|
|
|
|
|
298 |
sub testIntegrity { |
sub testIntegrity { |
299 |
|
|
300 |
my $self = shift; |
my $self = shift; |
560 |
|
|
561 |
# HACK: special case: querying by id does not translate into a common tangram query |
# HACK: special case: querying by id does not translate into a common tangram query |
562 |
# just load the object by given id(ent) |
# just load the object by given id(ent) |
563 |
if ($query->{criterias}->[0]->{key} eq 'id' && $query->{criterias}->[0]->{op} eq 'eq') { |
if ($query->{criterias} && ($query->{criterias}->[0]->{key} eq 'id' && $query->{criterias}->[0]->{op} eq 'eq')) { |
564 |
#print "LOAD!!!", "\n"; |
#print "LOAD!!!", "\n"; |
565 |
#exit; |
#exit; |
566 |
#return Set::Object->new( $self->{COREHANDLE}->load($query->{criterias}->[0]->{val}) ); |
#return Set::Object->new( $self->{COREHANDLE}->load($query->{criterias}->[0]->{val}) ); |