6 |
## |
## |
7 |
## ---------------------------------------------------------------------------------------- |
## ---------------------------------------------------------------------------------------- |
8 |
## $Log$ |
## $Log$ |
9 |
|
## Revision 1.9 2002/12/16 07:02:34 jonen |
10 |
|
## + added comment |
11 |
|
## |
12 |
|
## Revision 1.8 2002/12/15 02:03:09 joko |
13 |
|
## + fixed logging-messages |
14 |
|
## + additional metadata-checks |
15 |
|
## |
16 |
|
## Revision 1.7 2002/12/13 21:49:34 joko |
17 |
|
## + sub configure |
18 |
|
## + sub checkOptions |
19 |
|
## |
20 |
|
## Revision 1.6 2002/12/06 04:49:10 jonen |
21 |
|
## + disabled output-puffer here |
22 |
|
## |
23 |
|
## Revision 1.5 2002/12/05 08:06:05 joko |
24 |
|
## + bugfix with determining empty fields (Null) with DBD::CSV |
25 |
|
## + debugging |
26 |
|
## + updated comments |
27 |
|
## |
28 |
|
## Revision 1.4 2002/12/03 15:54:07 joko |
29 |
|
## + {import}-flag is now {prepare}-flag |
30 |
|
## |
31 |
|
## Revision 1.3 2002/12/01 22:26:59 joko |
32 |
|
## + minor cosmetics for logging |
33 |
|
## |
34 |
## Revision 1.2 2002/12/01 04:43:25 joko |
## Revision 1.2 2002/12/01 04:43:25 joko |
35 |
## + mapping deatil entries may now be either an ARRAY or a HASH |
## + mapping deatil entries may now be either an ARRAY or a HASH |
36 |
## + erase flag is used now (for export-operations) |
## + erase flag is used now (for export-operations) |
53 |
use warnings; |
use warnings; |
54 |
|
|
55 |
use Data::Dumper; |
use Data::Dumper; |
56 |
|
#use Hash::Merge qw( merge ); |
57 |
|
|
58 |
use misc::HashExt; |
use misc::HashExt; |
59 |
use libp qw( md5_base64 ); |
use libp qw( md5_base64 ); |
60 |
use libdb qw( quotesql hash2Sql ); |
use libdb qw( quotesql hash2Sql ); |
64 |
# get logger instance |
# get logger instance |
65 |
my $logger = Log::Dispatch::Config->instance; |
my $logger = Log::Dispatch::Config->instance; |
66 |
|
|
67 |
|
$| = 1; |
68 |
|
|
69 |
sub new { |
sub new { |
70 |
my $invocant = shift; |
my $invocant = shift; |
71 |
my $class = ref($invocant) || $invocant; |
my $class = ref($invocant) || $invocant; |
72 |
my $self = { @_ }; |
my $self = {}; |
73 |
$logger->debug( __PACKAGE__ . "->new(@_)" ); |
$logger->debug( __PACKAGE__ . "->new(@_)" ); |
74 |
bless $self, $class; |
bless $self, $class; |
75 |
$self->_init(); |
$self->configure(@_); |
76 |
return $self; |
return $self; |
77 |
} |
} |
78 |
|
|
79 |
|
|
80 |
|
sub configure { |
81 |
|
my $self = shift; |
82 |
|
my @args = @_; |
83 |
|
if (!isEmpty(\@args)) { |
84 |
|
my %properties = @_; |
85 |
|
# merge args to properties |
86 |
|
map { $self->{$_} = $properties{$_}; } keys %properties; |
87 |
|
$self->_init(); |
88 |
|
} else { |
89 |
|
#print "no args!", "\n"; |
90 |
|
} |
91 |
|
#print Dumper($self); |
92 |
|
} |
93 |
|
|
94 |
sub _init { |
sub _init { |
95 |
my $self = shift; |
my $self = shift; |
96 |
|
|
97 |
|
$self->{configured} = 1; |
98 |
|
|
99 |
# build new container if necessary |
# build new container if necessary |
100 |
$self->{container} = Data::Storage::Container->new() if !$self->{container}; |
$self->{container} = Data::Storage::Container->new() if !$self->{container}; |
113 |
} |
} |
114 |
|
|
115 |
|
|
116 |
|
sub prepareOptions { |
117 |
|
|
118 |
|
my $self = shift; |
119 |
|
my $opts = shift; |
120 |
|
|
121 |
|
#print Dumper($opts); |
122 |
|
|
123 |
|
$opts->{mode} ||= ''; |
124 |
|
$opts->{erase} ||= 0; |
125 |
|
#$opts->{import} ||= 0; |
126 |
|
|
127 |
|
$logger->info( __PACKAGE__ . "->prepareOptions( source_node $opts->{source_node} mode $opts->{mode} erase $opts->{erase} prepare $opts->{prepare} )"); |
128 |
|
|
129 |
|
if (!$opts->{mapping} || !$opts->{mapping_module}) { |
130 |
|
$logger->warning( __PACKAGE__ . "->prepareOptions: No mapping supplied - please check key 'mappings' in BizWorks/Config.pm"); |
131 |
|
} |
132 |
|
|
133 |
|
my $evstring = "use $opts->{mapping_module};"; |
134 |
|
eval($evstring); |
135 |
|
if ($@) { |
136 |
|
$logger->warning( __PACKAGE__ . "->prepareOptions: error while trying to access mapping - $@"); |
137 |
|
return; |
138 |
|
} |
139 |
|
|
140 |
|
# resolve mapping metadata (returned from sub) |
141 |
|
my $mapObject = $opts->{mapping_module}->new(); |
142 |
|
#print Dumper($map); |
143 |
|
my $source_node_name = $opts->{source_node}; |
144 |
|
# check if mapping for certain node is contained in mapping object |
145 |
|
if (!$mapObject->can($source_node_name)) { |
146 |
|
$logger->warning( __PACKAGE__ . "->prepareOptions: Can't access mapping for node \"$source_node_name\" - please check $opts->{mapping_module}."); |
147 |
|
return; |
148 |
|
} |
149 |
|
my $map = $mapObject->$source_node_name; |
150 |
|
|
151 |
|
# remove asymmetries from $map (patch keys) |
152 |
|
$map->{source_node} = $map->{source}; delete $map->{source}; |
153 |
|
$map->{target_node} = $map->{target}; delete $map->{target}; |
154 |
|
$map->{mapping} = $map->{details}; delete $map->{details}; |
155 |
|
$map->{direction} = $map->{mode}; delete $map->{mode}; |
156 |
|
|
157 |
|
# defaults (mostly for backward-compatibility) |
158 |
|
$map->{source_node} ||= $source_node_name; |
159 |
|
$map->{source_ident} ||= 'storage_method:id'; |
160 |
|
$map->{target_ident} ||= 'property:oid'; |
161 |
|
$map->{direction} ||= $opts->{mode}; # | PUSH | PULL | FULL |
162 |
|
$map->{method} ||= 'checksum'; # | timestamp |
163 |
|
$map->{source_exclude} ||= [qw( cs )]; |
164 |
|
|
165 |
|
# merge map to opts |
166 |
|
map { $opts->{$_} = $map->{$_}; } keys %$map; |
167 |
|
|
168 |
|
#print Dumper($opts); |
169 |
|
|
170 |
|
# TODO: move this to checkOptions... |
171 |
|
|
172 |
|
# check - do we have a target? |
173 |
|
if (!$opts->{target_node}) { |
174 |
|
$logger->warning( __PACKAGE__ . "->prepareOptions: No target given - please check metadata declaration."); |
175 |
|
return; |
176 |
|
} |
177 |
|
|
178 |
|
|
179 |
|
#return $opts; |
180 |
|
return 1; |
181 |
|
|
182 |
|
} |
183 |
|
|
184 |
|
|
185 |
|
sub checkOptions { |
186 |
|
my $self = shift; |
187 |
|
my $opts = shift; |
188 |
|
|
189 |
|
my $result = 1; |
190 |
|
|
191 |
|
# check - do we have a target node? |
192 |
|
if (!$opts->{target_node}) { |
193 |
|
$logger->warning( __PACKAGE__ . "->checkOptions: Error while resolving resource metadata - no 'target node' could be determined."); |
194 |
|
$result = 0; |
195 |
|
} |
196 |
|
|
197 |
|
# check - do we have a mapping? |
198 |
|
if (!$opts->{mapping} && !$opts->{mapping_module}) { |
199 |
|
$logger->warning( __PACKAGE__ . "->checkOptions: Error while resolving resource metadata - no 'mapping' could be determined."); |
200 |
|
$result = 0; |
201 |
|
} |
202 |
|
|
203 |
|
return $result; |
204 |
|
|
205 |
|
} |
206 |
|
|
207 |
|
|
208 |
# TODO: some feature to show off the progress of synchronization (cur/max * 100) |
# TODO: some feature to show off the progress of synchronization (cur/max * 100) |
209 |
sub syncNodes { |
sub syncNodes { |
210 |
|
|
211 |
my $self = shift; |
my $self = shift; |
212 |
my $args = shift; |
my $args = shift; |
213 |
|
|
214 |
|
if (!$self->{configured}) { |
215 |
|
$logger->critical( __PACKAGE__ . "->syncNodes: Synchronization object is not configured/initialized correctly." ); |
216 |
|
return; |
217 |
|
} |
218 |
|
|
219 |
# remember arguments through the whole processing |
# remember arguments through the whole processing |
220 |
$self->{args} = $args; |
$self->{args} = $args; |
221 |
|
|
238 |
} |
} |
239 |
|
|
240 |
# decompose identifiers for each partner |
# decompose identifiers for each partner |
241 |
# TODO: take this list from already established/given metadata |
# TODO: refactor!!! take this list from already established/given metadata |
242 |
foreach ('source', 'target') { |
foreach ('source', 'target') { |
243 |
|
|
244 |
# get/set metadata for further processing |
# get/set metadata for further processing |
293 |
#print "iiiiisprov: ", Dumper($self->{meta}->{$_}->{storage}), "\n"; |
#print "iiiiisprov: ", Dumper($self->{meta}->{$_}->{storage}), "\n"; |
294 |
} |
} |
295 |
|
|
296 |
|
#print Dumper($self->{meta}); |
297 |
|
|
298 |
$logger->info( __PACKAGE__ . "->syncNodes: source=$self->{meta}->{source}->{dbkey}/$self->{meta}->{source}->{node} $direction_arrow target=$self->{meta}->{target}->{dbkey}/$self->{meta}->{target}->{node}" ); |
$logger->info( __PACKAGE__ . "->syncNodes: source=$self->{meta}->{source}->{dbkey}/$self->{meta}->{source}->{node} $direction_arrow target=$self->{meta}->{target}->{dbkey}/$self->{meta}->{target}->{node}" ); |
299 |
|
|
300 |
# build mapping |
# build mapping |
322 |
|
|
323 |
} |
} |
324 |
|
|
325 |
|
#print Dumper($self->{meta}); |
326 |
|
|
327 |
# check partners/nodes: does partner exist / is node available? |
# check partners/nodes: does partner exist / is node available? |
328 |
foreach my $partner (keys %{$self->{meta}}) { |
foreach my $partner (keys %{$self->{meta}}) { |
329 |
next if $self->{meta}->{$partner}->{storage}->{locator}->{type} eq 'DBI'; # for DBD::CSV - re-enable for others |
|
330 |
|
# 1. check partners & storages |
331 |
|
if (!$self->{meta}->{$partner}) { |
332 |
|
$logger->critical( __PACKAGE__ . "->syncNodes: Could not find partner '$partner' in configuration metadata." ); |
333 |
|
return; |
334 |
|
} |
335 |
|
|
336 |
|
my $dbkey = $self->{meta}->{$partner}->{dbkey}; |
337 |
|
|
338 |
|
if (!$self->{meta}->{$partner}->{storage}) { |
339 |
|
$logger->critical( __PACKAGE__ . "->syncNodes: Could not access storage of partner '$partner' (named '$dbkey'), looks like a configuration-error." ); |
340 |
|
return; |
341 |
|
} |
342 |
|
|
343 |
|
# TODO: |
344 |
|
# 2. check if partners (and nodes?) are actually available.... |
345 |
|
# eventually pre-check mode of access-attempt (read/write) here to provide an "early-croak" if possible |
346 |
|
|
347 |
|
# 3. check nodes |
348 |
|
next if $self->{meta}->{$partner}->{storage}->{locator}->{type} eq 'DBI'; # HACK for DBD::CSV - re-enable for others |
349 |
|
# get node-name |
350 |
my $node = $self->{meta}->{$partner}->{node}; |
my $node = $self->{meta}->{$partner}->{node}; |
351 |
if (!$self->{meta}->{$partner}->{storage}->existsChildNode($node)) { |
if (!$self->{meta}->{$partner}->{storage}->existsChildNode($node)) { |
352 |
$logger->critical( __PACKAGE__ . "->syncNodes: Could not reach \"$node\" at \"$partner\"." ); |
$logger->critical( __PACKAGE__ . "->syncNodes: Could not reach node \"$node\" at partner \"$partner\"." ); |
353 |
return; |
return; |
354 |
} |
} |
355 |
|
|
356 |
} |
} |
357 |
|
|
358 |
# TODO: |
# TODO: |
376 |
|
|
377 |
# import flag means: prepare the source node to be syncable |
# import flag means: prepare the source node to be syncable |
378 |
# this is useful if there are e.g. no "ident" or "checksum" columns yet inside a DBI like (row-based) storage |
# this is useful if there are e.g. no "ident" or "checksum" columns yet inside a DBI like (row-based) storage |
379 |
if ($self->{args}->{import}) { |
if ($self->{args}->{prepare}) { |
380 |
$self->_prepareNode_MetaProperties('source'); |
$self->_prepareNode_MetaProperties('source'); |
381 |
$self->_prepareNode_DummyIdent('source'); |
$self->_prepareNode_DummyIdent('source'); |
382 |
#return; |
#return; |
415 |
$results ||= $self->_getNodeList('source', $filter); |
$results ||= $self->_getNodeList('source', $filter); |
416 |
} |
} |
417 |
|
|
418 |
# get reference to node list from convenient method provided by corehandle |
# get reference to node list from convenient method provided by CORE-HANDLE |
419 |
#$results ||= $self->{source}->getListUnfiltered($self->{meta}->{source}->{node}); |
#$results ||= $self->{source}->getListUnfiltered($self->{meta}->{source}->{node}); |
420 |
#$results ||= $self->{meta}->{source}->{storage}->getListUnfiltered($self->{meta}->{source}->{node}); |
#$results ||= $self->{meta}->{source}->{storage}->getListUnfiltered($self->{meta}->{source}->{node}); |
421 |
$results ||= $self->_getNodeList('source'); |
$results ||= $self->_getNodeList('source'); |
493 |
my $identOK = $self->_resolveNodeIdent('source'); |
my $identOK = $self->_resolveNodeIdent('source'); |
494 |
#if (!$identOK && lc $self->{args}->{direction} ne 'import') { |
#if (!$identOK && lc $self->{args}->{direction} ne 'import') { |
495 |
if (!$identOK) { |
if (!$identOK) { |
496 |
$logger->critical( __PACKAGE__ . "->syncNodes: Can not synchronize: No ident found in source node, maybe try to \"import\" this node first." ); |
#print Dumper($self->{meta}->{source}); |
497 |
|
$logger->critical( __PACKAGE__ . "->syncNodes: No ident found in source node \"$self->{meta}->{source}->{node}\", try to \"prepare\" this node first?" ); |
498 |
return; |
return; |
499 |
} |
} |
500 |
|
|
501 |
#print "statload", "\n"; |
#print "statload", "\n"; |
502 |
#print "ident: ", $self->{node}->{source}->{ident}, "\n"; |
#print "ident: ", $self->{node}->{source}->{ident}, "\n"; |
503 |
|
#print Dumper($self->{node}); |
504 |
|
|
505 |
my $statOK = $self->_statloadNode('target', $self->{node}->{source}->{ident}); |
my $statOK = $self->_statloadNode('target', $self->{node}->{source}->{ident}); |
506 |
|
|
507 |
|
#print Dumper($self->{node}); |
508 |
|
|
509 |
# mark node as new either if there's no ident or if stat/load failed |
# mark node as new either if there's no ident or if stat/load failed |
510 |
if (!$statOK) { |
if (!$statOK) { |
591 |
$tc->{attempt_new}++; |
$tc->{attempt_new}++; |
592 |
$self->_doTransferToTarget('insert'); |
$self->_doTransferToTarget('insert'); |
593 |
# asymmetry: refetch node from target to re-calculate new ident and checksum (TODO: is IdentAuthority of relevance here?) |
# asymmetry: refetch node from target to re-calculate new ident and checksum (TODO: is IdentAuthority of relevance here?) |
594 |
|
#print Dumper($self->{node}); |
595 |
$self->_statloadNode('target', $self->{node}->{target}->{ident}, 1); |
$self->_statloadNode('target', $self->{node}->{target}->{ident}, 1); |
596 |
$self->_readChecksum('target'); |
$self->_readChecksum('target'); |
597 |
|
|
617 |
# change ident in source (take from target), if transfer was ok and target is an IdentAuthority |
# change ident in source (take from target), if transfer was ok and target is an IdentAuthority |
618 |
# this is (for now) called a "retransmit" indicated by a "r"-character when verbosing |
# this is (for now) called a "retransmit" indicated by a "r"-character when verbosing |
619 |
if ($self->{node}->{status}->{ok} && $self->{meta}->{target}->{storage}->{isIdentAuthority}) { |
if ($self->{node}->{status}->{ok} && $self->{meta}->{target}->{storage}->{isIdentAuthority}) { |
620 |
|
print "r" if $self->{verbose}; |
621 |
#print Dumper($self->{meta}); |
#print Dumper($self->{meta}); |
622 |
#print Dumper($self->{node}); |
#print Dumper($self->{node}); |
623 |
#exit; |
#exit; |
624 |
$self->_doModifySource_IdentChecksum($self->{node}->{target}->{ident}); |
$self->_doModifySource_IdentChecksum($self->{node}->{target}->{ident}); |
|
print "r" if $self->{verbose}; |
|
625 |
} |
} |
626 |
|
|
627 |
print ":" if $self->{verbose}; |
print ":" if $self->{verbose}; |
631 |
print "\n" if $self->{verbose}; |
print "\n" if $self->{verbose}; |
632 |
|
|
633 |
# build user-message from some stats |
# build user-message from some stats |
634 |
my $msg = "stats: $tc"; |
my $msg = "statistics: $tc"; |
635 |
|
|
636 |
if ($tc->{error_per_row}) { |
if ($tc->{error_per_row}) { |
637 |
$msg .= "\n"; |
$msg .= "\n"; |
648 |
} |
} |
649 |
|
|
650 |
|
|
651 |
|
# refactor this as some core-function to do a generic dump resolving data-encapsulations of e.g. Set::Object |
652 |
sub _dumpCompact { |
sub _dumpCompact { |
653 |
my $self = shift; |
my $self = shift; |
654 |
|
|
660 |
my $item = {}; |
my $item = {}; |
661 |
foreach my $key (keys %$_) { |
foreach my $key (keys %$_) { |
662 |
my $val = $_->{$key}; |
my $val = $_->{$key}; |
663 |
|
|
664 |
|
#print Dumper($val); |
665 |
|
|
666 |
if (ref $val eq 'Set::Object') { |
if (ref $val eq 'Set::Object') { |
667 |
#print "========================= SET", "\n"; |
#print "========================= SET", "\n"; |
668 |
#print Dumper($val); |
#print Dumper($val); |
669 |
#print Dumper($val->members()); |
#print Dumper($val->members()); |
670 |
#$val = $val->members(); |
#$val = $val->members(); |
671 |
#$vars->[$count]->{$key} = $val->members() if $val->can("members"); |
#$vars->[$count]->{$key} = $val->members() if $val->can("members"); |
672 |
#$item->{$key} = $val->members() if $val->can("members"); |
#$item->{$key} = $val->members() if $val->can("members"); |
673 |
$item->{$key} = $val->members(); |
$item->{$key} = $val->members(); |
674 |
#print Dumper($vars->[$count]->{$key}); |
#print Dumper($vars->[$count]->{$key}); |
675 |
|
|
676 |
} else { |
} else { |
677 |
$item->{$key} = $val; |
$item->{$key} = $val; |
678 |
} |
} |
679 |
|
|
680 |
} |
} |
681 |
push @data, $item; |
push @data, $item; |
682 |
$count++; |
$count++; |
683 |
} |
} |
684 |
|
|
685 |
#print "Dump:", "\n"; |
#print "Dump:", Dumper(@data), "\n"; |
|
#print Dumper(@data); |
|
686 |
|
|
687 |
$Data::Dumper::Indent = 0; |
$Data::Dumper::Indent = 0; |
688 |
my $result = Dumper(@data); |
my $result = Dumper(@data); |
689 |
$Data::Dumper::Indent = 2; |
$Data::Dumper::Indent = 2; |
690 |
return $result; |
return $result; |
691 |
|
|
692 |
} |
} |
693 |
|
|
694 |
|
|
918 |
} |
} |
919 |
} |
} |
920 |
|
|
921 |
|
|
922 |
|
#print Dumper($self->{meta}); |
923 |
|
|
924 |
# DBI speaks SQL |
# DBI speaks SQL |
925 |
if ($self->{meta}->{$descent}->{storage}->{locator}->{type} eq 'DBI') { |
if ($self->{meta}->{$descent}->{storage}->{locator}->{type} eq 'DBI') { |
933 |
#print $action, "\n"; |
#print $action, "\n"; |
934 |
#$action = "anc"; |
#$action = "anc"; |
935 |
#print "yai", "\n"; |
#print "yai", "\n"; |
936 |
|
|
937 |
|
#print Dumper($map); |
938 |
|
#delete $map->{cs}; |
939 |
|
|
940 |
if (lc($action) eq 'insert') { |
if (lc($action) eq 'insert') { |
941 |
$sql_main = hash2Sql($self->{meta}->{$descent}->{node}, $map, 'SQL_INSERT'); |
$sql_main = hash2Sql($self->{meta}->{$descent}->{node}, $map, 'SQL_INSERT'); |
942 |
} elsif (lc $action eq 'update') { |
} elsif (lc $action eq 'update') { |
944 |
$sql_main = hash2Sql($self->{meta}->{$descent}->{node}, $map, 'SQL_UPDATE', $crit); |
$sql_main = hash2Sql($self->{meta}->{$descent}->{node}, $map, 'SQL_UPDATE', $crit); |
945 |
} |
} |
946 |
|
|
947 |
#print "sql: ", $sql_main, "\n"; |
#$sql_main = "UPDATE currencies_csv SET oid='abcdef' WHERE text='Australian Dollar' AND key='AUD';"; |
948 |
#exit; |
#$sql_main = "UPDATE currencies_csv SET oid='huhu2' WHERE ekey='AUD'"; |
949 |
|
|
950 |
|
#print "sql: ", $sql_main, "\n"; |
951 |
|
#exit; |
952 |
|
|
953 |
# transfer data |
# transfer data |
954 |
my $sqlHandle = $self->{meta}->{$descent}->{storage}->sendCommand($sql_main); |
my $sqlHandle = $self->{meta}->{$descent}->{storage}->sendCommand($sql_main); |
955 |
|
|
956 |
|
#exit; |
957 |
|
|
958 |
# handle errors |
# handle errors |
959 |
if ($sqlHandle->err) { |
if ($sqlHandle->err) { |
960 |
#if ($self->{args}->{debug}) { print "sql-error with statement: $sql_main", "\n"; } |
#if ($self->{args}->{debug}) { print "sql-error with statement: $sql_main", "\n"; } |
1030 |
hash2object($object, $map); |
hash2object($object, $map); |
1031 |
|
|
1032 |
# ... and re-update@orm. |
# ... and re-update@orm. |
1033 |
|
#print Dumper($object); |
1034 |
$self->{meta}->{$descent}->{storage}->update($object); |
$self->{meta}->{$descent}->{storage}->update($object); |
1035 |
|
|
1036 |
# asymmetry: get ident after insert |
# asymmetry: get ident after insert |
1037 |
# TODO: |
# TODO: |
1038 |
# - just do this if it is an IdentAuthority |
# - just do this if it is an IdentAuthority |
1039 |
# - use IdentProvider metadata here |
# - use IdentProvider metadata here |
1040 |
$self->{node}->{$descent}->{ident} = $self->{meta}->{$descent}->{storage}->id($object); |
#print Dumper($self->{meta}->{$descent}); |
1041 |
|
my $oid = $self->{meta}->{$descent}->{storage}->id($object); |
1042 |
|
#print "oid: $oid", "\n"; |
1043 |
|
$self->{node}->{$descent}->{ident} = $oid; |
1044 |
|
|
1045 |
|
|
1046 |
} elsif (lc $action eq 'update') { |
} elsif (lc $action eq 'update') { |
1137 |
#print "\n", "Attempt to fetch entry implicitely by ident failed: no ident given! This may result in an insert if no write-protection is in the way.", "\n"; |
#print "\n", "Attempt to fetch entry implicitely by ident failed: no ident given! This may result in an insert if no write-protection is in the way.", "\n"; |
1138 |
return; |
return; |
1139 |
} |
} |
1140 |
|
|
1141 |
|
# patch for DBD::CSV |
1142 |
|
if ($ident && $ident eq 'Null') { |
1143 |
|
return; |
1144 |
|
} |
1145 |
|
|
1146 |
my $result = $self->{meta}->{$descent}->{storage}->sendQuery({ |
#print "yai!", "\n"; |
1147 |
|
|
1148 |
|
my $query = { |
1149 |
node => $self->{meta}->{$descent}->{node}, |
node => $self->{meta}->{$descent}->{node}, |
1150 |
subnodes => [qw( cs )], |
subnodes => [qw( cs )], |
1151 |
criterias => [ |
criterias => [ |
1153 |
op => 'eq', |
op => 'eq', |
1154 |
val => $ident }, |
val => $ident }, |
1155 |
] |
] |
1156 |
}); |
}; |
1157 |
|
|
1158 |
|
#print Dumper($query); |
1159 |
|
|
1160 |
|
my $result = $self->{meta}->{$descent}->{storage}->sendQuery($query); |
1161 |
|
|
1162 |
my $entry = $result->getNextEntry(); |
my $entry = $result->getNextEntry(); |
1163 |
|
|
1164 |
|
#print Dumper($entry); |
1165 |
|
#print "pers: " . $self->{meta}->{$descent}->{storage}->is_persistent($entry), "\n"; |
1166 |
|
#my $state = $self->{meta}->{$descent}->{storage}->_fetch_object_state($entry, { name => 'TransactionHop' } ); |
1167 |
|
#print Dumper($state); |
1168 |
|
|
1169 |
my $status = $result->getStatus(); |
my $status = $result->getStatus(); |
1170 |
|
|
1171 |
|
#print Dumper($status); |
1172 |
|
|
1173 |
# TODO: enhance error handling (store inside tc) |
# TODO: enhance error handling (store inside tc) |
1174 |
#if (!$row) { |
#if (!$row) { |
1175 |
# print "\n", "row error", "\n"; |
# print "\n", "row error", "\n"; |
1176 |
# next; |
# next; |
1177 |
#} |
#} |
1178 |
if (($status && $status->{err}) || !$entry) { |
|
1179 |
#$logger->critical( __PACKAGE__ . "->_loadNode (ident=\"$ident\") failed" ); |
# these checks run before actually loading payload- and meta-data to node-container |
1180 |
return; |
|
1181 |
} |
# 1st level - hard error |
1182 |
|
if ($status && $status->{err}) { |
1183 |
|
$logger->debug( __PACKAGE__ . "->_statloadNode (ident=\"$ident\") failed - hard error (that's ok): $status->{err}" ); |
1184 |
|
return; |
1185 |
|
} |
1186 |
|
|
1187 |
|
# 2nd level - logical (empty/notfound) error |
1188 |
|
if (($status && $status->{empty}) || !$entry) { |
1189 |
|
$logger->debug( __PACKAGE__ . "->_statloadNode (ident=\"$ident\") failed - logical error (that's ok)" ); |
1190 |
|
#print "no entry (logical)", "\n"; |
1191 |
|
return; |
1192 |
|
} |
1193 |
|
|
1194 |
|
#print Dumper($entry); |
1195 |
|
|
1196 |
# was: |
# was: |
1197 |
# $self->{node}->{$descent}->{ident} = $ident; |
# $self->{node}->{$descent}->{ident} = $ident; |
1198 |
# is: |
# is: |
1199 |
# TODO: re-resolve ident from entry via metadata "IdentProvider" |
# TODO: re-resolve ident from entry via metadata "IdentProvider" here - like elsewhere |
1200 |
$self->{node}->{$descent}->{ident} = $ident; |
$self->{node}->{$descent}->{ident} = $ident; |
1201 |
$self->{node}->{$descent}->{payload} = $entry; |
$self->{node}->{$descent}->{payload} = $entry; |
1202 |
|
|
1203 |
} |
} |
1204 |
|
|
1205 |
return 1; |
return 1; |
1223 |
$self->{meta}->{source}->{IdentProvider}->{arg} => $ident_new, |
$self->{meta}->{source}->{IdentProvider}->{arg} => $ident_new, |
1224 |
cs => $self->{node}->{target}->{checksum}, |
cs => $self->{node}->{target}->{checksum}, |
1225 |
}; |
}; |
1226 |
#print Dumper($map); |
|
1227 |
#print Dumper($self->{node}); |
#print Dumper($map); |
1228 |
#exit; |
#print Dumper($self->{node}); |
1229 |
|
#exit; |
1230 |
|
|
1231 |
$self->_modifyNode('source', 'update', $map); |
$self->_modifyNode('source', 'update', $map); |
1232 |
} |
} |
1233 |
|
|
1309 |
} |
} |
1310 |
my $crit = join ' AND ', @crits; |
my $crit = join ' AND ', @crits; |
1311 |
print "p" if $self->{verbose}; |
print "p" if $self->{verbose}; |
1312 |
|
|
1313 |
|
#print Dumper($map); |
1314 |
|
#print Dumper($crit); |
1315 |
|
|
1316 |
$self->_modifyNode($descent, 'update', $map, $crit); |
$self->_modifyNode($descent, 'update', $map, $crit); |
1317 |
$i++; |
$i++; |
1318 |
} |
} |