Import, run and deploy "Rhapsody to Excel" sample

Import this ruleset

  1. Click File > New > Example.
  2. Choose Rulescomposer Sample in the New Example window and press Next.
  3. Expand folder Rhapsody ruleset in the Import Rulescomposer Sample window and press Next.
  4. Choose Rhapsody to Excel in this folder and press Next.
  5. In last window press Finish.

A project com.sodius.mdw.rhapsody.rhapsody2excel is created in the workspace.

This project contains in src folder only one package com.sodius.mdw.rhapsody2excel and only one file Class2List.mqr, please open this file.

Here is the behavior of this ruleset:

  1. Code generator requires a single input argument of type rhapsody when we wish to deploy this ruleset:

    public ruleset Class2List(in rhp :rhapsody)

  2. As a second argument for output is forbidden, we should create an inner model to assume Excel transformation.

    var exc : excel = context.getWorkbench().getMetamodelManager().getMetamodel("excel").createModel();

  3. we need class com.sodius.mdw.metamodel.rhapsody.proxy.ProxyPreloader when we want to use instruction getInstances("Class") in a deployed ruleset (See tutorial):

    var myProxyPreloader : ProxyPreloader = ProxyPreloader.getNewProxyPreloader(rhp);
    myProxyPreloader.preload();

  4. We need to prepare main structure of Excel workbook:

    var workbook : excel.Workbook = exc.create("Workbook");
    var sheet : excel.Sheet = exc.create("Sheet");
    workbook.sheets.add(sheet);

  5. To simply example, we create only one cell to insert class name in each row:

    var row : excel.Row = exc.create("Row");
    var cell : excel.Cell = exc.create("Cell");
    cell.value = class.name;
    row.cells.add(cell);
    sheet.rows.add(row);

  6. Finally, we can save model in a XLS file:

    var app : rhapsody.Application = rhp.getInstances("Application").first();
    var path : String = app.activeProject.activeConfiguration.getPath();
    exc.write("Excel Workbook", path + "\\output.xls");

Run this ruleset

  1. Click Run > Run Configurations...
  2. Expand folder Rulescomposer in the Run Configurations window.
  3. Choose Rhp Class 2 XLS List launch configuration in this folder and press Run.
  4. You will find a compliant Excel file output.xls in the code generation folder of the Rhapsody active configuration.

Deploy this ruleset

  1. Click File > Export...
  2. Expand folder Rulescomposer in the Export window.
  3. Choose Deployable Rulescomposer configuration and press Next.
  4. Choose Rhp Class 2 XLS List launch configuration and press Next.
  5. Select Deploy JAR file.
  6. Fill Export directory with c:\tmp and press Finish.

  7. Return in Rational Rhapsody application.

  8. Click Tools > Customize...
  9. Create a new customized tool Rhapsody to Excel (See tutorial):
    With Command =
    <rhapsodyInstallationDirectory>\Sodius\RulesComposer\bin\rhp_generate.bat
    With Arguments =
    C:\tmp\Rhp_Class_2_XLS_List.launch

  10. You can now launch command Tools > Rhapsody to Excel.
Note:This tutorial can be used to deploy the sample "Rhapsody to Relational" (see using ATL in RulesComposer).

Prev Section: Launch an external ruleset
Next Section: Deploy a Launch Configuration and use it in a Rich Client Program