6 |
## |
## |
7 |
## ---------------------------------------------------------------------------------------- |
## ---------------------------------------------------------------------------------------- |
8 |
## $Log$ |
## $Log$ |
9 |
|
## Revision 1.9 2003/04/09 07:53:34 joko |
10 |
|
## minor namespace update |
11 |
|
## |
12 |
|
## Revision 1.8 2003/04/09 07:27:02 joko |
13 |
|
## minor update (just cosmetics) |
14 |
|
## |
15 |
## Revision 1.7 2003/03/27 15:31:16 joko |
## Revision 1.7 2003/03/27 15:31:16 joko |
16 |
## fixes to modules regarding new namespace(s) below Data::Mungle::* |
## fixes to modules regarding new namespace(s) below Data::Mungle::* |
17 |
## |
## |
54 |
|
|
55 |
use Data::Dumper; |
use Data::Dumper; |
56 |
use Hash::Merge qw( merge ); |
use Hash::Merge qw( merge ); |
57 |
use libdb qw( hash2Sql ); |
use shortcuts::database qw( hash2sql ); |
58 |
use Data::Mungle::Transform::Deep qw( merge_to ); |
use Data::Mungle::Transform::Deep qw( merge_to ); |
59 |
|
|
60 |
|
|
186 |
] |
] |
187 |
}; |
}; |
188 |
|
|
|
# trace |
|
|
#print "query:", "\n"; |
|
|
#print Dumper($query); |
|
|
|
|
189 |
# send query and fetch first entry from result |
# send query and fetch first entry from result |
190 |
my $result = $self->{meta}->{$descent}->{storage}->sendQuery($query); |
my $result = $self->{meta}->{$descent}->{storage}->sendQuery($query); |
191 |
my $entry = $result->getNextEntry(); |
my $entry = $result->getNextEntry(); |
358 |
# TODO: wrap this around '$storageHandle->sendQuery(...)'!? |
# TODO: wrap this around '$storageHandle->sendQuery(...)'!? |
359 |
my $sql_main; |
my $sql_main; |
360 |
if (lc($action) eq 'insert') { |
if (lc($action) eq 'insert') { |
361 |
$sql_main = hash2Sql($self->{meta}->{$descent}->{accessorName}, $map, 'SQL_INSERT'); |
$sql_main = hash2sql($self->{meta}->{$descent}->{accessorName}, $map, 'SQL_INSERT'); |
362 |
} elsif (lc $action eq 'update') { |
} elsif (lc $action eq 'update') { |
363 |
$crit ||= "$self->{meta}->{$descent}->{IdentProvider}->{arg}='$self->{node}->{$descent}->{ident}'"; |
$crit ||= "$self->{meta}->{$descent}->{IdentProvider}->{arg}='$self->{node}->{$descent}->{ident}'"; |
364 |
$sql_main = hash2Sql($self->{meta}->{$descent}->{accessorName}, $map, 'SQL_UPDATE', $crit); |
$sql_main = hash2sql($self->{meta}->{$descent}->{accessorName}, $map, 'SQL_UPDATE', $crit); |
365 |
} |
} |
366 |
my $sqlHandle = $self->{meta}->{$descent}->{storage}->sendCommand($sql_main); |
my $sqlHandle = $self->{meta}->{$descent}->{storage}->sendCommand($sql_main); |
367 |
|
|
503 |
|
|
504 |
} elsif (lc $action eq 'update') { |
} elsif (lc $action eq 'update') { |
505 |
|
|
506 |
# get fresh object from orm first |
# Get fresh object from orm first. |
507 |
|
# TODO: Review, is a 'sendQuery' required in this place? |
508 |
|
# By now: NO! It's more expensive and we can just expect existing objects for update operations. |
509 |
|
# If it doesn't exist either, we assume the engine will fail on issuing the 'update' operation later... |
510 |
$object = $self->{meta}->{$descent}->{storage}->load($self->{node}->{$descent}->{ident}); |
$object = $self->{meta}->{$descent}->{storage}->load($self->{node}->{$descent}->{ident}); |
511 |
|
|
|
#print Dumper($self->{node}); |
|
|
|
|
512 |
# mix in values |
# mix in values |
513 |
#print Dumper($object); |
merge_to($object, $map); |
|
# TODO: use Hash::Merge here??? |
|
|
merge_to($object, $map); |
|
|
#print Dumper($object); |
|
|
#exit; |
|
514 |
|
|
515 |
# update orm |
# update orm |
516 |
$self->{meta}->{$descent}->{storage}->update($object); |
$self->{meta}->{$descent}->{storage}->update($object); |
517 |
|
|
518 |
} |
} |
519 |
|
|
|
#exit; |
|
|
|
|
520 |
my $error = 0; |
my $error = 0; |
521 |
|
|
522 |
# 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! |