Skip to main content

skip to main content

developerWorks  >  Rational  >

IBM Rational Business Developer Extension V7.0

UML to EGL transformation

developerWorks
Document options

Document options requiring JavaScript are not displayed


Rate this page

Help us improve this content


Level: Intermediate

Niranjan Vasudevamurthy (niravasu@in.ibm.com), Technology Evangelist, IBM India

02 Oct 2007

UML (Unified Modeling Language) to EGL (Enterprise Generation Language) transformations (using a combination of IBM® Rational® Business Developer Extension and IBM® Rational® Software Architect) allow you to model complex applications graphically. In addition, they enable you to implement EGL services or fully CRUD (create, read, update, and delete) - capable applications with no manual coding. This increases productivity and reduces errors.

Introduction to UML to EGL application transformations

UML (Unified Modeling Language) to EGL (Enterprise Generation Language) transformations (using a combination of Rational Business Developer Extension and Rational Software Architect) allow you to model complex applications graphically. In addition, they enable you to implement EGL services or fully CRUD (create, read, update, and delete)- capable applications with no manual coding. This increases productivity and reduces errors.

You can also perform automated transformations starting from relational database schemas.

The resulting output includes:

  • EGL SqlRecords and DataItems
  • Data access layer
    • Common CRUD operations
    • Services or Libraries
    • Support functions
  • JSF (Java™Server Faces)-based JSPs (JavaServer Pages) and corresponding EGL Handlers
  • DDL (Data Definition Language) script for defining the database tables (if the starting point of the transformation is a class diagram)
Editor's Note
The examples in this article use IBM® Rational® Software Architect Version 7.0.0.2, IBM® Rational® Business Developer Extension Version 7.0, and Microsoft® Windows® XP Professional SP2.

Model-driven development: Generating source code from UML models

You can use a transformation to generate source code from a UML model. Before you can run the transformation, you will need to create a transformation parameters model file, and then apply those parameters to the UML model.

In general, model-driven development (MDD) follows these steps:

  1. Model your application with a UML model that describes the functionality at the highest level.
  2. Choose the UML to EGL transformation.
  3. Create a transformation parameters model (TPM) file, which is a file tied to the UML model that describes how to translate the UML elements into elements in the source language. The TPM file contains information such as how to convert types and names into the source language, and how the output code should be structured.
  4. Run the transformations and create code in the output language.
  5. Edit and implement the output code.

Creating a new UML project and class diagram

Before you run the transformation, you will model your application with a UML model. From the high-level perspective, the steps that are necessary to create a UML model include:

  1. Launch Rational Software Architect.
  2. Create a UML modeling project and a default class diagram.
  3. Add classes to the class diagram, which will be the input for UML to EGL transformation.

Launch Rational Software Architect

  1. Select IBM Rational Software Architect from the Windows Program menu, or select IBM Software Development Platform>IBM Rational Software Architect > IBM Rational Software Architect from the Start menu, as shown in Figure 1.

Figure 1. Launching Rational Software Architect
Launching Rational Software Architect
  1. This will launch the IBM® Rational® Software Delivery Platform, which will initially prompt you for a workspace. Enter C:\RBDWrkSpace and click OK.

Create a UML modeling project

  1. Create a new UML project by selecting File>New>Other>UML Project.
  2. Name it EGLUMLProject, as shown in Figure 2.

Figure 2. Creating and naming the project
window with project and model details
  1. Click Next and select Blank Model from the templates.
  2. Name the model EGLUMLModel.
  3. Leave the default diagram as Class Diagram and click Finish, as shown in Figure 3.

Figure 3. Creating a new UML model from a standard template
window with template choices

Adding classes to the class diagram

  1. Create two classes (Student and Seminar) in the class diagram. The attributes for both the classes should be created as shown in Table 1.

Table 1. Create two classes with these attributes
Class nameAttributes
Student Class
  • Student_ID:Integer
  • Name:String
  • Address:String
  • PhoneNumber:Integer
