/[cvs]/nfo/perl/libs/Data/Transfer/Sync/StorageInterface.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Transfer/Sync/StorageInterface.pm

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

revision 1.5 by joko, Thu Feb 20 20:24:33 2003 UTC revision 1.8 by joko, Wed Apr 9 07:27:02 2003 UTC
# Line 6  Line 6 
6  ##  ##
7  ##    ----------------------------------------------------------------------------------------  ##    ----------------------------------------------------------------------------------------
8  ##    $Log$  ##    $Log$
9    ##    Revision 1.8  2003/04/09 07:27:02  joko
10    ##    minor update (just cosmetics)
11    ##
12    ##    Revision 1.7  2003/03/27 15:31:16  joko
13    ##    fixes to modules regarding new namespace(s) below Data::Mungle::*
14    ##
15    ##    Revision 1.6  2003/02/21 01:47:53  joko
16    ##    renamed core function
17    ##
18  ##    Revision 1.5  2003/02/20 20:24:33  joko  ##    Revision 1.5  2003/02/20 20:24:33  joko
19  ##    + additional pre-flight checks  ##    + additional pre-flight checks
20  ##  ##
# Line 42  use mixin::with qw( Data::Transfer::Sync Line 51  use mixin::with qw( Data::Transfer::Sync
51    
52  use Data::Dumper;  use Data::Dumper;
53  use Hash::Merge qw( merge );  use Hash::Merge qw( merge );
54  use libdb qw( hash2Sql );  use shortcuts::db qw( hash2sql );
55  use Data::Transform::Deep qw( hash2object );  use Data::Mungle::Transform::Deep qw( merge_to );
56    
57    
58  # get logger instance  # get logger instance
# Line 174  sub _statloadNode { Line 183  sub _statloadNode {
183        ]        ]
184      };      };
185    
     # trace  
       #print "query:", "\n";  
       #print Dumper($query);  
   
186      # send query and fetch first entry from result      # send query and fetch first entry from result
187        my $result = $self->{meta}->{$descent}->{storage}->sendQuery($query);        my $result = $self->{meta}->{$descent}->{storage}->sendQuery($query);
188        my $entry = $result->getNextEntry();        my $entry = $result->getNextEntry();
# Line 350  sub _modifyNode { Line 355  sub _modifyNode {
355        # TODO: wrap this around '$storageHandle->sendQuery(...)'!?        # TODO: wrap this around '$storageHandle->sendQuery(...)'!?
356        my $sql_main;        my $sql_main;
357        if (lc($action) eq 'insert') {        if (lc($action) eq 'insert') {
358          $sql_main = hash2Sql($self->{meta}->{$descent}->{accessorName}, $map, 'SQL_INSERT');          $sql_main = hash2sql($self->{meta}->{$descent}->{accessorName}, $map, 'SQL_INSERT');
359        } elsif (lc $action eq 'update') {        } elsif (lc $action eq 'update') {
360          $crit ||= "$self->{meta}->{$descent}->{IdentProvider}->{arg}='$self->{node}->{$descent}->{ident}'";          $crit ||= "$self->{meta}->{$descent}->{IdentProvider}->{arg}='$self->{node}->{$descent}->{ident}'";
361          $sql_main = hash2Sql($self->{meta}->{$descent}->{accessorName}, $map, 'SQL_UPDATE', $crit);          $sql_main = hash2sql($self->{meta}->{$descent}->{accessorName}, $map, 'SQL_UPDATE', $crit);
362        }        }
363        my $sqlHandle = $self->{meta}->{$descent}->{storage}->sendCommand($sql_main);        my $sqlHandle = $self->{meta}->{$descent}->{storage}->sendCommand($sql_main);
364    
# Line 471  sub _modifyNode { Line 476  sub _modifyNode {
476          # mix in (merge) values ...          # mix in (merge) values ...
477            # TODO: use Hash::Merge here? benchmark!            # TODO: use Hash::Merge here? benchmark!
478            # no! we'd need a Object::Merge here! it's *...2object*            # no! we'd need a Object::Merge here! it's *...2object*
479            hash2object($object, $map);            merge_to($object, $map);
480        
481          # trace          # trace
482            #print Dumper($object);            #print Dumper($object);
# Line 495  sub _modifyNode { Line 500  sub _modifyNode {
500    
501      } elsif (lc $action eq 'update') {      } elsif (lc $action eq 'update') {
502                
503        # get fresh object from orm first        # Get fresh object from orm first.
504          # TODO: Review, is a 'sendQuery' required in this place?
505          # By now: NO! It's more expensive and we can just expect existing objects for update operations.
506          # If it doesn't exist either, we assume the engine will fail on issuing the 'update' operation later...
507        $object = $self->{meta}->{$descent}->{storage}->load($self->{node}->{$descent}->{ident});        $object = $self->{meta}->{$descent}->{storage}->load($self->{node}->{$descent}->{ident});
508    
 #print Dumper($self->{node});  
         
509        # mix in values        # mix in values
510          #print Dumper($object);        merge_to($object, $map);
         # TODO: use Hash::Merge here???  
         hash2object($object, $map);  
         #print Dumper($object);  
         #exit;  
511    
512        # update orm        # update orm
513          $self->{meta}->{$descent}->{storage}->update($object);        $self->{meta}->{$descent}->{storage}->update($object);
514                    
515      }      }
516    
 #exit;  
       
517      my $error = 0;      my $error = 0;
518    
519      # handle new style callbacks - this is a HACK - do this without an eval!      # handle new style callbacks - this is a HACK - do this without an eval!

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

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