Skip to main content

Notice: this Wiki will be going read only early in 2024 and edits will no longer be possible. Please see: https://gitlab.eclipse.org/eclipsefdn/helpdesk/-/wikis/Wiki-shutdown-plan for the plan.

Jump to: navigation, search

Difference between revisions of "VIATRA2/Basics"

(The Hello World transformation)
(Redirecting to VIATRA2/GettingStarted)
 
(18 intermediate revisions by 3 users not shown)
Line 1: Line 1:
= VIATRA2 Basics =
+
#REDIRECT [[VIATRA2/GettingStarted]]
 
+
== Basic concepts ==
+
 
+
 
+
=== Model space ===
+
VIATRA2 is a model transformation engine which can be used to manipulate abstract models (software, architecture, domain-specific) by creating model-to-model and model-to-code transformations. VIATRA2 stores models in the [[VIATRA2 Model Space]], supports the uniform representation of metamodels and models in a single logical container (as opposed to EMF where metamodels and models are separated), using an arbitrary number of metamodeling levels.
+
 
+
=== Transformations ===
+
Model-to-model and model-to-code transformations are specified using the [[VIATRA2 Transformation Language]] (VTCL) which is a textual domain-specific programming language tailored for this specific task. TODO
+
 
+
=== Model import and export ===
+
VIATRA2 supports the programmatic import of metamodels and models from other tools using an Application Programming Interface (API).TODO
+
Model exports are supported using (i) code generation, or (ii) the VIATRA2 modeling API accessible from any Java program.
+
 
+
== Simple examples ==
+
 
+
=== First steps ===
+
 
+
==== Model space wizard ====
+
In order to begin working with VIATRA2, you'll first need to create a model space instance to store your models.
+
 
+
# Create a new project in Eclipse. The project can be of any type.
+
# In the project, create a new file (right click|new|other).
+
# In the wizard, select "VIATRA2 VPM Model space" from the "VIATRA2 Framework Release3" category.
+
# Specify the file name <b>and click Next</b> (not Finish).
+
# On the modelspace fragments selection screen, select "VPM Core and Datatypes metamodel".
+
# Click Finish.
+
 
+
[[Image:VIATRA2_Wizard_0.png]]
+
 
+
Once the wizard is finished, you should have the new VPML file in your project. VPML files are XML serializations of the VIATRA2 model space, you can have any number of VPML files open at the same time, meaning that you can work with multiple model spaces concurrently.
+
 
+
==== Model space editor and VIATRA2 views ====
+
Double-click the newly created VPML file to open the VIATRA2 model editor (or select Open With|VIATRA2 model editor from the context menu).
+
You should also open the <b>VIATRA2 model spaces view</b> (Window|Show view|Other|VIATRA2 Model spaces) and the <b>VIATRA2 Textual Output view</b> to get the basic home screen:
+
 
+
[[Image:VIATRA2_Screen_0.png]]
+
 
+
==== Editing models with the editor ====
+
You can browse around the model space using the tree viewer. It is also practical to open the <b>Properties view</b> to see and edit the properties of model elements. The editor supports creating and deleting elements through the context menu. You can double click on any element to edit its name.
+
 
+
The basic elements in VIATRA2 are entities and relations. Entites represent graph nodes which relations represent graph edges. You can define <b>instanceOf</b>, <b>superTypeOf</b> relations between them (multi-level metamodeling). Entities are arranged into hierarchical name spaces which is displayed in the tree view of the model editor.
+
 
+
The <b>Properties view</b> uses the <b>Fully Qualified names</b> of elements for manipulation. FQNs are generated from the hierarchy, the FQN of a relation is the FQN of its source + the name of the relation (separated with a dot). If you enter an invalid FQN, the properties view will not save your changes.
+
 
+
You can save your model with Ctrl+S (File|Save) or File|Save as.
+
 
+
==== Creating a simple model ====
+
 
+
There is two ways to create a simple model in VIATRA2:
+
 
+
# Manual editing with the model editor;
+
# Using the textual modeling language (VTML) and importing it into the model space.
+
 
+
For this example, we'll use Option 2.
+
 
+
* Create a new file in your project and enter "test.vtml" as the file name (File|New|File).
+
* Double click the file and enter the following:
+
 
+
<source lang="text">
+
entity(Test)
+
{
+
entity(A);
+
entity(B);
+
relation(R,A,B);
+
}
+
</source>
+
 
+
This defines a simple model in the "Test" namespace, with two nodes (A,B) and a relation R between them.
+
 
+
* Save the file, and using <b>drag-and-drop</b>, drop the VTML file onto the "modelspace1" entry in the VIATRA2 Model spaces view.
+
 
+
[[Image:VIATRA2_Editor_Screen2.png]]
+
 
+
=== The Hello World transformation ===
+
 
+
* Create a new file in your project, name it "helloworld.vtcl".
+
* Double click on the file, the VTCL editor will open.
+
* Enter the following:
+
 
+
<source lang="text">
+
namespace test;
+
machine hello
+
{
+
rule main() = seq
+
{
+
println("Hello VIATRA2 world!");
+
}
+
}
+
</source>
+
 
+
* There are multiple possibilities to load this transformation into VIATRA2:
+
** Drag-and-drop the VTCL file onto the "modelspace1" entry just like with model imports;
+
** Simply save the file (Ctrl+S), it will be loaded.
+
** If you have saved but performed another edit, pressing Alt+P (parse) will have the same effect as saving.
+
 
+
* After the transformation is loaded, you can run the transformation by:
+
** Pressing Alt+R in the editor (the editor has to have focus)
+
** Double clicking on the (M) icon in the model spaces view
+
** Right-click on the transformation in the model spaces view and select Run.
+
 
+
[[Image:VIATRA2_Editor_Screen_2.png]]
+

Latest revision as of 15:25, 16 March 2010

Back to the top