Last change
on this file since 1568 was
1487,
checked in by nanardon, 9 years ago
|
Run Stat with unexported objects active
|
-
Property svn:executable set to
*
|
File size:
1.6 KB
|
Rev | Line | |
---|
[1427] | 1 | package LATMOS::Accounts::Task::Stats; |
---|
| 2 | |
---|
| 3 | use strict; |
---|
| 4 | use warnings; |
---|
| 5 | use base qw(LATMOS::Accounts::Task); |
---|
| 6 | use LATMOS::Accounts; |
---|
| 7 | use LATMOS::Accounts::Log; |
---|
| 8 | use LATMOS::Accounts::Utils; |
---|
| 9 | |
---|
| 10 | =head1 NAME |
---|
| 11 | |
---|
| 12 | LATMOS::Accounts::Task::Stats - Store value to perform some statistics |
---|
| 13 | |
---|
| 14 | =head1 DESCRIPTION |
---|
| 15 | |
---|
| 16 | =cut |
---|
| 17 | |
---|
| 18 | sub init { |
---|
| 19 | my ($self) = @_; |
---|
[1465] | 20 | my $LA = LATMOS::Accounts->new($self->{config}, noacl => 1); |
---|
[1427] | 21 | my $labase = $self->{base} ? $LA->base($self->{base}) : $LA->base; |
---|
| 22 | $labase && $labase->load or die "Cannot load base"; |
---|
| 23 | |
---|
| 24 | $self->{_la} = $LA; |
---|
| 25 | $self->{_base} = $labase; |
---|
| 26 | |
---|
| 27 | 1; |
---|
| 28 | } |
---|
| 29 | |
---|
| 30 | sub needupd { 1 } |
---|
| 31 | |
---|
| 32 | sub run { |
---|
| 33 | my ($self) = @_; |
---|
| 34 | |
---|
[1487] | 35 | $self->{_base}->temp_switch_unexported( |
---|
| 36 | sub { |
---|
| 37 | foreach my $stat ($self->{_base}->list_objects('stat')) { |
---|
| 38 | my $ostat = $self->{_base}->get_object('stat', $stat); |
---|
| 39 | # Don't process unexported stat objects |
---|
| 40 | $ostat->_get_attributes('unexported') and next; |
---|
| 41 | if ($ostat->collect) { |
---|
| 42 | $self->{_base}->commit; |
---|
| 43 | } else { |
---|
| 44 | $self->{_base}->rollback; |
---|
| 45 | } |
---|
| 46 | } |
---|
| 47 | }, |
---|
| 48 | 1 |
---|
| 49 | ); |
---|
[1437] | 50 | |
---|
| 51 | return 1; |
---|
[1427] | 52 | } |
---|
| 53 | |
---|
| 54 | 1; |
---|
| 55 | |
---|
| 56 | __END__ |
---|
| 57 | |
---|
| 58 | =head1 SEE ALSO |
---|
| 59 | |
---|
| 60 | L<LATMOS::Accounts>, L<LATMOS::Accounts::Task> |
---|
| 61 | |
---|
| 62 | =head1 AUTHOR |
---|
| 63 | |
---|
| 64 | Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt> |
---|
| 65 | |
---|
| 66 | =head1 COPYRIGHT AND LICENSE |
---|
| 67 | |
---|
| 68 | Copyright (C) 2012 CNRS SA/CETP/LATMOS |
---|
| 69 | |
---|
| 70 | This library is free software; you can redistribute it and/or modify |
---|
| 71 | it under the same terms as Perl itself, either Perl version 5.10.0 or, |
---|
| 72 | at your option, any later version of Perl 5 you may have available. |
---|
| 73 | |
---|
| 74 | =cut |
---|
| 75 | |
---|
Note: See
TracBrowser
for help on using the repository browser.