Changeset 1791
Legend:
- Unmodified
- Added
- Removed
-
trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Root.pm
r1692 r1791 90 90 91 91 $c->stash->{template} = 'login/index.tt'; 92 return 0; 92 93 } 93 94 -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/Stat.pm
r1790 r1791 94 94 95 95 my $op = $self->_get_attributes('aggregateFunction'); 96 if (my $attr = $self->base->attribute($otype, $attribute)) { 97 if (my $obj = $attr->reference) { 98 if (my @reffilter = $self->_get_attributes('refFilter')) { 99 $reffiltered = {}; 100 foreach ($self->base->search_objects($obj, @reffilter)) { 101 $reffiltered->{$_} = 1; 102 } 103 } 104 } 105 if ($self->_get_attributes('refall') && $attr->has_values_list && !$op) { 106 foreach ($attr->can_values) { 96 97 my ($refOtype, $refAttr) = ($otype, undef); 98 99 foreach (split(/\./, $attribute)) { 100 if (my $attr = $self->base->attribute($refOtype, $_)) { 101 if (my $obj = $attr->reference) { 102 ($refOtype, $refAttr) = ($obj, $attr); 103 } else { 104 ($refOtype, $refAttr) = (undef, undef); 105 } 106 } 107 } 108 109 if ($refAttr && $refOtype) { 110 if (my @reffilter = $self->_get_attributes('refFilter')) { 111 $reffiltered = {}; 112 foreach ($self->base->search_objects($refOtype, @reffilter)) { 113 $reffiltered->{$_} = 1; 114 } 115 } 116 if ($self->_get_attributes('refall') && $refAttr->has_values_list && !$op) { 117 foreach ($refAttr->can_values) { 107 118 if ($reffiltered && !$reffiltered->{$_}) { 108 119 next; … … 136 147 next; 137 148 } 138 $_ ||= '(none)';149 defined($_) && $_ ne '' or $_ = '(none)'; 139 150 if ($op) { 140 151 push(@{$aggdata{$id}}, $_); -
trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Bases/Sql/objects.pm
r1788 r1791 639 639 640 640 sub attributes_summary { 641 my ($class, $base, $attribute) = @_; 641 my ($class, $base, $dotAttribute) = @_; 642 643 my ($attribute, $recursiveAttr) = $dotAttribute =~ /(\w+)(?:\.(.*))?/; 644 642 645 my $attr = $base->attribute($class->type, $attribute) or do { 643 646 $base->log(LA_ERR, "Cannot instantiate %s attribute", $attribute); … … 676 679 677 680 my %values; 678 while (my $res = $sth->fetchrow_hashref) { 679 $values{$res->{value}} = 1 if ($res->{value}); 681 if ($recursiveAttr) { 682 my $otype = $attr->reference or do { 683 $base->log(LA_ERR, "Cannot do recursive search, no ref for attribute %s", $attribute); 684 return; 685 }; 686 my %parentRes = $base->attributes_summary_by_object($otype, $recursiveAttr) or return; 687 688 while (my $res = $sth->fetchrow_hashref) { 689 defined($res->{value}) or next; 690 $values{ $parentRes{ $res->{value} } } = 1; 691 } 692 } else { 693 while (my $res = $sth->fetchrow_hashref) { 694 $values{$res->{value}} = 1 if ($res->{value}); 695 } 680 696 } 681 697 sort keys %values … … 689 705 690 706 sub attributes_summary_by_object { 691 my ($class, $base, $attribute) = @_; 707 my ($class, $base, $dotAttribute) = @_; 708 709 my ($attribute, $recursiveAttr) = $dotAttribute =~ /(\w+)(?:\.(.*))?/; 710 692 711 my $attr = $base->attribute($class->type, $attribute) or do { 693 712 $base->log(LA_ERR, "Cannot instantiate %s attribute", $attribute); … … 702 721 return; 703 722 } 723 704 724 if ($attr->{managed}) { 705 725 return $class->SUPER::attributes_summary_by_object($base, $attribute); … … 726 746 727 747 my %values; 728 while (my $res = $sth->fetchrow_hashref) { 729 defined($res->{value}) or next; 730 push(@{ $values{ $res->{name} } }, $res->{value}); 748 if ($recursiveAttr) { 749 my $otype = $attr->reference or do { 750 $base->log(LA_ERR, "Cannot do recursive search, no ref for attribute %s", $attribute); 751 return; 752 }; 753 my %parentRes = $base->attributes_summary_by_object($otype, $recursiveAttr) or return; 754 755 while (my $res = $sth->fetchrow_hashref) { 756 defined($res->{value}) or next; 757 push(@{ $values{ $res->{name} } }, @{ $parentRes{ $res->{value} } || []}); 758 } 759 } else { 760 while (my $res = $sth->fetchrow_hashref) { 761 defined($res->{value}) or next; 762 push(@{ $values{ $res->{name} } }, $res->{value}); 763 } 731 764 } 732 765 %values
Note: See TracChangeset
for help on using the changeset viewer.