DbView         Database visualization



Organization of the code



General description

The code is divided into big sections:

Database adaptors

A database adaptor is a set of classes, within a package. For example, the following package represents a database adaptor:

If you look at this package, you see that it contains 4 classes:

The list of mandatory classes for a database exporter is defined in the following class: org.dbview.input_addons.InputCatalog

See attribut "ADAPTORS":

private static final ArrayList ADAPTORS = new ArrayList() {{ add("Cli"); add("Configuration"); add("Description"); add("Loader"); }};

Class Description
Cli This class is responsible for extracting values from the command line. It creates a XML document that represents the command line configuration.
Description This class is used to print a brief description of the adaptor.
Configuration This class contains the parameters used to connect to a database. It takes the XML document created by the class "Cli" and process it.
Loader This class loads the database's structure and create an internal representation.

If you plan to add a new adapter ("youNewAdaptor"):

  1. Create a new package "org.dbview.addons.input.youNewAdaptor"
  2. Create the mandatory classes listed above.
  3. Recompile the software.

The package that represents the new adaptor must be the package that contains all database adaptors :

org.dbview.addons.input

See attribut "ADD_ON_PATTERN", of class "org.dbview.input_addons.InputCatalog".

private static final Pattern ADD_ON_PATTERN = Pattern.compile("^(.+\\.addons\\.input\\.([^\\.]+))\\.([^\\.]+)\\.class$");

Database exporter

A database exporter is a set of classes, within a package. For example, the following packages represent database adaptors:

The adapter's name given through the command line is converted into a "Lower Camel Case" string. See the method below:


If you look at these packages, you see that they contain 3 classes:

The list of mandatory classes for a database exporter is defined in the following class: org.dbview.output_addons.OutputCatalog

See attribut "ADAPTORS":

private static final ArrayList ADAPTORS = new ArrayList() {{ add("Cli"); add("Description"); add("Exporter"); }};

Class Description
Cli This class is responsible for extracting values from the command line. It creates a XML document that represents the command line configuration.
Description This class is used to print a brief description of the adaptor.
Exporter This class is responsible for the generation of the database representation.

If you plan to add a new exporter ("youNewExporter"):

  1. Create a new package "org.dbview.addons.output.table.youNewExporter"
  2. Create the mandatory classes listed above.
  3. Recompile the software.

The package that represents the new exporter must be the package that contains all database exporters :

org.dbview.addons.output.table

See attribut "ADD_ON_PATTERN", of class "org.dbview.output_addons.OutputCatalog".

private static final Pattern ADD_ON_PATTERN = Pattern.compile("^(.+\\.addons\\.output\\.[^\\.]+\\.([^\\.]+))\\.([^\\.]+)\\.class$");

Database structure

All elements that represent a database are defined into the package "org.dbview.db.structure".

If you need an example on how to use the database representation, you can look at the code of class: "org.dbview.addons.output.table.dotFull.Exporter".

Resources

A resource is a software add-on that extends the application. Now, DbView only define one resource: the soft foreign key detector.

Resources are located in the following package:

org.dbview.resources.theResourceName

Soft foreign key detectors are located into the following packahe:

org.dbview.resources.softforeignkeydetectors

A soft foreign key detector is a class. For example: "FkTargetTableName"

Adding a new soft foreign key detector is easy:

  1. Add a new class to the package "org.dbview.resources.softforeignkeydetectors".
  2. Your class must implement the following methods:
    • public Boolean isFk(String in_field_name)
    • public String referenceTable(String in_field_name)
    • public String referenceField(String in_field_name)
    • public String description()
  3. Recompile the software.

The adapter's name given through the command line is converted into a "Lower Camel Case" string. See the method below:


Utilities

The package "org.dbview.utils" contains some utilities.

Runtimes

The section "runtime" contains three entries:

Name Description
org.dbview.runtime This package contains the entry point.
org.dbview.runtime.actions This package contains the actions' implementations. For each command selector, you have a corresponding method.
org.dbview.runtime.cli This package contains the command line parser. The parser returns a hash table that contains the information extracted from the command line.
Directory structure

Directory Description
src JAVA source.
conf This directory contains configuration files. Now, it contains only one configuration file: "resources.properties". Please note that this file contains information that is used by the ANT script (at compile time) and by the application.
data This directory contains run time data. Now, it contains only one file: "profiles.xml". This file contains the profiles' repository.
doc Some documentation.
libs External software components:
  • Args4j (command line parsing)
  • Jaxen (XPath)
  • Jdom (XML)
  • JgraphT (Graph theory)
  • Junit (Unit testing)
  • All the necessary JDBC4 adaptors
test-data Some files that contain test data.
Important files

Name Description
build.xml ANT specification file. Ti compile: ant clean, then ant
dbview.bat Script that launches the DbView application under Windows.
dbview.sh Script that launches the DbView application under MAC OS, linux, and UNIXes.
doxygen Configuration file for DoxyGen.
data/profile.xml This is the profiles' repository.
extensions/databaseAdaptors.jar This JAR contains all the database adaptors.
extensions/exporters.jar This JAR contains all the database exporters.
extensions/softForeignKeyDetectors.jar This JAR contains all the soft foreign key detectors.
Build instructions

Action Command
Clean ant clean
Build all ant
Build documentation ant doc
Run all JUNIT test suite ant testall
Print the CLASSPATH ant show-classpath
Print all classes that are part of the DBVIEW application ant show-class-dbview
Print all classes that are part of the unitary test suite ant show-class-test
Print all classes that represent soft foreign key detectors ant show-class-fk
Print all classes that represent database adaptors ant show-class-input-adaptor
Print all classes that represent database exporters ant show-class-output-adaptor