/[cvs]/nfo/perl/libs/Data/Storage/Handler/Tangram.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage/Handler/Tangram.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.4 by joko, Fri Oct 25 11:44:44 2002 UTC revision 1.5 by joko, Sun Nov 17 06:35:18 2002 UTC
# Line 3  Line 3 
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
# Line 48  sub getNewPerlObjectByPkgName { Line 52  sub getNewPerlObjectByPkgName {
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    
# Line 56  sub _initSchema { Line 60  sub _initSchema {
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}) {
# Line 71  sub connect { Line 75  sub connect {
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            
# Line 94  sub connect { Line 98  sub connect {
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  }  }
# Line 109  sub getChildNodes { Line 115  sub getChildNodes {
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        
# Line 132  sub existsChildNode { Line 135  sub existsChildNode {
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    
# Line 154  sub testIntegrity { Line 158  sub testIntegrity {
158      return;      return;
159    }    }
160    
161      $self->{locator}->{status}->{integrity} = 1;
162    return 1;    return 1;
163    
164  }  }
# Line 165  sub _getSubLayerHandle { Line 170  sub _getSubLayerHandle {
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();
# Line 229  sub configureCOREHANDLE { Line 232  sub 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                                                      } ) ) {                                                      } ) ) {
# Line 250  sub deploySchema { Line 256  sub deploySchema {
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    

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.5

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed