--- /dev/null
+<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
+<HTML>
+<HEAD>
+ <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
+ <TITLE></TITLE>
+ <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1Beta (Win32)">
+ <META NAME="CREATED" CONTENT="20030628;15450300">
+ <META NAME="CHANGED" CONTENT="20030703;16152310">
+ <STYLE>
+ <!--
+ @page { size: 21.59cm 27.94cm; margin: 2cm }
+ P { margin-bottom: 0.21cm }
+ H3 { margin-bottom: 0.21cm }
+ H3.western { font-family: "Arial", sans-serif }
+ H3.cjk { font-family: "MS Mincho" }
+ -->
+ </STYLE>
+</HEAD>
+<BODY LANG="" DIR="LTR">
+Author: jparrai<br>
+Date: 28-06-2003<br>
+Subject: Highlights of the structure of data in Quantum.<br>
+<H3 CLASS="western">Quantum program data structure</H3>
+<P>After loading the Quantum plug-in, the saved-state file (an xml file) is loaded
+ up. Bookmarks are loaded into the <font face="Courier New, Courier, mono">BookmarkContentProvider
+ </font>and the <font face="Courier New, Courier, mono">SubsetContentProvider</font>
+ classes, where they are stored in the form of a vector of <font face="Courier New, Courier, mono">BookmarkNode</font>
+ and SubsetNode respectively.</P>
+<P>A <font face="Courier New, Courier, mono">SubsetNode</font> has a number of
+ children, objects of class <font face="Courier New, Courier, mono">ObjectNode</font>.
+ Each <font face="Courier New, Courier, mono">ObjectNode</font> has an <font face="Courier New, Courier, mono">ObjectMetaData</font>
+ instance that will hold the metadata (columns names, sizes and that stuff) of
+ the table or view that it (the <font face="Courier New, Courier, mono">ObjectNode</font>)
+ references. That metadata is loaded from the saved-state file also on load-up
+ of the plug-in (three hypen-words in a single-sentence, wow! :)</P>
+<P>A <font face="Courier New, Courier, mono">BookmarkNode</font> represents a
+ connection with a database. It will be displayed by the <font face="Courier New, Courier, mono">BookmarView</font>
+ view. When you double-click on one of the bookmarks, the function <font face="Courier New, Courier, mono">MultiSQLServer.connect(current)</font>
+ willl be called. <font face="Courier New, Courier, mono">MultiSQLServer</font>
+ is a Singleton (a class that will have a single instance), so we can get the
+ instance of it with <font face="Courier New, Courier, mono">MultiSQLServer.getInstance()</font>.</P>
+<P>The <font face="Courier New, Courier, mono">connect()</font> function will
+ use the JDBC driver and connect to the database. After that, the BookmarkNode
+ will have its <font face="Courier New, Courier, mono">con</font> member assigned
+ (not null). After the connection, the function that is answering your double-clicking
+ (<font face="Courier New, Courier, mono">ConnectAction.run()</font>), will try
+ to get the tables, views, etc from that connection. To do that, it will call
+ <font face="Courier New, Courier, mono">BookmarkView.refreshBookmarkData()</font>,
+ that will query the database. As the procedure to get the tables may be different
+ for each database, the actual querying is delegated to another class <font face="Courier New, Courier, mono">SQLHelper</font>,
+ that will centralize that kind of procedures (the ones that depend on the type
+ of the database). The called function in this case is <font face="Courier New, Courier, mono">getTableList()</font>.
+ <font face="Courier New, Courier, mono">SQLHelper</font> is not a Singleton,
+ although it could be, but we don't really need an instance because the functions
+ are all static.</P>
+<P>The <font face="Courier New, Courier, mono">getTableList()</font> will try
+ to get the tables from the function <font face="Courier New, Courier, mono">MultiSQLServer.listTables()</font>,
+ if the jdbc adapter of the bookmark is generic. listTables will ask the jdbc
+ driver directly for the list of tables, using the <font face="Courier New, Courier, mono">DatabaseMetadata.getTables()
+ </font>call. If the adapter is not generic, it will use a SQL statement to get
+ the list of table names. This SQL statement will be of course different in every
+ database, so it will come from the <font face="Courier New, Courier, mono">DatabaseAdapter</font>
+ class. </P>
+<P>The <font face="Courier New, Courier, mono">DatabaseAdapter</font> class is
+ the one where you should put all the functions that will be different for each
+ database. Then for each database, you create an "adapter" class derived
+ from <font face="Courier New, Courier, mono">DatabaseAdapter</font>, and implement
+ all the necessary abstract functions. So you get a proper adapter using <font face="Courier New, Courier, mono">DatabaseAdapter
+ adapter = AdapterFactory.getInstance().getAdapter(current.getType())</font>,
+ and the returned adapter will have the proper type (always a derived type from
+ <font face="Courier New, Courier, mono">DatabaseAdapter</font>). Then calls
+ to the adapter object will be redirected to the proper function.</P>
+<P>The <font face="Courier New, Courier, mono">TableNode</font> objects generated
+ will have metadata, i.e. columns. That information is saved in an object of
+ class <font face="Courier New, Courier, mono">ObjectMetaData</font> in the TableNode
+ object. This ObjectMetaData class is part of the metadata package, that has
+ basically four classes:</P>
+<P><font face="Courier New, Courier, mono">MetaDataJDBCInterface</font> : Basically
+ takes care (through static functions) of passing the metadata from the jdbc
+ driver to the ObjectMetadata class.</P>
+<P><font face="Courier New, Courier, mono">MetaDataXMLInterface</font> : Handles
+ interface between an ObjectMetaData and XML storage. It can write an existing
+ metadata object to XML and generate a new ObjectMetaData from existing XML.</P>
+<P><font face="Courier New, Courier, mono">ObjectMetaData</font> : The class that
+ has all the metadata. Rather underdeveloped, one must add functions as needed.
+ The metadata is saved in the form of StringMatrix objects.</P>
+<P><font face="Courier New, Courier, mono">StringMatrix</font> : A matrix of strings.
+ Saves the results from the jdbc driver, usually given as ResultSet objects,
+ that are very similar in structure but sequential in nature (you access the
+ records one at a time). The first line of the matrix are the names of the columns,
+ and the rest hold the values.</P>
+<P> </P>
+<P><img src="structure.gif" width="749" height="313"></P>
+<P><br>
+</P>
+<P> </P>
+</BODY>
+</HTML>
\ No newline at end of file