MoDisco/SimpleTransformationChain

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.

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:

Contextual menu populated with MoDisco entries

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.

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

Setup

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).

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.

Basic way

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

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

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

Note: the source metamodel must be named "kdm", and the source model "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.

Initialize a workflow

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

Open the "Run configurations..." dialog.
Then, press the "New" button to create a configuration of type "MoDisco Workflow".

Enter a name for this configuration, "Discovery of PetStore application" for example.
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.

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 it in different configurations and check coherency of all steps.

SimpleTransformationsChain way

Open the "Run configurations..." dialog.
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.
Select Discoverer kind "Discover UML model from java project".
Enter path to the project of PetStore application.

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.

Visualize the UML model

There is different possibility to visualize the target model, and explore informations located in.

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.).