/[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.35 by jonen, Sat Apr 19 16:09:48 2003 UTC
# Line 3  Line 3 
3  #  $Id$  #  $Id$
4  #  #
5  #  $Log$  #  $Log$
6    #  Revision 1.35  2003/04/19 16:09:48  jonen
7    #  + added operator dispatching (currently for getting ref-type) at 'getListFiltered'
8    #
9    #  Revision 1.34  2003/04/11 01:18:53  joko
10    #  sendQuery:
11    #  + introduced crud action 'DELETE'
12    #
13  #  Revision 1.33  2003/04/09 06:07:43  joko  #  Revision 1.33  2003/04/09 06:07:43  joko
14  #  revamped 'sub sendQuery'  #  revamped 'sub sendQuery'
15  #  #
# Line 502  sub getListFiltered { Line 509  sub getListFiltered {
509    #    objects => $objects,    #    objects => $objects,
510    #  );    #  );
511        
512      # HACK: build eval-string (sorry) to get filtered list - please give advice here      # TODO: is_op?
513      push @tfilters, '$remote->{' . $filter->{key} . '}' . " $filter->{op} '$filter->{val}'";      # dispatch un-common operators if exists
514        if($filter->{op} eq "ref") {
515          push @tfilters, 'ref($remote->{' . $filter->{key} . '})' . " eq '$filter->{val}'";
516        } else {
517          # HACK: build eval-string (sorry) to get filtered list - please give advice here
518          push @tfilters, '$remote->{' . $filter->{key} . '}' . " $filter->{op} '$filter->{val}'";
519        }
520    
521    }    }
522    
# Line 564  sub sendQuery { Line 577  sub sendQuery {
577    # mode = OID|SPECIAL    # mode = OID|SPECIAL
578    my $mode = '';    my $mode = '';
579    my $ident = '';    my $ident = '';
580    my $action = '';    my $crud = '';
581        
582        
583    # dispatch type and mode    # dispatch type and mode
584        
585      # defaults - 1      # defaults - 1
586      if ($query->{options}) {      if ($query->{options}) {
587        $action = $query->{options}->{action};        $crud = $query->{options}->{crud};
588          $crud ||= $query->{options}->{action};
589      }      }
590    
591      # defaults - 2      # defaults - 2
592      $type ||= 'TRANSPARENT';      $type ||= 'TRANSPARENT';
593      $action ||= 'load';      $crud ||= 'RETRIEVE';
594    
595      if ($query->{options}->{OID}) {      if ($query->{options}->{OID}) {
596        $type = 'ITEM';        $type = 'ITEM';
# Line 585  sub sendQuery { Line 599  sub sendQuery {
599            
600      } elsif (my $guid = $query->{options}->{GUID}) {      } elsif (my $guid = $query->{options}->{GUID}) {
601        $type = 'TRANSPARENT';        $type = 'TRANSPARENT';
602        $query->{criterias} = [ { key => 'guid', op => 'eq', val => $guid } ];        $query->{criterias} = [ { key => 'guid', op => 'eq', val => $guid } ];    
603        
604        # if operator is different (dispatcher for 'getListFiltered')
605        } elsif (my $op = $query->{options}->{op}) {
606          $type = 'TRANSPARENT';
607          $query->{criterias} = [ { key => $query->{options}->{meta_label}, op => $op, val => $query->{options}->{meta_value} } ];    
608    
609      }      }
610        
611      # HACK: special case: querying by id does not translate into a common tangram query      # HACK: special case: querying by id does not translate into a common tangram query
# Line 604  sub sendQuery { Line 623  sub sendQuery {
623    if ($type eq 'ITEM' && $ident) {    if ($type eq 'ITEM' && $ident) {
624    
625      if ($mode eq 'OID') {          if ($mode eq 'OID') {    
626          # TODO: review this case!
627        $result = $self->getObject($ident, $query->{options});        $result = $self->getObject($ident, $query->{options});
628            
629      } elsif ($mode eq 'SPECIAL.SYNC') {      } elsif ($mode eq 'SPECIAL.SYNC') {
# Line 635  sub sendQuery { Line 655  sub sendQuery {
655        
656    } elsif ($type eq 'TRANSPARENT') {    } elsif ($type eq 'TRANSPARENT') {
657    
658      if ($action eq 'load') {      if ($crud eq 'RETRIEVE') {
659    
660        my $list = $self->getListFiltered($query->{node}, $query->{criterias});        my $list = $self->getListFiltered($query->{node}, $query->{criterias});
661        #return $self->createSet($object);        #return $self->createSet($object);
# Line 662  sub sendQuery { Line 682  sub sendQuery {
682        #my $res = $self->{COREHANDLE}->select($h, $h->{);        #my $res = $self->{COREHANDLE}->select($h, $h->{);
683        $result = $self->createCursor($query->{node});        $result = $self->createCursor($query->{node});
684    
685      } elsif ($action eq 'save') {      } elsif ($crud eq 'UPDATE') {
686    
687        # 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) ...
688        my $childquery = deep_copy($query);        my $childquery = deep_copy($query);
689        $childquery->{options}->{action} = 'load';        $childquery->{options}->{crud} = 'RETRIEVE';
690        delete $childquery->{payload};        delete $childquery->{payload};
691    
692        # ... to use it to fetch fresh object using ourselves (sendQuery).        # ... to use it to fetch a fresh object using ourselves (sendQuery).
693        my $cursor = $self->sendQuery($childquery);        my $cursor = $self->sendQuery($childquery);
694        my $status = $cursor->getStatus();        my $status = $cursor->getStatus();
695        my $object = $cursor->getNextEntry();        my $object = $cursor->getNextEntry();
# Line 681  sub sendQuery { Line 701  sub sendQuery {
701        # Execute update operation at orm.        # Execute update operation at orm.
702        $self->update($object);        $self->update($object);
703            
704        } elsif ($crud eq 'DELETE') {
705    
706          # Patch current query to be a loader (e.g. change action) ...
707          my $childquery = deep_copy($query);
708          $childquery->{options}->{crud} = 'RETRIEVE';
709    
710          # ... to use it to fetch a fresh object using ourselves (sendQuery).
711          my $cursor = $self->sendQuery($childquery);
712          my $status = $cursor->getStatus();
713          my $object = $cursor->getNextEntry();
714    
715          $self->erase($object);
716    
717      }      }
718    
719    }    }

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

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