Home m16e-nome.png Consulting & Software Solutions

Gaudí - User's Guide (v. 1.0)


The last version of this document will allways be available at http://www.m16e.com/en/opensource/gaudi/last/doc/index.html.

Index:


1. Installation

Unpack the file you have downloaded in a directory of your choice, for intance, /usr/local/m16e, with the command:

tar jxvf gaudi-v1r0.bz2

It creates a directory for Gaudí (gaudi-v1r0), with the following directories inside:

diagrams contains a diagram example
doc contains the User Guide
i18n contains the localization files
img contains the images for the icons
lib contains the jar files
sql contains a SQL script to create the test database
xgm contains the layout files for the application dialogs

The following files will be copied to gaudi-v1r0's directory:

Filename Description
gaudi.sh initialization script
dbeditor.properties properties file
db-field-types.xml file providing data type abstraction between databases

Next, you should edit 'dbeditor.properties' and fill it with the apropriate values for your environment. The properties file should have the following fields:

Field Name Description
Database connection
db.driver.name driver's name
db.driver.protocol protocol's name
db.sep.pm separator between the protocol and the machine name
db.machine machine's name
db.sep.md separator between the machine name and the database name
db.name database's name
db.schema schema's name
db.user user's name
db.password password
db.run.sql command to run SQL scripts
db.family to distinguish between DBMS 'flavours' (currently, it can be either 'postgres' or 'others').
Default work directories
xgm.dir the directory in which are saved XML GUI files
sql.dir the directory in which are saved SQL files
diagrams.dir the base directory for saving diagrams (optional)
gen.xgm.dir the base directory for generated XML GUI files (optional)
gen.classes.dir the base directory for generated java code (optional)
gen.classes.package default package for generated java code (optional)
Miscellaneous
inc.hscroll number of pixels to move when pressing the left and right arrow keys
inc.vscroll number of pixels to move when pressing the up and down arrow keys
editor text editor for SQL files
browser browser for viewing HTML help files
Localization data
locale.language language
locale.country country code
locale.variant variant
timezone timezone

Here is a sample file, filled with the apropriate values for a PostgreSQL database on the same machine (localhost), named 'example1', using gvim as the editor and Mozilla browser and localized for Portugal:


db.driver.name=org.postgresql.Driver
db.driver.protocol=jdbc:postgresql
db.sep.pm=://
db.machine=localhost
db.sep.md=/
db.name=example1
db.schema=
db.password=
db.user=_your_username_

db.run.sql=psql -f

db.family=postgres

xgm.dir=/usr/local/m16e/gaudi/xgm
diagrams.dir=/usr/local/m16e/gaudi/diagrams
gen.xgm.dir=/usr/local/m16e/gaudi/new-xgm-files
gen.classes.dir=/usr/local/m16e/gaudi/new-java-files
gen.classes.package=com.company.your.project

inc.hscroll=10
inc.vscroll=10

editor=gvim
browser=mozilla

locale.language=pt
locale.country=PT
locale.variant=EURO

timezone=Europe/Lisbon


2. Running the Application

