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. Transformation requires an input argument of type rhapsody and an output argument of type excel:
    public ruleset Class2List(in rhp :rhapsody, out exc : excel)
  2. 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();
  3. We add only one sheet to main structure of Excel workbook:
    var sheet : excel.Sheet = exc.create("Sheet");
    workbook.sheets.add(sheet);
  4. In this 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);

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.
  4. Select Main tab and select argument exc (out) in Parameters grid.
  5. Choose an output file, you have 3 choices: XMI, Excel Workbook, CSV, and press OK.
  6. Press Run to finish.
  7. You will find a compliant Excel file output.xls in the code generation folder of the Rhapsody active configuration.

Deploy this ruleset

  1. ClickFile > 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\rp_launchconfig.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).

Change output file

To change output file, you have 2 ways:

  1. Choose a different file in launch configuration (see this point) and deploy the configuration again (see this chapter).
     
  2. Or open file C:\tmp\Rhp_Class_2_XLS_List.launch with simple text editor and change file in uri attribute C:\test.xlsx:
    <?xml version="1.0" encoding="UTF-8"?>
    <configuration name="Rhp_Class_2_XLS_List">
      <classpath file="Rhp_Class_2_XLS_List.classpath"/>
      <entryPoint ruleSet="com.sodius.mdw.rhapsody2excel.Class2List" rule="main">
        <arguments>
          <argument connectorName="Rhapsody On-Demand" uri=""/>
          <argument connectorName="Excel Workbook" uri="C:\test.xlsx"/>
        </arguments>
      </entryPoint>
      <options directory="" forceOverwrite="false"/>
    </configuration>

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