1 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
 
   4         <META HTTP-EQUIV="CONTENT-TYPE" CONTENT="text/html; charset=windows-1252">
 
   6         <META NAME="GENERATOR" CONTENT="OpenOffice.org 1.1Beta  (Win32)">
 
   7         <META NAME="CREATED" CONTENT="20030628;15450300">
 
   8         <META NAME="CHANGED" CONTENT="20030703;16152310">
 
  11                 @page { size: 21.59cm 27.94cm; margin: 2cm }
 
  12                 P { margin-bottom: 0.21cm }
 
  13                 H3 { margin-bottom: 0.21cm }
 
  14                 H3.western { font-family: "Arial", sans-serif }
 
  15                 H3.cjk { font-family: "MS Mincho" }
 
  19 <BODY LANG="" DIR="LTR">
 
  22 Subject: Highlights of the structure of data in Quantum.<br>
 
  23 <H3 CLASS="western">Quantum program data structure</H3>
 
  24 <P>After loading the Quantum plug-in, the saved-state file (an xml file) is loaded 
 
  25   up. Bookmarks are loaded into the <font face="Courier New, Courier, mono">BookmarkContentProvider 
 
  26   </font>and the <font face="Courier New, Courier, mono">SubsetContentProvider</font> 
 
  27   classes, where they are stored in the form of a vector of <font face="Courier New, Courier, mono">BookmarkNode</font> 
 
  28   and SubsetNode respectively.</P>
 
  29 <P>A <font face="Courier New, Courier, mono">SubsetNode</font> has a number of 
 
  30   children, objects of class <font face="Courier New, Courier, mono">ObjectNode</font>. 
 
  31   Each <font face="Courier New, Courier, mono">ObjectNode</font> has an <font face="Courier New, Courier, mono">ObjectMetaData</font> 
 
  32   instance that will hold the metadata (columns names, sizes and that stuff) of 
 
  33   the table or view that it (the <font face="Courier New, Courier, mono">ObjectNode</font>) 
 
  34   references. That metadata is loaded from the saved-state file also on load-up 
 
  35   of the plug-in (three hypen-words in a single-sentence, wow! :)</P>
 
  36 <P>A <font face="Courier New, Courier, mono">BookmarkNode</font> represents a 
 
  37   connection with a database. It will be displayed by the <font face="Courier New, Courier, mono">BookmarView</font> 
 
  38   view. When you double-click on one of the bookmarks, the function <font face="Courier New, Courier, mono">MultiSQLServer.connect(current)</font> 
 
  39   willl be called. <font face="Courier New, Courier, mono">MultiSQLServer</font> 
 
  40   is a Singleton (a class that will have a single instance), so we can get the 
 
  41   instance of it with <font face="Courier New, Courier, mono">MultiSQLServer.getInstance()</font>.</P>
 
  42 <P>The <font face="Courier New, Courier, mono">connect()</font> function will 
 
  43   use the JDBC driver and connect to the database. After that, the BookmarkNode 
 
  44   will have its <font face="Courier New, Courier, mono">con</font> member assigned 
 
  45   (not null). After the connection, the function that is answering your double-clicking 
 
  46   (<font face="Courier New, Courier, mono">ConnectAction.run()</font>), will try 
 
  47   to get the tables, views, etc from that connection. To do that, it will call 
 
  48   <font face="Courier New, Courier, mono">BookmarkView.refreshBookmarkData()</font>, 
 
  49   that will query the database. As the procedure to get the tables may be different 
 
  50   for each database, the actual querying is delegated to another class <font face="Courier New, Courier, mono">SQLHelper</font>, 
 
  51   that will centralize that kind of procedures (the ones that depend on the type 
 
  52   of the database). The called function in this case is <font face="Courier New, Courier, mono">getTableList()</font>. 
 
  53   <font face="Courier New, Courier, mono">SQLHelper</font> is not a Singleton, 
 
  54   although it could be, but we don't really need an instance because the functions 
 
  56 <P>The <font face="Courier New, Courier, mono">getTableList()</font> will try 
 
  57   to get the tables from the function <font face="Courier New, Courier, mono">MultiSQLServer.listTables()</font>, 
 
  58   if the jdbc adapter of the bookmark is generic. listTables will ask the jdbc 
 
  59   driver directly for the list of tables, using the <font face="Courier New, Courier, mono">DatabaseMetadata.getTables() 
 
  60   </font>call. If the adapter is not generic, it will use a SQL statement to get 
 
  61   the list of table names. This SQL statement will be of course different in every 
 
  62   database, so it will come from the <font face="Courier New, Courier, mono">DatabaseAdapter</font> 
 
  64 <P>The <font face="Courier New, Courier, mono">DatabaseAdapter</font> class is 
 
  65   the one where you should put all the functions that will be different for each 
 
  66   database. Then for each database, you create an "adapter" class derived 
 
  67   from <font face="Courier New, Courier, mono">DatabaseAdapter</font>, and implement 
 
  68   all the necessary abstract functions. So you get a proper adapter using <font face="Courier New, Courier, mono">DatabaseAdapter 
 
  69   adapter = AdapterFactory.getInstance().getAdapter(current.getType())</font>, 
 
  70   and the returned adapter will have the proper type (always a derived type from 
 
  71   <font face="Courier New, Courier, mono">DatabaseAdapter</font>). Then calls 
 
  72   to the adapter object will be redirected to the proper function.</P>
 
  73 <P>The <font face="Courier New, Courier, mono">TableNode</font> objects generated 
 
  74   will have metadata, i.e. columns. That information is saved in an object of 
 
  75   class <font face="Courier New, Courier, mono">ObjectMetaData</font> in the TableNode 
 
  76   object. This ObjectMetaData class is part of the metadata package, that has 
 
  77   basically four classes:</P>
 
  78 <P><font face="Courier New, Courier, mono">MetaDataJDBCInterface</font> : Basically 
 
  79   takes care (through static functions) of passing the metadata from the jdbc 
 
  80   driver to the ObjectMetadata class.</P>
 
  81 <P><font face="Courier New, Courier, mono">MetaDataXMLInterface</font> : Handles 
 
  82   interface between an ObjectMetaData and XML storage. It can write an existing 
 
  83   metadata object to XML and generate a new ObjectMetaData from existing XML.</P>
 
  84 <P><font face="Courier New, Courier, mono">ObjectMetaData</font> : The class that 
 
  85   has all the metadata. Rather underdeveloped, one must add functions as needed. 
 
  86   The metadata is saved in the form of StringMatrix objects.</P>
 
  87 <P><font face="Courier New, Courier, mono">StringMatrix</font> : A matrix of strings. 
 
  88   Saves the results from the jdbc driver, usually given as ResultSet objects, 
 
  89   that are very similar in structure but sequential in nature (you access the 
 
  90   records one at a time). The first line of the matrix are the names of the columns, 
 
  91   and the rest hold the values.</P>
 
  93 <P><img src="structure.gif" width="749" height="313"></P>