A Simple Case Study

A brief overview of the Wires* tool is provided and the user will be guided through a simple step-by-step example of Wires*. A simple metamodel for Enterprises is considered. This metamodel describes a company and its employees:

In the example, a government decides to protect Small and Medium-sized Enterprises. This new policy forbids the establishment of businesses whose staff exceeds 10 employees. The objective is to design a chain of transformation using the graphical notation provided by Wires* to comply with the law regulation. For this purpose, we have designed an ATL transformation that divides one business into two small ones (Divide.atl), and an ATL query to get the number of enterpise workers (Workers.atl). This transformation wil be applied only to enterprises with more than 10 employees.

Creating a Wires* Project

The Wires_Tutorial.zip file contains the Wires* project with all the files required to follow this tutorial. The contents of this zip file are:

  • WiresTutorial. The ATL project that contains (in different folders) all the resources.
    • inModels. It includes the Enterprise input model.
    • ModelTypes. It contains the Enterprise metamodel.
    • outModels. The folder where the output model will be stored.
    • TransformationTypes. It includes the ATL transformation files.
    • WiresModel. It contains the solution to this problem: the Wires* models and diagrams. Please ignore these files to follow the tutorial.

To import this project, right click on the navigation view Import...-> General -> Existing Projects into Workspace -> Select archive file and then select the Wires_Tutorial.zip file.

Creating a Wires* Model

Once we have all the coresponding models, metamodels, and ATL transformatons, we are ready to create a new Wires* Diagram for solving the problem. For this purpose, the user should move to the navigator view and select with the mouse right click->New->Examples->Wires Diagram, then click on Next and give names to the diagram (a .wires_diagram file) and to the model (a .wires file) represented by the diagram. In particular, we will create two Wires* diagrams: a types diagram (named workersTypes.wires_diagram), including the types definition, and an execution diagram (named workers.wires_diagram), including the chain of ATL transformation's execution.

Designing the Types Diagram

The next step is to edit the types diagram (workersTypes.wires_diagram) and to define the types of our models and transformations (including queries). For this purpose, we need to create a Model Type (for the Enterprise Metamodel), an Atomic Model Transformation Type (for the Divide transformation), and a Query Type (for the Workers query) in the types diagram. We use the palette on the right to draw these elements. In the Properties view (Window->Show view->Other ... -> General -> Properties), for each element, users need to indicate the type name and the file's path.

Firstly, we draw a Model Type element. We set its name and path in the properties view. To fill the path gap we have to select the Enterprise metamodel file (Enterprise.ecore).

Then, we draw Atomic Model Transformation Type and Query Type elements. For these elements we select the Divide.atl and Workers.atl files, respectively, in their path properties. The Formal parameters appear automatically when selecting the transformation path for Atomic Model Transf Type, but do not appear for Query Type. To create them manually just hover the mouse pointer over the Atomic Model Transformation Type or the Query Type and select the Input Formal Parameter and Output Formal Parameter icons. If we select these created elements, we can edit the name and type of the transformation input and output in the properties perspective. We have to fill the Name, TypeEl (the model type which the input or output model should conforms to) and Type Name properties. So, for Query Type, create one Input Formal Param name it "IN", type "Enterprise" as Type Name, and select Model Type Enterprise as typeEl (if it's not filled automatically when typing the Type Name property). Finally, create one Output Formal Param name it "OUT", type "Integer" as Type Name, and select Model Type Integer as typeEl.

Designing the Execution Diagram

Now all the types are specified, so we are going to create the diagram that describes the sequence of execution strictly speaking. For being able to select the types from types diagram we have to load the types diagram resource. To do that just right click in the instances diagram canvas and click Load Resource ...; then select the types diagram file.

First, we draw a Model element and edit its properties. We have to fill in the Name, Path and Type properties. We select the model file (model.enterprise) in the Path gap and the Model Type Enterprise value in the Type gap. The next step is draw a Query element and select the Query Type WorkersType value in the Type gap. The actual parameters will be created automatically but we can edit them too. Last step is drawing a Data Flow element to join the model with the query input parameter. To do that just select DataFlow from Palette, drag & drop between the model and the query input parameter.

Next step corresponds to the specification of the Decision Node. Decision Nodes are useful tools for helping you to choose between several courses of action. This element has a condition and two branches associated. Its condition determines which branch is taken for the routine execution. Note that the Input Actual Parameter takes the query output value and it is used in the Decision Node condition. It is identified with the same name in the condition and in the Input Actual Parameter, which has no Type. To specify the DecisionNode select it from the palette and click on the diagram, then fill the expression property with "x>10". To specify the input parameter select Input Actual Parameter from the palette and click on the DecisionNode, select the paremeter we just drawn and type "x" as name in the properties view. Finally, select DataFlow from the palette and drag & drop between the query output parameter and the DecisionNode input parameter.

At this stage, we are going to create the two courses of action. If the Decision Node condition does not hold, the input model will not be altered, but just copied. Otherwise, if the condition holds, the Divide ATL transformation is going to be executed. This transformation splits an enterprise in two smaller enterprises.

First, select Identity Transformation element from the palette and click on the diagram; type "id" as name property. Draw an Input Actual Parameter and an Ouput Actual Parameter for the Identity Transformation we just drawn. Edit the parameters name properties in the properties view typing "model" for both. Use DataFlow to join the initial model (model : Enterprise) and the input actual paremeter of the identity transformation. Then select False Branch from the palette and drag & drop between the Decision Node and the Identity Transformation. We use the Identity Transformation element to duplicate (not to alter) the input model. This kind of transformation (and its input and output parameters) do not need a Type definition (their behavior is predefined). Note that the input and the output parameters should have the same name.

Second, draw an Atomic Model Transformation from the palette, type "divide" as name and select the DivideType in the Type gap (in the properties view). The actual paremeters are automatically created. Use Data Flow to join the initial model (model : Enterprise) and the input actual parameter of the "divide" transformation. Then select True Branch from the palette and drag & drop between the Decision Node and the "divide" transformation.

It is necessary to create a model element to represent the output transformation model. We select its type property (ModelType Enterprise) and its path (by typing the workspace relative path, for instance, WiresTutorial\outModels\out.enterprise) in the properties perspective.

Finally, use Data Flow to join the output parameters of the "id" transformation and the "divide" transformation with the output model.

Executing a Wires* Model

As last step, move to the navigator view and select mouse right click in workers.wires and select Execute Wires* Model. The Wires* model wil be executed, and therefore the output model (outModels\out.enterprise) will be generated.

You can try changing the Decision Node condition or the input model to get different results.