source: tags/5.2.1/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Basessynchro.pm @ 2626

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

Order module to optimize data update

File size: 1.9 KB
Line 
1package LATMOS::Accounts::Task::Basessynchro;
2
3use strict;
4use warnings;
5use base qw(LATMOS::Accounts::Task);
6use LATMOS::Accounts;
7use LATMOS::Accounts::Log;
8
9=head1 NAME
10
11LATMOS::Accounts::Task::Basessynchro - Synchronize bases
12
13=head1 DESCRIPTION
14
15This module is responsible of the copy of object from main base to others
16
17=cut
18
19sub order { 2 }
20
21sub run {
22    my ($self) = @_;
23    my $LA = LATMOS::Accounts->new($self->{config}, noacl => 1) or do {
24        la_log LA_ERR, "Cannot instantiate LA";
25        return 1;
26    };
27
28    if (my $mail = $LA->val($self->{syncname} || $LA->default_synchro_name, 'maillog')) {
29        la_set_log(mail => $mail);
30    }
31
32    my $sync = $LA->create_synchro(
33        $self->{syncname} || $LA->default_synchro_name,
34        test     => $self->{test},
35    ) or do {
36       la_log LA_ERR, "cannot create sync object";
37       return;
38    };
39
40    $sync->load_dest and do {
41        la_log LA_ERR, "Cannot load destination";
42        return;
43    };
44
45    $sync->process() or do {
46        la_log LA_ERR, "Sync has failed\n";
47        return;
48    };
49
50    return 1;
51}
52
53sub reset_savepoint {
54    my ($self) = @_;
55    my $LA = LATMOS::Accounts->new($self->{config}, noacl => 1) or do {
56        la_log LA_ERR, "Cannot instantiate LA";
57        return;
58    };
59    my $sync = $LA->create_synchro(
60        $self->{syncname} || $LA->default_synchro_name,
61        test     => $self->{test},
62    ) or do {
63       la_log LA_ERR, "cannot create sync object";
64       return;
65    };
66
67
68    $sync->reset_savepoint
69}
70
711;
72
73=head1 SEE ALSO
74
75L<LATMOS::Accounts>, L<LATMOS::Accounts::Bases>
76
77=head1 AUTHOR
78
79Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
80
81=head1 COPYRIGHT AND LICENSE
82
83Copyright (C) 2008, 2009 CNRS SA/CETP/LATMOS
84
85This library is free software; you can redistribute it and/or modify
86it under the same terms as Perl itself, either Perl version 5.10.0 or,
87at your option, any later version of Perl 5 you may have available.
88
89=cut
Note: See TracBrowser for help on using the repository browser.