|
Introduction
iQgen is a tool for generating program code from a model stored as XMI.
While generating it preserves manually added code. This approach is called "forward engineering".
You can use any case tool that supports the XMI standard file format for the Unified Modeling Language (UML),
e.g MID's INNOVATOR 7 or Rational Rose 2000 Enterprise Edition, to design your models.
You can generate exactly the code you need, because iQgen is based on templates you can modify.
The templates are standard Java Server Pages (JSP).
Forward engineering helps you to concentrate on the business aspects of your problem domain. There is no need to bother about technical details.
The generator enhances your development process using templates which describe the architecture of your project.
Changing the architecture means adapting the templates. This provides additional flexiblity for your development process.
Installing iQgen
Installation instructions can be found on the iQgen download page.
Using iQgen
There are three ways of using iQgen:
The following paragraphs describe these three types of usage in detail.
GUI
On Windows systems you can start iQgen by selecting the corresponding entry in the start menu or by double clicking on {install-dir}/iqgen.bat.
On Unix you need to run {installdir}/iqgen.sh.
If you start one of these programs without passing any arguments, iQgen will start using the GUI mode.
Figure 1 shows the main screen.

Figure 1: Initial screen of iQgen
In figure 1 you can see the screen of the sample transformation "Tutorial_1".
A transformation is defined as a set of configuration items as displayed in the initial screen above.
The main items of a transformation (the so called configuration set) are:
-
Source model file (any XMI file that has been exported by a CASE tool)
-
Target generation path (the root directory of the generated code)
-
Template directory (the directory that contains all the templates to be used by the generator)
-
Master template (a special template that controls the generation process; the default is main.jsp)
As soon as the source model is selected the generator loads the XMI file.
The model contents are displayed as shown in figure 2 in the pane "Model Elements".

Figure 2: Loaded objects
You do not need to generate the whole model every time. Instead you can select single or multiple model elements which you want to generate.
To start the generation process just click on the arrow next to the transformation name. If no element has been selected, the whole model will be generated.
Tranformations
The generator enables you to organize your work using transformations. A transformation is defined by
-
Source model file
-
Target generation path
-
Template directory
-
Master template
You can create or open a transformation using the File menu.

Figure 3: iQgen File menu
Create Transformation
To create a transformation a name must be assigned. This name must be unique within
the list of tranformations and may only consists of alphanumeric characters and "_" (e.g. Tutorial_1).
If an invalid name is entered, the transformation cannot be created and the button "OK" remains inactive.

Figure 4: iQgen create transformation view
Open Transformation
To open an existing transformation use the "Open Transformation..." item in the File menu, choose the transformation in the window which appears and press "OK".
Alternatively you can select the transformation name in the toolbar.

Figure 5: Open transformation view
Save Transformation
To save the current transformation use the "Save Transformation" item in the File menu. Then the transformation is saved.
Alternatively you can select the save transformation icon in the toolbar.
Command Line
Usage:
On Windows systems:
iqgen.bat "-xmi=(File) -out=(Dir) -jsp=(Dir) -main=(filename) [-nobackup] [Options] [Filter]"
or
iqgen.bat "-transform=(name of transformation)"
on Unix/Linux systems:
iqgen.sh -xmi=(File) -out=(Dir) -jsp=(Dir) -main=(filename) [-nobackup] [Options] [Filter]
or
iqgen.sh "-transform=(name of transformation)"
Basic settings:
| Option |
Comment |
| -transform=[name] |
Name of defined transformation |
| -xmi=[file] |
XMI input file |
| -out=[dir] |
Output directory |
| -jsp=[dir] |
Jsp directory |
| -main=[filename] |
Name of the master jsp file (projection) |
| -nobackup |
If set, no backup files will be created during merge |
Options:
| Option |
Comment |
| -verbose |
Verbose mode |
| -quiet |
quiet mode |
Filter:
| Option |
Comment |
| -name=[pattern] |
Generates only model elements with name "pattern" (*) |
| -stereotype=[pattern] |
Generates only model elements with stereotype "pattern" (*) |
| -filename=[pattern] |
Generates only files with name "pattern" (*) |
(*) A pattern can include "*" and "?"
Example:
iqgen.bat "-xmi=./samples/getting_started/tutorial_1/model/crm.xml -out=./samples/getting_started/tutorial_1/src -jsp=./samples/getting_started/tutorial_1/templates -main=main.jsp -nobackup"
or
iqgen.bat "-transform=tutorial_1 -nobackup"
Ant-Integration
For information about installing Ant please refer to the Ant installation documentation.
In the directory ../samples/getting_started/tutorial_1 you can find an Ant build script build.xml, which
starts the generation of the tutorial. The most interesting task is "generate-code":
<target name="generate-code" depends="prepare" if="generator_is_present">
<generate
jspDir="${basedir}/templates"
xmiFile="${basedir}/model/crm.xml"
outputDir="${gen.dir}"
mainJsp="main.jsp"
compiler=""/>
</target> |
or
<target name="generate-code" depends="prepare" if="generator_is_present">
<generate transform="tutorial_1"/>
</target>
|
Before this Ant task can be used iQgen has to be installed "into Ant".
You have to copy the iqgen.jar into the lib-directory of Ant (in the ANT_HOME directory) to do so.
After having completed the installation simply run Ant in the tutorial_1 directory:
-
Change into the directory ./samples/getting_started/tutorial_1
-
Type in "ant"
The generated code will be written to ./src. The tutorial also generates its own build.xml file, which compiles the generated classes and creates a JAR file.
|