This post will explain how to develop a Java program executable from Rever DB-Main. This module will access the Rever DB-Main repository and generate a dictionary (in CSV format), which contains information about all properties of objects in a schema (see example below).

To do this, you need to install Eclipse with Java 1.8 and Rever DB-Main on your computer.

Creating the Eclipse project

Launch Eclipse and go to the menu [New/Java project…]. Enter a project name (« Dictionary » in our example) and click the [Next] button.

Click the [Libraries] tab and add the jidbm.jar library (located in the bin directory of the installation directory of Rever DB-Main) by clicking the [Add external JAR…] button.

Finish the creation of your project by clicking the [Finish] button.

Creating the Dictionary plug-in

In your « Dictionary » project, got to the [New/Class] menu and enter the name « DictionaryGeneration » as class name.

Complete the creation of the class by clicking the [Finish] button. The complete source code for the Dictionary class is located at this address.

Edit the DictionaryGeneration class and create the method « runDBM() » (see below). This is the method called by Rever DB-Main when executing a Java plug-in. If this method is not in the program, the execution will stop. The corresponding code is :

public class Dictionary {
  private static PrintWriter fw = null;
   * Method called by DB-MAIN to generate a CSV file containing an attribute
   * dictionary of current schema.
   * @throws IOException
  public static void runDBM() throws IOException {
    // Open the DB-MAIN console
    new DBMConsole();
    // Create the DBMLibrary instance
    DBMLibrary lib = new DBMLibrary();
    // Get the current schema
    DBMSchema sch = lib.getCurrentDBMSchema();
    if (sch == null) {
      System.out.println("Error: Select a schema before.");
    } else {
      // Create a new CSV file
      JFileChooser fc = new JFileChooser("");
      int rVal = fc.showSaveDialog(null);
      if (rVal == JFileChooser.APPROVE_OPTION) {
        try {
          fw = new PrintWriter(fc.getSelectedFile());
        } catch (Exception wri) {
          System.out.println("Error: Impossible to write in the file "
              + fc.getSelectedFile().getName() + ".");
      } else {
      // Write labels of columns in the CSV file
          "Owner,Attribute,Cardinalities,Type,Lenght,Decimal number");
      // For each entity type of the current schema, displays its
      // attributes
      DBMEntityType ent = sch.getFirstDataObjectEntityType();
      while (ent != null) {
        ent = sch.getNextDataObjectEntityType(ent);
      // Close the CSV file

The instruction « new DBMConsole(); » allows to open a console in which will be displayed the different messages (System.out.println(…)). The instruction « DBMSchema sch = lib.getCurrentDBMSchema() » returns the current schema (the one that is visible in Rever DB-Main).

To better understand how to navigate the Rever DB-Main repository, here is the part that interests us to write the module :

A schema is composed of data objects (« DBMDataObject ») among which :

  • entity types (« DBMEntityType »)
  • relationship types (« DBMRelationshipType »)
  • simple attributes (« DBMSimpleAttribute »)
  • and compound attributes (attributes decomposed into sub-attributes, « DBMCompoundAttribute »).

To browse the entity types of a schema, you must use the methods « getFirstDataObjectEntityType » (which gives the first entity type of the schema) and « getNextDataObjectEntityType » (which gives the next entity type of a given entity type).

To compile the code of the « runDBM » method, it is necessary to create the « displayEntity » method taking as argument the current entity type. Here is the corresponding code :

   * Method that for a given entity type browse all these attributes.
   * @param ent
   *            entity type to be processed
  private static void displayEntity(DBMEntityType ent) {
    // Print the entity type name in console
    System.out.println("Entity type: " + ent.getName());
    // For each attribute, displays its properies
    DBMAttribute att = ent.getFirstAttribute();
    while (att != null) {
      displayAttribute(att, "", ent);
      att = ent.getNextAttribute(att);

This method scans the attributes of an entity type to display their properties. It uses the « displayAttribute » method taking as argument the current attribute, a prefix for the display of its name and of its owner. The code for this new method is :

   * Method that for a given attribute displays these properties and browse
   * its sub-attributes if it is a compound attribute.
   * @param att
   *            attribute to be processed
   * @param prefix
   *            prefix of attribute name
   * @param ent
   *            owner of attribute att
  private static void displayAttribute(DBMAttribute att, String prefix,
      DBMEntityType ent) {
    // Write attribute owner name, its name with prefix and its
    // cardinalities in CSV file
    fw.print(ent.getName() + "," + prefix + att.getName() + ","
        + att.getMinimumCardinality() + "-"
        + att.getMaximumCardinality());
    if (att.isSimpleAttribute()) {// Simple attribute
      // Write simple attribute name in console
      System.out.println("Simple attribute: " + att.getName());
      // Write simple attribute type, lenght and number of decimals in CSV
      // file
      DBMSimpleAttribute siatt = (DBMSimpleAttribute) att;
      fw.println("," + siatt.getTypeName() + "," + siatt.getLength() + ","
          + siatt.getDecimalNumber());
    } else {
      // Write coumpound attribute type
      // Display sub-attributes of compound attribute
      displayCompoundAttribute((DBMCompoundAttribute) att, prefix, ent);

There are two types of attributes : simple attributes (« DBMSimpleAttribute ») and compound attributes (« DBMCompoundAttribute ») which in turn possess simple or compound attributes. The method « displayAttribute » writes the common properties of attributes in the CSV file and then tests the attribute type. If it’s a simple attribute, the properties specific to this attribute type are written in the CSV file, otherwise, in the case of a compound attribute, these sub-attributes are reviewed and displayed in the CSV file. The code of the method « displayCompoundAttribute » is :

   * Method that, for a given compound attribute, browses its sub-attributes.
   * @param coatt
   *            compound attribute to be processed
   * @param prefix
   *            prefix used for sub-attributes
   * @param ent
   *            owner of coatt
  private static void displayCompoundAttribute(DBMCompoundAttribute coatt,
      String prefix, DBMEntityType ent) {
    // Write compound attribute name in console
    System.out.println("Compound attribute: " + coatt.getName());
    // For each sub-attributes of coatt, display their properties
    DBMAttribute att = coatt.getFirstAttribute();
    while (att != null) {
      displayAttribute(att, prefix + coatt.getName() + ".", ent);
      att = coatt.getNextAttribute(att);

For each attribute of the compound attribute, you call on the method which displays the properties of the attributes in the CSV file.

The encoding of the Java program is now finished.

Running the plug-in

In order to test the Java program, you need to launch Rever DB-Main. In the « About » window, click the [Library (Demo project)] button.

Double-click the « Library/Conceptual] schema to open it (and thus make it current). To run the Java program, go to the [File/Execute plugin…] menu and open the « Dictionary.class » file which is in the « bin » directory of your « Dictionary » project.

The Rever DB-Main console will open with the window to create the CSV file. Give a name to the file and click the « OK » button. The Java program will write the debugging information in the console and create your CSV file with the list of all the current schema attributes as well as their properties.


You just created your first Java plug-in for Rever DB-Main. Immediately, the possibilities of extending your favorite modeling tool come to mind.

To help you further develop plug-ins, you can consult the reference manual of the JIDBM (« JIDBM-reference-manual.pdf ») and its Javadoc (« JIDBM-javadoc ») distributed with Rever DB-Main (either from the [Start/DB-MAIN…] menu under Windows, either from the « doc » directory of the installation directory of Rever DB-Main under Linux).

In the plug-ins directory of the Rever DB-Main distribution, there are also two Java plug-ins with their source code. They are :

« » (« sql » directory) : simplified SQL script generator for database creation.

« » (« statistic » directory) : simplified generator of schema statistics.

You can try and modify these two plug-ins to suit your needs.