source: trunk/LATMOS-Accounts-Web/lib/LATMOS/Accounts/Web/Controller/Remote/Listing.pm @ 1570

Last change on this file since 1570 was 1570, checked in by nanardon, 8 years ago

Add Remote/ tree for distant quering

File size: 1.3 KB
Line 
1package LATMOS::Accounts::Web::Controller::Remote::Listing;
2use Moose;
3use namespace::autoclean;
4
5BEGIN { extends 'Catalyst::Controller'; }
6
7=head1 NAME
8
9LATMOS::Accounts::Web::Controller::Remote::Listing - Catalyst Controller
10
11=head1 DESCRIPTION
12
13Catalyst Controller.
14
15=head1 METHODS
16
17=cut
18
19
20=head2 index
21
22=cut
23
24sub index :Path :Args(0) {
25    my ( $self, $c ) = @_;
26
27    my $base = $c->model('Accounts')->db;
28
29    my $otype = $c->req->param('otype');
30    my @search = $c->req->param('q');
31    my @attrs = $c->req->param('attribute');
32
33    if (!$base->is_supported_object($otype)) {
34        $c->res->status('404');
35        return;
36    }
37
38    my %objects = map { $_ => {} } $c->model('Accounts')->db->search_objects($otype, @search);
39
40    foreach my $attr (@attrs) {
41        foreach (keys %objects) {
42            $objects{$_}{$attr} = [];
43        }
44        my %res = $base->attributes_summary_by_object($otype, $attr);
45        foreach my $obj (keys %res) {
46            exists($objects{$obj}) or next;
47            $objects{$obj}{$attr} = $res{$obj};
48        }
49    }
50
51    $c->stash->{data} = \%objects;
52}
53
54
55
56=encoding utf8
57
58=head1 AUTHOR
59
60Olivier Thauvin,Guyancourt - B1428,+33 1 80285052,
61
62=head1 LICENSE
63
64This library is free software. You can redistribute it and/or modify
65it under the same terms as Perl itself.
66
67=cut
68
69__PACKAGE__->meta->make_immutable;
70
711;
Note: See TracBrowser for help on using the repository browser.