1 |
joko |
1.1 |
=pod |
2 |
|
|
|
3 |
|
|
|
4 |
|
|
=head1 NAME |
5 |
|
|
|
6 |
|
|
Data::Storage - Interface for accessing various Storage implementations for Perl in an independent way |
7 |
|
|
|
8 |
|
|
|
9 |
|
|
=head1 AIMS |
10 |
|
|
|
11 |
|
|
- should encapsulate Tangram, DBI, DBD::CSV and LWP:: to access them in an unordinary (more convenient) way ;) |
12 |
|
|
- introduce a generic layered structure, refactor *SUBLAYER*-stuff, make (e.g.) this possible: |
13 |
|
|
Perl Data::Storage[DBD::CSV] -> Perl LWP:: -> Internet HTTP/FTP/* -> Host Daemon -> csv-file |
14 |
|
|
- provide generic synchronization mechanisms across arbitrary/multiple storages based on ident/checksum |
15 |
|
|
maybe it's possible to have schema-, structural- and semantical modifications synchronized??? |
16 |
|
|
|
17 |
|
|
|
18 |
|
|
=head1 SYNOPSIS |
19 |
|
|
|
20 |
joko |
1.2 |
=head2 ACCESS |
21 |
joko |
1.1 |
|
22 |
joko |
1.2 |
# connect to LDAP |
23 |
|
|
my $ldapLocator = Data::Storage::Locator->new( |
24 |
|
|
ldap => { |
25 |
|
|
type => "NetLDAP", |
26 |
|
|
dsn => "ldap:host=192.168.10.150;binddn='cn=root, o=netfrag.org, c=de';pass=secret", |
27 |
|
|
basedn => "o=netfrag.org, c=de", |
28 |
|
|
want_transactions => 0, |
29 |
|
|
syncable => 1, |
30 |
|
|
}, |
31 |
|
|
); |
32 |
|
|
my $ldapStorage = Data::Storage->new($ldapLocator); |
33 |
|
|
$ldapStorage->connect(); |
34 |
|
|
|
35 |
|
|
# connect to MAPI |
36 |
|
|
my $mapiLocator = Data::Storage::Locator->new( |
37 |
|
|
outlook => { |
38 |
|
|
type => "MAPI", |
39 |
|
|
showProfileChooser => $self->{config}->get("mapi_showProfileChooser"), |
40 |
|
|
ProfileName => $self->{config}->get("mapi_ProfileName"), |
41 |
|
|
ProfilePass => $self->{config}->get("mapi_ProfilePass"), |
42 |
|
|
syncable => 1, |
43 |
|
|
}, |
44 |
|
|
); |
45 |
|
|
my $mapiStorage = Data::Storage->new($mapiLocator); |
46 |
|
|
$mapiStorage->connect(); |
47 |
joko |
1.1 |
|
48 |
|
|
|
49 |
joko |
1.2 |
=head2 SYNCHRONIZATION |
50 |
|
|
|
51 |
|
|
This functionality is (in the meanwhile) provided by the Data::Transfer::Sync module. |
52 |
joko |
1.1 |
|
53 |
joko |
1.2 |
=head3 proposal V1 |
54 |
joko |
1.1 |
|
55 |
|
|
my $nodemapping = { |
56 |
|
|
'LangText' => 'langtexts.csv', |
57 |
|
|
'Currency' => 'currencies.csv', |
58 |
|
|
'Country' => 'countries.csv', |
59 |
|
|
}; |
60 |
|
|
|
61 |
|
|
my $propmapping = { |
62 |
|
|
'LangText' => [ |
63 |
|
|
[ 'source:lcountrykey' => 'target:country' ], |
64 |
|
|
[ 'source:lkey' => 'target:key' ], |
65 |
|
|
[ 'source:lvalue' => 'target:text' ], |
66 |
|
|
], |
67 |
|
|
'Currency' => [ |
68 |
|
|
[ 'source:ckey' => 'target:key' ], |
69 |
|
|
[ 'source:cname' => 'target:text' ], |
70 |
|
|
], |
71 |
|
|
'Country' => [ |
72 |
|
|
[ 'source:ckey' => 'target:key' ], |
73 |
|
|
[ 'source:cname' => 'target:text' ], |
74 |
|
|
], |
75 |
|
|
}; |
76 |
|
|
|
77 |
|
|
s ub syncResource { |
78 |
|
|
|
79 |
|
|
my $self = shift; |
80 |
|
|
my $node_source = shift; |
81 |
|
|
my $mode = shift; |
82 |
|
|
my $opts = shift; |
83 |
|
|
|
84 |
|
|
$mode ||= ''; |
85 |
|
|
$opts->{erase} ||= 0; |
86 |
|
|
|
87 |
|
|
$logger->info( __PACKAGE__ . "->syncResource( node_source $node_source mode $mode erase $opts->{erase} )"); |
88 |
|
|
|
89 |
|
|
# resolve metadata for syncing requested resource |
90 |
|
|
my $node_target = $nodemapping->{$node_source}; |
91 |
|
|
my $mapping = $propmapping->{$node_source}; |
92 |
|
|
|
93 |
|
|
if (!$node_target || !$mapping) { |
94 |
|
|
# loggger.... "no target, sorry!" |
95 |
|
|
print "error while resolving resource metadata", "\n"; |
96 |
|
|
return; |
97 |
|
|
} |
98 |
|
|
|
99 |
|
|
if ($opts->{erase}) { |
100 |
|
|
$self->_erase_all($node_source); |
101 |
|
|
} |
102 |
|
|
|
103 |
|
|
# create new sync object |
104 |
|
|
my $sync = Data::Transfer::Sync->new( |
105 |
|
|
storages => { |
106 |
joko |
1.2 |
L => $self->{storage}->{backend}, |
107 |
|
|
R => $self->{storage}->{resources}, |
108 |
joko |
1.1 |
}, |
109 |
|
|
id_authorities => [qw( L ) ], |
110 |
|
|
checksum_authorities => [qw( L ) ], |
111 |
|
|
write_protected => [qw( R ) ], |
112 |
|
|
verbose => 1, |
113 |
|
|
); |
114 |
|
|
|
115 |
|
|
# sync |
116 |
|
|
# todo: filter!? |
117 |
|
|
$sync->syncNodes( { |
118 |
|
|
direction => $mode, # | +PUSH | +PULL | -FULL | +IMPORT | -EXPORT |
119 |
|
|
method => 'checksum', # | -timestamp | -manual |
120 |
|
|
source => "L:$node_source", |
121 |
|
|
source_ident => 'storage_method:id', |
122 |
|
|
source_exclude => [qw( id cs )], |
123 |
|
|
target => "R:$node_target", |
124 |
|
|
target_ident => 'property:oid', |
125 |
|
|
mapping => $mapping, |
126 |
|
|
} ); |
127 |
|
|
|
128 |
|
|
} |
129 |
joko |
1.2 |
|
130 |
|
|
=head3 proposal V2 |
131 |
|
|
|
132 |
|
|
# create a new synchronization object |
133 |
|
|
my $sync = Data::Transfer::Sync->new( 'sync_version' => $sync_version, __parent => $self ); |
134 |
|
|
|
135 |
|
|
# configure the synchronization-object |
136 |
|
|
$sync->configure( |
137 |
|
|
source => { |
138 |
|
|
storage => { |
139 |
|
|
handle => $mapiStorage, |
140 |
|
|
#isIdentAuthority => 1, |
141 |
|
|
#isChecksumAuthority => 1, |
142 |
|
|
#writeProtected => 1, |
143 |
|
|
}, |
144 |
|
|
}, |
145 |
|
|
target => { |
146 |
|
|
storage => { |
147 |
|
|
handle => $ldapStorage, |
148 |
|
|
#idAuthority => 1, |
149 |
|
|
#isChecksumAuthority => 1, |
150 |
|
|
#isWriteProtected => 0, |
151 |
|
|
}, |
152 |
|
|
}, |
153 |
|
|
verbose => 1, |
154 |
|
|
); |
155 |
joko |
1.1 |
|
156 |
|
|
|
157 |
|
|
=head2 NOTE |
158 |
|
|
|
159 |
|
|
This module heavily relies on DBI and Tangram, but adds a lot of additional bugs and quirks. |
160 |
|
|
Please look at their documentation and/or this code for additional information. |
161 |
|
|
|
162 |
|
|
|
163 |
|
|
=head1 REQUIREMENTS |
164 |
|
|
|
165 |
|
|
For full functionality: |
166 |
|
|
DBI from CPAN |
167 |
|
|
DBD::mysql from CPAN |
168 |
|
|
Tangram 2.04 from CPAN (hmmm, 2.04 won't do in some cases) |
169 |
|
|
Tangram 2.05 from http://... (2.05 seems okay but there are also additional patches from our side) |
170 |
|
|
Class::Tangram from CPAN |
171 |
|
|
DBD::CSV from CPAN |
172 |
|
|
MySQL::Diff from http://adamspiers.org/computing/mysqldiff/ |
173 |
|
|
... and all their dependencies |
174 |
|
|
|
175 |
|
|
|
176 |
|
|
=head1 DESCRIPTION |
177 |
|
|
|
178 |
|
|
=head2 Data::Storage |
179 |
|
|
|
180 |
|
|
Data::Storage is a module for accessing various "data structures / kinds of structured data" stored inside |
181 |
|
|
various "data containers". |
182 |
|
|
We tried to use the AdapterPattern to implement a wrapper-layer around known CPAN modules. |
183 |
|
|
(e.g. DBI, Tangram, XML::Simple) |
184 |
|
|
References: |
185 |
|
|
- http://c2.com/cgi/wiki?AdapterPattern |
186 |
|
|
- http://home.earthlink.net/~huston2/dp/adapter.html |
187 |
|
|
|
188 |
|
|
=head2 Why? |
189 |
|
|
|
190 |
|
|
You will get a better code-structure (not bad for later maintenance) in growing Perl code projects, |
191 |
|
|
especially when using multiple database connections at the same time. |
192 |
|
|
You will be able to switch between different _kinds_ of implementations used for storing data. |
193 |
|
|
Your code will use the very same API to access these storage layers. |
194 |
|
|
... implementation has to be changed for now |
195 |
|
|
Maybe you will be able to switch "on-the-fly" without changing any bits in code in the future.... |
196 |
|
|
... but that's not the focus |
197 |
|
|
|
198 |
|
|
=head2 What else? |
199 |
|
|
|
200 |
|
|
Having this, we were able to do implement a generic data synchronization module more easy, |
201 |
|
|
please look at Data::Transfer. |
202 |
|
|
|
203 |
|
|
|
204 |
|
|
=head1 AUTHORS / COPYRIGHT |
205 |
|
|
|
206 |
|
|
The Data::Storage module is Copyright (c) 2002 Andreas Motl. |
207 |
|
|
All rights reserved. |
208 |
|
|
You may distribute it under the terms of either the GNU General Public |
209 |
|
|
License or the Artistic License, as specified in the Perl README file. |
210 |
|
|
|
211 |
|
|
|
212 |
|
|
=head1 ACKNOWLEDGEMENTS |
213 |
|
|
|
214 |
|
|
Larry Wall for Perl, Tim Bunce for DBI, Jean-Louis Leroy for Tangram and Set::Object, |
215 |
|
|
Sam Vilain for Class::Tangram, Jochen Wiedmann and Jeff Zucker for DBD::CSV & Co., |
216 |
|
|
Adam Spiers for MySQL::Diff and all contributors. |
217 |
|
|
|
218 |
|
|
|
219 |
|
|
=head1 SUPPORT / WARRANTY |
220 |
|
|
|
221 |
|
|
Data::Storage is free software. IT COMES WITHOUT WARRANTY OF ANY KIND. |
222 |
|
|
|
223 |
|
|
|
224 |
|
|
=head1 TODO |
225 |
|
|
|
226 |
|
|
|
227 |
|
|
=head2 BUGS |
228 |
|
|
|
229 |
|
|
"DBI-Error [Tangram]: DBD::mysql::st execute failed: Unknown column 't1.requestdump' in 'field list'" |
230 |
|
|
|
231 |
|
|
... occours when operating on object-attributes not introduced yet: |
232 |
|
|
this should be detected and appended/replaced through: |
233 |
|
|
"Schema-Error detected, maybe (just) an inconsistency. |
234 |
|
|
Please check if your declaration in schema-module "a" matches structure in database "b" or try to run" |
235 |
|
|
db_setup.pl --dbkey=import --action=deploy |
236 |
|
|
|
237 |
|
|
|
238 |
|
|
Compare schema (structure diff) with database ... |
239 |
|
|
|
240 |
|
|
... when issuing "db_setup.pl --dbkey=import --action=deploy" |
241 |
|
|
on a database with an already deployed schema, use an additional "--update" then |
242 |
|
|
to lift the schema inside the database to the current declared schema. |
243 |
|
|
You will have to approve removals and changes on field-level while |
244 |
|
|
new objects and new fields are introduced silently without any interaction needed. |
245 |
|
|
In future versions there may be additional options to control silent processing of |
246 |
|
|
removals and changes. |
247 |
|
|
See this CRUD-table applying to the actions occouring on Classes and Class variables when deploying schemas, |
248 |
|
|
don't mix this up with CRUD-actions on Objects, these are already handled by (e.g.) Tangram itself. |
249 |
|
|
Classes: |
250 |
|
|
C create -> yes, handled automatically |
251 |
|
|
R retrieve -> no, not subject of this aspect since it is about deployment only |
252 |
|
|
U update -> yes, automatically for Class meta-attributes, yes/no for Class variables (look at the rules down here) |
253 |
|
|
D delete -> yes, just by user-interaction |
254 |
|
|
Class variables: |
255 |
|
|
C create -> yes, handled automatically |
256 |
|
|
R retrieve -> no, not subject of this aspect since it is about deployment only |
257 |
|
|
U update -> yes, just by user-interaction; maybe automatically if it can be determined that data wouldn't be lost |
258 |
|
|
D delete -> yes, just by user-interaction |
259 |
|
|
|
260 |
|
|
It's all about not to be able to loose data simply while this is in pre-alpha stage. |
261 |
|
|
And loosing data by being able to modify and redeploy schemas easily is definitely quite easy. |
262 |
|
|
|
263 |
|
|
As we can see, creations of Classes and new Class variables is handled |
264 |
|
|
automatically and this is believed to be the most common case under normal circumstances. |
265 |
|
|
|
266 |
|
|
|
267 |
|
|
=head2 FEATURES |
268 |
|
|
|
269 |
|
|
- Get this stuff together with UML (Unified Modeling Language) and/or standards from ODMG. |
270 |
|
|
- Make it possible to load/save schemas in XMI (XML Metadata Interchange), |
271 |
|
|
which seems to be most commonly used today, perhaps handle objects with OIFML. |
272 |
|
|
Integrate/bundle this with a web-/html-based UML modeling tool or |
273 |
|
|
some other interesting stuff like the "Co-operative UML Editor" from Uni Darmstadt. (web-/java-based) |
274 |
|
|
- Enable Round Trip Engineering. Keep code and diagrams in sync. Don't annoy/bother the programmers. |
275 |
|
|
- Add support for some more handlers/locators to be able to |
276 |
|
|
access the following standards/protocols/interfaces/programs/apis transparently: |
277 |
|
|
+ DBD::CSV (via Data::Storage::Handler::DBI) |
278 |
|
|
(-) Text::CSV, XML::CSV, XML::Excel |
279 |
|
|
- MAPI |
280 |
|
|
- LDAP |
281 |
|
|
- DAV (look at PerlDAV: http://www.webdav.org/perldav/) |
282 |
|
|
- Mbox (use formail for seperating/splitting entries/nodes) |
283 |
|
|
- Cyrus (cyrdeliver - what about cyrretrieve (export)???) |
284 |
|
|
- use File::DiffTree, use File::Compare |
285 |
|
|
- Hibernate |
286 |
|
|
- "Win32::UserAccountDb" |
287 |
|
|
- "*nix::UserAccountDb" |
288 |
|
|
- .wab - files (Windows Address Book) |
289 |
|
|
- .pst - files (Outlook Post Storage?) |
290 |
|
|
- XML (e.g. via XML::Simple?) |
291 |
|
|
- Move to t3, look at InCASE |
292 |
|
|
- some kind of security layer for methods/objects |
293 |
|
|
- acls (stored via tangram/ldap?) for functions, methods and objects (entity- & data!?) |
294 |
|
|
- where are the hooks needed then? |
295 |
|
|
- is Data::Storage & Co. okay, or do we have to touch the innards of DBI and/or Tangram? |
296 |
|
|
- an attempt to start could be: |
297 |
|
|
- 'sub getACLByObjectId($id, $context)' |
298 |
|
|
- 'sub getACLByMethodname($id, $context)' |
299 |
|
|
- 'sub getACLByName($id, $context)' |
300 |
|
|
( would require a kinda registry to look up these very names pointing to arbitrary locations (code, data, ...) ) |
301 |
|
|
- add more hooks and various levels |
302 |
|
|
- better integrate introduced 'getObjectByGuid'-mechanism from Data::Storage::Handler::Tangram |
303 |
|
|
|
304 |
|
|
|
305 |
|
|
=head3 LINKS / REFERENCES |
306 |
|
|
|
307 |
|
|
Specs: |
308 |
|
|
UML 1.3 Spec: http://cgi.omg.org/cgi-bin/doc?ad/99-06-08.pdf |
309 |
|
|
XMI 1.1 Spec: http://cgi.omg.org/cgi-bin/doc?ad/99-10-02.pdf |
310 |
|
|
XMI 2.0 Spec: http://cgi.omg.org/docs/ad/01-06-12.pdf |
311 |
|
|
ODMG: http://odmg.org/ |
312 |
|
|
OIFML: http://odmg.org/library/readingroom/oifml.pdf |
313 |
|
|
|
314 |
|
|
CASE Tools: |
315 |
|
|
Rational Rose (commercial): http://www.rational.com/products/rose/ |
316 |
|
|
Together (commercial): http://www.oi.com/products/controlcenter/index.jsp |
317 |
|
|
InCASE - Tangram-based Universal Object Editor |
318 |
|
|
Sybase PowerDesigner: http://www.sybase.com/powerdesigner |
319 |
|
|
|
320 |
|
|
UML Editors: |
321 |
|
|
Fujaba (free, university): http://www.fujaba.de/ |
322 |
|
|
ArgoUML (free): http://argouml.tigris.org/ |
323 |
|
|
Poseidon (commercial): http://www.gentleware.com/products/poseidonDE.php3 |
324 |
|
|
Co-operative UML Editor (research): http://www.darmstadt.gmd.de/concert/activities/internal/umledit.html |
325 |
|
|
Metamill (commercial): http://www.metamill.com/ |
326 |
|
|
Violet (university, research, education): http://www.horstmann.com/violet/ |
327 |
|
|
PyUt (free): http://pyut.sourceforge.net/ |
328 |
|
|
(Dia (free): http://www.lysator.liu.se/~alla/dia/) |
329 |
|
|
UMLet (free, university): http://www.swt.tuwien.ac.at/umlet/index.html |
330 |
|
|
Voodoo (free): http://voodoo.sourceforge.net/ |
331 |
|
|
Umbrello UML Modeller: http://uml.sourceforge.net/ |
332 |
|
|
|
333 |
|
|
UML Tools: |
334 |
|
|
http://www.objectsbydesign.com/tools/umltools_byPrice.html |
335 |
|
|
|
336 |
|
|
Further readings: |
337 |
|
|
http://www.google.com/search?q=web+based+uml+editor&hl=en&lr=&ie=UTF-8&oe=UTF-8&start=10&sa=N |
338 |
|
|
http://www.fernuni-hagen.de/DVT/Aktuelles/01FHHeidelberg.pdf |
339 |
|
|
http://www.enhyper.com/src/documentation/ |
340 |
|
|
http://cis.cs.tu-berlin.de/Dokumente/Diplomarbeiten/2001/skinner.pdf |
341 |
|
|
http://citeseer.nj.nec.com/vilain00diagrammatic.html |
342 |
|
|
http://archive.devx.com/uml/articles/Smith01/Smith01-3.asp |
343 |
|
|
|
344 |
|
|
|
345 |
|
|
=cut |
346 |
|
|
|