Changeset 293


Ignore:
Timestamp:
01/11/11 23:09:20 (13 years ago)
Author:
nanardon
Message:
  • add parent dir function: search pkg owning the directories
Location:
server/trunk/web/lib/Sophie/Controller
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • server/trunk/web/lib/Sophie/Controller/Analysis.pm

    r287 r293  
    103103} 
    104104 
     105sub parentdir : XMLRPC { 
     106    my ($self, $c, $distspec, $id, $pool) = @_; 
     107    $pool ||= $id; 
     108 
     109    my @dir = $c->model('Base::UsersFiles')->search( 
     110            { 
     111                pid => [ $id ], 
     112            }, 
     113            { 
     114                select   => [ qw(dirname) ], 
     115                group_by => [ qw(dirname) ], 
     116                order_by => [ qw(dirname) ], 
     117            } 
     118    )->get_column('dirname')->all; 
     119 
     120    $c->forward('/analysis/solver/parentdir', [ $distspec, \@dir, $pool ]); 
     121} 
     122 
    105123=head1 AUTHOR 
    106124 
  • server/trunk/web/lib/Sophie/Controller/Analysis/Solver.pm

    r284 r293  
    122122} 
    123123 
     124sub parentdir : XMLRPC { 
     125    my ($self, $c, $searchspec, $folder, $pool) = @_; 
     126 
     127    my %need_pool; 
     128    my %need_pkgid; 
     129    my %bydir; 
     130    my @notfound; 
     131    foreach my $dir (@{ $folder }) { 
     132        $dir =~ s:/$::; 
     133        my $found = 0; 
     134        my $res = $c->forward('/search/rpm/byfile', [ $searchspec, $dir, ]); 
     135        if (@{$res}) { 
     136            $found = 1; 
     137            foreach (@{$res}) { 
     138                $need_pkgid{$_} = 1; 
     139                $bydir{$dir}{pkg}{$_} = 1; 
     140            } 
     141        }  
     142        if ($pool) { 
     143            $res = $c->forward('/user/folder/byfile', [ $pool, $dir, ]); 
     144            if (@{$res}) { 
     145                $found = 1; 
     146                foreach (@{$res}) { 
     147                    $need_pool{$_} = 1; 
     148                    $bydir{$dir}{pool}{$_} = 1; 
     149 
     150                } 
     151            } 
     152        } 
     153        push(@notfound, $dir) unless($found); 
     154    } 
     155    return $c->stash->{xmlrpc} = { 
     156        notfound => \@notfound, 
     157        pkg => [ keys %need_pkgid ], 
     158        pool => [ keys %need_pool ], 
     159        bydir => \%bydir, 
     160    }; 
     161} 
    124162 
    125163=head1 AUTHOR 
     
    1381761; 
    139177 
    140  
    141 =head1 AUTHOR 
    142  
    143 Olivier Thauvin 
    144  
    145 =head1 LICENSE 
    146  
    147 This library is free software. You can redistribute it and/or modify 
    148 it under the same terms as Perl itself. 
    149  
    150 =cut 
    151  
    152 __PACKAGE__->meta->make_immutable; 
    153  
    154 1; 
Note: See TracChangeset for help on using the changeset viewer.