/[cvs]/nfo/perl/libs/Data/Storage/Handler/Tangram.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage/Handler/Tangram.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.33 by joko, Wed Apr 9 06:07:43 2003 UTC revision 1.34 by joko, Fri Apr 11 01:18:53 2003 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.34  2003/04/11 01:18:53  joko
7    #  sendQuery:
8    #  + introduced crud action 'DELETE'
9    #
10  #  Revision 1.33  2003/04/09 06:07:43  joko  #  Revision 1.33  2003/04/09 06:07:43  joko
11  #  revamped 'sub sendQuery'  #  revamped 'sub sendQuery'
12  #  #
# Line 564  sub sendQuery { Line 568  sub sendQuery {
568    # mode = OID|SPECIAL    # mode = OID|SPECIAL
569    my $mode = '';    my $mode = '';
570    my $ident = '';    my $ident = '';
571    my $action = '';    my $crud = '';
572        
573        
574    # dispatch type and mode    # dispatch type and mode
575        
576      # defaults - 1      # defaults - 1
577      if ($query->{options}) {      if ($query->{options}) {
578        $action = $query->{options}->{action};        $crud = $query->{options}->{crud};
579          $crud ||= $query->{options}->{action};
580      }      }
581    
582      # defaults - 2      # defaults - 2
583      $type ||= 'TRANSPARENT';      $type ||= 'TRANSPARENT';
584      $action ||= 'load';      $crud ||= 'RETRIEVE';
585    
586      if ($query->{options}->{OID}) {      if ($query->{options}->{OID}) {
587        $type = 'ITEM';        $type = 'ITEM';
# Line 604  sub sendQuery { Line 609  sub sendQuery {
609    if ($type eq 'ITEM' && $ident) {    if ($type eq 'ITEM' && $ident) {
610    
611      if ($mode eq 'OID') {          if ($mode eq 'OID') {    
612          # TODO: review this case!
613        $result = $self->getObject($ident, $query->{options});        $result = $self->getObject($ident, $query->{options});
614            
615      } elsif ($mode eq 'SPECIAL.SYNC') {      } elsif ($mode eq 'SPECIAL.SYNC') {
# Line 635  sub sendQuery { Line 641  sub sendQuery {
641        
642    } elsif ($type eq 'TRANSPARENT') {    } elsif ($type eq 'TRANSPARENT') {
643    
644      if ($action eq 'load') {      if ($crud eq 'RETRIEVE') {
645    
646        my $list = $self->getListFiltered($query->{node}, $query->{criterias});        my $list = $self->getListFiltered($query->{node}, $query->{criterias});
647        #return $self->createSet($object);        #return $self->createSet($object);
# Line 662  sub sendQuery { Line 668  sub sendQuery {
668        #my $res = $self->{COREHANDLE}->select($h, $h->{);        #my $res = $self->{COREHANDLE}->select($h, $h->{);
669        $result = $self->createCursor($query->{node});        $result = $self->createCursor($query->{node});
670    
671      } elsif ($action eq 'save') {      } elsif ($crud eq 'UPDATE') {
672    
673        # Patch current query to be a loader (e.g. change action, remove payload) ...        # Patch current query to be a loader (e.g. change action, remove payload) ...
674        my $childquery = deep_copy($query);        my $childquery = deep_copy($query);
675        $childquery->{options}->{action} = 'load';        $childquery->{options}->{crud} = 'RETRIEVE';
676        delete $childquery->{payload};        delete $childquery->{payload};
677    
678        # ... to use it to fetch fresh object using ourselves (sendQuery).        # ... to use it to fetch a fresh object using ourselves (sendQuery).
679        my $cursor = $self->sendQuery($childquery);        my $cursor = $self->sendQuery($childquery);
680        my $status = $cursor->getStatus();        my $status = $cursor->getStatus();
681        my $object = $cursor->getNextEntry();        my $object = $cursor->getNextEntry();
# Line 681  sub sendQuery { Line 687  sub sendQuery {
687        # Execute update operation at orm.        # Execute update operation at orm.
688        $self->update($object);        $self->update($object);
689            
690        } elsif ($crud eq 'DELETE') {
691    
692          # Patch current query to be a loader (e.g. change action) ...
693          my $childquery = deep_copy($query);
694          $childquery->{options}->{crud} = 'RETRIEVE';
695    
696          # ... to use it to fetch a fresh object using ourselves (sendQuery).
697          my $cursor = $self->sendQuery($childquery);
698          my $status = $cursor->getStatus();
699          my $object = $cursor->getNextEntry();
700    
701          $self->erase($object);
702    
703      }      }
704    
705    }    }

Legend:
Removed from v.1.33  
changed lines
  Added in v.1.34

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed