3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.49 2004/11/03 14:12:34 jonen |
7 |
|
# replaced print with logger->info |
8 |
|
# |
9 |
|
# Revision 1.48 2004/10/28 11:35:51 jonen |
10 |
|
# + bugfix related to select-criterias(filter) |
11 |
|
# |
12 |
|
# Revision 1.47 2004/08/31 14:26:08 jonen |
13 |
|
# updated |
14 |
|
# |
15 |
|
# Revision 1.46 2004/05/06 12:54:34 jonen |
16 |
|
# + bugfix related to multiple select-'filter' |
17 |
|
# |
18 |
|
# Revision 1.45 2003/12/14 01:48:36 jonen |
19 |
|
# small HACK at _insertChildNode: some special Childnodes should not be created because existing objects have to be selected! |
20 |
|
# TODO: make this more generic, e.g. implement a special flag at Schema |
21 |
|
# |
22 |
|
# Revision 1.44 2003/12/04 01:01:50 joko |
23 |
|
# + sendQuery now returns result even on crud=UPDATE |
24 |
|
# |
25 |
|
# Revision 1.43 2003/07/02 11:07:12 jonen |
26 |
|
# re-activate filtering of results *after* results are fetched from tangram |
27 |
|
# (needed for e.g. UserManagment) |
28 |
|
# |
29 |
|
# Revision 1.42 2003/07/01 23:24:17 joko |
30 |
|
# now using package before using function |
31 |
|
# |
32 |
# Revision 1.41 2003/06/29 02:03:45 joko |
# Revision 1.41 2003/06/29 02:03:45 joko |
33 |
# fix:? initialize schema on startup |
# fix:? initialize schema on startup |
34 |
# |
# |
192 |
|
|
193 |
use Data::Dumper; |
use Data::Dumper; |
194 |
use Tangram; |
use Tangram; |
195 |
|
use Class::Tangram; |
196 |
|
|
197 |
use DesignPattern::Object; |
use DesignPattern::Object; |
198 |
use Data::Storage::Result::Tangram; |
use Data::Storage::Result::Tangram; |
202 |
# get logger instance |
# get logger instance |
203 |
my $logger = Log::Dispatch::Config->instance; |
my $logger = Log::Dispatch::Config->instance; |
204 |
|
|
205 |
|
#$Tangram::TRACE = *STDOUT; |
206 |
|
|
207 |
# this holds the complete instantiated schema from tangram |
# this holds the complete instantiated schema from tangram |
208 |
my $schema_tangram; |
my $schema_tangram; |
541 |
my @results; |
my @results; |
542 |
$logger->debug( __PACKAGE__ . "->getListFiltered( nodename => '" . $in->{nodename} . "' )" ); |
$logger->debug( __PACKAGE__ . "->getListFiltered( nodename => '" . $in->{nodename} . "' )" ); |
543 |
|
|
544 |
#print Dumper($filters); |
#print "Filter_payload: " . Dumper($in->{filters}) . "\n"; |
545 |
|
|
546 |
# 1. "Remote Object Handle" - get set of objects from odbms by object name |
# 1. "Remote Object Handle" - get set of objects from odbms by object name |
547 |
my $remote = $self->{_COREHANDLE}->remote($in->{nodename}); |
my $remote = $self->{_COREHANDLE}->remote($in->{nodename}); |
597 |
$orm_filter_tmp = $left->$op($right); |
$orm_filter_tmp = $left->$op($right); |
598 |
} |
} |
599 |
|
|
600 |
if (not $orm_filter) { |
if (!ref($orm_filter)) { |
601 |
$orm_filter = $orm_filter_tmp; |
$orm_filter = $orm_filter_tmp; |
602 |
} else { |
} else { |
603 |
$orm_filter = $orm_filter->and($orm_filter_tmp); |
$orm_filter = $orm_filter->and($orm_filter_tmp); |
606 |
} |
} |
607 |
|
|
608 |
$orm_query->{filter} = $orm_filter; |
$orm_query->{filter} = $orm_filter; |
609 |
|
|
610 |
|
# debug point: |
611 |
|
#print "Filter: " . Dumper($orm_query->{filter}) . "\n"; |
612 |
|
|
613 |
# was: |
# was: |
614 |
|
|
646 |
#@results = eval($evalstring); |
#@results = eval($evalstring); |
647 |
#die $@ if $@; |
#die $@ if $@; |
648 |
|
|
649 |
=pod |
# filter results - NEEDED for e.g. UserManagment !! |
650 |
# filter results |
if ($in->{filters}->[0]->{op} && ($in->{filters}->[0]->{op} eq "ref")) { |
|
if ($filters->[0]->{op} && ($filters->[0]->{op} eq "ref")) { |
|
651 |
#print "Filter->op eq 'ref'.\n"; |
#print "Filter->op eq 'ref'.\n"; |
652 |
my $att_name = $filters->[0]->{key}; |
my $att_name = $in->{filters}->[0]->{key}; |
653 |
my $att_val = $filters->[0]->{val}; |
my $att_val = $in->{filters}->[0]->{val}; |
654 |
my @filtered; |
my @filtered; |
655 |
foreach(@results) { |
foreach(@results) { |
656 |
if(ref($_->{$att_name}) eq $att_val) { |
if(ref($_->{$att_name}) eq $att_val) { |
659 |
} |
} |
660 |
@results = @filtered; |
@results = @filtered; |
661 |
} |
} |
|
=cut |
|
662 |
|
|
663 |
#print "results: " . Dumper(\@results); |
#print "results: " . Dumper(\@results); |
664 |
|
|
730 |
|
|
731 |
} elsif (my $guid = $query->{options}->{GUID}) { |
} elsif (my $guid = $query->{options}->{GUID}) { |
732 |
$type = 'TRANSPARENT'; |
$type = 'TRANSPARENT'; |
733 |
$query->{criterias} = [ { key => 'guid', op => 'eq', val => $guid } ]; |
if(ref($query->{criterias}) eq 'ARRAY') { |
734 |
|
push @{$query->{criterias}}, { key => 'guid', op => 'eq', val => $guid }; |
735 |
|
} else { |
736 |
|
$query->{criterias} = [ { key => 'guid', op => 'eq', val => $guid } ]; |
737 |
|
} |
738 |
|
} |
739 |
# if operator is different (dispatcher for 'getListFiltered') |
# if operator is different (dispatcher for 'getListFiltered') |
740 |
} elsif (my $op = $query->{options}->{op}) { |
if (my $op = $query->{options}->{op}) { |
741 |
$type = 'TRANSPARENT'; |
$type = 'TRANSPARENT'; |
742 |
$query->{criterias} = [ { key => $query->{options}->{meta_label}, op => $op, val => $query->{options}->{meta_value} } ]; |
if(ref($query->{criterias}) eq 'ARRAY') { |
743 |
|
push @{$query->{criterias}}, { key => $query->{options}->{meta_label}, op => $op, val => $query->{options}->{meta_value} }; |
744 |
|
} else { |
745 |
|
$query->{criterias} = [ { key => $query->{options}->{meta_label}, op => $op, val => $query->{options}->{meta_value} } ]; |
746 |
|
} |
747 |
} |
} |
748 |
|
|
749 |
# 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 |
839 |
my $options = { utf8 => 1, php => 1 }; |
my $options = { utf8 => 1, php => 1 }; |
840 |
merge_to($object, $query->{payload}, $options); |
merge_to($object, $query->{payload}, $options); |
841 |
|
|
842 |
|
#print Dumper($object); |
843 |
|
|
844 |
# Execute update operation at orm. |
# Execute update operation at orm. |
845 |
$self->update($object); |
$self->update($object); |
846 |
|
$result = $self->createResult([ $object ]); |
847 |
|
|
848 |
} elsif ($crud eq 'DELETE') { |
} elsif ($crud eq 'DELETE') { |
849 |
|
|
857 |
my $object = $cursor->getNextEntry(); |
my $object = $cursor->getNextEntry(); |
858 |
|
|
859 |
$self->erase($object); |
$self->erase($object); |
860 |
|
$self->unload($object); |
861 |
|
|
862 |
} elsif ($crud eq 'CREATE') { |
} elsif ($crud eq 'CREATE') { |
863 |
|
|
864 |
my $nodename = $query->{node}; |
my $nodename = $query->{node}; |
865 |
my $newnode = $self->createNode($nodename); |
my $newnode = $self->createNode($nodename); |
866 |
my $id = $self->{_COREHANDLE}->insert($newnode); |
my $id = $self->{_COREHANDLE}->insert($newnode); |
867 |
|
|
868 |
print "Saved new node $nodename with GUID $newnode->{guid}, OID '$id': " . Dumper($newnode) . "\n"; |
$logger->info( __PACKAGE__ . "->sendQuery: Saved new node $nodename with GUID $newnode->{guid}, OID '$id'."); |
869 |
|
|
870 |
return $newnode; |
return $newnode; |
871 |
|
|
1047 |
$obj->{$_} = '0000-00-00 00:00:00'; |
$obj->{$_} = '0000-00-00 00:00:00'; |
1048 |
} elsif($attr_types->{$_} eq 'ref') { |
} elsif($attr_types->{$_} eq 'ref') { |
1049 |
if($attr_options->{$_}->{class}) { |
if($attr_options->{$_}->{class}) { |
1050 |
$obj->{$_} = $self->createNode($attr_options->{$_}->{class}); |
# HACK!!! |
1051 |
|
# STANDALONE Objects (objects which make sense to instanciat alone) should not created automaticly |
1052 |
|
# because they maybe exists and should only be SETTED not CREATED! |
1053 |
|
# TODO: Create a flag at the scheme for that reason! |
1054 |
|
# (e.g child_node => 1 for child-nodes only like e.g. UserData) |
1055 |
|
if($attr_options->{$_}->{class} eq 'NetPerson' || $attr_options->{$_}->{class} eq 'Event' || $attr_options->{$_}->{class} eq 'BetRule') { |
1056 |
|
#$obj->{$_} = undef(); |
1057 |
|
} else { |
1058 |
|
$obj->{$_} = $self->createNode($attr_options->{$_}->{class}); |
1059 |
|
} |
1060 |
} else { |
} else { |
1061 |
#$obj->{$_} = undef(); |
#$obj->{$_} = undef(); |
1062 |
} |
} |