source: trunk/LATMOS-Accounts/lib/LATMOS/Accounts/Task/Basessynchro.pm @ 1590

Last change on this file since 1590 was 1206, checked in by nanardon, 12 years ago

use 'savepoint' word instead checkpoint

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 run {
20    my ($self) = @_;
21    my $LA = LATMOS::Accounts->new($self->{config}, noacl => 1) or do {
22        la_log LA_ERR, "Cannot instantiate LA";
23        return 1;
24    };
25
26    if (my $mail = $LA->val($self->{syncname} || $LA->default_synchro_name, 'maillog')) {
27        la_set_log(mail => $mail);
28    }
29
30    my $sync = $LA->create_synchro(
31        $self->{syncname} || $LA->default_synchro_name,
32        test     => $self->{test},
33    ) or do {
34       la_log LA_ERR, "cannot create sync object";
35       return;
36    };
37
38    $sync->load_dest and do {
39        la_log LA_ERR, "Cannot load destination";
40        return;
41    };
42
43    $sync->process() or do {
44        la_log LA_ERR, "Sync has failed\n";
45        return;
46    };
47
48    return 1;
49}
50
51sub reset_savepoint {
52    my ($self) = @_;
53    my $LA = LATMOS::Accounts->new($self->{config}, noacl => 1) or do {
54        la_log LA_ERR, "Cannot instantiate LA";
55        return;
56    };
57    my $sync = $LA->create_synchro(
58        $self->{syncname} || $LA->default_synchro_name,
59        test     => $self->{test},
60    ) or do {
61       la_log LA_ERR, "cannot create sync object";
62       return;
63    };
64
65
66    $sync->reset_savepoint
67}
68
691;
70
71=head1 SEE ALSO
72
73L<LATMOS::Accounts>, L<LATMOS::Accounts::Bases>
74
75=head1 AUTHOR
76
77Olivier Thauvin, E<lt>olivier.thauvin@latmos.ipsl.frE<gt>
78
79=head1 COPYRIGHT AND LICENSE
80
81Copyright (C) 2008, 2009 CNRS SA/CETP/LATMOS
82
83This library is free software; you can redistribute it and/or modify
84it under the same terms as Perl itself, either Perl version 5.10.0 or,
85at your option, any later version of Perl 5 you may have available.
86
87=cut
Note: See TracBrowser for help on using the repository browser.