| 1 | package Crop::Object::Warehouse::Lang::SQL::Query::Select::Node::Bundle; | ||
| 2 | use base qw/ Crop::Object::Warehouse::Lang::SQL::Query::Select::Node /; | ||
| 3 | |||
| 4 | =begin nd | ||
| 5 | Class: Crop::Object::Warehouse::Lang::SQL::Query::Select::Node::Bundle | ||
| 6 | Bundle node. | ||
| 7 | =cut | ||
| 8 | |||
| 9 | use v5.14; | ||
| 10 | use warnings; | ||
| 11 | |||
| 12 | use Crop::Object::Constants; | ||
| 13 | use Crop::Object::Collection; | ||
| 14 | |||
| 15 | use Crop::Debug; | ||
| 16 | |||
| 17 | =begin nd | ||
| 18 | Method: init_parent_view ( ) | ||
| 19 | Initialize parent view. | ||
| 20 | |||
| 21 | Set up <Crop::Object::Collection> in parent view. | ||
| 22 | Returns: | ||
| 23 | $self | ||
| 24 | =cut | ||
| 25 | sub _init_parent_view { | ||
| 26 | my $self = shift; | ||
| 27 | |||
| 28 | $self->{parent}{current}{$self->{parent_view}} //= Crop::Object::Collection->new($self->{class}); | ||
| 29 | } | ||
| 30 | |||
| 31 | =begin nd | ||
| 32 | Method: parse_row ($row) | ||
| 33 | Handle row of the raw data from database and put object to the right place. | ||
| 34 | |||
| 35 | Parameters: | ||
| 36 | $row - hashref to the entire row | ||
| 37 | |||
| 38 | Returns: | ||
| 39 | new node - default action | ||
| 40 | =cut | ||
| 41 | sub parse_row { | ||
| 42 | my ($self, $row) = @_; | ||
| 43 | |||
| 44 | $self->_init_parent_view; | ||
| 45 | |||
| 46 | my $item = $self->{class}->new($row->{$self->{table_effective}})->Set_state(DWHLINK); | ||
| 47 | $item->_Is_key_defined or return; | ||
| 48 | |||
| 49 | # my $found_in_cache = $self->see_cache($item); | ||
| 50 | # $item = $found_in_cache if $found_in_cache; | ||
| 51 | |||
| 52 | $self->{parent}{current}{$self->{parent_view}}->Push($item); | ||
| 53 | $self->{current} = $item; | ||
| 54 | } | ||
| 55 | |||
| 56 | 1; |