An application developed by:
Silvia Bindelli
Claudio Criscione
Mauro Luigi Drago
Written by:
Silvia Bindelli
Summary
1. A brief introduction |
1. A brief introductionGnuler is a Java application which allows you to generate, starting
from the UML class diagram of your application, the corresponding DB
diagram in the form of a Hybernate description file, which can be used
as is to create the persistent layer underlying your application. But what's most, you can use gnumler engine to create a tool capable to map any kind of diagram |
2. How to deploy GnumlerYou can download Gnumler in the form of a .jar file. To deploy it you have to: Using Linux:from console: Using Windows: |
3. How can I use it? a simple exampleLet's see now a simple example of what you can do with Gnumler.
Suppose we have an UML diagram described in a xmi file. You can
generate this kind of diagram with any specific tool, let's say
Umbrello.
A good example could be the one of the Hiberante tutorial, you can see the code below.
package events;
What you can find above is the java code of our example. Suppose now
you have a description of that in an xmi format, just like the
following one |
Loading existing modelsTo load the .xmi description of an existing model just choose Load XMI from the file menu. Now you can choose either to generate the mapping (selecting UMLToDbLogicTranslation from the Tool menu and then generating the visualization of both the models (the class diagram and the DB representation) by the GenerateGraph button in the menu bar, or just to visualize the UML diagram (again by the GenerateGraph button). |
4. Creating and modifying an UML diagram4.1 Adding a new Class You can add a new class to the diagram by choosing the Add Class To Model button from the menu bar. You can type in the window which appears to you the class' name and you'll see it appearing at the top-left corner of the main window. Modifying an existing class 1. Select from the graph the class you want to modify. 2. Select the Modify the selected Class button from the menu bar. This option allows you to modify the class' name. To modify a class' attribute or connection see next paragraphs. 3. Enter the new name for the selected class. Removing an existing class Select the class you want to remove and then select Remove the selected class from the model button. You'll see the class disappearing. 4.2 Adding an attribute to a class To add an attribute to a class you have to select the class and then choose the Add Attribute/Column button from the menu bar at the bottom-left corner. Enter the name of the new attribute and press "ok". You'll see it appearing both in the Attributes' list on the left and inside the class in diagram. Modifying an existing attribute 1. Select the class containing the attribute to modify, to make its attributes' list appearing on the left. 2. Select the attribute to remove from the list. 3. Choose the Modify Attribute/Column button from the menu on the bottom left side. 4. Type the new name for the attribute in the dialog and then click ok. Removing an existing attribute 1. Select the class containing the attribute to modify, to make its attributes' list appearing on the left. 2. Select the attribute to remove from the list. 3. Choose the remove attribute/column button from the menu on the bottom left side. 4.3 Adding a connection to the UML diagram 1. Select the class you want the connection to start from. 2. Choose the Add Connection to selected class button from the top menu. You'll now see a window where to set the link features. 3. Choose the target class from the menu and the cardinality to apply at each side of the connection. 4. Click ok to make the changings effective. Removing an existing connection 1. Select the link in the diagram. 2. Choose the Remove connection/generalization button from the top menu. The connection will immediately disappeare. 4.3 Adding a generalization to the UML diagram 1. Select the class you want to be the "son". 2. Choose the Add Generalization to selected class button from the top menu (last button on the righ). You'll now see a window where to set choose the parent class. 3. Choose the parent class from the menu. 4. Click ok to make changings effective. Removing an existing generalization 1. Select the link in the diagram. 2. Choose the Remove connection/generalization button from the top menu. The generalization will immediately disappeare. |
5. Creating and modifying a DbLogic diagram5.1 Adding a new table to the diagram You can add a new table to the diagram by choosing the Add table to model button from the menu bar. You can type in the window which appears to you the table's name and you'll see it appearing at the top-right corner of the main window. Modifying an existing table 1. Select from the graph the table you want to modify. 2. Select the Modify selected Table button from the menu bar. This option allows you to modify the table's name. To modify a table's column or connection see next paragraphs. 3. Enter the new name for the selected table. Removing an existing talbe Select the table you want to remove and then select Remove selected table from model button. You'll see the table disappearing. 5.2 Adding a column to a table 1. Select the table. 2. Choose the Add Attribute/Column button from the menu bar at the bottom-left corner. 3. Enter the name of the new column. 4. Set it as a primary key or not. 5. Choose the type of the new column from the menu. 6. When you'll click the ok button you'll see the new column appearing in the box on the left. Modifying an existing column 1. Select the table containing the column to modify, to make its columns' list appearing on the left. 2. Select the column to remove from the list. 3. Choose the Modify Attribute/Column button from the menu on the bottom left side. 4. Type the new name for the column in the dialog. 5. Set it as a primary key or not. 6. Choose the new type of the column from the menu. 7. When you'll click the ok button you'll see the new column appearing in the box on the left. Removing an existing column 1. Select the table containing the column to remove, to make its columns' list appearing on the left. 2. Select the column to remove from the list. 3. Choose the remove attribute/column button from the menu on the bottom left side. 4.3 Adding an association to the DbLogic diagram 1. Select the table you want the connection to start from. 2. Choose the Add Connection to selected class button from the top menu. You'll now see a window where to set the link features. 3. Choose the target table from the menu and the cardinality of the association. 4. Choose if you want an ID to be created in each table 5. Click ok to make the changings effective. Removing an existing association 1. Select the link in the diagram. 2. Choose the Remove connection/generalization button from the top menu. The association will immediately disappeare. |
How to generate the mappingHow to generate an automated mapping of a uml diagramStarting from a given class diagram, imported as an XMI description or created using gnumler tools, you can generate its mapping by choosing UMLToDBLogicTranslation from the Tool menu. How to generate a personalized mappingHow to map an existing class 1. Select the class for which you want to generate a mapping 2. Choose the map the selected class button from the bottom-left menu bar. A dialog will appear, where to set the mapping features. 3. Type a name for the new mapping. 4. You can choose either to map the class to one or more table, selecting a master table and zero or more slave tables from the lists. 5. If you want to map the class to a new table not yet created, type its name in the above field. 6. You can now choose either to have an automatic map of the class' attributes to the table's columns or not (you'll see into next paragraphs how to map each attribute). 7. Clicking the ok button the new mapping will appear into the left column's list. Clicking over the mapped class/table in the graph the correspondant tables/class while be eyelighted. How to map an existing generalization 1. Select the generalization you want to map. How to remove a class mapping 2. Select the mapping to remove from the list into the top-left box. 3. Choose the remove class mapping button from the menu on the bottom left side. How to map an attribute 1. Select the class containing the attribute to map, to make its attributes' list appearing on the left. 2. Select the attribute to map from the list. 3. Now you'll see a window where to choose mapping settings. 4. Type into the upper field a name for the new mapping. 5. Select the target table from the left box, and the target columns from the right box (containing only the columns of the selected table). 6. Given a selected table, if you want to map the attribute to a non-existing column, you can just create it inserting its name into the above field. 7. You can now click the ok button to make your changings effective. You'll see then the new mapping appearing into the proper box on the left. How to remove an attribute mapping 1. Select the class containing the attribute's mapping to remove, to make its attributes' list and their mappings' one appearing on the left. 2. Select the attribiute mapping to remove from the list. 3. Choose the Remove attribute mapping button from the menu on the bottom left side. |
How to obtain the inverse mapping (from UML to DbLogic)To obtain the inverse mapping given a DbLogic model (you can build it using gnumler as shown in previous chapters) just choose DbLogictoUMLTranslation from the Tool menu. An automated mapping to a class diagram will be generate. To visualize it just click over the Generate Graph button from the menu bar. |
After the mapping: closer to the DBGnumler allows you to get an useful representation of the generated mapping- When you have finished creating diagrams and mapping, you can: Visualize the correspondant XML Hibernate description You can do that choosing Show XML from the top menu bar. Get the SQL - DLL output To do that just choose Output SQL - DLL from the Tool menu. Export to the database You just have to choose Export to Database from the Tool menu. This way database tables will be created as specified. |