--- nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2003/03/27 15:31:14 1.30 +++ nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2003/04/05 21:24:09 1.31 @@ -1,8 +1,11 @@ ############################################ # -# $Id: Tangram.pm,v 1.30 2003/03/27 15:31:14 joko Exp $ +# $Id: Tangram.pm,v 1.31 2003/04/05 21:24:09 joko Exp $ # # $Log: Tangram.pm,v $ +# Revision 1.31 2003/04/05 21:24:09 joko +# modified 'sub getChildNodes': now contains code from 'querySchema' +# # Revision 1.30 2003/03/27 15:31:14 joko # fixes to modules regarding new namespace(s) below Data::Mungle::* # @@ -231,33 +234,61 @@ sub getChildNodes { my $self = shift; - my @nodes; + my $mode = shift; + $mode ||= 'core'; + + $logger->debug( __PACKAGE__ . "->getChildNodes($mode)" ); - $logger->debug( __PACKAGE__ . "->getChildNodes()" ); + if ($mode eq 'core') { - # create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE - #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} ); + my @nodes; + + # create new DBI - Data::Storage - object from already connected DBI::db - handle inside the current COREHANDLE + #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} ); + + # todo: should we retrieve information from the schema here + # rather than poorly getting table names from underlying dbi? + my $storage = $self->_getSubLayerHandle(); + @nodes = @{$storage->getChildNodes()}; + #$storage->_configureCOREHANDLE(); + #print "getchildnodes\n"; + #print Dumper($self); + #if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { + + # TODO: REVIEW + #$storage->disconnect(); + + $self->{meta}->{childnodes} = \@nodes; + + return \@nodes; - # todo: should we retrieve information from the schema here - # rather than poorly getting table names from underlying dbi? - my $storage = $self->_getSubLayerHandle(); - @nodes = @{$storage->getChildNodes()}; - #$storage->_configureCOREHANDLE(); -#print "getchildnodes\n"; -#print Dumper($self); - #if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { + } elsif ($mode eq 'root') { + + # FIXME: this will return *all* known classes to 'Class::Tangram', + # which might not be what you expect since more than one instance + # of Tangram may be in memory and Class::Tangram seems to + # offer no methods to determine this or filter its result(s) according + # to a specific database. + my @object_names = Class::Tangram::known_classes(); + my @concret_names; + my $o_cnt; + foreach (sort @object_names) { + push @concret_names, $_ if (!Class::Tangram::class_is_abstract($_)); + $o_cnt++; + } - # TODO: REVIEW - #$storage->disconnect(); + my $result = { + all => \@object_names, + concrete => \@concret_names, + }; + return $result; - $self->{meta}->{childnodes} = \@nodes; + } - return \@nodes; } - sub testIntegrity { my $self = shift;