QVT Plugin 18.0 
 Readme 

(Build ID: 171038)



    

Introduction


Top

The MagicDraw QVT plugin contains jsr-223 compliant QVT script engine that lets user to run QVT transformations from the Macros Engine, Simulation plugins or script language supported by MagicDraw.

    

Installation


Top
To install the QVT plugin:
  1. From the MagicDraw main menu select Help > Resource/Plugin Manager.
  2. Check for the available updates and new resources.
  3. Select the check box near the QVT plugin and click Download/Install.
  4. Restart MagicDraw.
NOTE: For MagicDraw 17.0 (not MagicDraw 17.0 SP1 and later) you should add 
-Dorg.eclipse.emf.ecore.EPackage.Registry.INSTANCE=org.eclipse.emf.ecore.impl.EPackageRegistryImpl 

property as JAVA_ARGS= value into the md.properties file that can be found in <MagicDraw installation directory>\bin. This forces EMF to use a non-delegating global EPackage registry, otherwise the transformations will fail.

To check if the QVT Operational engine has been installed:
  1. From the Tools menu, select  Macros > Create Macros.
  2. In the Create Macros dialog, click the Macro Language arrow to see the value list. It should contain the "QVT Operational" value.


    

Usage


Top

You can run a QVT transformation script in one of the following ways:

From Macros Engine For a quick start please follow the example.

To start QVT ChangeRootElementName example:

  1. Install the QVT plugin and restart MagicDraw.
  2. From the Tools menu, select Macros > Organize Macros. The Organize Macros dialog will open.
  3. Click the Add button. The Macro Information dialog will open.
  4. Specify macro name. 
  5. As a Macro Language choose QVT Operational
  6. Click ... button next to the File box and  go to <MagicDraw installation directory>\samples\QVT to select ChangeRootElementName.qvto.
  7. Click Add to specify the arguments of the macro:
Name Type Array
model string false
  1. Click OK to save the information.
  2. Open any MagicDraw project.
  3. Open the Organize Macros dialog once again.
  4. Select the macro and click Run. The Macro Arguments dialog will open.
  5. Specify the arguments for parameters:
Name Value
model md:model
  1. The macro is executed and the root element name is changed.
On how to start the SimpleUML to RDB QVT Operational Sample, read <MagicDraw installation directory>\samples\QVT\UML to RDB\SimpleUML_to_RDB_Sample_readme.html

For more information on how to create a macro (NOTE: the QVT Operational engine will be used as a macro), please refer to  MagicDraw MacroEngine UserGuide.pdf that can be found in <MagicDraw installation directory>\manual.

NOTES:

Creating script in any MagicDraw supported scripting language (most flexible way)

To call QVT transformation from script use jsr-223 ScriptEngine interface:


            ScriptEngineManager manager = new ScriptEngineManager();
            ScriptEngine qvtEngine = manager.getEngineByName("QVTO");
            qvtEngine.put("param1", value1);
            qvtEngine.put("param2", value2);
            qvtEngine.put(ScriptEngine.FILENAME, "path to script file");

            try
            {
                qvtEngine.eval((String) null);
                Resource resource = resourceSet.createResource(URI.createFileURI("pim.rdb"));
                List<EObject> attribute = (List<EObject>)qvtEngine.get("inout/out param name");
                resource.getContents().add(attribute.get(0));
            }
            catch (ScriptException e)
            {
                e.printStackTrace();
            }

You should be able to run the script not only from file but by directly passing script content as the parameter to engine:

            qvtEngine.eval("script content");

Parameters passed to engine are mapped to the transformation parameters by name. If the transformation has a parameter with name 'model', you should put a value to QVT engine with the same name:
            qvtEngine.put("model", some value).

The following parameter value types are supported: String, EObject, Collection<EObject> and  ModelExtent. Parameter with value type string has special usage. This parameter's value is  not used directly by the transformation but instead is used to locate the object of type QVTParameter. 

Found object will contain the code to extract the actual parameter value that is passed to the transformation. For example, it is defined MDModelParameter class with the name 'md:model' that returns the current project model as value. By putting the parameter qvtEngine.put("model", "md:model")  it is told the engine to locate QVTParameter in QVTParameterRegistry by 'md:model' name and call getValue() method to extract the actual parameter value. This is useful when the QVT transformations are run as macros in MagicDraw.


For the QVT engine there are defined couple engine specific parameters: QVTO_EXECUTION_CONTEXT, QVTO_E_PACKAGE_REGISTRY and QVTO_SCRIPT_NAME. You can set them as normal parameters to engine:

            qvtEngine.put(QVTEngineConstants.QVTO_EXECUTION_CONTEXT, executionContext);
NOTES:


Running script from Simulation toolkit plugin

It is run as any other MagicDraw supported script.

For more details please refer to the Simulation toolkit plugin documentation.

    

Session handling


Top

Every modification in a MagicDraw model must be done in the MagicDraw specific session. QVT transformation engine is not an exception. Therefore it is created the MagicDraw specific Script engine factory MDQVTScriptEngineFactory that will create proxy around the QVT ScriptEngine implementation. The proxy code handle all the MagicDraw session details (creates/closes/joins session). The session is handled only for the QVT ScriptEngine eval(..) methods.

By default MDQVTScriptEngineFactory is created as the QVT ScriptEngine factory. If you want to use a factory without the MagicDraw session code, specify QVTScriptEngineFactory in the javax.script.ScriptEngineFactory file.


    

Limitations


Top
Current QVT script engine implementation binds only those parameters that are specified in the transformation definition (signature).

    

Where to find more information or support?


Top

Web page

To download the plugin and to get contact information, please go to: http://www.nomagic.com/products/magicdraw-addons/qvt-plugin.html.

 Knowledge base and new issue registration

We are awaiting your comments and suggestions. More than a half of the features of the current version added because our demo version users have requested them. Do not miss the chance to see your desired features in the future versions!

Samples

After you have installed MagicDraw and QVT plugin for MagicDraw, samples of QVT can be found in <MagicDraw installation directory>\samples\QVT

Frequently Asked Questions

Please visit our website for FAQ at http://www.nomagic.com/support/faq.html