Description of UnQL+ model transformation demonstration

BiG team

Oct. 29 2008

1 Overview

This document describes how to use our demonstration page of model transformation system based on UnQL+ [5]. UnQL+ is our extension of UnQL[3] to support graph editing primitives.


2 Quick Tour

  1. On the demonstration page, you can see the image of source DB at the beginning.
  2. Below the image, you can select UnQL+ queries by the list box. Select ``class2rdb6.unql''.

  3. Push ``Select Query'' button.

  4. The text representation of the query chosen appears at a large textbox. You can edit the text if you want, but leave the text intact at the moment. Below the box there are three check boxes. Check the ``Validate Input'' and ``Print UnCAL expression''. Below the check boxes, there are two buttons ``submit'' and ``cancel''. Push the ``submit'' button to issue the UnQL+ query displayed (it will take some time).

  5. On the ``UnQL+ query result'' page, you will see sections ``Input model'', ``executed command:'', ``message by processor:'', and ``Result Graph:''.

    In the ``message by processor'' section, you can see the result of the input validation between the banner **** begin Input validation message *** and **** end Input validation message ***. Other information such as ``Submitted Query'' and ``Executed UnCAL expr.'' are sandwiched similarly.

    The ``Result Graph:'' section shows the result of the transformation, represented as a graph. This graph represents two tables named ``Phone'' and ``Person'', as you can see two edges labeled ``Table'' originated from the top node, the pointed nodes from which you can find edges respectively ``Phone'' and ``Person'' by following the edges ``name'' and ``String'' successively.


3 How the Overall Transformation Works

The demonstration system consists of a set of CGI programs that call UnQL+ model transformation on the background. A brief step-by-step explanation of the execution sequence follows.
  1. Load input model in graph representation as displayed in the ``Input model'' section at the start page.

  2. Load the transformation written in UnQL+. In this demo, you can choose one of the three examples from the list box in the ``Choose from transformations below'' section. Regardless of this choice, any other transformation can be executed by editing the query after pushing ``Select Query'' button.

  3. Load the Input/Output Metamodel written in Kernel MetaMetaModel(KM3)[1] for validation.

  4. Validate the input model using the Metamodel chosen above. In this demo, you should check the ``Validate Input'' box if you actually want to turn on this validation step. This check box may not be active if no KM3 Metamodel is available for the chosen example.

  5. Translate UnQL+ source to UnCAL expression by a desugaring algorithm described in [4] and [3]. In this demo, you can see this UnCAL expression between the banners begin/end Executed UnCAL expr. in the ``message by processor:'' section by checking the ``Print UnCAL expression'' box before submitting the query.

  6. Infer the type of the UnCAL expression statically. You may see an error message by this type system if you edit sample transformation and submit ill-typed query. If this typing process succeeds, the UnCAL expression is augmented with this type information.

  7. (Optionally) rewrite this UnCAL expression for optimization using fusion and other simplification rules. Some rules make use of the type information augmented in the previous stage.

  8. Validate output graph using another KM3 source. You can turn on this validation by checking ``Validate Output`` box.

  9. Render the output graph representation using DOT system1, graph layout products developed by AT&T. In this demonstration, you can see this result in the ``Result Graph:'' section. Because of the cyclic structure of the model, the root node is not always rendered at the top.


4 Sample Transformations you can Choose

You can currently choose the following three transformations.

view source db
produces the input graph itself. This transformation corresponds to an identity transformation. Since it is the simplest code of UnQL+, it is the best one to start with and modify.

select $db where true

The input/output validation is based on KM3 Class package, which is listed in Figure 1.

Figure 1: KM3 metamodel for classes
\begin{figure}\small\begin{quote}
\begin{verbatim}package Class {
datatype S...
...lass PrimitiveDataType extends Named {
}
}\end{verbatim}\end{quote}\end{figure}

class2rdb6.unql
represents the simplified version of the model transformation ``Class to 2RDBMS'' that was proposed as a common example to all the participants of the International Workshop on Model Transformations in Practice 2005[2]. The input and output validation is based on KM3 Class and Table package (Figure 2), respectively.
Figure 2: KM3 metamodel for tables
\begin{figure}\small\begin{quote}
\begin{verbatim}package Table {
datatype St...
...lass PrimitiveDataType extends Named {
}
}\end{verbatim}\end{quote}\end{figure}

fusion.unql+
exemplifies composition of a selection followed by transformation using graph editing primitive replace that is a part of our language extensions to the original UnQL.
replace $G by {"Telephone":{}}
where
  {Class.name.String:$G} in
    select $c
    where
      {Association.dest:$c} in $db,
      {Class.name.String:$p} in $c,
      {$L:$Any} in $p,
      $L = "Phone",
  {$L:$Any} in $G,
  $L = "Phone"

