Difference between revisions of "MoDisco/SimpleTransformationChain"

From Eclipsepedia

Jump to: navigation, search
(Current limitations)
(Install)
 
(31 intermediate revisions by 2 users not shown)
Line 1: Line 1:
The goal of the SimpleTransformationsChain plug-in is gathering the [http://wiki.eclipse.org/MoDisco#Infrastructure infrastructure] and [http://wiki.eclipse.org/MoDisco#Technologies technologies] plug-ins and providing orchestration of these plug-ins. These additional facilities reuse the features offered by the other plug-ins in order to allow performing more elaborate operations and complex tasks, such as directly generating a UML model from a Java project. It also provides an additional feature trying to detect bidirectional associations in target UML model.
+
The goal of the SimpleTransformationsChain plug-in is gathering the [[MoDisco#Infrastructure|infrastructure]] and [[MoDisco#Technologies|technologies]] plug-ins and providing orchestration of these plug-ins. These additional facilities reuse the features offered by the other plug-ins in order to allow performing more elaborate operations and complex tasks, such as directly generating a UML model from a Java project. It also provides an additional feature trying to detect bidirectional associations in target UML model.
  
=Description=
+
=Quick Start Guide=
  
After discovery of your application, you will obtain a UML model. This model could be imported in some usual modelers like Papyrus or UML2 Tools from Modeling project.
+
After discovery of your application, you will obtain a UML model. This model could be imported in some usual modelers like [http://www.eclipse.org/modeling/mdt/papyrus/ Papyrus] from the Modeling project.
  
[[Image:MoDisco_SimpleCaptchaExample_UmlModelView.jpg|center|An example of UML model discovered from famous Pet Store application]]
+
[[Image:MoDisco_simpletransformationschain_tutorial_PetStore_UML_inModelBrowser.png|frame|center|An example of UML model discovered from the famous '''Pet Store''' application]]
  
 
==Contextual menu==
 
==Contextual menu==
Line 11: Line 11:
 
The SimpleTransformationsChain plugin offers simple Eclipse contextual actions to dynamically launch the additionally provided features.
 
The SimpleTransformationsChain plugin offers simple Eclipse contextual actions to dynamically launch the additionally provided features.
  
You can launch the “Discover UML model from Java project” action from a Java project by right-clicking on the corresponding Java project (into your workspace) and then selecting the appropriate action in the provided contextual menu.
+
You can launch the "Discover UML model from Java project" action from a Java project by right-clicking on the corresponding Java project (in your workspace) and then selecting the appropriate action under '''Discovery > Discoverers''' in the provided contextual menu:
  
[[Image:MoDisco_ContextualMenuOfBidirectionalAssociationDetection.jpg|center|Contextual menu populated whit MoDisco entries]]
+
[[Image:MoDisco_DiscoverUMLfromJavaProject_menu.png|frame|center|Contextual menu populated with MoDisco entries]]
  
 
==Launch configuration==
 
==Launch configuration==
  
The SimpleTransformationsChain plugin is conform to Discoverer extension point, so in launch configurations, you are able to create a discoverer launcher dedicated to a project.
+
The SimpleTransformationsChain plugin is registered with the "discoverer" extension point, so in launch configurations, you are able to create a discoverer launcher dedicated to a project:
  
[[Image:MoDisco_SimpleTransformationsChainDiscoverer.jpg|center|Launch configuration of SimpleTransformationsChain discoverer for Pet Store application]]
+
Open the launch configurations:
  
==Java API==
+
[[Image:MoDisco_Run_RunConfigurations.png|frame|center|Launch Configurations...]]
  
To use programmatically the SimpleTransformationsChain plugin, you will have to instantiate the class ''ModelplexKnowledgeDiscoveryFramework'' and use following method:
+
Create a new '''MoDisco Discovery''' launch configuration, and select the discoverer "discoverUMLModelWithBidirectionalAssociationsFromProject" from the drop-down list:
<source lang="java">public Resource getUML2ModelFromJavaSource(IJavaProject javaProject,URI umlTargetModelUri) throws ATLCoreException;</source>
+
  
=Requirements=
+
[[Image:MoDisco_LaunchConfigs_selectDiscoverUmlModelWithBidiAssocFromProject.png|frame|center|Select the discoverer]]
  
Eclipse Galileo with modeling plugins:
+
Then, select your project in the "Source element" field:
* EMF
+
 
* EMF UML2
+
[[Image:MoDisco_LaunchConfig_SelectSourceProject.png|frame|center|Selecting a source project]]
* ATL 3.0.0
+
 
+
And finally, click '''Run''' to start the discovery.
A complete bundle of Modeling components can be found at this url: [http://www.eclipse.org/downloads/download.php?file=/technology/epp/downloads/release/galileo/R/eclipse-modeling-galileo-incubation-win32.zip Eclipse Modeling Galileo Bundle]
+
 
 +
== Discoverer API ==
 +
 
 +
First, add the following plug-in dependencies to your project ('''Require-Bundle''' in your Manifest.MF):
 +
* org.eclipse.uml2.uml
 +
* org.eclipse.modisco.usecase.simpletransformationschain
 +
* org.eclipse.modisco.infra.discovery.core
 +
 
 +
Then, you can use the following discoverer classes:
 +
* DiscoverUmlModelFromJavaProject: from an IJavaProject (defined in jdt.core)
 +
* DiscoverUmlModelFromProject: from an IProject
 +
* DiscoverUmlModelWithBidirectionalAssociationsFromJavaProject: from an IJavaProject, with bidirectional associations
 +
* DiscoverUmlModelWithBidirectionalAssociationsFromProject: from an IProject, with bidirectional associations
 +
 
 +
For example, to discover a UML model from a Java project:
 +
<source lang="java">
 +
DiscoverUmlModelWithBidirectionalAssociationsFromJavaProject discoverer = new DiscoverUmlModelWithBidirectionalAssociationsFromJavaProject();
 +
discoverer.discoverElement(javaProject, monitor);
 +
Resource umlModel = discoverer.getTargetModel();
 +
</source>
 +
 
 +
To have a monitor to pass to the <code>discoverElement</code> method, you can either call the discoverer in an Eclipse Job, or pass a new NullProgressMonitor if you don't need progress reporting.
  
Warning : after installation, you will have to change your eclipse settings (file eclipse.ini) to increase memory size allowed to 1Go at least, parameter "-Xmx1024m".
 
  
Example :
 
-startup
 
plugins/org.eclipse.equinox.launcher_1.0.200.v20090520.jar
 
--launcher.library
 
plugins/org.eclipse.equinox.launcher.win32.win32.x86_1.0.200.v20090519
 
-product
 
org.eclipse.epp.package.modeling.product
 
--launcher.XXMaxPermSize
 
256M
 
-showsplash
 
org.eclipse.platform
 
--launcher.XXMaxPermSize
 
256m
 
-vmargs
 
-Dosgi.requiredJavaVersion=1.5
 
-Xms40m
 
-Xmx1024m
 
-XX:ThreadStackSize=4096
 
  
 
=Team=
 
=Team=
Line 62: Line 63:
 
=Install=
 
=Install=
  
To install this plugin, you will have to retrieve it and its dependencies from [http://wiki.eclipse.org/MoDisco/SVN MoDisco SVN].
+
You can [[MoDisco/Installation|install]] the discoverer from the MoDisco update site.
All following bundles are available in folder "plugins/trunk":
+
  
* org.eclipse.gmt.modisco.modelplex
+
As part of the "Use cases layer" which is not embedded in MoDisco SDK, you cannot install it from eclipse or modeling update site. Please use MoDisco release update site.
* org.eclipse.gmt.modisco.kdm.uml2converter
+
* org.eclipse.gmt.modisco.j2se5
+
* org.eclipse.gmt.modisco.j2se5.discoverer
+
* org.eclipse.gmt.modisco.kdm
+
* org.eclipse.gmt.modisco.common.core
+
  
=User manual=
+
=Description=
  
To illustrate SimpleTransformationsChain plugin, we will use a sample inspired from the [http://java.sun.com/developer/technicalArticles/J2EE/petstore/ Pet Store Application].
+
To illustrate the SimpleTransformationsChain plug-in, we will use a sample inspired from the [http://java.sun.com/developer/technicalArticles/J2EE/petstore/ Pet Store Application].
  
==Get and install use case==
+
== Setup ==
  
The models are available from [http://wiki.eclipse.org/MoDisco/SVN MoDisco SVN (how to...)] in subdirectory "examples/trunk/org.eclipse.gmt.modisco.usecase.simpletransformationschain" or from downloadable archive. If you use a SVN client in eclipse (Subversive or Subclipse), the project will be immediately available in your Eclipse workspace.
+
Sources of the Pet Store application are available here: http://www.oracle.com/technetwork/java/petstore1-3-1-02-139690.html
  
Sources of Pet Store application are  available from [https://blueprints.dev.java.net/servlets/ProjectDocumentList?folderID=5315&expandFolder=5315&folderID=0 Sun downloads].
 
 
You may have to download several libraries to obtain an eclipse project without errors (JPA, JTA, JSF-apis and Servlets-jsp-apis).
 
You may have to download several libraries to obtain an eclipse project without errors (JPA, JTA, JSF-apis and Servlets-jsp-apis).
 
A complete bundle is also available from [http://www.mia-software.com/html/miaStudio/download/modisco/examples/javapetstore-2.0-ea5.zip Mia-Software...]
 
A complete bundle is also available from [http://www.mia-software.com/html/miaStudio/download/modisco/examples/javapetstore-2.0-ea5.zip Mia-Software...]
To view this application in your Eclipse workspace, you will have to extract content of this archive, and use the "import" wizard (import project in workspace).
+
To view this application in your Eclipse workspace, you will have to extract the content of this archive, and use the "import" wizard (import project in workspace).
  
==Get the UML model of Pet Store application==
+
== Get UML model of Pet Store application ==
  
We will explains different ways to get the UML model, it will demonstrate how several simple steps have been combined to build a complex task : discover a UML model from a java project.
+
We will explain different ways to obtain the UML model; it will demonstrate how several simple steps have been combined to build a complex task : discover a UML model from a java project.
  
 
===Basic way===
 
===Basic way===
  
It exists several tools that are each able to perform a specific task, we will see how each task works.
+
There are several tools that are each able to perform a specific task; we will see how each task works.
  
 
====Get the java model====
 
====Get the java model====
  
Open the "Run configurations..." dialog.
+
* Open the '''Run configurations...''' dialog.
Then, press the "New" button to create a configuration of type "MoDisco Discoverers".
+
* Then, press the "New" button to create a configuration of type "MoDisco Discovery".
 +
* Enter a name for this configuration, "PetStore reverse to Java model" for example.
 +
* Select the discoverer named "org.eclipse.modisco.java.discoverer.project".
 +
* Enter the path to the project containing the PetStore application in the "Source element" field.
 +
* Set SERIALIZE_TARGET to true
  
Enter a name for this configuration, "PetStore reverse to J2SE5 model" for example.
+
[[Image:MoDisco_Run_Configurations_PetStore_reverseJava.png|frame|center|Java Discoverer configuration]]
Select Discoverer kind "Discover J2SE5 model from java project".
+
Enter path to the project of PetStore application.
+
  
[[Image:MoDisco_JavaDiscoverer.jpg|center|Java Discoverer configuration element.]]
+
Finally, press the '''Run''' button to get the Java model.
  
Finally, press "Run" button to get the J2SE5 model.
+
You could also use the the contextual menu (right click) when the project containing the Pet Store application is selected. Select '''Discovery > Discoverers > Discover Java Project''':
  
You could also use the the contextual menu (right click) when the project of Pet Store application is selected. Navigate in MoDisco/java menus, click on "Discover J2SE5 model from java project" menu item.
+
[[Image:MoDisco_DiscoverJavaProject_Menu.png|frame|center|Menu to discover a Java project]]
  
[[Image:MoDisco_SimpleCaptchaExample_J2SE5ModelView.jpg|center|The J2SE5 model, a focus on SimpleCaptcha class.]]
+
[[Image:MoDisco_simpletransformationschain_PetStore_JavaXMI_inModelBrowser.png|frame|center|The Java model, with a focus on the '''SimpleCaptcha''' class.]]
  
 
==== Get the KDM model  ====
 
==== Get the KDM model  ====
  
Using the ATL transformation [http://dev.eclipse.org/viewsvn/index.cgi/plugins/trunk/org.eclipse.gmt.modisco.j2se5.discoverer/src/org/eclipse/gmt/modisco/j2se5/resources/transformations/J2SE5ToKDM.atl?root=Modeling_MODISCO&view=log J2SE5toKDM], we will transform the J2SE5 model into a KDM model. We have to configure another configuration to perform such transformation.
+
Using the ATL transformation [https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco/plugins/trunk/org.eclipse.modisco.java.discoverer/src/org/eclipse/modisco/java/discoverer/internal/resources/transformations/javaToKdm.atl javaToKdm], we will transform the Java model into a KDM model. We have to define another configuration to perform this transformation:
  
Open the "Run configurations..." dialog. Then, press the "New" button to create a configuration of type "ATL Transformation".  
+
* Open the '''Run configurations...''' dialog
 +
* Press the "New" button to create a configuration of type '''ATL Transformation'''
 +
* Enter a name for this configuration, "Java to Kdm transformation" for example
 +
* Select the ATL module in your workspace, "/Transformations/JavaToKdm.atl" for example
 +
* Select metamodel URIs from the EMF Registry (<nowiki>http://www.eclipse.org/MoDisco/Java/0.2.incubation/java</nowiki> and <nowiki>http://www.eclipse.org/MoDisco/kdm/action</nowiki>)
 +
* '''Note''': the source metamodel parameter must be named "java" and the source model parameter must be named "IN", otherwise the transformation won't work
 +
* Select the source model ("_java.xmi" file) in your workspace, and enter a path for your target model ("_kdm.xmi" file).
  
Enter a name for this configuration, "Java to Kdm transformation" for example. Select ATL module in your workspace, "/Transformations/JavaToKdm.atl" for example. Select metamodels uris from EMF Registry (<nowiki>http://www.eclipse.org/MoDisco/J2SE5</nowiki> and <nowiki>http://www.eclipse.org/MoDisco/kdm/action</nowiki>). Select source model in your workspace, and enter a path for your target model.
+
[[Image:MoDisco_simpletransformationschain_tutorial_Run_Configurations-JavaToKDM.png|frame|center|configuration of the ''Java to Kdm'' ATL Transformation]]
  
[[Image:MoDisco JavaToKdmTransformation.jpg|center|Java to Kdm ATL Transformation configuration element.]]
+
Finally, press the '''Run''' button to get the KDM model.  
  
Finally, press "Run" button to get the KDM model.  
+
You could also use the the contextual menu (right click) when the Java model of the Pet Store application is selected: '''Discovery > Discoverers > Discover KDM model from Java model'''.
  
You could also use the the contextual menu (right click) when the j2se5 model of Pet Store application is selected. Navigate in MoDisco menu, click on "Discover KDM model from J2SE5 model" menu item.
+
[[Image:MoDisco_PetStore_kdm_xmi_inModelBrowser.png|frame|center|The KDM model, with a focus on the '''SimpleCaptcha''' class.]]
 
+
[[Image:MoDisco SimpleCaptchaExample KDMModelView.jpg|center|The KDM model, a focus on SimpleCaptcha class.]]
+
  
 
==== Get the UML model====
 
==== Get the UML model====
  
Using the ATL transformation [http://dev.eclipse.org/viewsvn/index.cgi/plugins/trunk/org.eclipse.gmt.modisco.kdm.uml2converter/src/org/eclipse/gmt/modisco/kdm/uml2converter/resources/transformations/KDMtoUML.atl?root=Modeling_MODISCO&view=log KDMtoUML], we will transform the KDM model into a UML model.
+
Using the ATL transformation [https://dev.eclipse.org/svnroot/modeling/org.eclipse.mdt.modisco/plugins/trunk/org.eclipse.modisco.kdm.uml2converter/src/org/eclipse/modisco/kdm/uml2converter/internal/resources/transformations/KDMtoUML.atl KDMtoUML], we will transform the KDM model into a UML model.
We have to configure another configuration to perform such transformation.
+
  
Open the "Run configurations..." dialog.
+
We have to define another launch configuration to perform this transformation:
Then, press the "New" button to create a configuration of type "ATL Transformation".
+
  
Enter a name for this configuration, "Kdm to Uml transformation" for example.
+
* Open the '''Run configurations...''' dialog
Select ATL module in your workspace, "/Transformations/KdmToUml.atl" for example.
+
* Press the "New" button to create a configuration of type '''ATL Transformation'''
Select metamodels uris from EMF Registry ( <nowiki>http://www.eclipse.org/MoDisco/kdm/action</nowiki> and <nowiki>http://www.eclipse.org/uml2/2.1.0/UML</nowiki>).
+
* Enter a name for this configuration, '''Kdm to Uml transformation''' for example.
Select source model in your workspace, and enter a path for your target model.
+
* Select the ATL module in your workspace, "/Transformations/KdmToUml.atl" for example.
 +
* Select metamodel URIs from EMF Registry (<nowiki>http://www.eclipse.org/MoDisco/kdm/action</nowiki> and <nowiki>http://www.eclipse.org/uml2/2.1.0/UML</nowiki>)
 +
* '''Note''': the source metamodel parameter must be named "kdm", and the source model parameter must be named "kdmInput", otherwise the transformation won't work
 +
* Select the source model in your workspace, and enter a path for your target model.
  
[[Image:MoDisco_KdmToUmlTransformation.jpg|center|Java to Kdm ATL Transformation configuration element.]]
+
[[Image:MoDisco_simpletransformationschain_tutorial_Run_Configurations_KDMtoUML.png|frame|center|configuration of the '''Java to Kdm''' ATL Transformation]]
  
Finally, press "Run" button to get the UML model.
+
Finally, press the '''Run''' button to get the UML model.
  
You could also use the the contextual menu (right click) when the kdm model of Pet Store application is selected. Navigate in MoDisco menu, click on "Discover UML model from KDM model" menu item.
+
You could also use the the contextual menu (right click) when the kdm model of the Pet Store application is selected: '''Discovery > Discoverers > Discover UML model from KDM model'''.
  
[[Image:MoDisco_SimpleCaptchaExample_UMLModelView.jpg|center|The UML model, a focus on SimpleCaptcha class.]]
+
[[Image:MoDisco_simpletransformationschain_tutorial_PetStore_UML_inModelBrowser.png|frame|center|The UML model, with a focus on the '''SimpleCaptcha''' class.]]
  
 
====Initialize a workflow====
 
====Initialize a workflow====
  
To be able to chain previous tasks, MoDisco a workflow initializer.
+
To be able to chain previous tasks, MoDisco provides a workflow initializer:
  
Open the "Run configurations..." dialog.
+
* Open the '''Run configurations...''' dialog
Then, press the "New" button to create a configuration of type "MoDisco Workflow".
+
* Pess the '''New''' button to create a configuration of type '''MoDisco Workflow'''.
 +
* Enter a name for this configuration, for example "Discovery of PetStore application".
 +
* Press the '''Load...''' button to successively add configurations "PetStore reverse to Java model", "Java to Kdm transformation" and "Kdm to Uml transformation" (or whatever you named your previous launch configurations).
  
Enter a name for this configuration, "Discovery of PetStore application" for example.
+
[[Image:MoDisco_Run_Configurations_DiscoveryOfPetStoreApplication.png|frame|center|The workflow configuration to execute all steps to get a UML model from a java project]]
Then, press the "Load..." button to successively add  "PetStore reverse to J2SE5 model" configuration, "Java to Kdm transformation" configuration and "Kdm to Uml transformation" configuration.
+
  
[[Image:MoDisco_DiscoveryOfPetStoreWorkflow.jpg|center|The workflow configuration element to represent all steps to get a Uml model from a java project.]]
+
* Finally, press the '''Run''' button to get the UML model.
  
Finally, press "Run" button to get the UML model.
+
This is a first way to get a UML model from a java application. However when parameters change (the selected java application, target UML model, ...), you will have to change the different configurations in order to restore the coherence of all steps, by making sure the input of each step is produced by the previous step.
This is a first way to get a Uml model from a java application, however when parameters change (the selected java application, target uml model, ...), you will have to change it in different configurations and check coherency of all steps.
+
  
 +
===The SimpleTransformationsChain way===
  
----
+
* Open the '''Run configurations...''' dialog
 +
* Press the '''New''' button to create a configuration of type '''MoDisco Discoverers'''.
 +
* Enter a name for this configuration, "PetStore reverse to UML model" for example.
 +
* Select Discoverer kind "org.eclipse.modisco.usecase.simpletransformationschain.discovererUMLModelFromProject".
 +
* Enter the path to the PetStore application project
 +
* Set the '''SERIALIZE_TARGET''' parameter to '''true'''
  
===SimpleTransformationsChain way===
+
[[Image:MoDisco_Run_Configurations_PetStoreReverseToUMLModel.png|frame|center|SimpleTransformationsChain Discoverer configuration]]
  
Open the "Run configurations..." dialog.
+
* Finally, press the '''Run''' button to get the UML model.
Then, press the "New" button to create a configuration of type "MoDisco Discoverers".
+
  
Enter a name for this configuration, "PetStore reverse to UML model" for example.
+
You could also use the the contextual menu (right click) when the Pet Store application project is selected: '''Discovery > Discoverers > Discover UML model from Java project'''
Select Discoverer kind "Discover UML model from java project".
+
Enter path to the project of PetStore application.
+
  
[[Image:MoDisco_SimpleTransformationsChainDiscoverer.jpg|center|SimpleTransformationsChain Discoverer configuration element.]]
+
[[Image:MoDisco_simpletransformationschain_tutorial_PetStore_UML_inModelBrowser.png|frame|center|The UML model, with a focus on the '''SimpleCaptcha''' class.]]
 
+
Finally, press "Run" button to get the UML model.
+
 
+
You could also use the the contextual menu (right click) when the project of Pet Store application is selected. Navigate in MoDisco/java menus, click on "Discover UML model from java project" menu item.
+
 
+
[[Image:MoDisco_SimpleCaptchaExample_UMLModelView.jpg|center|The UML model, a focus on SimpleCaptcha class.]]
+
  
 
==Visualize the UML model==
 
==Visualize the UML model==
  
There is different possibility to visualize the target model, and explore informations located in.
+
There are different possibilities for visualizing and exploring the target model.
  
 
===Using MoDisco model browser===
 
===Using MoDisco model browser===
  
The MoDisco model browser show basically the model as a tree. It proposes a view of all instances sorted by metaclass, and offer the possibility to visualize all links in model (empty or not, cardinality, etc.).
+
The MoDisco model browser displays the model as a tree. It proposes a view of all instances sorted by metaclass, and offers the possibility to visualize all links in the model (whether empty or not, with cardinality, etc.)
  
[http://wiki.eclipse.org/MoDisco/ModelEditor more details ...]
+
* [[MoDisco/Components/ModelBrowser|More details on the MoDisco model browser]]
  
===Using UML2 Tool===
+
===Using UML2 Tools===
  
After installation of UML2 Tool, a component of Modeling/MDT project, you will be able to initialize class diagrams from the UML model.
+
After the installation of UML2 Tools, a component of the Modeling/MDT project, you will be able to initialize class diagrams from the UML model.
  
 
[[Image:MoDisco_SimpleCaptchaExample_UMLDiagramView.jpg|center|One UML class diagram, a focus on SimpleCaptcha class.]]
 
[[Image:MoDisco_SimpleCaptchaExample_UMLDiagramView.jpg|center|One UML class diagram, a focus on SimpleCaptcha class.]]
 +
 +
===Using Papyrus===
 +
 +
See [http://www.eclipse.org/modeling/mdt/papyrus/ the Papyrus project page]
  
 
=Current limitations=
 
=Current limitations=
  
As this component is an aggregation of existing components, its limitations reflect this architecture: the main limitations come from the [http://wiki.eclipse.org/MoDisco/KDM/UMLConverter#Current_Limitations KDM to UML converter].
+
As this component is an aggregation of existing components, its limitations reflect this architecture: the main limitations come from the [[MoDisco/Components/KDM/Documentation/0.9#Current_Limitations|KDM to UML converter]].
  
 +
{{MoDisco}}
 
[[Category:MoDisco]]
 
[[Category:MoDisco]]

Latest revision as of 03:12, 19 August 2011

The goal of the SimpleTransformationsChain plug-in is gathering the infrastructure and technologies plug-ins and providing orchestration of these plug-ins. These additional facilities reuse the features offered by the other plug-ins in order to allow performing more elaborate operations and complex tasks, such as directly generating a UML model from a Java project. It also provides an additional feature trying to detect bidirectional associations in target UML model.

Contents

[edit] Quick Start Guide

After discovery of your application, you will obtain a UML model. This model could be imported in some usual modelers like Papyrus from the Modeling project.

An example of UML model discovered from the famous Pet Store application

[edit] Contextual menu

The SimpleTransformationsChain plugin offers simple Eclipse contextual actions to dynamically launch the additionally provided features.

You can launch the "Discover UML model from Java project" action from a Java project by right-clicking on the corresponding Java project (in your workspace) and then selecting the appropriate action under Discovery > Discoverers in the provided contextual menu:

Contextual menu populated with MoDisco entries

[edit] Launch configuration

The SimpleTransformationsChain plugin is registered with the "discoverer" extension point, so in launch configurations, you are able to create a discoverer launcher dedicated to a project:

Open the launch configurations:

Launch Configurations...

Create a new MoDisco Discovery launch configuration, and select the discoverer "discoverUMLModelWithBidirectionalAssociationsFromProject" from the drop-down list:

Select the discoverer

Then, select your project in the "Source element" field:

Selecting a source project

And finally, click Run to start the discovery.

[edit] Discoverer API

First, add the following plug-in dependencies to your project (Require-Bundle in your Manifest.MF):

  • org.eclipse.uml2.uml
  • org.eclipse.modisco.usecase.simpletransformationschain
  • org.eclipse.modisco.infra.discovery.core

Then, you can use the following discoverer classes:

  • DiscoverUmlModelFromJavaProject: from an IJavaProject (defined in jdt.core)
  • DiscoverUmlModelFromProject: from an IProject
  • DiscoverUmlModelWithBidirectionalAssociationsFromJavaProject: from an IJavaProject, with bidirectional associations
  • DiscoverUmlModelWithBidirectionalAssociationsFromProject: from an IProject, with bidirectional associations

For example, to discover a UML model from a Java project:

DiscoverUmlModelWithBidirectionalAssociationsFromJavaProject discoverer = new DiscoverUmlModelWithBidirectionalAssociationsFromJavaProject();
discoverer.discoverElement(javaProject, monitor);
Resource umlModel = discoverer.getTargetModel();

To have a monitor to pass to the discoverElement method, you can either call the discoverer in an Eclipse Job, or pass a new NullProgressMonitor if you don't need progress reporting.


[edit] Team

Gabriel Barbier (Mia-Software)

[edit] Install

You can install the discoverer from the MoDisco update site.

As part of the "Use cases layer" which is not embedded in MoDisco SDK, you cannot install it from eclipse or modeling update site. Please use MoDisco release update site.

[edit] Description

To illustrate the SimpleTransformationsChain plug-in, we will use a sample inspired from the Pet Store Application.

[edit] Setup

Sources of the Pet Store application are available here: http://www.oracle.com/technetwork/java/petstore1-3-1-02-139690.html

You may have to download several libraries to obtain an eclipse project without errors (JPA, JTA, JSF-apis and Servlets-jsp-apis). A complete bundle is also available from Mia-Software... To view this application in your Eclipse workspace, you will have to extract the content of this archive, and use the "import" wizard (import project in workspace).

[edit] Get UML model of Pet Store application

We will explain different ways to obtain the UML model; it will demonstrate how several simple steps have been combined to build a complex task : discover a UML model from a java project.

[edit] Basic way

There are several tools that are each able to perform a specific task; we will see how each task works.

[edit] Get the java model

  • Open the Run configurations... dialog.
  • Then, press the "New" button to create a configuration of type "MoDisco Discovery".
  • Enter a name for this configuration, "PetStore reverse to Java model" for example.
  • Select the discoverer named "org.eclipse.modisco.java.discoverer.project".
  • Enter the path to the project containing the PetStore application in the "Source element" field.
  • Set SERIALIZE_TARGET to true
Java Discoverer configuration

Finally, press the Run button to get the Java model.

You could also use the the contextual menu (right click) when the project containing the Pet Store application is selected. Select Discovery > Discoverers > Discover Java Project:

Menu to discover a Java project
The Java model, with a focus on the SimpleCaptcha class.

[edit] Get the KDM model

Using the ATL transformation javaToKdm, we will transform the Java model into a KDM model. We have to define another configuration to perform this transformation:

  • Open the Run configurations... dialog
  • Press the "New" button to create a configuration of type ATL Transformation
  • Enter a name for this configuration, "Java to Kdm transformation" for example
  • Select the ATL module in your workspace, "/Transformations/JavaToKdm.atl" for example
  • Select metamodel URIs from the EMF Registry (http://www.eclipse.org/MoDisco/Java/0.2.incubation/java and http://www.eclipse.org/MoDisco/kdm/action)
  • Note: the source metamodel parameter must be named "java" and the source model parameter must be named "IN", otherwise the transformation won't work
  • Select the source model ("_java.xmi" file) in your workspace, and enter a path for your target model ("_kdm.xmi" file).
configuration of the Java to Kdm ATL Transformation

Finally, press the Run button to get the KDM model.

You could also use the the contextual menu (right click) when the Java model of the Pet Store application is selected: Discovery > Discoverers > Discover KDM model from Java model.

The KDM model, with a focus on the SimpleCaptcha class.

[edit] Get the UML model

Using the ATL transformation KDMtoUML, we will transform the KDM model into a UML model.

We have to define another launch configuration to perform this transformation:

  • Open the Run configurations... dialog
  • Press the "New" button to create a configuration of type ATL Transformation
  • Enter a name for this configuration, Kdm to Uml transformation for example.
  • Select the ATL module in your workspace, "/Transformations/KdmToUml.atl" for example.
  • Select metamodel URIs from EMF Registry (http://www.eclipse.org/MoDisco/kdm/action and http://www.eclipse.org/uml2/2.1.0/UML)
  • Note: the source metamodel parameter must be named "kdm", and the source model parameter must be named "kdmInput", otherwise the transformation won't work
  • Select the source model in your workspace, and enter a path for your target model.
configuration of the Java to Kdm ATL Transformation

Finally, press the Run button to get the UML model.

You could also use the the contextual menu (right click) when the kdm model of the Pet Store application is selected: Discovery > Discoverers > Discover UML model from KDM model.

The UML model, with a focus on the SimpleCaptcha class.

[edit] Initialize a workflow

To be able to chain previous tasks, MoDisco provides a workflow initializer:

  • Open the Run configurations... dialog
  • Pess the New button to create a configuration of type MoDisco Workflow.
  • Enter a name for this configuration, for example "Discovery of PetStore application".
  • Press the Load... button to successively add configurations "PetStore reverse to Java model", "Java to Kdm transformation" and "Kdm to Uml transformation" (or whatever you named your previous launch configurations).
The workflow configuration to execute all steps to get a UML model from a java project
  • Finally, press the Run button to get the UML model.

This is a first way to get a UML model from a java application. However when parameters change (the selected java application, target UML model, ...), you will have to change the different configurations in order to restore the coherence of all steps, by making sure the input of each step is produced by the previous step.

[edit] The SimpleTransformationsChain way

  • Open the Run configurations... dialog
  • Press the New button to create a configuration of type MoDisco Discoverers.
  • Enter a name for this configuration, "PetStore reverse to UML model" for example.
  • Select Discoverer kind "org.eclipse.modisco.usecase.simpletransformationschain.discovererUMLModelFromProject".
  • Enter the path to the PetStore application project
  • Set the SERIALIZE_TARGET parameter to true
SimpleTransformationsChain Discoverer configuration
  • Finally, press the Run button to get the UML model.

You could also use the the contextual menu (right click) when the Pet Store application project is selected: Discovery > Discoverers > Discover UML model from Java project

The UML model, with a focus on the SimpleCaptcha class.

[edit] Visualize the UML model

There are different possibilities for visualizing and exploring the target model.

[edit] Using MoDisco model browser

The MoDisco model browser displays the model as a tree. It proposes a view of all instances sorted by metaclass, and offers the possibility to visualize all links in the model (whether empty or not, with cardinality, etc.)

[edit] Using UML2 Tools

After the installation of UML2 Tools, a component of the Modeling/MDT project, you will be able to initialize class diagrams from the UML model.

One UML class diagram, a focus on SimpleCaptcha class.

[edit] Using Papyrus

See the Papyrus project page

[edit] Current limitations

As this component is an aggregation of existing components, its limitations reflect this architecture: the main limitations come from the KDM to UML converter.


MoDisco
Components Infrastructure: KDM · SMM · GASTM · Model Browser · Discovery Manager · MoDisco Workflow · Query Manager · Facet Manager · Metrics Visualization Builder · KDM Source Extension
Technologies: Java · JEE · EjbJar · WebApp · XML
Use Cases: Simple Transformation Chain · Model Filter
Help Installation · SVN
Project API Policy · Retention Policy · Project Plan · metrics · Accessibility Guidelines · Capabilities Disablement