--- nfo/perl/libs/Data/Transfer/Sync/Core.pm 2003/02/14 14:03:49 1.6 +++ nfo/perl/libs/Data/Transfer/Sync/Core.pm 2004/05/11 20:03:48 1.11 @@ -1,11 +1,29 @@ -## $Id: Core.pm,v 1.6 2003/02/14 14:03:49 joko Exp $ +## ------------------------------------------------------------------------- +## +## $Id: Core.pm,v 1.11 2004/05/11 20:03:48 jonen Exp $ ## ## Copyright (c) 2002 Andreas Motl ## ## See COPYRIGHT section in pod text below for usage and distribution rights. ## -## ---------------------------------------------------------------------------------------- +## ------------------------------------------------------------------------- ## $Log: Core.pm,v $ +## Revision 1.11 2004/05/11 20:03:48 jonen +## bugfix[joko] related to Attribute Map +## +## Revision 1.10 2003/06/25 23:03:57 joko +## no debugging +## +## Revision 1.9 2003/05/13 08:17:52 joko +## buildAttributeMap now propagates error +## +## Revision 1.8 2003/03/27 15:31:15 joko +## fixes to modules regarding new namespace(s) below Data::Mungle::* +## +## Revision 1.7 2003/02/21 08:01:11 joko +## debugging, logging +## renamed module +## ## Revision 1.6 2003/02/14 14:03:49 joko ## + logging, debugging ## - refactored code to sister module @@ -59,7 +77,7 @@ ## + minor cosmetics for logging ## ## Revision 1.2 2002/12/01 04:43:25 joko -## + mapping deatil entries may now be either an ARRAY or a HASH +## + mapping detail entries may now be either an ARRAY or a HASH ## + erase flag is used now (for export-operations) ## + expressions to refer to values inside deep nested structures ## - removed old mappingV2-code @@ -71,7 +89,7 @@ ## ## Revision 1.1 2002/10/10 03:44:21 cvsjoko ## + new -## ---------------------------------------------------------------------------------------- +## ------------------------------------------------------------------------- package Data::Transfer::Sync::Core; @@ -86,11 +104,13 @@ use Data::Dumper; -use misc::HashExt; -use Data::Compare::Struct qw( getDifference isEmpty ); +#use misc::HashExt; +use Hash::Serializer; +use Data::Mungle::Compare::Struct qw( getDifference isEmpty ); +use Data::Mungle::Transform::Deep qw( deep_copy expand ); use Data::Storage::Container; use DesignPattern::Object; -use libdb qw( quotesql ); +use shortcuts::database qw( quotesql ); # get logger instance my $logger = Log::Dispatch::Config->instance; @@ -152,7 +172,7 @@ $logger->debug( __PACKAGE__ . "->_run" ); # for statistics - my $tc = OneLineDumpHash->new( {} ); + my $tc = Hash::Serializer->new( {} ); my $results; # set of objects is already in $self->{args} @@ -175,7 +195,8 @@ return; } - + #print Dumper(@$results); + #exit; # check if we actually *have* a synchronization method if (!$self->{options}->{metadata}->{syncMethod}) { @@ -186,12 +207,15 @@ # dereference my @results = @{$results}; + #print Dumper(@results); # iterate through set foreach my $source_node_real (@results) { print ":" if $self->{verbose}; + #print Dumper($source_node_real); + $tc->{total}++; #print "======================== iter", "\n"; @@ -203,12 +227,13 @@ # - after all, just take care for now that this object doesn't get updated! # - so, just use its reference for now - if some cloning is needed in future, do this here! my $source_node = $source_node_real; + #my $source_node = expand($source_node_real); # modify entry - handle new style callbacks (the readers) # trace - #print Dumper($source_node); - #exit; + #print Dumper($source_node); + #exit; my $descent = 'source'; @@ -224,6 +249,8 @@ foreach my $node (keys %{$callbacks->{read}}) { + #print "cb_node: $node", "\n"; + my $object = $source_node; my $value; # = $source_node->{$node}; @@ -334,7 +361,6 @@ $tc->{skip}++; print "s" if $self->{verbose}; next; - } # first reaction on entry-status: continue with next entry if the current is already "in sync" @@ -343,9 +369,17 @@ next; } - # build map to actually transfer the data from source to target - $self->buildAttributeMap(); + #print Dumper($self->{node}->{source}); + # build map to actually transfer the data from source to target + if (!$self->buildAttributeMap()) { + #$logger->warning( __PACKAGE__ . "->_run: Attribute Map could not be created. Will not insert or modify node."); + push( @{$tc->{error_per_row}}, "Attribute Map could not be created. Will not insert or modify node $self->{node}->{source}->{ident}."); + #push( @{$tc->{error_per_row}}, "Attribute Map could not be created. Will not insert or modify node " . Dumper($self->{node}->{source}) . "."); + $tc->{error}++; + print "e" if $self->{verbose}; + next; + } # trace #print Dumper($self->{node}); exit; @@ -409,6 +443,9 @@ $self->_doModifySource_IdentChecksum($self->{node}->{target}->{ident}); } + #print "UNLOAD", "\n"; + #$self->{meta}->{source}->{storage}->unload( $self->{node}->{source}->{payload} ); + } print "\n" if $self->{verbose}; @@ -424,7 +461,8 @@ # todo!!! #sysevent( { usermsg => $msg, level => $level }, $taskEvent ); - $logger->info( __PACKAGE__ . "->_run: $msg" ); + #$logger->info( __PACKAGE__ . "->_run: $msg" ); + $logger->info($msg . "\n"); return $tc; @@ -585,7 +623,7 @@ $i++; } - print "\n" if $self->{verbose}; + #print "\n" if $self->{verbose}; if (!$i) { $logger->warning( __PACKAGE__ . "->_prepareNode_DummyIdent: no nodes touched" );