--- nfo/perl/libs/Data/Transfer/Sync/Core.pm 2003/02/11 05:30:47 1.5 +++ nfo/perl/libs/Data/Transfer/Sync/Core.pm 2003/06/25 23:03:57 1.10 @@ -1,11 +1,30 @@ -## $Id: Core.pm,v 1.5 2003/02/11 05:30:47 joko Exp $ +## ------------------------------------------------------------------------- +## +## $Id: Core.pm,v 1.10 2003/06/25 23:03:57 joko Exp $ ## ## Copyright (c) 2002 Andreas Motl ## ## See COPYRIGHT section in pod text below for usage and distribution rights. ## -## ---------------------------------------------------------------------------------------- +## ------------------------------------------------------------------------- ## $Log: Core.pm,v $ +## 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 +## ## Revision 1.5 2003/02/11 05:30:47 joko ## + minor fixes and some debugging mud ## @@ -55,7 +74,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 @@ -67,7 +86,7 @@ ## ## Revision 1.1 2002/10/10 03:44:21 cvsjoko ## + new -## ---------------------------------------------------------------------------------------- +## ------------------------------------------------------------------------- package Data::Transfer::Sync::Core; @@ -82,11 +101,12 @@ 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::Storage::Container; use DesignPattern::Object; -use libdb qw( quotesql ); +use shortcuts::database qw( quotesql ); # get logger instance my $logger = Log::Dispatch::Config->instance; @@ -148,7 +168,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} @@ -165,6 +185,8 @@ # get reference to node list from convenient method provided by CORE-HANDLE $results ||= $self->_getNodeList('source'); + #print Dumper($results); + # checkpoint: do we actually have a list to iterate through? if (!$results || !@{$results}) { $logger->notice( __PACKAGE__ . "->_run: No nodes to synchronize." ); @@ -201,8 +223,10 @@ my $source_node = $source_node_real; # modify entry - handle new style callbacks (the readers) -#print Dumper($source_node); -#exit; + + # trace + #print Dumper($source_node); + #exit; my $descent = 'source'; @@ -221,7 +245,8 @@ my $object = $source_node; my $value; # = $source_node->{$node}; -#print Dumper($self->{options}); + # trace + #print Dumper($self->{options}); # ------------ half-redundant: make $self->callCallback($object, $value, $opts) #my $perl_callback = $self->{meta}->{$descent}->{node} . '::' . $node . '_read'; @@ -230,11 +255,9 @@ #print $evalstring, "\n"; exit; my $cb_result = eval($evalstring); if ($@) { - #die $@; - $logger->error( __PACKAGE__ . "->_run: $@" ); $error = 1; - #print $@, "\n"; - return; + $logger->error( __PACKAGE__ . "->_run: $@" ); + next; } # ------------ half-redundant: make $self->callCallback($object, $value, $opts) @@ -329,7 +352,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" @@ -339,8 +361,12 @@ } # build map to actually transfer the data from source to target - $self->buildAttributeMap(); - + if (!$self->buildAttributeMap()) { + #$logger->warning( __PACKAGE__ . "->_run: Attribute Map could not be created. Will not insert or modify node."); + $tc->{skip}++; + print "e" if $self->{verbose}; + next; + } # trace #print Dumper($self->{node}); exit; @@ -419,7 +445,8 @@ # todo!!! #sysevent( { usermsg => $msg, level => $level }, $taskEvent ); - $logger->info( __PACKAGE__ . "->_run: $msg" ); + #$logger->info( __PACKAGE__ . "->_run: $msg" ); + $logger->info($msg . "\n"); return $tc; @@ -580,7 +607,7 @@ $i++; } - print "\n" if $self->{verbose}; + #print "\n" if $self->{verbose}; if (!$i) { $logger->warning( __PACKAGE__ . "->_prepareNode_DummyIdent: no nodes touched" ); @@ -597,12 +624,6 @@ return ''; } -sub _erase_all { - my $self = shift; - my $descent = shift; - #my $node = shift; - my $node = $self->{meta}->{$descent}->{node}; - $self->{meta}->{$descent}->{storage}->eraseAll($node); -} 1; +__END__