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

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

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

revision 1.6 by joko, Fri Feb 14 14:03:49 2003 UTC revision 1.11 by jonen, Tue May 11 20:03:48 2004 UTC
# Line 1  Line 1 
1    ## -------------------------------------------------------------------------
2    ##
3  ##    $Id$  ##    $Id$
4  ##  ##
5  ##    Copyright (c) 2002  Andreas Motl <andreas.motl@ilo.de>  ##    Copyright (c) 2002  Andreas Motl <andreas.motl@ilo.de>
6  ##  ##
7  ##    See COPYRIGHT section in pod text below for usage and distribution rights.  ##    See COPYRIGHT section in pod text below for usage and distribution rights.
8  ##  ##
9  ##    ----------------------------------------------------------------------------------------  ## -------------------------------------------------------------------------
10  ##    $Log$  ##    $Log$
11    ##    Revision 1.11  2004/05/11 20:03:48  jonen
12    ##    bugfix[joko] related to Attribute Map
13    ##
14    ##    Revision 1.10  2003/06/25 23:03:57  joko
15    ##    no debugging
16    ##
17    ##    Revision 1.9  2003/05/13 08:17:52  joko
18    ##    buildAttributeMap now propagates error
19    ##
20    ##    Revision 1.8  2003/03/27 15:31:15  joko
21    ##    fixes to modules regarding new namespace(s) below Data::Mungle::*
22    ##
23    ##    Revision 1.7  2003/02/21 08:01:11  joko
24    ##    debugging, logging
25    ##    renamed module
26    ##
27  ##    Revision 1.6  2003/02/14 14:03:49  joko  ##    Revision 1.6  2003/02/14 14:03:49  joko
28  ##    + logging, debugging  ##    + logging, debugging
29  ##    - refactored code to sister module  ##    - refactored code to sister module
# Line 59  Line 77 
77  ##    + minor cosmetics for logging  ##    + minor cosmetics for logging
78  ##  ##
79  ##    Revision 1.2  2002/12/01 04:43:25  joko  ##    Revision 1.2  2002/12/01 04:43:25  joko
80  ##    + mapping deatil entries may now be either an ARRAY or a HASH  ##    + mapping detail entries may now be either an ARRAY or a HASH
81  ##    + erase flag is used now (for export-operations)  ##    + erase flag is used now (for export-operations)
82  ##    + expressions to refer to values inside deep nested structures  ##    + expressions to refer to values inside deep nested structures
83  ##    - removed old mappingV2-code  ##    - removed old mappingV2-code
# Line 71  Line 89 
89  ##  ##
90  ##    Revision 1.1  2002/10/10 03:44:21  cvsjoko  ##    Revision 1.1  2002/10/10 03:44:21  cvsjoko
91  ##    + new  ##    + new
92  ##    ----------------------------------------------------------------------------------------  ## -------------------------------------------------------------------------
93    
94    
95  package Data::Transfer::Sync::Core;  package Data::Transfer::Sync::Core;
# Line 86  use mixin::with qw( Data::Transfer::Sync Line 104  use mixin::with qw( Data::Transfer::Sync
104    
105  use Data::Dumper;  use Data::Dumper;
106    
107  use misc::HashExt;  #use misc::HashExt;
108  use Data::Compare::Struct qw( getDifference isEmpty );  use Hash::Serializer;
109    use Data::Mungle::Compare::Struct qw( getDifference isEmpty );
110    use Data::Mungle::Transform::Deep qw( deep_copy expand );
111  use Data::Storage::Container;  use Data::Storage::Container;
112  use DesignPattern::Object;  use DesignPattern::Object;
113  use libdb qw( quotesql );  use shortcuts::database qw( quotesql );
114    
115  # get logger instance  # get logger instance
116  my $logger = Log::Dispatch::Config->instance;  my $logger = Log::Dispatch::Config->instance;
# Line 152  sub _run { Line 172  sub _run {
172    $logger->debug( __PACKAGE__ . "->_run" );    $logger->debug( __PACKAGE__ . "->_run" );
173    
174    # for statistics    # for statistics
175    my $tc = OneLineDumpHash->new( {} );    my $tc = Hash::Serializer->new( {} );
176    my $results;    my $results;
177        
178    # set of objects is already in $self->{args}    # set of objects is already in $self->{args}
# Line 175  sub _run { Line 195  sub _run {
195      return;      return;
196    }    }
197    
198      #print Dumper(@$results);
199      #exit;
200    
201    # check if we actually *have* a synchronization method    # check if we actually *have* a synchronization method
202    if (!$self->{options}->{metadata}->{syncMethod}) {    if (!$self->{options}->{metadata}->{syncMethod}) {
# Line 186  sub _run { Line 207  sub _run {
207        
208    # dereference    # dereference
209    my @results = @{$results};    my @results = @{$results};
210      #print Dumper(@results);
211    
212    # iterate through set    # iterate through set
213    foreach my $source_node_real (@results) {    foreach my $source_node_real (@results) {
214    
215      print ":" if $self->{verbose};      print ":" if $self->{verbose};
216    
217        #print Dumper($source_node_real);
218    
219      $tc->{total}++;      $tc->{total}++;
220    
221  #print "========================  iter", "\n";  #print "========================  iter", "\n";
# Line 203  sub _run { Line 227  sub _run {
227      #   - after all, just take care for now that this object doesn't get updated!      #   - after all, just take care for now that this object doesn't get updated!
228      #   - so, just use its reference for now - if some cloning is needed in future, do this here!      #   - so, just use its reference for now - if some cloning is needed in future, do this here!
229      my $source_node = $source_node_real;      my $source_node = $source_node_real;
230        #my $source_node = expand($source_node_real);
231    
232      # modify entry - handle new style callbacks (the readers)      # modify entry - handle new style callbacks (the readers)
233    
234      # trace      # trace
235        #print Dumper($source_node);      #print Dumper($source_node);
236        #exit;      #exit;
237    
238      my $descent = 'source';      my $descent = 'source';
239    
# Line 224  sub _run { Line 249  sub _run {
249    
250        foreach my $node (keys %{$callbacks->{read}}) {        foreach my $node (keys %{$callbacks->{read}}) {
251                    
252            #print "cb_node: $node", "\n";
253            
254          my $object = $source_node;          my $object = $source_node;
255          my $value; # = $source_node->{$node};          my $value; # = $source_node->{$node};
256    
# Line 334  sub _run { Line 361  sub _run {
361        $tc->{skip}++;        $tc->{skip}++;
362        print "s" if $self->{verbose};        print "s" if $self->{verbose};
363        next;        next;
         
364      }      }
365    
366      # first reaction on entry-status: continue with next entry if the current is already "in sync"      # first reaction on entry-status: continue with next entry if the current is already "in sync"
# Line 343  sub _run { Line 369  sub _run {
369        next;        next;
370      }      }
371    
372      # build map to actually transfer the data from source to target      #print Dumper($self->{node}->{source});
     $self->buildAttributeMap();  
373    
374        # build map to actually transfer the data from source to target
375        if (!$self->buildAttributeMap()) {
376          #$logger->warning( __PACKAGE__ . "->_run: Attribute Map could not be created. Will not insert or modify node.");
377          push( @{$tc->{error_per_row}}, "Attribute Map could not be created. Will not insert or modify node $self->{node}->{source}->{ident}.");
378          #push( @{$tc->{error_per_row}}, "Attribute Map could not be created. Will not insert or modify node " . Dumper($self->{node}->{source}) . ".");
379          $tc->{error}++;
380          print "e" if $self->{verbose};
381          next;
382        }
383    
384      # trace      # trace
385        #print Dumper($self->{node}); exit;        #print Dumper($self->{node}); exit;
# Line 409  sub _run { Line 443  sub _run {
443        $self->_doModifySource_IdentChecksum($self->{node}->{target}->{ident});        $self->_doModifySource_IdentChecksum($self->{node}->{target}->{ident});
444      }      }
445    
446        #print "UNLOAD", "\n";
447        #$self->{meta}->{source}->{storage}->unload( $self->{node}->{source}->{payload} );
448    
449    }    }
450    
451    print "\n" if $self->{verbose};    print "\n" if $self->{verbose};
# Line 424  sub _run { Line 461  sub _run {
461            
462      # todo!!!      # todo!!!
463      #sysevent( { usermsg => $msg, level => $level }, $taskEvent );      #sysevent( { usermsg => $msg, level => $level }, $taskEvent );
464      $logger->info( __PACKAGE__ . "->_run: $msg" );      #$logger->info( __PACKAGE__ . "->_run: $msg" );
465        $logger->info($msg . "\n");
466    
467    return $tc;    return $tc;
468    
# Line 585  sub _prepareNode_DummyIdent { Line 623  sub _prepareNode_DummyIdent {
623      $i++;      $i++;
624    }    }
625    
626    print "\n" if $self->{verbose};    #print "\n" if $self->{verbose};
627        
628    if (!$i) {    if (!$i) {
629      $logger->warning( __PACKAGE__ . "->_prepareNode_DummyIdent: no nodes touched" );      $logger->warning( __PACKAGE__ . "->_prepareNode_DummyIdent: no nodes touched" );

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

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