Seminar Class
  • Seminar_ID:Integer
  • Name:String
  • Seminar_Fees:Integer
  1. Add a One-to-One Association relationship between these two classes, as shown in Figure 4.

Figure 4. One-to-one association
boxes joined by a line


Back to top


Mapping UML objects to EGL objects

The UML to EGL transformation recognizes a set of UML model elements to perform the transformation. The following list describes the recognized elements, as well as the output generated during the transformation for the element.

  • Package: All UML packages result in the creation of an EGL package.
  • Class: A class in the UML model represents a database table. For each class in the model, the following are created:
    • EGL SqlRecord
    • A table definition in the DDL (this definition is located in the <project> /scripts/data/createTables.sql directory, where <project> is the location of the project)
    • A library or service containing functions for performing create, read, update, and delete operations on the class
    • A search/list JSP and corresponding Pagehandler functions that provide search operations on the database table and present view lists of results
    • A detail JSP and corresponding Pagehandler functions for displaying the details of a specific database row (add, update, and delete operations can also be performed through the detail pages)
  • Operation: From each operation element a function stub in the data access library is generated, and each operation parameter becomes an EGL parameter.
  • Attribute : Each attribute element in the UML model represents a database column. For each Attribute, the following is generated:
    • An EGL SqlRecord Field
    • A column definition in the DDL
  • Association: An association element represents the relationship between two end classes. Associations with more than two end classes are ignored during the transformation. The following is generated for an association:
    • Foreign key definitions in the DDL
    • Columns inserted into the database tables (representing the association ends)


Back to top


Creating a new EGL Web project for the transformation

The EGL Web project contains the EGL code, Web pages, and a sample database, all of which make up the logic, data, and interface of the application. The Enterprise Application Resource project (EAR project) contains information about deploying an application in the Java™ 2 Platform, Enterprise Edition (J2EE) framework, because the project will have a Web interface, you need to create an EGL Web project, not an EGL project.

Creating a new EGL Web project for the transformation

  1. Select File > New > Other.
  2. Select EGL Web Project and click Next.
  3. Name the project EGLWeb7.
  4. Also create a new EAR Project by clicking New under the EAR Membership. Call it EGLWeb7EAR, as shown in Figure 5.
  5. Click Finish and do not switch to Web perspective when asked.

Figure 5. Creating an EGL-enabled Web project
window with EGL Web project details


Back to top


Creating the transformation parameters model (TPM) file

This section explains you how to create a new TPM file. A TPM file contains the metadata that describes how to transform a UML file to EGL code.

Create a TPM file by performing the following steps:

  1. Right-Click the UML Model (in this example it would be EGLUMLModel) and click Edit Transformation Parameters, as shown in Figure 6.

Figure 6. Opening the edit dialog
pop-up menu
  1. In the Create a New TPM file window, make sure that your UML file is listed in the Target Model field.
  2. Select the EGL Web project for the new TPM File.
  3. Click the Browse button in the Folder section and select the EGL Web project that you created previously, as shown in Figure 7.
  4. Click the Finish button.

Figure 7. Specifying settings for a new TPM file
window with TPM file details


Back to top


Configuring the TPM file

The TPM file allows you to customize the transformation of a UML model to source code.

The steps to configure a TPM file include the following:

  1. Select the UML to EGL transformation
  2. Specify class transformation parameters
  3. Specify the Key column for classes
  4. Configure primitive type parameters

Select the UML to EGL transformation

  1. Open the TPM file by double-clicking it in the Project Explorer view.
  2. At the top right corner of the editor, select the Manage applied transformations checkbox. This opens the Manage Your Transformation Parameters window, as shown in Figure 8.

Figure 8. Transformation Parameters Editor
window with arrow pointing to text
  1. 3. Move the transformations that you want to use into the Selected Transforms list by clicking a transformation in the Available Transforms list and then clicking Add, as shown in Figure 9.
  2. 4. Click OK.

Figure 9. Selecting available transformations
window showing available and selected transformations

Specifying class transformation parameters

Figure 10 shows the parameters that apply to the UML class element. Right-click the class to select EGL Application Transformation.


