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