--- nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2002/10/25 11:44:44 1.4 +++ nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2002/11/17 06:35:18 1.5 @@ -1,8 +1,12 @@ ################################# # -# $Id: Tangram.pm,v 1.4 2002/10/25 11:44:44 joko Exp $ +# $Id: Tangram.pm,v 1.5 2002/11/17 06:35:18 joko Exp $ # # $Log: Tangram.pm,v $ +# Revision 1.5 2002/11/17 06:35:18 joko +# + locator metadata can now be reached via ->{locator} +# - getChildNodes is now wrapped via COREHANDLE +# # Revision 1.4 2002/10/25 11:44:44 joko # + sub _initSchema # + sub existsChildNode @@ -48,7 +52,7 @@ $logger->debug( __PACKAGE__ . "->getNewPerlObjectByPkgName( pkgname $pkgname args $args )" ); my $evstring = "use $pkgname;"; eval($evstring); - $@ && $logger->error( __PACKAGE__ . ':' . __LINE__ . " Error in eval: " . $@ ); + $@ && $logger->error( __PACKAGE__ . ':' . __LINE__ . " Error in eval $evstring: " . $@ ); return $pkgname->new($args); } @@ -56,7 +60,7 @@ my $self = shift; $logger->debug( __PACKAGE__ . "->_initSchema()" ); #if (!$self->{schema_tangram}) { - 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} } ); $self->{schema_tangram} = $obj->getSchema(); #} if (!$self->{schema_tangram}) { @@ -71,7 +75,7 @@ my $self = shift; my $dsn = shift; - $dsn ||= $self->{dbi}->{dsn}; + $dsn ||= $self->{locator}->{dbi}->{dsn}; $logger->debug( __PACKAGE__ . "->connect( dsn $dsn )" ); @@ -94,6 +98,8 @@ #$self->_configureUnderlyingStorage; $self->configureCOREHANDLE(); + $self->{locator}->{status}->{connected} = 1; + return 1; } @@ -109,14 +115,11 @@ #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 $storage = $self->_getSubLayerHandle(); + @nodes = @{$storage->getChildNodes()}; #$storage->_configureCOREHANDLE(); - +#print "getchildnodes\n"; +#print Dumper($self); #if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) { - if (my $result = $storage->sendCommand( 'SHOW TABLES;' ) ) { - while ( my $row = $result->_getNextEntry() ) { - push @nodes, $row; - } - } $storage->disconnect(); @@ -132,6 +135,7 @@ my $nodename = shift; $logger->debug( __PACKAGE__ . "->getChildNode( nodename $nodename )" ); $self->getChildNodes() unless $self->{meta}->{childnodes}; + #print Dumper($self->{meta}->{childnodes}); return grep $nodename, @{$self->{meta}->{childnodes}}; } @@ -154,6 +158,7 @@ return; } + $self->{locator}->{status}->{integrity} = 1; return 1; } @@ -165,15 +170,13 @@ $logger->debug( __PACKAGE__ . "->_getSubLayerHandle()" ); - use Data::Dumper; #print Dumper($self); - #exit; - + # hack, make more generic! if (!$self->{dataStorageLayer}) { $logger->debug( __PACKAGE__ . "->_getSubLayerHandle() creating new dataStorageLayer" ); #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} ); + my $loc = Data::Storage::Locator->new( { type => "DBI", dbi => $self->{locator}->{dbi} } ); $self->{dataStorageLayer} = Data::Storage->new( $loc, { protected => 1 } ); #$self->{STORAGE_UNDER_THE_HOOD}->{STORAGEHANDLE}->_configureCOREHANDLE(); #$self->{STORAGE_UNDER_THE_HOOD}->_configureCOREHANDLE(); @@ -229,12 +232,15 @@ sub deploySchema { my $self = shift; - #my $dsn = $self->{locator}->{dbi}->{dsn}; - my $dsn = $self->{dbi}->{dsn}; + my $args = shift; + + my $dsn = $self->{locator}->{dbi}->{dsn}; + #my $dsn = $self->{dbi}->{dsn}; $logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" ); my $ok; + # TODO: is this DBI->connect okay here like it is? regarding errors.....??? if ( my $dbh = DBI->connect($dsn, '', '', { PrintError => 0, } ) ) { @@ -250,8 +256,8 @@ sub retreatSchema { my $self = shift; - #my $dsn = $self->{locator}->{dbi}->{dsn}; - my $dsn = $self->{dbi}->{dsn}; + my $dsn = $self->{locator}->{dbi}->{dsn}; + #my $dsn = $self->{dbi}->{dsn}; $logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" );