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 |
# |
# |
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'; |
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') { |
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); |
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(); |
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 |
} |
} |