/[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.5 by joko, Sat Feb 22 16:53:42 2003 UTC
# Line 4  Line 4 
4  ##    $Id$  ##    $Id$
5  ##    --------------------------------------------------------------------------------  ##    --------------------------------------------------------------------------------
6  ##    $Log$  ##    $Log$
7    ##    Revision 1.5  2003/02/22 16:53:42  joko
8    ##    minor update: debugging
9    ##
10    ##    Revision 1.4  2003/02/20 21:11:15  joko
11    ##    renamed module
12    ##    modified runtime namespace hierarchy
13    ##
14    ##    Revision 1.3  2003/02/14 14:18:36  joko
15    ##    + new get-/setter-methods
16    ##
17    ##    Revision 1.2  2003/02/11 09:48:57  joko
18    ##    - moved notice output out of this module
19    ##    + some fixes
20    ##
21  ##    Revision 1.1  2003/02/09 16:27:06  joko  ##    Revision 1.1  2003/02/09 16:27:06  joko
22  ##    + initial commit  ##    + initial commit
23  ##  ##
# Line 18  use warnings; Line 32  use warnings;
32  #use base 'OEF::Component::Task';  #use base 'OEF::Component::Task';
33  use base qw(  use base qw(
34    DesignPattern::Object    DesignPattern::Object
35    DesignPattern::Object::Logger    DesignPattern::Logger
36  );  );
37    
38    
39  use Data::Dumper;  use Data::Dumper;
40  use Getopt::Long;  use Getopt::Long;
41    use Data::Transfer::Sync;
42    
43    
44  # get logger instance  # get logger instance
# Line 48  EOU Line 63  EOU
63    exit;    exit;
64  }  }
65    
66  sub getoptions {  sub readoptions {
67    my $self = shift;    my $self = shift;
68    
69    GetOptions(    GetOptions(
# Line 67  sub getoptions { Line 82  sub getoptions {
82    );    );
83  }    }  
84    
85    sub getoptions {
86      my $self = shift;
87      return $self->{opt};
88    }
89    
90    sub setoptions {
91      my $self = shift;
92      my $options = shift;
93      # FIXME: is this really true?
94      $self->{opt} = $options;
95    }
96    
97  sub getoptions_old {  sub getoptions_old {
98    my $self = shift;    my $self = shift;
99    GetOptions(    GetOptions(
# Line 105  sub run { Line 132  sub run {
132    my $self = shift;    my $self = shift;
133    $self->_before_run();    $self->_before_run();
134    $self->prepare();    $self->prepare();
135    $self->tellWhatIAmDoing();    #$self->tellWhatIAmDoing();
136      #$self->_tellWhatIWillDo();
137    $self->sync();    $self->sync();
138  }  }
139    
 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" );  
     
 }  
   
140  sub prepare {  sub prepare {
141    my $self = shift;    my $self = shift;
142    
143      #print Dumper($self->{opt});
144      #exit;
145    
146    # TODO:    # TODO:
147    # - move this to Data::Transfer::Sync::checkOptions!!!    # - move this to Data::Transfer::Sync::checkOptions!!!
148    # - use 'syncable'???    # - use 'syncable'???
# Line 194  sub sync { Line 183  sub sync {
183      # is api-version specified?      # is api-version specified?
184      my $sync_version = $self->{opt}->{sv};      my $sync_version = $self->{opt}->{sv};
185      $sync_version ||= 'V1';      $sync_version ||= 'V1';
186        #$sync_version = 'V2';
187    
188      #print "version: $sync_version", "\n";
189    
190    # create a new synchronization object    # create a new synchronization object
191      my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version );      my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version, __parent => $self );
192    
193    # trace    # trace
194      #print Dumper($self);      #print Dumper($self);
195        #print Dumper($self);
196        #exit;
197    
198      # checks
199        if (!$self->{app}->{storage}->{$self->{opt}->{source}}) {
200          $logger->critical("Sync source storage handle undefined!");
201        }
202        if (!$self->{app}->{storage}->{$self->{opt}->{target}}) {
203          $logger->critical("Sync target storage handle undefined!");
204        }
205    
206    # configure the synchronization-object    # configure the synchronization-object
207      $sync->configure(      $sync->configure(
208        source => {        source => {
209          storage => {          storage => {
210            #handle => $mapiStorage,            #handle => $mapiStorage,
211            handle => $self->{app}->{$self->{opt}->{source}},            handle => $self->{app}->{storage}->{$self->{opt}->{source}},
212            writeProtected => 1,            #isIdentAuthority => $self->{app}->{config}->{{$self->{opt}->{source}},
213              #isChecksumAuthority => 1,
214              #writeProtected => 1,
215          },          },
216        },        },
217        target => {        target => {
218          storage => {          storage => {
219            #handle => $ldapStorage,            #handle => $ldapStorage,
220            handle => $self->{app}->{$self->{opt}->{target}},            handle => $self->{app}->{storage}->{$self->{opt}->{target}},
221            idAuthority => 1,            #idAuthority => 1,
222            isChecksumAuthority => 1,            #isChecksumAuthority => 1,
223            writeProtected => 0,            #isWriteProtected => 0,
224          },          },
225        },        },
226        verbose => 1,        verbose => 1,
227      );      );
228        
229      # TODO:
230    =pod
231      $sync->configure(
232        'source.storage.handle' => ...,
233        'target.storage.handle' => ...,
234      );
235    =cut
236    
237    # trace    # trace
238      #print Dumper($sync);      #print Dumper($sync);

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

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