4 |
## $Id$ |
## $Id$ |
5 |
## -------------------------------------------------------------------------------- |
## -------------------------------------------------------------------------------- |
6 |
## $Log$ |
## $Log$ |
7 |
|
## Revision 1.4 2003/02/20 21:11:15 joko |
8 |
|
## renamed module |
9 |
|
## modified runtime namespace hierarchy |
10 |
|
## |
11 |
|
## Revision 1.3 2003/02/14 14:18:36 joko |
12 |
|
## + new get-/setter-methods |
13 |
|
## |
14 |
|
## Revision 1.2 2003/02/11 09:48:57 joko |
15 |
|
## - moved notice output out of this module |
16 |
|
## + some fixes |
17 |
|
## |
18 |
## Revision 1.1 2003/02/09 16:27:06 joko |
## Revision 1.1 2003/02/09 16:27:06 joko |
19 |
## + initial commit |
## + initial commit |
20 |
## |
## |
29 |
#use base 'OEF::Component::Task'; |
#use base 'OEF::Component::Task'; |
30 |
use base qw( |
use base qw( |
31 |
DesignPattern::Object |
DesignPattern::Object |
32 |
DesignPattern::Object::Logger |
DesignPattern::Logger |
33 |
); |
); |
34 |
|
|
35 |
|
|
36 |
use Data::Dumper; |
use Data::Dumper; |
37 |
use Getopt::Long; |
use Getopt::Long; |
38 |
|
use Data::Transfer::Sync; |
39 |
|
|
40 |
|
|
41 |
# get logger instance |
# get logger instance |
60 |
exit; |
exit; |
61 |
} |
} |
62 |
|
|
63 |
sub getoptions { |
sub readoptions { |
64 |
my $self = shift; |
my $self = shift; |
65 |
|
|
66 |
GetOptions( |
GetOptions( |
79 |
); |
); |
80 |
} |
} |
81 |
|
|
82 |
|
sub getoptions { |
83 |
|
my $self = shift; |
84 |
|
return $self->{opt}; |
85 |
|
} |
86 |
|
|
87 |
|
sub setoptions { |
88 |
|
my $self = shift; |
89 |
|
my $options = shift; |
90 |
|
# FIXME: is this really true? |
91 |
|
$self->{opt} = $options; |
92 |
|
} |
93 |
|
|
94 |
sub getoptions_old { |
sub getoptions_old { |
95 |
my $self = shift; |
my $self = shift; |
96 |
GetOptions( |
GetOptions( |
129 |
my $self = shift; |
my $self = shift; |
130 |
$self->_before_run(); |
$self->_before_run(); |
131 |
$self->prepare(); |
$self->prepare(); |
132 |
$self->tellWhatIAmDoing(); |
#$self->tellWhatIAmDoing(); |
133 |
$self->sync(); |
$self->sync(); |
134 |
} |
} |
135 |
|
|
|
my $c_string_default = ''; |
|
|
sub c_string { |
|
|
my $value = shift; |
|
|
$value ||= "[$c_string_default]"; |
|
|
return $value; |
|
|
} |
|
|
|
|
|
sub tellWhatIAmDoing { |
|
|
my $self = shift; |
|
|
|
|
|
$c_string_default = 'n/a'; |
|
|
my $source = c_string($self->{opt}->{'source'}); |
|
|
my $source_node = c_string($self->{opt}->{'source-node'}); |
|
|
my $source_type = c_string($self->{opt}->{'source-type'}); |
|
|
my $target = c_string($self->{opt}->{'target'}); |
|
|
my $target_node = c_string($self->{opt}->{'target-node'}); |
|
|
my $target_type = c_string($self->{opt}->{'target-type'}); |
|
|
|
|
|
my $mapping_module = c_string($self->{opt}->{'mapping-module'}); |
|
|
my $mode = uc c_string($self->{opt}->{'mode'}); |
|
|
|
|
|
my $ql = "$mode INTO $source NODE $source_node TYPE $source_type SELECT NODE $target_node TYPE $target_type FROM $target USING MODULE $mapping_module;"; |
|
|
#$logger->notice( __PACKAGE__ . ": $ql" ); |
|
|
$logger->notice( $ql ); |
|
|
|
|
|
return; |
|
|
|
|
|
my $actioning = ucfirst $self->{opt}->{'action'} . 'ing'; |
|
|
|
|
|
# FIXME: this is weird! |
|
|
my $long = <<EOT; |
|
|
|
|
|
- $actioning data of type $target_type and |
|
|
filtered by $target_node from the storage named $target |
|
|
to the storage named $source - filtered by $source_node. |
|
|
- Will attempt to convert the data to $source_type. |
|
|
EOT |
|
|
chomp($long); |
|
|
$logger->notice( __PACKAGE__ . ": $long" ); |
|
|
|
|
|
} |
|
|
|
|
136 |
sub prepare { |
sub prepare { |
137 |
my $self = shift; |
my $self = shift; |
138 |
|
|
178 |
$sync_version ||= 'V1'; |
$sync_version ||= 'V1'; |
179 |
|
|
180 |
# create a new synchronization object |
# create a new synchronization object |
181 |
my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version ); |
my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version, __parent => $self ); |
182 |
|
|
183 |
# trace |
# trace |
184 |
#print Dumper($self); |
#print Dumper($self); |
185 |
|
#print Dumper($self); |
186 |
|
#exit; |
187 |
|
|
188 |
|
# checks |
189 |
|
if (!$self->{app}->{storage}->{$self->{opt}->{source}}) { |
190 |
|
$logger->critical("Sync source storage handle undefined!"); |
191 |
|
} |
192 |
|
if (!$self->{app}->{storage}->{$self->{opt}->{target}}) { |
193 |
|
$logger->critical("Sync target storage handle undefined!"); |
194 |
|
} |
195 |
|
|
196 |
# configure the synchronization-object |
# configure the synchronization-object |
197 |
$sync->configure( |
$sync->configure( |
198 |
source => { |
source => { |
199 |
storage => { |
storage => { |
200 |
#handle => $mapiStorage, |
#handle => $mapiStorage, |
201 |
handle => $self->{app}->{$self->{opt}->{source}}, |
handle => $self->{app}->{storage}->{$self->{opt}->{source}}, |
202 |
writeProtected => 1, |
#isIdentAuthority => $self->{app}->{config}->{{$self->{opt}->{source}}, |
203 |
|
#isChecksumAuthority => 1, |
204 |
|
#writeProtected => 1, |
205 |
}, |
}, |
206 |
}, |
}, |
207 |
target => { |
target => { |
208 |
storage => { |
storage => { |
209 |
#handle => $ldapStorage, |
#handle => $ldapStorage, |
210 |
handle => $self->{app}->{$self->{opt}->{target}}, |
handle => $self->{app}->{storage}->{$self->{opt}->{target}}, |
211 |
idAuthority => 1, |
#idAuthority => 1, |
212 |
isChecksumAuthority => 1, |
#isChecksumAuthority => 1, |
213 |
writeProtected => 0, |
#isWriteProtected => 0, |
214 |
}, |
}, |
215 |
}, |
}, |
216 |
verbose => 1, |
verbose => 1, |
217 |
); |
); |
218 |
|
|
219 |
|
# TODO: |
220 |
|
=pod |
221 |
|
$sync->configure( |
222 |
|
'source.storage.handle' => ..., |
223 |
|
'target.storage.handle' => ..., |
224 |
|
); |
225 |
|
=cut |
226 |
|
|
227 |
# trace |
# trace |
228 |
#print Dumper($sync); |
#print Dumper($sync); |