Changeset 11637 for branches

Show
Ignore:
Timestamp:
11/11/08 16:21:55 (8 weeks ago)
Author:
javier.amor.garcia@…
Message:

fixed reportUrls to manage moduels with multiple tableInfos refs #1152

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • branches/pop-proxy-branch/ebox/src/EBox/LogObserver.pm

    r11636 r11637  
    1313# along with this program; if not, write to the Free Software 
    1414# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA 
    15  
    16  
     15# 
    1716# Class: EBox::LogObserver 
    1817# 
     
    2524use strict; 
    2625use warnings; 
     26 
     27use Perl6::Junction qw(any); 
    2728 
    2829sub new  
     
    183184      my $rawUrl = "/ebox/Logs/Index?selected=$index&refresh=1"; 
    184185 
    185 #    my $tableInfo = $self->tableInfo(); 
    186     if (not $tableInfo->{consolidate}) { 
    187         push @urls, [ domain => $tableInfo->{name},  raw => $rawUrl, ]; 
    188         next; 
     186 
     187      if (not $tableInfo->{consolidate}) { 
     188          push @urls, [ domain => $tableInfo->{name},  raw => $rawUrl, ]; 
     189          next; 
     190      } 
     191       
     192      my @consolidateTables = keys %{ $tableInfo->{consolidate} }; 
     193       
     194       
     195      my @reportComposites = grep { 
     196          ((ref $_) =~ m/::Report::/) and  
     197              ($self->_compositeUsesDbTable($_, \@consolidateTables) ) 
     198      } @{ $self->composites }; 
     199 
     200 
     201       
     202      (ref $self) =~  m/::(.*?)$/;; 
     203      my $urlModName= $1; 
     204 
     205      my $first = 1; 
     206      foreach my $comp (@reportComposites) { 
     207          my $compName = $comp->name(); 
     208          my @compUrls =( 
     209                         domain => $tableInfo->{name}, 
     210                         summary => "/ebox/$urlModName/Composite/$compName", 
     211                      ); 
     212          if ($first) { 
     213              push @compUrls, (raw => $rawUrl ); 
     214              $first =0; 
     215          }     
     216          else { 
     217              push @compUrls, ( raw => undef); 
     218          } 
     219           
     220          push @urls, \@compUrls; 
     221      } 
     222       
     223      if (not @reportComposites) { 
     224          push @urls, [ domain => $tableInfo->{name},  raw => $rawUrl, ]; 
     225           
     226      } 
     227       
     228       
     229       
     230  } 
     231 
     232    return \@urls; 
     233} 
     234 
     235 
     236sub _compositeUsesDbTable 
     237{ 
     238    my ($self, $composite, $dbTables_r) = @_; 
     239     
     240    my $usesDbTable = 0; 
     241    foreach my $component (@{ $composite->components() } ) { 
     242        if ($component->can('dbTableName')) { 
     243            if ($component->dbTableName() eq any( @{ $dbTables_r } )) { 
     244                $usesDbTable = 1; 
     245            } 
     246 
     247            last; 
     248        } 
    189249    } 
    190250 
    191     my @reportComposites = grep { 
    192         (ref $_) =~ m/::Report::/; 
    193     } @{ $self->composites }; 
    194  
    195     (ref $self) =~  m/::(.*?)$/;; 
    196     my $urlModName= $1; 
    197  
    198     my $first = 1; 
    199     foreach my $comp (@reportComposites) { 
    200         my $compName = $comp->name(); 
    201         my @compUrls =( 
    202                        domain => $tableInfo->{name}, 
    203                        summary => "/ebox/$urlModName/Composite/$compName", 
    204                       ); 
    205         if ($first) { 
    206             push @compUrls, (raw => $rawUrl ); 
    207             $first =0; 
    208         }     
    209         else { 
    210             push @compUrls, ( raw => undef); 
    211         } 
    212  
    213         push @urls, \@compUrls; 
    214       } 
    215        
    216       if (not @reportComposites) { 
    217         push @urls, [ domain => $tableInfo->{name},  raw => $rawUrl, ]; 
    218          
    219       } 
    220  
    221   
    222  
    223     } 
    224  
    225  
    226  
    227      
    228  
    229     return \@urls; 
    230 } 
    231  
     251    return $usesDbTable; 
     252} 
    232253 
    233254