This transformation first retrieves a subgraph, using select expression, which corresponds to a class placed at destination association named ``Phone'', and then replace the name with ``Telephone''.


5 Editing the Sample Transformations

If you are dissatisfied with the given transformation example, you can edit it in-place at the textbox in the ``UnQL+ query edit'' page before pressing ``submit'' button. For example, if you choose ``view source db'' and enclose the variable reference $db with a tree constructor ``{result: }'' like
select {result: $db} where true
you can see the ``result'' edge above the root node No. 69 in addition to the input graph.

6 Interpreting Validation Messages

If the validation succeeds, the validator prints a map of known classifiers, which maps a node number to the name of feature associated with the node as a result of the validation. For example, consider the message produced by selecting sample query ``view source db'' with ``Validate Input'' box checked.
********* begin Input validation message *************
Input validation took 0.001239 CPU seconds
Validation succeeded.
VMap{Bid(2) => `datatype "Boolean"; Bid(5) => `datatype "Boolean";
  Bid(8) => `datatype "Boolean"; Bid(11) => `datatype "String";
  Bid(15) => `datatype "String";
  Bid(17) => `klasse{kname = "PrimitiveDataType"};
  Bid(18) => `klasse{kname = "PrimitiveDataType"};
  Bid(22) => `datatype "String"; Bid(26) => `datatype "String";
  Bid(30) => `datatype "String"; Bid(31) => `klasse{kname = "Attribute"};
  Bid(32) => `klasse{kname = "Attribute"};
  Bid(33) => `klasse{kname = "Attribute"}; Bid(36) => `datatype "Boolean";
  Bid(39) => `datatype "Boolean"; Bid(42) => `datatype "Boolean";
  Bid(44) => `klasse{kname = "Class"}; Bid(47) => `klasse{kname = "Class"};
  Bid(50) => `datatype "String"; Bid(51) => `klasse{kname = "Class"};
  Bid(54) => `klasse{kname = "Class"}; Bid(57) => `datatype "String";
  Bid(60) => `datatype "String"; Bid(61) => `klasse{kname = "Association"};
  Bid(64) => `datatype "String"; Bid(65) => `klasse{kname = "Association"};
  Bid(68) => `datatype "String"}
********** end Input validation message **************
The output Bid(2) => `datatype "Boolean" at the 4th line of the output denotes that the node No. 2 is detected to have a primitive data type ``Boolean'', while at the 11th line Bid(32) => `klasse{kname = "Attribute"}; means that node No. 32 belongs to a class named ``Attribute''.

Next we investigate the cases in which validation fails. Please select ``view source db'' at the list box at the start page and press ``submit''. On the next page, replace the content with the following transformation:

replace {$L:$G1} by {nameXXX:$G1}
where {Association: $G} in $db,
      {$L: $G1} in $G, $L=name
After checking the ``Validate Output'' box, press ``submit''. In the result graph, you can see the ``name'' label of the edges that is originated from the nodes that are pointed by the root node by ``nameXXX''. This time, validator says
Validation failed.
Failure("Validation fails at Bid(70). Feature \"name\" is missing.")
which means that we miss the ``name'' feature that is required for every class as is indicated in the KM3 Class.km3 source in Figure 1.

Another error message can be exposed similarly using the following transformation:

replace {$L:$G1} by {Assoc:$G1}
where {$L:$G1} in $db, $L=Association
This time we get:

Validation failed.
Failure("Validation fails at Bid(69). ALLbl(\"Assoc\") is invalid.")
since we replaced using the transformation the topmost ``Association'' edges with ``Assoc'' edges. The validator complains because the class ``Assoc'' is not in the KM3 source.

Bibliography

1
ATLAS group.
KM3:Kernel MetaMetaModel manual.
http://www.eclipse.org/gmt/atl/doc/.

2
J. Bezivin, B. Rumpe, and Tratt L Schürr A.
Model transformation in practice workshop announcement.
In MTiP 2005, International Workshop on Model Transformations in Practice. Springer-Verlag, 2005.

3
Peter Buneman, Mary F. Fernandez, and Dan Suciu.
UnQL: a query language and algebra for semistructured data based on structural recursion.
VLDB Journal: Very Large Data Bases, 9(1):76-110, 2000.

4
Soichiro Hidaka, Zhenjiang Hu, Hiroyuki Kato, and Keisuke Nakano.
Towards compostional approach to model transformations for software development.
Technical Report GRACE-TR08-01, GRACE Center, National Institute of Informatics, August 2008.

5
Soichiro Hidaka, Zhenjiang Hu, Hiroyuki Kato, and Keisuke Nakano.
Towards a compositional approach to model transformation for software development.
In SAC '09: Proceedings of the 2009 ACM symposium on Applied computing. ACM, 2009.
To appear.



Footnotes

... system1
http://hoagland.org/Dot.html
Big Team
2008-10-30