Figure 10. Specify database, page, and button options
tabbed window
  • Schema name: The name of the database schema to which the table being transformed belongs. If a schema name is not specified, the name of the model will be used.
  • Table name: The name of the database table represented by the class. If a table name is not specified, the class name is used.
  • Record name:The name of the EGL SqlRecord that represents the class. If a record name is not specified, the class name is used. If defaulting to class name, the transformation may alias the class name to ensure that it is a valid EGL name.
  • List/Search Page: The title that is added to the JSP representing the list view of the class. The default value is class_name List Page, where class_name is the name of the class.
  • Details Page: The title that will be added to the JSP representing the detail view of the class. The default value is class_name List Page, where class_name is the name of the class.
  • Add Button: Label that will be displayed on the Add button in JSPs. The default value is Add.
  • Delete Button: Label that will be displayed on the Delete button in JSPs. The default value is Delete.
  • Update Button: Label that will be displayed on the Update button in JSPs. The default value is Update.
  • Search Button: Label that will be displayed on the Search button in JSPs. The default value is Search.
  • Maximum record rows per page: The number of result set rows that will be displayed per page in the list JSP. The default value is 5.

Specify the Key column for the classes

  1. Expand the Student class.
  2. Select the Student_ID attribute, then right-click and select EGL Application Transformation.
  3. In the Configure property parameters for EGL Application transformation section, select the Is Key Column checkbox, as shown in Figure 11.

Figure 11. Specifying the Key column for Student
window with two frames
  1. Configure the Key property for the Seminar class. Expand the Seminar class.
  2. Select the Seminar_ID attribute, then right-click it and select EGL Application Transformation.
  3. In the Configure property parameters for EGL Application transformation section, select the Is Key Column checkbox, as shown in Figure 12.

Figure 12. Specifying the Key column for Seminar Transformation
window with options to select

Configuring the primitive type parameters for EGL Application Transformation

The parameters in this category are used to define UML data types, allowing you to expand the data types that can be associated with an UML attribute.

To specify the parameters to be used by the EGL Application Transformation when transforming a UML primitive type element, follow these steps.

  1. Expand the Primitive types under the list of objects defined in the UML Model.
  2. Select the defined primitive type, right-click it and select EGL Application Transformation.
  3. Under the Configure primitive type parameters section, select the appropriate EGL type.
  4. In this example, for the Date primitive type in the UML model, select the DATE EGL Type, as shown in Figure 13. If no appropriate EGL type is selected for a UML primitive type, then a default of String type will be created.

Figure 13. Specify parameters to be used by the EGL Application Transformation
tabbed window

Run the Transformation

To generate the EGL code from the UML model, perform the following steps.

  1. 1. Click the Run transformation button in the Transformation parameters file, as shown in Figure 14.
  2. 2. Click Finish.

Figure 14. Select one of the objects defined in the business model
window with list

After the transformation runs, there are several new EGL packages in the EGL Source folder of the EGL Web Project (in this case, EGLWeb7) which includes eglumlmodel.data, eglumlmodel.access, and eglumlmodel.primitivetypes.data.

  • eglumlmodel.data holds the records.
  • eglumlmodel.access package holds the libraries.
  • eglumlmodel.primitivetypes.data package holds the dataitems.

    Note: In the above packages, "eglumlmodel" is prefixed with the name of the UML model from which EGL code is generated.

Additionally, DDL script for defining the database tables is also generated. The SQL file is stored under the <project>/scripts/data/createTables.sql directory, where <project> is the location of the project.

Finally, JSF-based JSPs and corresponding EGL Handlers are also generated.



Resources

Learn

Get products and technologies

Discuss


About the author

Niranjan is a Technology Evangelist. He works for IBM at India Software Labs, Bangalore on Rational tools.




Rate this page


Please take a moment to complete this form to help us better serve you.



 


 


Not
useful
Extremely
useful
 


Share this....

digg Digg this story del.icio.us del.icio.us Slashdot Slashdot it!



Back to top