/[cvs]/nfo/perl/libs/Data/Storage.pm
ViewVC logotype

Diff of /nfo/perl/libs/Data/Storage.pm

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

revision 1.4 by joko, Sun Oct 27 18:35:07 2002 UTC revision 1.7 by joko, Sun Nov 17 06:07:18 2002 UTC
# Line 7  Line 7 
7  #################################  #################################
8  #  #
9  #  $Log$  #  $Log$
10    #  Revision 1.7  2002/11/17 06:07:18  joko
11    #  + creating the handler is easier than proposed first - for now :-)
12    #  + sub testAvailability
13    #
14    #  Revision 1.6  2002/11/09 01:04:58  joko
15    #  + updated pod
16    #
17    #  Revision 1.5  2002/10/29 19:24:18  joko
18    #  - reduced logging
19    #  + added some pod
20    #
21  #  Revision 1.4  2002/10/27 18:35:07  joko  #  Revision 1.4  2002/10/27 18:35:07  joko
22  #  + added pod  #  + added pod
23  #  #
# Line 33  BEGIN { Line 44  BEGIN {
44  $Data::Storage::VERSION = 0.01;  $Data::Storage::VERSION = 0.01;
45  }  }
46    
47    
48  =head1 NAME  =head1 NAME
49    
50  Data::Storage - Interface for accessing various Storage implementations for Perl in an independent way  Data::Storage - Interface for accessing various Storage implementations for Perl in an independent way
# Line 61  Data::Storage - Interface for accessing Line 73  Data::Storage - Interface for accessing
73  =head2 NOTE  =head2 NOTE
74    
75  This module heavily relies on DBI and Tangram, but adds a lot of additional bugs and quirks.  This module heavily relies on DBI and Tangram, but adds a lot of additional bugs and quirks.
76  Please look at their documentation and this code for additional information.  Please look at their documentation and/or this code for additional information.
77    
78    
79    =head1 REQUIREMENTS
80    
81    For full functionality:
82      DBI              from CPAN
83      Tangram          from CPAN
84      Class::Tangram   from CPAN
85      MySQL::Diff      from http://adamspiers.org/computing/mysqldiff/
86      ... and all their dependencies
87    
88  =cut  =cut
89    
90  # The POD text continues at the end of the file.  # The POD text continues at the end of the file.
# Line 75  use strict; Line 96  use strict;
96  use warnings;  use warnings;
97    
98  use Data::Storage::Locator;  use Data::Storage::Locator;
99    use Data::Dumper;
100    
101    # TODO: actually implement level (integrate with Log::Dispatch)
102    my $TRACELEVEL = 0;
103    
104  # get logger instance  # get logger instance
105  my $logger = Log::Dispatch::Config->instance;  my $logger = Log::Dispatch::Config->instance;
# Line 83  sub new { Line 108  sub new {
108    my $invocant = shift;    my $invocant = shift;
109    my $class = ref($invocant) || $invocant;    my $class = ref($invocant) || $invocant;
110    #my @args = normalizeArgs(@_);    #my @args = normalizeArgs(@_);
111      
112    my $arg_locator = shift;    my $arg_locator = shift;
113    my $arg_options = shift;    my $arg_options = shift;
114      
115    #my $self = { STORAGEHANDLE => undef, @_ };    #my $self = { STORAGEHANDLE => undef, @_ };
116    my $self = { STORAGEHANDLE => undef, locator => $arg_locator, options => $arg_options };    my $self = { STORAGEHANDLE => undef, locator => $arg_locator, options => $arg_options };
117    $logger->debug( __PACKAGE__ . "[$self->{locator}->{type}]" . "->new(@_)" );    #$logger->debug( __PACKAGE__ . "[$self->{locator}->{type}]" . "->new(@_)" );
118      $logger->debug( __PACKAGE__ . "[$arg_locator->{type}]" . "->new(@_)" );
119    return bless $self, $class;    return bless $self, $class;
120  }  }
121    
# Line 111  sub AUTOLOAD { Line 137  sub AUTOLOAD {
137    my $method = $AUTOLOAD;    my $method = $AUTOLOAD;
138    $method =~ s/^.*:://;    $method =~ s/^.*:://;
139    
140    # advanced logging of AUTOLOAD calls    # advanced logging of AUTOLOAD calls ...
141      my $logstring = "";    # ... nice but do it only when TRACING (TODO) is enabled
142      $logstring .= __PACKAGE__ . "[$self->{locator}->{type}]" . "->" . $method;      if ($TRACELEVEL) {
143      #print "count: ", $#_, "\n";        my $logstring = "";
144      #$logstring .= Dumper(@_) if ($#_ != -1);        $logstring .= __PACKAGE__ . "[$self->{locator}->{type}]" . "->" . $method;
145      my $tabcount = int( (80 - length($logstring)) / 10 );        #print "count: ", $#_, "\n";
146      $logstring .= "\t" x $tabcount . "(AUTOLOAD)";        #$logstring .= Dumper(@_) if ($#_ != -1);
147      # TODO: only ok if logstring doesn't contain        my $tabcount = int( (80 - length($logstring)) / 10 );
148      #            e.g. "Data::Storage[Tangram]->insert(SystemEvent=HASH(0x5c0034c))          (AUTOLOAD)"        $logstring .= "\t" x $tabcount . "(AUTOLOAD)";
149      # but that would be way too specific as long as we don't have an abstract handler for this  ;)        # TODO: only ok if logstring doesn't contain
150      $logger->debug( $logstring );        #            e.g. "Data::Storage[Tangram]->insert(SystemEvent=HASH(0x5c0034c))          (AUTOLOAD)"
151          # but that would be way too specific as long as we don't have an abstract handler for this  ;)
152          $logger->debug( $logstring );
153          #print join('; ', @_);
154        }
155        
156    # filtering AUTOLOAD calls    # filtering AUTOLOAD calls
157    if ($self->_filter_AUTOLOAD($method)) {    if ($self->_filter_AUTOLOAD($method)) {
158        #print "_accessStorage\n";
159      $self->_accessStorage();      $self->_accessStorage();
160      $self->{STORAGEHANDLE}->$method(@_);      $self->{STORAGEHANDLE}->$method(@_);
161    }    }
# Line 155  sub normalizeArgs { Line 186  sub normalizeArgs {
186  sub _accessStorage {  sub _accessStorage {
187    my $self = shift;    my $self = shift;
188    # TODO: to some tracelevel!    # TODO: to some tracelevel!
189    $logger->debug( __PACKAGE__ .  "[$self->{locator}->{type}]" . "->_accessStorage()" );    if ($TRACELEVEL) {
190        $logger->debug( __PACKAGE__ .  "[$self->{locator}->{type}]" . "->_accessStorage()" );
191      }
192    if (!$self->{STORAGEHANDLE}) {    if (!$self->{STORAGEHANDLE}) {
193      $self->_createStorageHandle();      $self->_createStorageHandle();
194    }    }
# Line 163  sub _accessStorage { Line 196  sub _accessStorage {
196    
197  sub _createStorageHandle {  sub _createStorageHandle {
198    my $self = shift;    my $self = shift;
   
199    my $type = $self->{locator}->{type};    my $type = $self->{locator}->{type};
200    $logger->debug( __PACKAGE__ .  "[$type]" . "->_createStorageHandle()" );    $logger->debug( __PACKAGE__ .  "[$type]" . "->_createStorageHandle()" );
201    
202    my $pkg = "Data::Storage::Handler::" . $type . "";    my $pkg = "Data::Storage::Handler::" . $type . "";
203        
204    # propagate args to handler    # try to load perl module at runtime
205    # needs some more thoughts! (not only "dbi" to Tangram, when (in future) db is not more the common case)    my $evalstr = "use $pkg;";
206    if ($type eq 'DBI') {    eval($evalstr);
207      use Data::Storage::Handler::DBI;    if ($@) {
208      #my @args = %{$self->{locator}->{dbi}};      $logger->error( __PACKAGE__ .  "[$type]" . "->_createStorageHandle(): $@" );
209      my @args = %{$self->{locator}};      return;
     # create new storage handle  
     $self->{STORAGEHANDLE} = $pkg->new( @args );  
   }  
   if ($type eq 'Tangram') {  
     use Data::Storage::Handler::Tangram;  
     #$self->{STORAGEHANDLE} = $pkg->new( dsn => $self->{locator}->{dbi}->{dsn} );  
     #my @args = %{$self->{locator}->{dbi}};  
     my @args = %{$self->{locator}};  
     # create new storage handle  
     $self->{STORAGEHANDLE} = $pkg->new( @args );  
   
     #$self->{STORAGEHANDLE_UNDERLYING} = $self->{STORAGEHANDLE}->getUnderlyingStorage();  
     #$self->{STORAGEHANDLE_UNDERLYING}->_configureCOREHANDLE();  
210    }    }
211        
212      # build up some additional arguments to pass on
213      #my @args = %{$self->{locator}};
214      my @args = ();
215    
216      # create new storage handle object, propagate arguments to handler
217      # pass locator by reference to be able to store status information in it
218      $self->{STORAGEHANDLE} = $pkg->new( locator => $self->{locator}, @args );
219    
220  }  }
221    
222  sub addLogDispatchHandler {  sub addLogDispatchHandler {
# Line 248  sub testDsn { Line 275  sub testDsn {
275      $dbh->disconnect();      $dbh->disconnect();
276      return 1;      return 1;
277    } else {    } else {
278      $logger->error( __PACKAGE__ .  "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr );      $logger->warning( __PACKAGE__ .  "[$self->{locator}->{type}]" . "->testDsn(): " . "DBI-error: " . $DBI::errstr );
279    }    }
280  }  }
281    
282    sub testAvailability {
283      my $self = shift;
284      my $status = $self->testDsn();
285      $self->{locator}->{status}->{available} = $status;
286      return $status;
287    }
288    
289  sub createDb {  sub createDb {
290    my $self = shift;    my $self = shift;
291    my $dsn = $self->{locator}->{dbi}->{dsn};    my $dsn = $self->{locator}->{dbi}->{dsn};
# Line 329  License or the Artistic License, as spec Line 363  License or the Artistic License, as spec
363    
364  =head1 ACKNOWLEDGEMENTS  =head1 ACKNOWLEDGEMENTS
365    
366  Larry Wall and the C<perl5-porters> for Perl,  Larry Wall for Perl, Tim Bunce for DBI, Jean-Louis Leroy for Tangram and Set::Object,
367  Tim Bunce for DBI, Jean-Louis Leroy for Tangram and Set::Object,  Sam Vilain for Class::Tangram, Adam Spiers for MySQL::Diff and all contributors.
 Sam Vilain for Class::Tangram.  
368    
369    
370  =head1 SUPPORT / WARRANTY  =head1 SUPPORT / WARRANTY
# Line 373  Data::Storage is free software. IT COMES Line 406  Data::Storage is free software. IT COMES
406      R retrieve  ->  no, not subject of this aspect since it is about deployment only      R retrieve  ->  no, not subject of this aspect since it is about deployment only
407      U update    ->  yes, just by user-interaction; maybe automatically if it can be determined that data wouldn't be lost      U update    ->  yes, just by user-interaction; maybe automatically if it can be determined that data wouldn't be lost
408      D delete    ->  yes, just by user-interaction      D delete    ->  yes, just by user-interaction
409    It's all about not to be able to loose data simply while this is in alpha stage.    
410      It's all about not to be able to loose data simply while this is in pre-alpha stage.
411      And loosing data by being able to modify and redeploy schemas easily is definitely quite easy.
412      
413      As we can see, creations of Classes and new Class variables is handled
414      automatically and this is believed to be the most common case under normal circumstances.
415    
416    
417  =head2 Introduce some features:  =head2 Introduce some features:
418    
419    Get this stuff together with UML (Unified Modeling Language) and/or standards from ODMG.    - Get this stuff together with UML (Unified Modeling Language) and/or standards from ODMG.
420    Make it possible to load/save schemas in XMI (XML Metadata Interchange),    - Make it possible to load/save schemas in XMI (XML Metadata Interchange),
421    which seems to be most commonly used today, perhaps handle objects with OIFML.      which seems to be most commonly used today, perhaps handle objects with OIFML.
422    Integrate/bundle this with a web-/html-based UML modeling tool or      Integrate/bundle this with a web-/html-based UML modeling tool or
423    some other interesting stuff like the "Co-operative UML Editor" from Uni Darmstadt. (web-/java-based)      some other interesting stuff like the "Co-operative UML Editor" from Uni Darmstadt. (web-/java-based)
424    Enable Round Trip Engineering. Keep code and diagrams in sync. Don't annoy/bother the programmer.    - Enable Round Trip Engineering. Keep code and diagrams in sync. Don't annoy/bother the programmers.
425      - Add some more handlers:
426        - look at DBD::CSV, Text::CSV, XML::CSV, XML::Excel
427      - Add some more locations/locators:
428        - PerlDAV: http://www.webdav.org/perldav/
429      - Move to t3, use InCASE
430    
431    
432  =head3 Links:  =head3 Links:
433    
434      Specs:
435      UML 1.3 Spec: http://cgi.omg.org/cgi-bin/doc?ad/99-06-08.pdf      UML 1.3 Spec: http://cgi.omg.org/cgi-bin/doc?ad/99-06-08.pdf
436      XMI 1.1 Spec: http://cgi.omg.org/cgi-bin/doc?ad/99-10-02.pdf      XMI 1.1 Spec: http://cgi.omg.org/cgi-bin/doc?ad/99-10-02.pdf
437      XMI 2.0 Spec: http://cgi.omg.org/docs/ad/01-06-12.pdf      XMI 2.0 Spec: http://cgi.omg.org/docs/ad/01-06-12.pdf
438      ODMG: http://odmg.org/      ODMG: http://odmg.org/
439      OIFML: http://odmg.org/library/readingroom/oifml.pdf      OIFML: http://odmg.org/library/readingroom/oifml.pdf
     Co-operative UML Editor: http://www.darmstadt.gmd.de/concert/activities/internal/umledit.html  
440    
441    further readings:    CASE Tools:
442        Rational Rose (commercial): http://www.rational.com/products/rose/
443        Together (commercial): http://www.oi.com/products/controlcenter/index.jsp
444        InCASE - Tangram-based Universal Object Editor
445        Sybase PowerDesigner: http://www.sybase.com/powerdesigner
446      
447      UML Editors:
448        Fujaba (free, university): http://www.fujaba.de/
449        ArgoUML (free): http://argouml.tigris.org/
450        Poseidon (commercial): http://www.gentleware.com/products/poseidonDE.php3
451        Co-operative UML Editor (research): http://www.darmstadt.gmd.de/concert/activities/internal/umledit.html
452        Metamill (commercial): http://www.metamill.com/
453        Violet (university, research, education): http://www.horstmann.com/violet/
454        PyUt (free): http://pyut.sourceforge.net/
455        (Dia (free): http://www.lysator.liu.se/~alla/dia/)
456        UMLet (free, university): http://www.swt.tuwien.ac.at/umlet/index.html
457        Voodoo (free): http://voodoo.sourceforge.net/
458        Umbrello UML Modeller: http://uml.sourceforge.net/
459    
460      UML Tools:
461        http://www.objectsbydesign.com/tools/umltools_byPrice.html
462    
463      Further readings:
464      http://www.google.com/search?q=web+based+uml+editor&hl=en&lr=&ie=UTF-8&oe=UTF-8&start=10&sa=N      http://www.google.com/search?q=web+based+uml+editor&hl=en&lr=&ie=UTF-8&oe=UTF-8&start=10&sa=N
465      http://www.fernuni-hagen.de/DVT/Aktuelles/01FHHeidelberg.pdf      http://www.fernuni-hagen.de/DVT/Aktuelles/01FHHeidelberg.pdf
466      http://www.enhyper.com/src/documentation/      http://www.enhyper.com/src/documentation/
# Line 403  Data::Storage is free software. IT COMES Line 468  Data::Storage is free software. IT COMES
468      http://citeseer.nj.nec.com/vilain00diagrammatic.html      http://citeseer.nj.nec.com/vilain00diagrammatic.html
469      http://archive.devx.com/uml/articles/Smith01/Smith01-3.asp      http://archive.devx.com/uml/articles/Smith01/Smith01-3.asp
470    
   maybe useful for / to be integrated with:  
     ArapXML: http://xml.coverpages.org/ni2001-09-24-b.html  

Legend:
Removed from v.1.4  
changed lines
  Added in v.1.7

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