| 1 |
NAME |
NAME |
| 2 |
Data::Storage - Interface for accessing various Storage implementations |
Data::Storage - Interface for accessing various Storage implementations for Perl in an independent way |
| 3 |
for Perl in an independent way |
|
| 4 |
|
AIMS |
| 5 |
|
- should encapsulate Tangram, DBI, DBD::CSV and LWP:: to access them in an unordinary (more convenient) way ;) |
| 6 |
|
- introduce a generic layered structure, refactor *SUBLAYER*-stuff, make (e.g.) this possible: |
| 7 |
|
Perl Data::Storage[DBD::CSV] -> Perl LWP:: -> Internet HTTP/FTP/* -> Host Daemon -> csv-file |
| 8 |
|
- provide generic synchronization mechanisms across arbitrary/multiple storages based on ident/checksum |
| 9 |
|
maybe it's possible to have schema-, structural- and semantical modifications synchronized??? |
| 10 |
|
|
| 11 |
SYNOPSIS |
SYNOPSIS |
| 12 |
... the basic way: |
BASIC ACCESS |
| 13 |
|
|
| 14 |
|
ADVANCED ACCESS |
| 15 |
|
|
| 16 |
... via inheritance: |
... via inheritance: |
| 17 |
|
|
| 28 |
); |
); |
| 29 |
$self->{storage}->insert($proxyObj); |
$self->{storage}->insert($proxyObj); |
| 30 |
|
|
| 31 |
|
SYNCHRONIZATION |
| 32 |
|
|
| 33 |
|
my $nodemapping = { |
| 34 |
|
'LangText' => 'langtexts.csv', |
| 35 |
|
'Currency' => 'currencies.csv', |
| 36 |
|
'Country' => 'countries.csv', |
| 37 |
|
}; |
| 38 |
|
|
| 39 |
|
my $propmapping = { |
| 40 |
|
'LangText' => [ |
| 41 |
|
[ 'source:lcountrykey' => 'target:country' ], |
| 42 |
|
[ 'source:lkey' => 'target:key' ], |
| 43 |
|
[ 'source:lvalue' => 'target:text' ], |
| 44 |
|
], |
| 45 |
|
'Currency' => [ |
| 46 |
|
[ 'source:ckey' => 'target:key' ], |
| 47 |
|
[ 'source:cname' => 'target:text' ], |
| 48 |
|
], |
| 49 |
|
'Country' => [ |
| 50 |
|
[ 'source:ckey' => 'target:key' ], |
| 51 |
|
[ 'source:cname' => 'target:text' ], |
| 52 |
|
], |
| 53 |
|
}; |
| 54 |
|
|
| 55 |
|
sub syncResource { |
| 56 |
|
|
| 57 |
|
my $self = shift; |
| 58 |
|
my $node_source = shift; |
| 59 |
|
my $mode = shift; |
| 60 |
|
my $opts = shift; |
| 61 |
|
|
| 62 |
|
$mode ||= ''; |
| 63 |
|
$opts->{erase} ||= 0; |
| 64 |
|
|
| 65 |
|
$logger->info( __PACKAGE__ . "->syncResource( node_source $node_source mode $mode erase $opts->{erase} )"); |
| 66 |
|
|
| 67 |
|
# resolve metadata for syncing requested resource |
| 68 |
|
my $node_target = $nodemapping->{$node_source}; |
| 69 |
|
my $mapping = $propmapping->{$node_source}; |
| 70 |
|
|
| 71 |
|
if (!$node_target || !$mapping) { |
| 72 |
|
# loggger.... "no target, sorry!" |
| 73 |
|
print "error while resolving resource metadata", "\n"; |
| 74 |
|
return; |
| 75 |
|
} |
| 76 |
|
|
| 77 |
|
if ($opts->{erase}) { |
| 78 |
|
$self->_erase_all($node_source); |
| 79 |
|
} |
| 80 |
|
|
| 81 |
|
# create new sync object |
| 82 |
|
my $sync = Data::Transfer::Sync->new( |
| 83 |
|
storages => { |
| 84 |
|
L => $self->{bizWorks}->{backend}, |
| 85 |
|
R => $self->{bizWorks}->{resources}, |
| 86 |
|
}, |
| 87 |
|
id_authorities => [qw( L ) ], |
| 88 |
|
checksum_authorities => [qw( L ) ], |
| 89 |
|
write_protected => [qw( R ) ], |
| 90 |
|
verbose => 1, |
| 91 |
|
); |
| 92 |
|
|
| 93 |
|
# sync |
| 94 |
|
# todo: filter!? |
| 95 |
|
$sync->syncNodes( { |
| 96 |
|
direction => $mode, # | +PUSH | +PULL | -FULL | +IMPORT | -EXPORT |
| 97 |
|
method => 'checksum', # | -timestamp | -manual |
| 98 |
|
source => "L:$node_source", |
| 99 |
|
source_ident => 'storage_method:id', |
| 100 |
|
source_exclude => [qw( id cs )], |
| 101 |
|
target => "R:$node_target", |
| 102 |
|
target_ident => 'property:oid', |
| 103 |
|
mapping => $mapping, |
| 104 |
|
} ); |
| 105 |
|
|
| 106 |
|
} |
| 107 |
|
|
| 108 |
NOTE |
NOTE |
| 109 |
|
|
| 110 |
This module heavily relies on DBI and Tangram, but adds a lot of |
This module heavily relies on DBI and Tangram, but adds a lot of additional bugs and quirks. |
| 111 |
additional bugs and quirks. Please look at their documentation and/or |
Please look at their documentation and/or this code for additional information. |
|
this code for additional information. |
|
| 112 |
|
|
| 113 |
REQUIREMENTS |
REQUIREMENTS |
| 114 |
For full functionality: DBI from CPAN Tangram from CPAN Class::Tangram |
For full functionality: |
| 115 |
from CPAN MySQL::Diff from http://adamspiers.org/computing/mysqldiff/ |
DBI from CPAN |
| 116 |
... and all their dependencies |
DBD::mysql from CPAN |
| 117 |
|
Tangram 2.04 from CPAN (hmmm, 2.04 won't do in some cases) |
| 118 |
|
Tangram 2.05 from http://... (2.05 seems okay but there are also additional patches from our side) |
| 119 |
|
Class::Tangram from CPAN |
| 120 |
|
DBD::CSV from CPAN |
| 121 |
|
MySQL::Diff from http://adamspiers.org/computing/mysqldiff/ |
| 122 |
|
... and all their dependencies |
| 123 |
|
|
| 124 |
DESCRIPTION |
DESCRIPTION |
| 125 |
Data::Storage is module for a accessing various "data structures" stored |
Data::Storage |
|
inside various "data containers". It sits on top of DBI and/or Tangram. |
|
| 126 |
|
|
| 127 |
AUTHORS / COPYRIGHT |
Data::Storage is a module for accessing various "data structures / kinds of structured data" stored inside |
| 128 |
The Data::Storage module is Copyright (c) 2002 Andreas Motl. All rights |
various "data containers". |
| 129 |
reserved. |
We tried to use the AdapterPattern (http://c2.com/cgi/wiki?AdapterPattern) to implement a wrapper-layer |
| 130 |
|
around core CPAN modules (Tangram, DBI). |
| 131 |
|
|
| 132 |
|
Why? |
| 133 |
|
|
| 134 |
|
You will get a better code-structure (not bad for later maintenance) in growing Perl code projects, |
| 135 |
|
especially when using multiple database connections at the same time. |
| 136 |
|
You will be able to switch between different _kinds_ of implementations used for storing data. |
| 137 |
|
Your code will use the very same API to access these storage layers. |
| 138 |
|
... implementation has to be changed for now |
| 139 |
|
Maybe you will be able to switch "on-the-fly" without changing any bits in code in the future.... |
| 140 |
|
... but that's not the focus |
| 141 |
|
|
| 142 |
|
What else? |
| 143 |
|
|
| 144 |
You may distribute it under the terms of either the GNU General Public |
Having this, we were able to do implement a generic data synchronization module more easy, |
| 145 |
License or the Artistic License, as specified in the Perl README file. |
please look at Data::Transfer. |
| 146 |
|
|
| 147 |
|
AUTHORS / COPYRIGHT |
| 148 |
|
The Data::Storage module is Copyright (c) 2002 Andreas Motl. |
| 149 |
|
All rights reserved. |
| 150 |
|
You may distribute it under the terms of either the GNU General Public |
| 151 |
|
License or the Artistic License, as specified in the Perl README file. |
| 152 |
|
|
| 153 |
ACKNOWLEDGEMENTS |
ACKNOWLEDGEMENTS |
| 154 |
Larry Wall for Perl, Tim Bunce for DBI, Jean-Louis Leroy for Tangram and |
Larry Wall for Perl, Tim Bunce for DBI, Jean-Louis Leroy for Tangram and Set::Object, |
| 155 |
Set::Object, Sam Vilain for Class::Tangram, Adam Spiers for MySQL::Diff |
Sam Vilain for Class::Tangram, Jochen Wiedmann and Jeff Zucker for DBD::CSV & Co., |
| 156 |
and all contributors. |
Adam Spiers for MySQL::Diff and all contributors. |
| 157 |
|
|
| 158 |
SUPPORT / WARRANTY |
SUPPORT / WARRANTY |
| 159 |
Data::Storage is free software. IT COMES WITHOUT WARRANTY OF ANY KIND. |
Data::Storage is free software. IT COMES WITHOUT WARRANTY OF ANY KIND. |
| 160 |
|
|
| 161 |
TODO |
TODO |
| 162 |
Handle the following errors/cases: |
BUGS |
| 163 |
|
|
| 164 |
"DBI-Error [Tangram]: DBD::mysql::st execute failed: Unknown column 't1.requestdump' in 'field list'" |
"DBI-Error [Tangram]: DBD::mysql::st execute failed: Unknown column |
| 165 |
|
't1.requestdump' in 'field list'" |
| 166 |
|
|
| 167 |
... occours when operating on object-attributes not introduced yet: |
... occours when operating on object-attributes not introduced yet: |
| 168 |
this should be detected and appended/replaced through: |
this should be detected and appended/replaced through: |
| 169 |
"Schema-Error detected, maybe (just) an inconsistency. |
"Schema-Error detected, maybe (just) an inconsistency. |
| 170 |
Please check if your declaration in schema-module "a" matches structure in database "b" or try to run" |
Please check if your declaration in schema-module "a" matches structure in database "b" or try to run" |
| 171 |
db_setup.pl --dbkey=import --action=deploy |
db_setup.pl --dbkey=import --action=deploy |
| 172 |
|
|
| 173 |
Compare schema (structure diff) with database ... |
Compare schema (structure diff) with database ... |
| 174 |
|
|
| 175 |
... when issuing "db_setup.pl --dbkey=import --action=deploy" |
... when issuing "db_setup.pl --dbkey=import --action=deploy" |
| 176 |
on a database with an already deployed schema, use an additional "--update" then |
on a database with an already deployed schema, use an additional "--update" then |
| 198 |
As we can see, creations of Classes and new Class variables is handled |
As we can see, creations of Classes and new Class variables is handled |
| 199 |
automatically and this is believed to be the most common case under normal circumstances. |
automatically and this is believed to be the most common case under normal circumstances. |
| 200 |
|
|
| 201 |
Introduce some features: |
FEATURES |
| 202 |
|
|
| 203 |
- 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. |
| 204 |
- Make it possible to load/save schemas in XMI (XML Metadata Interchange), |
- Make it possible to load/save schemas in XMI (XML Metadata Interchange), |
| 206 |
Integrate/bundle this with a web-/html-based UML modeling tool or |
Integrate/bundle this with a web-/html-based UML modeling tool or |
| 207 |
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) |
| 208 |
- Enable Round Trip Engineering. Keep code and diagrams in sync. Don't annoy/bother the programmers. |
- Enable Round Trip Engineering. Keep code and diagrams in sync. Don't annoy/bother the programmers. |
| 209 |
- Add some more handlers: |
- Add support for some more handlers/locators to be able to |
| 210 |
- look at DBD::CSV, Text::CSV, XML::CSV, XML::Excel |
access the following standards/protocols/interfaces/programs/apis transparently: |
| 211 |
- Add some more locations/locators: |
+ DBD::CSV (via Data::Storage::Handler::DBI) |
| 212 |
- PerlDAV: http://www.webdav.org/perldav/ |
(-) Text::CSV, XML::CSV, XML::Excel |
| 213 |
- Move to t3, use InCASE |
- MAPI |
| 214 |
|
- LDAP |
| 215 |
|
- DAV (look at PerlDAV: http://www.webdav.org/perldav/) |
| 216 |
|
- Mbox (use formail for seperating/splitting entries/nodes) |
| 217 |
|
- Cyrus (cyrdeliver - what about cyrretrieve (export)???) |
| 218 |
|
- use File::DiffTree, use File::Compare |
| 219 |
|
- Hibernate |
| 220 |
|
- "Win32::UserAccountDb" |
| 221 |
|
- "*nix::UserAccountDb" |
| 222 |
|
- .wab - files (Windows Address Book) |
| 223 |
|
- .pst - files (Outlook Post Storage?) |
| 224 |
|
- XML (e.g. via XML::Simple?) |
| 225 |
|
- Move to t3, look at InCASE |
| 226 |
|
- some kind of security layer for methods/objects |
| 227 |
|
- acls (stored via tangram/ldap?) for functions, methods and objects (entity- & data!?) |
| 228 |
|
- where are the hooks needed then? |
| 229 |
|
- is Data::Storage & Co. okay, or do we have to touch the innards of DBI and/or Tangram? |
| 230 |
|
- an attempt to start could be: |
| 231 |
|
- 'sub getACLByObjectId($id, $context)' |
| 232 |
|
- 'sub getACLByMethodname($id, $context)' |
| 233 |
|
- 'sub getACLByName($id, $context)' |
| 234 |
|
( would require a kinda registry to look up these very names pointing to arbitrary locations (code, data, ...) ) |
| 235 |
|
|
| 236 |
Links: |
LINKS / REFERENCES |
| 237 |
|
|
| 238 |
Specs: |
Specs: |
| 239 |
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 |