/[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.21 by jonen, Mon Dec 16 22:20:49 2002 UTC revision 1.27 by joko, Fri Jan 31 06:30:59 2003 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.27  2003/01/31 06:30:59  joko
7    #  + enabled 'sendQuery'
8    #
9    #  Revision 1.26  2003/01/30 22:29:47  joko
10    #  + fixed module usage (removed dependency on 'libp.pm')
11    #
12    #  Revision 1.25  2003/01/19 02:30:05  joko
13    #  + fix: modified call to '_initSchema'
14    #
15    #  Revision 1.24  2002/12/22 14:13:01  joko
16    #  + sub dropDb
17    #
18    #  Revision 1.23  2002/12/19 16:31:53  joko
19    #  +- renamed sub to 'rebuildDb'
20    #
21    #  Revision 1.22  2002/12/18 22:28:16  jonen
22    #  + added extended logging at 'getObjectByGuid()'
23    #
24  #  Revision 1.21  2002/12/16 22:20:49  jonen  #  Revision 1.21  2002/12/16 22:20:49  jonen
25  #  + fixed bug at 'getObjectByGuid()'  #  + fixed bug at 'getObjectByGuid()'
26  #  #
# Line 98  use base ("Data::Storage::Handler::Abstr Line 116  use base ("Data::Storage::Handler::Abstr
116    
117  use Tangram;  use Tangram;
118  use Data::Dumper;  use Data::Dumper;
119  use libp qw( getNewPerlObjectByPkgName );  use DesignPattern::Object;
120  use Data::Storage::Result::Tangram;  use Data::Storage::Result::Tangram;
121  use Data::Compare::Struct qw( isEmpty );  use Data::Compare::Struct qw( isEmpty );
122  use Data::Transform::Deep qw( object2hash );  use Data::Transform::Deep qw( object2hash );
123  use Data::Transform::Encode qw( var2utf8 );  use Data::Transform::Encode qw( var2utf8 );
124    
   
125  # get logger instance  # get logger instance
126  my $logger = Log::Dispatch::Config->instance;  my $logger = Log::Dispatch::Config->instance;
127    
# Line 124  sub _initSchema { Line 141  sub _initSchema {
141    my $self = shift;    my $self = shift;
142    $logger->debug( __PACKAGE__ . "->_initSchema()" );    $logger->debug( __PACKAGE__ . "->_initSchema()" );
143    #if (!$schema_tangram) {    #if (!$schema_tangram) {
144      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} } );
145        my $obj = DesignPattern::Object->fromPackage($self->{locator}->{schema}, { 'EXPORT_OBJECTS' => $self->{locator}->{classnames}, 'want_transactions' => $self->{locator}->{want_transactions} } );
146      $schema_tangram = $obj->getSchema();      $schema_tangram = $obj->getSchema();
147    #}    #}
148    if (!$schema_tangram) {    if (!$schema_tangram) {
# Line 157  sub connect { Line 175  sub connect {
175      my $self = shift;      my $self = shift;
176            
177      my $dsn = shift;      my $dsn = shift;
178    
179    #print Dumper($self);
180    #exit;
181    
182        # TODO: re-enable
183      $dsn ||= $self->{locator}->{dbi}->{dsn};      $dsn ||= $self->{locator}->{dbi}->{dsn};
       
184      $logger->debug( __PACKAGE__ . "->connect( dsn $dsn )" );      $logger->debug( __PACKAGE__ . "->connect( dsn $dsn )" );
185            
186      #my $storage = Tangram::Relational->connect( $schema, $dsn );      #my $storage = Tangram::Relational->connect( $schema, $dsn );
# Line 170  sub connect { Line 192  sub connect {
192  #      return;  #      return;
193  #    }  #    }
194    
195      return unless $self->_initSchema();      #return unless $self->_initSchema();
196        $self->_initSchema();
197    
198      # create the main tangram storage object      # create the main tangram storage object
199      #$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn );      #$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn );
# Line 297  sub configureCOREHANDLE { Line 320  sub configureCOREHANDLE {
320    $logger->debug( __PACKAGE__ . "->configureCOREHANDLE" );    $logger->debug( __PACKAGE__ . "->configureCOREHANDLE" );
321    
322    #my $subLayer = $self->_getSubLayerHandle();    #my $subLayer = $self->_getSubLayerHandle();
323      #print Dumper($self);
324      #exit;
325    
326    # apply configured modifications    # apply configured modifications
327      if (exists $self->{dbi}->{trace_level} && exists $self->{dbi}->{trace_file}) {      if (exists $self->{dbi}->{trace_level} && exists $self->{dbi}->{trace_file}) {
# Line 362  sub retreatSchema { Line 387  sub retreatSchema {
387    return $ok;    return $ok;
388  }  }
389    
390  sub rebuildDbAndSchema {  sub rebuildDb {
391    my $self = shift;    my $self = shift;
392    $logger->info( __PACKAGE__ . "->rebuildDbAndSchema()" );    $logger->info( __PACKAGE__ . "->rebuildDb()" );
393    my @results;    my @results;
394    
395    # sum up results (bool (0/1)) in array    # sum up results (bool (0/1)) in array
# Line 404  sub getListFiltered { Line 429  sub getListFiltered {
429    my @results;    my @results;
430    $logger->debug( __PACKAGE__ . "->getListFiltered( nodename => '" . $nodename . "' )" );    $logger->debug( __PACKAGE__ . "->getListFiltered( nodename => '" . $nodename . "' )" );
431    
432    #print Dumper($filters);  #print Dumper($filters);
433        
434    my @tfilters;    my @tfilters;
435        
# Line 443  sub getListFiltered { Line 468  sub getListFiltered {
468    # HACK: build eval-string (sorry) to get filtered list - please give advice here    # HACK: build eval-string (sorry) to get filtered list - please give advice here
469    my $evalstring = 'return $self->{_COREHANDLE}->select($remote, ' . $tfilter . ');';    my $evalstring = 'return $self->{_COREHANDLE}->select($remote, ' . $tfilter . ');';
470        
471      #print "eval: $evalstring", "\n";
472      
473    # get filtered list/set    # get filtered list/set
474    @results = eval($evalstring);    @results = eval($evalstring);
475    die $@ if $@;    die $@ if $@;
# Line 502  sub sendQuery { Line 529  sub sendQuery {
529      #return $self->createSet( $self->{COREHANDLE}->load('300090018') );      #return $self->createSet( $self->{COREHANDLE}->load('300090018') );
530    }    }
531    
532    die("This should not be reached for now - redirect to \$self->getListFiltered() here!");    my $list = $self->getListFiltered($query->{node}, $query->{criterias});
533      #return $self->createSet($object);
534      #return $self->createSet($list);
535      return $self->createSet(@$list);
536    
537      #die("This should not be reached for now - redirect to \$self->getListFiltered() here!");
538    
539    
540    
   # TODO: do a common tangram query here  
541    
542      # try a generic tangram query here
543      # TODO: try to place an oql on top of that (search.cpan.org!)
544    my @crits;    my @crits;
545    foreach (@{$query->{criterias}}) {    foreach (@{$query->{criterias}}) {
546      my $op = '';      my $op = '';
# Line 563  sub getObjectByGuid { Line 598  sub getObjectByGuid {
598        
599    # Guid and Classname is needed    # Guid and Classname is needed
600    if(!$guid || !$options->{classname}) {    if(!$guid || !$options->{classname}) {
601       $logger->error( __PACKAGE__ . "->getObjectByGuid: No 'guid' OR no Classname in options hash was given but needed!" );
602      return;      return;
603    }    }
604        
# Line 575  sub getObjectByGuid { Line 611  sub getObjectByGuid {
611    my @result = $self->{_COREHANDLE}->select($obj_tmp, $obj_tmp->{guid} eq $guid);    my @result = $self->{_COREHANDLE}->select($obj_tmp, $obj_tmp->{guid} eq $guid);
612        
613    # we searched for global unique identifer of some object,    # we searched for global unique identifer of some object,
614    # so it think we can trust there would be only one result    # so I think we can trust there would be only one result
615    if($result[0]) {    if($result[0]) {
616      return $result[0];      return $result[0];
617    } else {    } else {
618      return "No Object with Classname $options->{classname} and GUID $options->{guid} found!";      $logger->error( __PACKAGE__ . "->getObjectByGuid: No Object with Classname $options->{classname} and GUID $guid found!" );
619        return;
620    }    }
621        
622  }  }
# Line 637  sub getCOREHANDLE { Line 674  sub getCOREHANDLE {
674    return $self->{_COREHANDLE};    return $self->{_COREHANDLE};
675  }  }
676    
677    sub dropDb {
678      my $self = shift;
679      my $storage = $self->_getSubLayerHandle();
680      return $storage->dropDb();
681    }
682    
683    sub testAvailability {
684      my $self = shift;
685      my $storage = $self->_getSubLayerHandle();
686      return $storage->testAvailability();
687    }
688    
689  1;  1;
690    __END__

Legend:
Removed from v.1.21  
changed lines
  Added in v.1.27

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