Query by Example: create queries based on selected model elements
Query by Example (QBE), a new feature to ease query development, was introduced in Viatra version 1.3. This new tool is primarily aimed at users who want to define queries, but are only familiar with the concrete syntax of a modeling language (i.e. the view presented through a graphical or textual editor), not the intricate details of its abstract syntax (metamodel, EPackgage).
Instead of manually writing .vql files, QBE allows the user to specify a query using an example - a selection of EMF instance objects highlighted in a model editor or viewer (both EMF tree editors and graphical editors are supported). The QBE tool will discover how the selected elements are related to each other in the model, and generate a .vql query that will find groups of model elements that are arranged similarly.
The Query by Example view allows the user to control the process of (a) identifying elements selected in an open model file as the example, (b) fine-tuning the options of interpreting the example, and (c) exporting the resulting query to .vql code. The exported query can be loaded into the Query Explorer (or the new Query Results view) for evaluation and testing; if necessary, adjustments can still be made in the Query by Example view (e.g. adding or removing additional constraints).
- The feature can be installed by selecting the VIATRA Query-by-Example (Incubation) addon from the VIATRA repository.
- A tutorial and screencast is available at the Viatra blog.