Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » VIATRA » Application of GTRULE(Help!)
Application of GTRULE [message #1637172] Thu, 26 February 2015 15:25 Go to next message
Paolo Rossi is currently offline Paolo RossiFriend
Messages: 6
Registered: February 2015
Junior Member
Hello,

i'm a newbie on VIATRA2 Framework, i need to do a model2model transformation. I have created both models and metamodels, i've created also a gtrule to map a source element to a target element, but when i run this transformation i've got the following error: "the value of the N variable can not be 'UNDEF' as it is an INPUT parameter for the node2node gtRule". I've followed the examples that i've found on various pdf tutorials. Can anyone help me? The code used is:

rule main(in G) = seq
{
forall N below Graphs.Grafo1 with apply node2node(N) do skip;

}

gtrule node2node(in N) = {

precondition pattern lhs(N) =
{
Graphs.Node(N);
}
postcondition pattern rhs(N) =
{
Graphs.Node(N);
Trees.Node(N);
}
action
{

let T = undef in
new(Trees.Tree(T));
new(Trees.Node(N));
}
}

The Transformation that i'm trying to develop, concern the mapping from a graph node to tree node.
Re: Application of GTRULE [message #1637251 is a reply to message #1637172] Thu, 26 February 2015 16:15 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 187
Registered: September 2015
Senior Member
Hi Paolo,

first of all, welcome to the VIATRA forums!

Next, I think the same problem was already discussed in https://www.eclipse.org/forums/index.php/t/636029/ take look if that solves your problem.

Finally, I wold recommend using asm rules instead of gtrule, they are a bit more easier to work with. Your code would look like this:

pattern graphNode(N) = {
  Graphs.Node(N);
}

rule main(in G) = seq {
  forall N below Graphs.Grafo1 with find graphNode(N) do seq {
    call node2node(N);  
  }
}

rule node2node(in N) = {
  let T = undef in new(Trees.Tree(T));
  new(Trees.Node(N));
}
Re: Application of GTRULE [message #1637309 is a reply to message #1637251] Thu, 26 February 2015 16:51 Go to previous messageGo to next message
Paolo Rossi is currently offline Paolo RossiFriend
Messages: 6
Registered: February 2015
Junior Member
Thanks for the quick response and efficient, now works correctly, You could also tell me how to do through gtrule, since I was asked to use exercise as preconditions and postconditions. I also wanted to ask you, looking at the thread that I have indicated, not by chance you have material or tutorial latest, as even my tutorials are dated. thanks again

[Updated on: Thu, 26 February 2015 16:57]

Report message to a moderator

Re: Application of GTRULE [message #1637339 is a reply to message #1637309] Thu, 26 February 2015 17:11 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 187
Registered: September 2015
Senior Member
Do we have more up-to-date material for VIATRA2?
Unfortunately, no, the most recent documents are on the Eclipse wiki (https://wiki.eclipse.org/VIATRA2).
We no longer develop VIATRA2 and have instead moved to develop EMF-IncQuery and a new generation of VIATRA that provides basic transformation primitives for writing transformations in Xtend (or plain Java).
Re: Application of GTRULE [message #1637347 is a reply to message #1637339] Thu, 26 February 2015 17:16 Go to previous messageGo to next message
Abel Hegedus is currently offline Abel HegedusFriend
Messages: 187
Registered: September 2015
Senior Member
As for doing the same with gtrules, the linked thread has an example, which translated to your case looks like this:

pattern graphNode(N) = {
  Graphs.Node(N);
}

rule main(in G) = seq {
  iterate choose N below Graphs.Grafo1 with find graphNode(N) do
    try choose with apply node2node(N) do skip;
}

gtrule node2node(in N) = {..}
Re: Application of GTRULE [message #1637348 is a reply to message #1637339] Thu, 26 February 2015 17:19 Go to previous message
Paolo Rossi is currently offline Paolo RossiFriend
Messages: 6
Registered: February 2015
Junior Member
I understand, since you mention it I will try to study even EMF-IncQuery and start using it. Regarding ASMrule I've written above, You could show me how to write them in a gtrule with precondition and postcondition and also recall it as the main rule? Thank you very much for your help and your availability.
Previous Topic:[model obfuscator] error while saving obfuscated model
Next Topic:Error while importing metamodels in model space
Goto Forum:
  


Current Time: Wed Sep 20 07:34:23 GMT 2017

Powered by FUDForum. Page generated in 0.04571 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software