3 |
# $Id$ |
# $Id$ |
4 |
# |
# |
5 |
# $Log$ |
# $Log$ |
6 |
|
# Revision 1.44 2003/12/04 01:01:50 joko |
7 |
|
# + sendQuery now returns result even on crud=UPDATE |
8 |
|
# |
9 |
|
# Revision 1.43 2003/07/02 11:07:12 jonen |
10 |
|
# re-activate filtering of results *after* results are fetched from tangram |
11 |
|
# (needed for e.g. UserManagment) |
12 |
|
# |
13 |
|
# Revision 1.42 2003/07/01 23:24:17 joko |
14 |
|
# now using package before using function |
15 |
|
# |
16 |
|
# Revision 1.41 2003/06/29 02:03:45 joko |
17 |
|
# fix:? initialize schema on startup |
18 |
|
# |
19 |
# Revision 1.40 2003/06/25 22:57:54 joko |
# Revision 1.40 2003/06/25 22:57:54 joko |
20 |
# major rework of "sub sendQuery / sub getListFiltered": now should be capable of "sorting" |
# major rework of "sub sendQuery / sub getListFiltered": now should be capable of "sorting" |
21 |
# |
# |
176 |
|
|
177 |
use Data::Dumper; |
use Data::Dumper; |
178 |
use Tangram; |
use Tangram; |
179 |
|
use Class::Tangram; |
180 |
|
|
181 |
use DesignPattern::Object; |
use DesignPattern::Object; |
182 |
use Data::Storage::Result::Tangram; |
use Data::Storage::Result::Tangram; |
186 |
# get logger instance |
# get logger instance |
187 |
my $logger = Log::Dispatch::Config->instance; |
my $logger = Log::Dispatch::Config->instance; |
188 |
|
|
189 |
|
#$Tangram::TRACE = *STDOUT; |
190 |
|
|
191 |
# this holds the complete instantiated schema from tangram |
# this holds the complete instantiated schema from tangram |
192 |
my $schema_tangram; |
my $schema_tangram; |
205 |
#if (!$schema_tangram) { |
#if (!$schema_tangram) { |
206 |
#my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } ); |
#my $obj = getNewPerlObjectByPkgName($self->{locator}->{schema}, { EXPORT_OBJECTS => $self->{locator}->{classnames}, want_transactions => $self->{locator}->{want_transactions} } ); |
207 |
my $obj = DesignPattern::Object->fromPackage($self->{locator}->{schema}, { 'EXPORT_OBJECTS' => $self->{locator}->{classnames}, 'want_transactions' => $self->{locator}->{want_transactions} } ); |
my $obj = DesignPattern::Object->fromPackage($self->{locator}->{schema}, { 'EXPORT_OBJECTS' => $self->{locator}->{classnames}, 'want_transactions' => $self->{locator}->{want_transactions} } ); |
208 |
$schema_tangram = $obj->getSchema(); |
$schema_tangram = $obj->getSchema() if $obj; |
209 |
#} |
#} |
210 |
if (!$schema_tangram) { |
if (!$schema_tangram) { |
211 |
$logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{schema}" ); |
$logger->error( __PACKAGE__ . "->_initSchema: No Schema available for $self->{locator}->{schema}." ); |
212 |
return 0; |
return 0; |
213 |
} |
} |
214 |
#$self->_patchSchema(); |
#$self->_patchSchema(); |
254 |
# return; |
# return; |
255 |
# } |
# } |
256 |
|
|
257 |
#return unless $self->_initSchema(); |
return unless $self->_initSchema(); |
258 |
$self->_initSchema(); |
#$self->_initSchema(); |
259 |
|
|
260 |
# create the main tangram storage object |
# create the main tangram storage object |
261 |
#$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn ); |
#$self->{COREHANDLE} = Tangram::Relational->connect( $schema, $dsn ); |
627 |
#@results = eval($evalstring); |
#@results = eval($evalstring); |
628 |
#die $@ if $@; |
#die $@ if $@; |
629 |
|
|
630 |
=pod |
# filter results - NEEDED for e.g. UserManagment !! |
631 |
# filter results |
if ($in->{filters}->[0]->{op} && ($in->{filters}->[0]->{op} eq "ref")) { |
|
if ($filters->[0]->{op} && ($filters->[0]->{op} eq "ref")) { |
|
632 |
#print "Filter->op eq 'ref'.\n"; |
#print "Filter->op eq 'ref'.\n"; |
633 |
my $att_name = $filters->[0]->{key}; |
my $att_name = $in->{filters}->[0]->{key}; |
634 |
my $att_val = $filters->[0]->{val}; |
my $att_val = $in->{filters}->[0]->{val}; |
635 |
my @filtered; |
my @filtered; |
636 |
foreach(@results) { |
foreach(@results) { |
637 |
if(ref($_->{$att_name}) eq $att_val) { |
if(ref($_->{$att_name}) eq $att_val) { |
640 |
} |
} |
641 |
@results = @filtered; |
@results = @filtered; |
642 |
} |
} |
|
=cut |
|
643 |
|
|
644 |
#print "results: " . Dumper(\@results); |
#print "results: " . Dumper(\@results); |
645 |
|
|
813 |
my $options = { utf8 => 1, php => 1 }; |
my $options = { utf8 => 1, php => 1 }; |
814 |
merge_to($object, $query->{payload}, $options); |
merge_to($object, $query->{payload}, $options); |
815 |
|
|
816 |
|
#print Dumper($object); |
817 |
|
|
818 |
# Execute update operation at orm. |
# Execute update operation at orm. |
819 |
$self->update($object); |
$self->update($object); |
820 |
|
$result = $self->createResult([ $object ]); |
821 |
|
|
822 |
} elsif ($crud eq 'DELETE') { |
} elsif ($crud eq 'DELETE') { |
823 |
|
|