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

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

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