--- nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2003/04/09 06:07:43 1.33 +++ nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2003/04/11 01:18:53 1.34 @@ -1,8 +1,12 @@ ############################################ # -# $Id: Tangram.pm,v 1.33 2003/04/09 06:07:43 joko Exp $ +# $Id: Tangram.pm,v 1.34 2003/04/11 01:18:53 joko Exp $ # # $Log: Tangram.pm,v $ +# Revision 1.34 2003/04/11 01:18:53 joko +# sendQuery: +# + introduced crud action 'DELETE' +# # Revision 1.33 2003/04/09 06:07:43 joko # revamped 'sub sendQuery' # @@ -564,19 +568,20 @@ # mode = OID|SPECIAL my $mode = ''; my $ident = ''; - my $action = ''; + my $crud = ''; # dispatch type and mode # defaults - 1 if ($query->{options}) { - $action = $query->{options}->{action}; + $crud = $query->{options}->{crud}; + $crud ||= $query->{options}->{action}; } # defaults - 2 $type ||= 'TRANSPARENT'; - $action ||= 'load'; + $crud ||= 'RETRIEVE'; if ($query->{options}->{OID}) { $type = 'ITEM'; @@ -604,6 +609,7 @@ if ($type eq 'ITEM' && $ident) { if ($mode eq 'OID') { + # TODO: review this case! $result = $self->getObject($ident, $query->{options}); } elsif ($mode eq 'SPECIAL.SYNC') { @@ -635,7 +641,7 @@ } elsif ($type eq 'TRANSPARENT') { - if ($action eq 'load') { + if ($crud eq 'RETRIEVE') { my $list = $self->getListFiltered($query->{node}, $query->{criterias}); #return $self->createSet($object); @@ -662,14 +668,14 @@ #my $res = $self->{COREHANDLE}->select($h, $h->{); $result = $self->createCursor($query->{node}); - } elsif ($action eq 'save') { + } elsif ($crud eq 'UPDATE') { # Patch current query to be a loader (e.g. change action, remove payload) ... my $childquery = deep_copy($query); - $childquery->{options}->{action} = 'load'; + $childquery->{options}->{crud} = 'RETRIEVE'; delete $childquery->{payload}; - # ... to use it to fetch fresh object using ourselves (sendQuery). + # ... to use it to fetch a fresh object using ourselves (sendQuery). my $cursor = $self->sendQuery($childquery); my $status = $cursor->getStatus(); my $object = $cursor->getNextEntry(); @@ -681,6 +687,19 @@ # Execute update operation at orm. $self->update($object); + } elsif ($crud eq 'DELETE') { + + # Patch current query to be a loader (e.g. change action) ... + my $childquery = deep_copy($query); + $childquery->{options}->{crud} = 'RETRIEVE'; + + # ... to use it to fetch a fresh object using ourselves (sendQuery). + my $cursor = $self->sendQuery($childquery); + my $status = $cursor->getStatus(); + my $object = $cursor->getNextEntry(); + + $self->erase($object); + } }