|
[Previous] [Overview] [Next]
Hands on Example: Tutorial 1
To get some hands-on experience with iQgen we recommend to run the tutorial 1 that comes with the iQgen distribution. You will find the templates in the directory samples/getting_started/tutorial_1/templates and the
XML models in XMI format in directory samples/getting_started/tutorial_1/model.
Model
Tutoral 1 uses the model depicted in the figure below.
It will not result in a complete application, but in the end you will have source code which can be compiled and you will obtain a deeper knowledge
of how to develop templates.
Packages:

Dependencies:

Tutorial Files
To give you an overview of the templates in tutorial 1, here's a table with short comments:
| Directory |
File |
Comment |
| . |
build.xml |
Ant Script for Generation |
| model |
Tutorial_1.xml |
XMI Vers. 1.0 model file |
| model |
Tutorial_1.mdl |
Rational Rose model file |
| templates |
main.jsp |
Modelelement to template mapping |
| templates |
interface.jsp |
Simple example that demonstrates how to generate a Java interface |
| templates |
class.jsp |
More complex example that generates Java class file. Uses other templates like associations, attributes, and operations |
| templates |
attributes.jsp |
Used by class.jsp. Generates attribute declarations, getter and setter methods. |
| templates |
operations.jsp |
Used by class.jsp. Generates methods. |
| templates |
associations.jsp |
Used by class.jsp |
| templates |
build.jsp |
PostProcessTemplates example |
| templates |
copyright.jsp |
Copyright text |
| templates |
drop_and_create.jsp |
Simple SQL script |
| templates |
params.jsp |
Utility JSP that is included by other templates. |
| templates |
utilities.jsp |
Utility JSP that is included by other templates. |
Generating
In order to generate the files for the given model, simply start iQgen, select the tutorial's model file. Set both the target and template directory and start the generation. You will then find the generated file in the output directory you chose.
In the next section we look at user defined taglibs and how to integrate them into iQGen.
You find some advanced template programming examples and the metamodel description here.
|