--- nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2003/05/10 17:31:18 1.36 +++ nfo/perl/libs/Data/Storage/Handler/Tangram.pm 2003/06/06 11:40:40 1.39 @@ -1,13 +1,24 @@ ############################################ # -# $Id: Tangram.pm,v 1.36 2003/05/10 17:31:18 jonen Exp $ +# $Id: Tangram.pm,v 1.39 2003/06/06 11:40:40 jonen Exp $ # # $Log: Tangram.pm,v $ +# Revision 1.39 2003/06/06 11:40:40 jonen +# fixed bug at 'getFilteredList' +# +# Revision 1.38 2003/05/13 16:38:38 joko +# problems with "tied" on 5.6.1/win32 +# +# Revision 1.37 2003/05/10 17:37:39 jonen +# corrected last commit +# # Revision 1.36 2003/05/10 17:31:18 jonen # + added new functions related to 'create' item # - createNode() # # creates non-persistent 'deep dummy filled' object -# - +# - insertChildNode() +# # inserts child node at given parent (child node haven't to exists, +# createNode will be injected transparently) # # Revision 1.35 2003/04/19 16:09:48 jonen # + added operator dispatching (currently for getting ref-type) at 'getListFiltered' @@ -518,7 +529,9 @@ # TODO: is_op? # dispatch un-common operators if exists if($filter->{op} eq "ref") { - push @tfilters, 'ref($remote->{' . $filter->{key} . '})' . " eq '$filter->{val}'"; + # do nothing, results will be filtered later cause 'tangram-filter' doesn't support 'ref' query + #print "Filter->op eq 'ref'.\n"; + #push @tfilters, 'ref($remote->{' . $filter->{key} . '})' . " eq '$filter->{val}'"; } else { # HACK: build eval-string (sorry) to get filtered list - please give advice here push @tfilters, '$remote->{' . $filter->{key} . '}' . " $filter->{op} '$filter->{val}'"; @@ -544,6 +557,23 @@ @results = eval($evalstring); die $@ if $@; + + # filter results + if($filters->[0]->{op} eq "ref") { + #print "Filter->op eq 'ref'.\n"; + my $att_name = $filters->[0]->{key}; + my $att_val = $filters->[0]->{val}; + my @filtered; + foreach(@results) { + if(ref($_->{$att_name}) eq $att_val) { + push @filtered, $_; + } + } + @results = @filtered; + } + + #print "results: " . Dumper(\@results); + return \@results; } @@ -955,32 +985,42 @@ #print "Create child object [$nodename]: " . Dumper($child_entry); } - # get reference of tied node + # get reference of tied node (seems, only on Linux node's are tied!!) my $tied_node = tied $parent->{$nodename}; # insert/change child entry at parent #print "reference: " . ref($parent->{$nodename}) . "\n"; if(ref($parent->{$nodename}) eq 'ARRAY') { - # all tangram types are tied as 'SCALAR' with special 'FETCH', 'STORE' methods per type, - # so a 'PUSH' is not implemented (which could be then done transparently) - my $array = $tied_node->FETCH; - push @$array, $child_entry; - $tied_node->STORE($array); - # node will be normaly untied at 'STORE' - if(tied $parent->{$nodename}) { print "already tied !!\n"; } - else { undef $tied_node; } - } - elsif(ref($parent->{$nodename}) eq 'HASH') { - if(my $key = $query_args->{hash_key}) { - # same problem as with 'ARRAY': - # all tangram types are tied as 'SCALAR' with special 'FETCH', 'STORE' methods per type. - my $hash = $tied_node->FETCH; - $hash->{$key} = $child_entry; - $tied_node->STORE($hash); + # (seems, only on Linux node's are tied!!) + if($tied_node) { + # all tangram types are tied as 'SCALAR' with special 'FETCH', 'STORE' methods per type, + # so a 'PUSH' is not implemented (which could be then done transparently) + my $array = $tied_node->FETCH; + push @$array, $child_entry; + $tied_node->STORE($array); # node will be normaly untied at 'STORE' if(tied $parent->{$nodename}) { print "already tied !!\n"; } else { undef $tied_node; } } else { + push @{$parent->{$nodename}}, $child_entry; + } + } + elsif(ref($parent->{$nodename}) eq 'HASH') { + if(my $key = $query_args->{hash_key}) { + # (seems, only on Linux node's are tied!!) + if($tied_node) { + # same problem as with 'ARRAY': + # all tangram types are tied as 'SCALAR' with special 'FETCH', 'STORE' methods per type. + my $hash = $tied_node->FETCH; + $hash->{$key} = $child_entry; + $tied_node->STORE($hash); + # node will be normaly untied at 'STORE' + if(tied $parent->{$nodename}) { print "already tied !!\n"; } + else { undef $tied_node; } + } else { + $parent->{$nodename}->{$key} = $child_entry; + } + } else { print "ERROR: No HASH KEY given, so not able to insert hash entry!"; } }