JSRunnable: JSCondition, JSNewContext, JSPostprocess

The JSRunnable Stereotype is not applicable to Rhapsody metaclass, so it can not be model in Rhapsody. It is an abstract M2M metaclass. It is the parent of JSCondition, JSNewContext and JSPostprocess. All of them can be linked to a MappingRule, and executed by the M2M Engine.
These elements can be created into M2MPackage elements via the contextual menus:

- Add New | M2M | JSCondition

- Add New | M2M | JSNewContext

- Add New | M2M | JSPostprocess

Add new JSRunnables

  1. JSCondition

    A JSCondition is Rhapsody Function used as a condition to apply the MappingRule. It must be implemented in JavaScript via the "Implementation" tab:

    JSCondition implementation

    The implemented code have access to all of the M2MRuleset JavaScript context (including init.js, JSRunnables, JSFunctions, JSVariables, JSFileLibraryies). The signature of this function is the following:

    boolean JSCondition_Name ( IRPModelElement element );


    To create it, right-click on a M2MPackage, and click on Add New | M2M | JSCondition.
    When the M2M Engine execute a MappingRule on a model element (IRPModelElement), it provides the IRPModelement which is being transformed as argument to this Function and executes it. Then, the M2M Engine checks the boolean result returned by the JavaScript code. If the value is 'True', it applies the MappingRule on the IRPModelement, if it returns 'False', the MappingRule is not applied.

  2. JSNewContext

    A JSNewContext is Rhapsody Function used to move the transformed element in a new owner. It must be implemented in JavaScript via the "Implementation" tab:

    JSNewContext implementation

    The implemented code have access to all of the M2MRuleset JavaScript context (including init.js, JSRunnables, JSFunctions, JSVariables, JSFileLibraryies). The signature of this function is the following:

    IRPModelElement JSNewContext_Name ( IRPModelElement element );


    To create it, right-click on a M2MPackage, and click on Add New | M2M | JSNewContext.
    Just after the M2M Engine transforms a model element, it executes this JSNewContext function linked to the MappingRule. This function return an IRPModelElement, and M2M Engine move the transformed element in this returned IRPModelElement.

  3. JSPostprocess

    A JSPostprocess is Rhapsody Function used to populate the model after an element is transformed. It must be implemented in JavaScript via the "Implementation" tab:

    JSPostprocess implementation

    The implemented code have access to all of the M2MRuleset JavaScript context (including init.js, JSRunnables, JSFunctions, JSVariables, JSFileLibraryies). The signature of this function is the following:

    void JSPostprocess_Name ( IRPModelElement element );


    To create it, right-click on a M2MPackage, and click on Add New | M2M | JSPostprocess.
    Once the M2M Engine transforms an element, and move it into the new context element, it executes the JSPostprocess function to populate the model with new elements.