Execute gaudi.sh (or a translated '.bat', if you're one of those who insist in using that thing).


3. Description

Upon launching the application we are prompted to enter the name of a database. Then we get a panel in which we'll draw the data structures.

At the bottom you will see a panel with the following buttons:

Icon Tool tip Description
Load / Save diagrams
  • Load: loads a diagram
  • Save: saves current diagram
  • Clear: clears the board
  • Open new Database: drops current connection and tries to establish a new one
Code generation and Database tools
  • Generate SQL file: generates a SQL file to initialize the tables from current diagram
  • Generate '.java' Files: generate java files binding current diagram's tables to Java objects
  • Generate '.xgm' Files: generates XML files describing the layout of both lists and forms views of each table
  • Rebuild Foreign Keys: rebuilds the database's foreign keys
  • Rebuild Database: tries to drop all the tables from current diagram then creates them
  • Edit SQL File: invokes the editor in a file containg this database's functions and constraints
  • Run SQL File: invokes the the SQL interpreter defined in the property db.run.sql to execute the file
Data I/O exports and imports the database's data in XML format (for moving data from one database to another)
Print & Scale
  • Print: prints the diagram
  • Scale: applies a scale to the diagram
Adds a Table or Foreign Key
  • New Table
  • New Foreign Key
Help invokes the browser to show the User's Guide

3.1. New Table

When you press this button, we get a list of the tables defined in the database to choose from. If you press the [Cancel] button, you create a new table.


Fig. 1 - Choosing a Table

3.2. New Constraint

This option lets you define constraints for tables. When you press this button, the cursor turns into a cross, and you shall draw a line from one table to the other.


Fig. 2 - Drawing a constraint

Clicking with the right button on the line, shows a popup menu with three options: 'Delete', 'Edit Fields' and 'Create Reference'.

If you choose 'Delete', as you might expect, it just drops the reference (if the table was not created).

'Edit Fields' allows you to edit the constraint fields.


Fig. 3 - Editing constraint fields.

a black arrow means a constraint not commited to the DB
a red arrow means a constraint already defined in the database

3.3. Working with Tables

Once we have a diagram with tables, we can perform several actions on a table. Clicking a table with the right button opens a popup menu.


Fig. 4 - Table Menu

Option Description
Rename renames a diagram's table
Table Alias the table's alias
Edit Table Meta Data edits the table's Meta Data
Edit Table Data edits the table's data
Delete deletes the table from the diagram
Generate Class generates Java code that binds this table with a Java object
Export Data to XML generates a XML file from the table contents (data)
Import Data from imports data from a XML into the table contents
Refresh refreshes the table in the diagram, after the table has been modified outside Gaudí
CREATE TABLE executes a CREATE TABLE clause, based on the table's layout
ALTER TABLE executes a ALTER TABLE clause (ADD COLUMN, RENAME COLUMN or REANAME TABLE)
DROP TABLE dropping the table from the database
Options opens a configuration dialog, allowing the user to change the appearence of the diagram

3.4. Editing the Table's Meta Data

Choosing this option opens a window for editing the table's layout.


Fig. 5 - Editing a Table's Meta Data

In this window there's a table with the following fields:

Fields Description
Field the field's name
Type the field's type
Length the field's length (for CHAR and VARCHAR types)
Key the field's order in the primary key
Nullable (new) indicates whether the field allows nulls or not
Unique (new) indicates whether the field is unique or not
Check (new) check constraint for this field
Alias an alias for the field (to be use in GUI generation)
Description a description for the field

3.5. Code Generation

Perhaps the major feature of this release is the ability to generate dedicated code to deal with the tables of a given database.

For each table in the database it creates a class named your.package.tables.Db[table-name], where [table-name] is the name of the table with the first letter capitalized, and every letter that follows an underscore also capitalized (all the underscores are deleted).

Then, a factory class is created (your.package.factory.DbFactory) to instatiate the database classes.

Because these classes extend com.m16e.free.tools.db.DbTab, which in turn extends com.m16e.free.tools.db.DbWorkingTable, they will let you invoke methods for inserting, deleting and updating the table's data, as well as for filling the table's tuples with data, via get/set methods on the table's fields (again to construct the get/set methods we have applied the same algorhytm to construct the method's names).

Along with these methods, there are 3 more others which were included to make the connection with with our GUI classes (see the package com.m16e.tools.xgm) -- or your GUI classes -- as smooth as possible.
These are:
getTabLayout: returns a string containg the preferred description of the list view (n tuples) for this table
getFormLayout: returns a string containg the preferred description of the form view (1 tuple) for this table
setData: sets the object's fields based on an XML codification of their values, in which the XML tags use the same names as the table's fields

This feature was mostly included to fit our needs, so the generated code may not seem apropriate for yours. Please, let us know if that's your case. We will help you to solve your problem!

3.6. Data Export and Import

This option exports the table's data to a XML file and imports it back in the database.

3.7. Navigation global view

In the bottom right corner of the diagram's panel there is a button which popups a small view of the whole diagram which you can use to navigate to the desired table.


Fig. 6 - Navigation panel

This feature was based on a component made by David Bismut (david.bismut@gmail.com).


Requirements

Java 2 Runtime Environment (JRE 1.5.0, or higher) (*)

DBMS with a JDBC type II driver




MEMÓRIA PERSISTENTE, Lda.
Av. N. Senhora da Esperança, 100-B - GOUVEIA
2705-645 S. João das Lampas - SINTRA
Tel.: (351) 219 291 591 - Fax: (351) 219 289 580
e-mail: geral@m16e.com