/[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.9 by joko, Tue Dec 3 05:29:40 2002 UTC revision 1.12 by joko, Wed Dec 4 11:34:49 2002 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.12  2002/12/04 11:34:49  joko
7    #  - $schema_tangram doesn't have to be in class?
8    #
9    #  Revision 1.11  2002/12/04 08:54:08  jonen
10    #  + untested bugfix: undef($object) after transform to hash at getObjectAsHash
11    #
12    #  Revision 1.10  2002/12/03 15:53:23  joko
13    #  + small bugfix regarding object hierarchy
14    #
15  #  Revision 1.9  2002/12/03 05:29:40  joko  #  Revision 1.9  2002/12/03 05:29:40  joko
16  #  + sub getObject  #  + sub getObject
17  #  + sub getObjectAsHash  #  + sub getObjectAsHash
# Line 68  use Data::Transform::Encode qw( var2utf8 Line 77  use Data::Transform::Encode qw( var2utf8
77  my $logger = Log::Dispatch::Config->instance;  my $logger = Log::Dispatch::Config->instance;
78    
79    
80    # this holds the complete instantiated schema from tangram
81    my $schema_tangram;
82    
83  sub getMetaInfo {  sub getMetaInfo {
84    my $self = shift;    my $self = shift;
85    $logger->debug( __PACKAGE__ . "->getMetaInfo()"  );    $logger->debug( __PACKAGE__ . "->getMetaInfo()"  );
# Line 79  sub getMetaInfo { Line 91  sub getMetaInfo {
91  sub _initSchema {  sub _initSchema {
92    my $self = shift;    my $self = shift;
93    $logger->debug( __PACKAGE__ . "->_initSchema()" );    $logger->debug( __PACKAGE__ . "->_initSchema()" );
94    #if (!$self->{schema_tangram}) {    #if (!$schema_tangram) {
95      my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } );      my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } );
96      $self->{schema_tangram} = $obj->getSchema();      $schema_tangram = $obj->getSchema();
97    #}    #}
98    if (!$self->{schema_tangram}) {    if (!$schema_tangram) {
99      $logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{schema}" );      $logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{schema}" );
100      return 0;      return 0;
101    }    }
# Line 112  sub connect { Line 124  sub connect {
124    
125      # create the main tangram storage object      # create the main tangram storage object
126      #$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn );      #$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn );
127      $self->{COREHANDLE} = Tangram::Relational->connect( $self->{schema_tangram}, $dsn );      $self->{COREHANDLE} = Tangram::Relational->connect( $schema_tangram, $dsn );
128        
129      # some attempts for configuring the wrapped underlying dbi.....      # some attempts for configuring the wrapped underlying dbi.....
130      #$self->{STORAGEHANDLE_UNDERLYING} = $self->getUnderlyingStorage();      #$self->{STORAGEHANDLE_UNDERLYING} = $self->getUnderlyingStorage();
# Line 259  sub deploySchema { Line 271  sub deploySchema {
271    my $ok;    my $ok;
272    if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) {    if ( my $dbh = DBI->connect($dsn, '', '', $self->{locator}->{dbi} ) ) {
273      return unless $self->_initSchema();      return unless $self->_initSchema();
274      $ok = Tangram::Relational->deploy($self->{schema_tangram}, $dbh );      $ok = Tangram::Relational->deploy($schema_tangram, $dbh );
275      $dbh->disconnect();      $dbh->disconnect();
276    }    }
277    return $ok;    return $ok;
# Line 280  sub retreatSchema { Line 292  sub retreatSchema {
292      #use Data::Dumper; print Dumper($self);      #use Data::Dumper; print Dumper($self);
293      $self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11");      $self->{dataStorageLayer}->removeLogDispatchHandler("Tangram11");
294            
295      $ok = Tangram::Relational->retreat($self->{schema_tangram}, $dbh );      $ok = Tangram::Relational->retreat($schema_tangram, $dbh );
296    
297      # answer "$ok=2" means "maybe" for now - we have to patch this to a constant here because...      # answer "$ok=2" means "maybe" for now - we have to patch this to a constant here because...
298      # - ... Tangram::Relational->retreat doesn't seem to return a valid status      # - ... Tangram::Relational->retreat doesn't seem to return a valid status
# Line 453  sub sendQuery { Line 465  sub sendQuery {
465  sub eraseAll {  sub eraseAll {
466    my $self = shift;    my $self = shift;
467    my $classname = shift;    my $classname = shift;
468    my $remote = $self->{storage}->remote($classname);    my $remote = $self->{COREHANDLE}->remote($classname);
469    my @objs = $self->{storage}->select($remote);    my @objs = $self->{COREHANDLE}->select($remote);
470    $self->{COREHANDLE}->erase(@objs);    $self->{COREHANDLE}->erase(@objs);
471  }  }
472    
# Line 479  sub getObjectAsHash { Line 491  sub getObjectAsHash {
491    my $obj = $self->getObject($oid);    my $obj = $self->getObject($oid);
492    my $deref = var_deref($obj);    my $deref = var_deref($obj);
493    var2utf8($deref) if ($options->{utf8});    var2utf8($deref) if ($options->{utf8});
494      undef($obj) if($options->{destroy});
495    return $deref;    return $deref;
496  }  }
497    
498    sub getSchema {
499      return $schema_tangram;
500    }
501    
502  1;  1;

Legend:
Removed from v.1.9  
changed lines
  Added in v.1.12

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