/[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.7 by joko, Sun Dec 1 04:46:19 2002 UTC revision 1.10 by joko, Tue Dec 3 15:53:23 2002 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.10  2002/12/03 15:53:23  joko
7    #  + small bugfix regarding object hierarchy
8    #
9    #  Revision 1.9  2002/12/03 05:29:40  joko
10    #  + sub getObject
11    #  + sub getObjectAsHash
12    #
13    #  Revision 1.8  2002/12/01 22:25:51  joko
14    #  + now utilizing metadata from storage locator when connecting to DBI in "raw"-mode
15    #
16  #  Revision 1.7  2002/12/01 04:46:19  joko  #  Revision 1.7  2002/12/01 04:46:19  joko
17  #  + sub eraseAll  #  + sub eraseAll
18  #  #
# Line 53  use Data::Dumper; Line 63  use Data::Dumper;
63  use libp qw( getNewPerlObjectByPkgName );  use libp qw( getNewPerlObjectByPkgName );
64  use Data::Storage::Result::Tangram;  use Data::Storage::Result::Tangram;
65  use Data::Compare::Struct qw( isEmpty );  use Data::Compare::Struct qw( isEmpty );
66    use Data::Transform::Deep qw( var_deref );
67    use Data::Transform::Encode qw( var2utf8 );
68    
69    
70  # get logger instance  # get logger instance
71  my $logger = Log::Dispatch::Config->instance;  my $logger = Log::Dispatch::Config->instance;
# Line 138  sub getChildNodes { Line 151  sub getChildNodes {
151  #print Dumper($self);  #print Dumper($self);
152    #if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) {    #if (my $result = $self->sendCommand( 'SHOW TABLES;' ) ) {
153        
154    $storage->disconnect();    # TODO: REVIEW
155      #$storage->disconnect();
156        
157    $self->{meta}->{childnodes} = \@nodes;    $self->{meta}->{childnodes} = \@nodes;
158        
# Line 242  sub deploySchema { Line 256  sub deploySchema {
256    my $args = shift;    my $args = shift;
257        
258    my $dsn = $self->{locator}->{dbi}->{dsn};    my $dsn = $self->{locator}->{dbi}->{dsn};
   #my $dsn = $self->{dbi}->{dsn};  
259    
260    $logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" );    $logger->debug( __PACKAGE__ . "->deploySchema( dsn $dsn )" );
261    
262    my $ok;    my $ok;
263    # TODO: is this DBI->connect okay here like it is? regarding errors.....???    if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) {
   if ( my $dbh = DBI->connect($dsn, '', '', {  
                                                       PrintError => 0,  
                                                     } ) ) {  
   
264      return unless $self->_initSchema();      return unless $self->_initSchema();
       
265      $ok = Tangram::Relational->deploy($self->{schema_tangram}, $dbh );      $ok = Tangram::Relational->deploy($self->{schema_tangram}, $dbh );
266      $dbh->disconnect();      $dbh->disconnect();
267    }    }
# Line 264  sub retreatSchema { Line 272  sub retreatSchema {
272    
273    my $self = shift;    my $self = shift;
274    my $dsn = $self->{locator}->{dbi}->{dsn};    my $dsn = $self->{locator}->{dbi}->{dsn};
   #my $dsn = $self->{dbi}->{dsn};  
275    
276    $logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" );    $logger->debug( __PACKAGE__ . "->retreatSchema( dsn $dsn )" );
277    
278    my $ok;    my $ok;
279    if ( my $dbh = DBI->connect($dsn, '', '', {    if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) {
                                                       #PrintError => 0,  
                                                       #RaiseError => 0,  
                                                     } ) ) {  
280    
281      return unless $self->_initSchema();      return unless $self->_initSchema();
282            
# Line 280  sub retreatSchema { Line 284  sub retreatSchema {
284      $self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11");      $self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11");
285            
286      $ok = Tangram::Relational->retreat($self->{schema_tangram}, $dbh );      $ok = Tangram::Relational->retreat($self->{schema_tangram}, $dbh );
287      $ok = 2;    # answer is "maybe" for now since Tangram::Relational->retreat doesn't seem to return a valid status  
288                      # idea: test this by checking for count of tables in database -      # answer "$ok=2" means "maybe" for now - we have to patch this to a constant here because...
289                      #          problem with this: there may be some left not having been included to the schema      # - ... Tangram::Relational->retreat doesn't seem to return a valid status
290        # - possible improvement:
291        #   - test this by checking for count of tables in database
292        #   - problem with this: there may be some left not having been included to the schema
293        #   - maybe better: use "->getChildNodes"?
294        $ok = 2;
295    
296      $dbh->disconnect();      $dbh->disconnect();
297    
298    }    }
299    return $ok;    return $ok;
300  }  }
# Line 445  sub sendQuery { Line 456  sub sendQuery {
456  sub eraseAll {  sub eraseAll {
457    my $self = shift;    my $self = shift;
458    my $classname = shift;    my $classname = shift;
459    my $remote = $self->{storage}->remote($classname);    my $remote = $self->{COREHANDLE}->remote($classname);
460    my @objs = $self->{storage}->select($remote);    my @objs = $self->{COREHANDLE}->select($remote);
461    $self->{COREHANDLE}->erase(@objs);    $self->{COREHANDLE}->erase(@objs);
462  }  }
463    
464    sub createDb {
465      my $self = shift;
466      my $storage = $self->_getSubLayerHandle();
467      return $storage->createDb();
468    }
469    
470    sub getObject {
471      my $self = shift;
472      my $oid = shift;
473      # TODO: review this
474      #if (!$self->{COREHANDLE}) { return; }
475      return $self->{COREHANDLE}->load($oid);
476    }
477    
478    sub getObjectAsHash {
479      my $self = shift;
480      my $oid = shift;
481      my $options = shift;
482      my $obj = $self->getObject($oid);
483      my $deref = var_deref($obj);
484      var2utf8($deref) if ($options->{utf8});
485      return $deref;
486    }
487    
488  1;  1;

Legend:
Removed from v.1.7  
changed lines
  Added in v.1.10

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