ExportMappingRule modeling

A M2MExportRuleset is composed by multiple ExportMappingRule elements. The ExportMappingRules can be created, either via the Add New menus when right-click on a model element in the Rhapsody Browser, or via a ExportMappingRulesTable.


Here are the instructions to complete a ExportMappingRule:
  1. You can now start to design your ExportMappingRules. It is recommended to create first a ExportMappingRulesTable, either directly in the M2MExportRuleset, or in a M2MEPackage of your choice.
  2. To proceed, right-click on the M2MExportRuleset or on the M2MEPackage, and click on Add new | M2MIE | ExportMappingRulesTable
  3. Once the ExportMappingRulesTable is created, double-click on it, it will open an empty table with several columns like 'Source Stereotype' and 'Target EClass'.
  4. Select in the scope of the TableView, the M2MEPackage where you want to create your ExportMappingRules.
  5. Click on "Add model element" on the right:

    ExportMappingRuleElement


    "Add model element" creates a new ExportMappingRule element and displays a new line in the ExportMappingRulesTable:

    ExportMappingRulesTable

  6. To design your ExportMappingRule, you need first to indicate the Source Metaclass (and/or Stereotype) and the Target EClass.
    The Target Owner EClass and Target Owner EFeature can be optionally used to add conditions to execute the rule:
    - if the Target Owner EClass is defined, then the element will be exported only if the target element is owned by an target owner element of type "target owner eClass" defined by this dependency.
    - if the Target Owner EFeature is defined, then the element will be exported only if its target owner has an eFeature with the same name as the "target owner eFeature" defined by this dependency. This eFeature must be a EReference with containment.
    The "Source Metaclass" column can be filled in by typing the name of a Rhapsody metaclass (e.g. Class, Package...). It will override the values of Tag AbstractRhpSourceMappingRule.sourceMetaclass.
    The "Source Stereotype" and "Target EClass" columns, can be filled by selecting a Stereotype or an EClass in the model via a drop-down box. It will create a sourceStereotype Dependency and a eClassRef Dependency

    Source and Target


    If the selected source Stereotype is applicable to at least one metaclass, the source metaclass column will not be used by the M2M Engine. It supports Stereotypes which are New-Term or not, and applicable to 0..* Rhapsody metaclasses.


  7. By default, the drop-down boxes in Rhapsody can not display more than 500 elements. In the case there are more than 500 Stereotypes in the project, add the dedicated property in rhapsody.ini. Before editing rhapsody.ini, make sure Rhapsody is closed. Then open rhapsody.ini with a text file editor, go to the section [General], and add the line MaxComboBoxSize=5000. The value 0 means unlimited. 5000 is enough to manage AUTOSAR profiles which contains thousands of Stereotypes.

  8. Drop-down boxes in Rhapsody tables are not always comfortable, especially when there are thousands of elements in the list. In this case, it is recommended to use the "Add New" menu on the ExportMappingRule element:
    - right-click in the browser on the ExportMappingRule element, and then Add new | M2MIE | sourceStereotype (sourceStereotype Dependency)
    - a dialog window will show up, and you will be able to search your Stereotype by typing its name in the "Depends On" field:

    Stereotype Drop-down box

  9. Filling in the source or target metaclass by hand in the table can lead to typing mistakes. To avoid this, the metaclass can be selected in the drow-down box of the Tag AbstractRhpSourceMappingRule.sourceMetaclass. To proceed,
    - Open Features dialog of the ExportMappingRule by right-clicking on the model element, and click on "Features..."
    - Click on "Tags" tab
    - Click on the Tag value field, and select the metaclass in the drop-down box:

    Metaclass Drop-down box

  10. Before implementing the ExportMappingRules, it is possible to follow a "Specification phase". Given that a ExportMappingRule Stereotype is applicable to the Requirement metaclass, Requirement ID and specification description can be completed. These fields can be displayed in the ExportMappingRulesTable:

    MappingRule Specification

    These fields have no effects to the transformation itself.
  11. It is possible to enable or disable a ExportMappingRule, by changing the value of the Tag AbstractMappingRule.activation via the drop-down box:

    MappingRule activation

  12. If it is needed to sort the execution of the ExportMappingRule by the M2M Engine, the column "Priority" must be completed with a number. It will overrides the Tag AbstractMappingRule.priority. At runtime, the M2M Engine will order all the Mapping Rules and follow this order when executing the transformation rules:

    MappingRule priority

  13. The column "Inheritance", is used to enable the source Stereotype inheritance. Selecting the value 'activated' or 'desactivated', overrides the Tag AbstractMappingRule.inheritance.

    MappingRule inheritance

  14. The columns "Condition Function", "New context Function", and "Post-process Function" are used to extend the ExportMappingRules with Rhapsody API requests. These extensions are described in the section JavaScript elements modeling for export.
    Those can be selected in the ExportMappingRulesTable via the model element selector:

    select JSNewContextmodel element selector

  15. The column "Strict matching" can be used to require or not a strict matching of the elements with the ExportMappingRule to allow the transformation:

    Strict matching
    When enabled (activated), the M2M Engine will check if there is a strict matching between an element and the ExportMappingRule before transforming it.
    For example, if the ExportMappingRule has the metaclass "Package" as source metaclass, without selected Stereotype, and if the option "Strict matching" is activated, "Package" elements witch a Stereotype applied will not be transformed. Only new-term "Package" will be transformed.