/[cvs]/nfo/perl/libs/OEF/Script/AbstractFeeder.pm
ViewVC logotype

Diff of /nfo/perl/libs/OEF/Script/AbstractFeeder.pm

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.1 by joko, Sun Feb 9 16:27:06 2003 UTC revision 1.6 by joko, Sat Jun 19 01:49:07 2004 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    --------------------------------------------------------------------------------  ##    --------------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.6  2004/06/19 01:49:07  joko
8    ##    enabled verbosing with Data::Transfer::Sync
9    ##    minor patch to option processing
10    ##
11    ##    Revision 1.5  2003/02/22 16:53:42  joko
12    ##    minor update: debugging
13    ##
14    ##    Revision 1.4  2003/02/20 21:11:15  joko
15    ##    renamed module
16    ##    modified runtime namespace hierarchy
17    ##
18    ##    Revision 1.3  2003/02/14 14:18:36  joko
19    ##    + new get-/setter-methods
20    ##
21    ##    Revision 1.2  2003/02/11 09:48:57  joko
22    ##    - moved notice output out of this module
23    ##    + some fixes
24    ##
25  ##    Revision 1.1  2003/02/09 16:27:06  joko  ##    Revision 1.1  2003/02/09 16:27:06  joko
26  ##    + initial commit  ##    + initial commit
27  ##  ##
# Line 18  use warnings; Line 36  use warnings;
36  #use base 'OEF::Component::Task';  #use base 'OEF::Component::Task';
37  use base qw(  use base qw(
38    DesignPattern::Object    DesignPattern::Object
39    DesignPattern::Object::Logger    DesignPattern::Logger
40  );  );
41    
42    
43  use Data::Dumper;  use Data::Dumper;
44  use Getopt::Long;  use Getopt::Long;
45    use Data::Transfer::Sync;
46    
47    
48  # get logger instance  # get logger instance
# Line 48  EOU Line 67  EOU
67    exit;    exit;
68  }  }
69    
70  sub getoptions {  sub readoptions {
71    my $self = shift;    my $self = shift;
72    
73    GetOptions(    GetOptions(
# Line 67  sub getoptions { Line 86  sub getoptions {
86    );    );
87  }    }  
88    
89    sub getoptions {
90      my $self = shift;
91      return $self->{opt};
92    }
93    
94    sub setoptions {
95      my $self = shift;
96      my $options = shift;
97      # FIXME: is this really true?
98      $self->{opt} = $options;
99    }
100    
101  sub getoptions_old {  sub getoptions_old {
102    my $self = shift;    my $self = shift;
103    GetOptions(    GetOptions(
# Line 105  sub run { Line 136  sub run {
136    my $self = shift;    my $self = shift;
137    $self->_before_run();    $self->_before_run();
138    $self->prepare();    $self->prepare();
139    $self->tellWhatIAmDoing();    #$self->tellWhatIAmDoing();
140      #$self->_tellWhatIWillDo();
141    $self->sync();    $self->sync();
142  }  }
143    
 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" );  
     
 }  
   
144  sub prepare {  sub prepare {
145    my $self = shift;    my $self = shift;
146    
147      #print Dumper($self->{opt});
148      #exit;
149    
150    # TODO:    # TODO:
151    # - move this to Data::Transfer::Sync::checkOptions!!!    # - move this to Data::Transfer::Sync::checkOptions!!!
152    # - use 'syncable'???    # - use 'syncable'???
153    
154    #if ($self->{app}->{config}->{databases}->{$self->{opt}->{target}}->{syncable}) {    #if ($self->{app}->{config}->{databases}->{$self->{opt}->{target}}->{syncable}) {
155      $self->{opt}->{action} ||= '';
156    
157      my $mode = '';      my $mode = '';
158      my $erase = 0;      my $erase = 0;
# Line 194  sub sync { Line 188  sub sync {
188      # is api-version specified?      # is api-version specified?
189      my $sync_version = $self->{opt}->{sv};      my $sync_version = $self->{opt}->{sv};
190      $sync_version ||= 'V1';      $sync_version ||= 'V1';
191        #$sync_version = 'V2';
192    
193      #print "version: $sync_version", "\n";
194    
195    # create a new synchronization object    # create a new synchronization object
196      my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version );      my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version, __parent => $self, verbose => 1 );
197    
198    # trace    # trace
199      #print Dumper($self);      #print Dumper($self);
200        #print Dumper($self);
201        #exit;
202    
203      # checks
204        if (!$self->{app}->{storage}->{$self->{opt}->{source}}) {
205          $logger->critical("Sync source storage handle undefined!");
206        }
207        if (!$self->{app}->{storage}->{$self->{opt}->{target}}) {
208          $logger->critical("Sync target storage handle undefined!");
209        }
210    
211    # configure the synchronization-object    # configure the synchronization-object
212      $sync->configure(      $sync->configure(
213        source => {        source => {
214          storage => {          storage => {
215            #handle => $mapiStorage,            #handle => $mapiStorage,
216            handle => $self->{app}->{$self->{opt}->{source}},            handle => $self->{app}->{storage}->{$self->{opt}->{source}},
217            writeProtected => 1,            #isIdentAuthority => $self->{app}->{config}->{{$self->{opt}->{source}},
218              #isChecksumAuthority => 1,
219              #writeProtected => 1,
220          },          },
221        },        },
222        target => {        target => {
223          storage => {          storage => {
224            #handle => $ldapStorage,            #handle => $ldapStorage,
225            handle => $self->{app}->{$self->{opt}->{target}},            handle => $self->{app}->{storage}->{$self->{opt}->{target}},
226            idAuthority => 1,            #idAuthority => 1,
227            isChecksumAuthority => 1,            #isChecksumAuthority => 1,
228            writeProtected => 0,            #isWriteProtected => 0,
229          },          },
230        },        },
231        verbose => 1,        verbose => 1,
232      );      );
233        
234      # TODO:
235    =pod
236      $sync->configure(
237        'source.storage.handle' => ...,
238        'target.storage.handle' => ...,
239      );
240    =cut
241    
242    # trace    # trace
243      #print Dumper($sync);      #print Dumper($sync);

Legend:
Removed from v.1.1  
changed lines
  Added in v.1.6

MailToCvsAdmin">MailToCvsAdmin
ViewVC Help
Powered by ViewVC 1.1.26 RSS 2.0 feed