Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » [QVTo] Mapping that needs to modify initial Model(I am having troubling figuring out how to make a mapping function that needs to create dependencies which did not exist on the initial metamodel)
[QVTo] Mapping that needs to modify initial Model [message #1702611] Thu, 23 July 2015 14:00 Go to next message
João Bastos is currently offline João BastosFriend
Messages: 9
Registered: September 2014
Junior Member
Hi,

First of all, I am quite new to QVTo and probably this was already answered or I can find it in some literature. However, I also seem to lack the knowledge to know what to look for. So if you have another topic or a link, would be great as well.

My problem is quite simple to explain.

I want to transform a metamodel A (of a graph structure) to a metamodel B (also a graph structure). Everything is very straighfoward except for one final transformation I want to make.

Both Metamodels have a basic of tasks and dependencies. However, from Metamodel A to B I want to make new dependencies between tasks.

I have two mappings

    tasksB += self.tasksA.xmap taskA2TaskB();
    dependenciesB += self.allSubobjectsOfType(Dependency)[Dependency].dependencyA2DependencyB();


These two are enough to convert from graph A to graph B. However, I wanted to know if I could while doing a mapping from taskA2TaskB also generate dependencies? Is that not possible ? Multiple outputs of a mapping?

I also tried making a second mapping function that maps from TasksA but now creates not TasksB but DependenciesB. However, this created as many dependencies as there are channels (obviously). So I tried to apply a when:

 mapping Task::specialTaskA2DependencyB() : DependencyB when {self.name.startsWith("special")}  {   


But this gives me an error saying that:

Precondition failed in mapping 'specialTaskA2DependencyB'

And the details do not help at all understanding why this error.

I am a bit lost already in Tutorials and Presentations of QVTo, but it felt it could be easier to ask for some help or tips.

Thank you in advance,
Joao
Re: [QVTo] Mapping that needs to modify initial Model [message #1702633 is a reply to message #1702611] Thu, 23 July 2015 16:03 Go to previous message
João Bastos is currently offline João BastosFriend
Messages: 9
Registered: September 2014
Junior Member
Solved, my own problem. The error on the when was do to the xmap indeed not finding a correct mapping. The variable name was incorrectly defined.

Regarding the transformation. I think I solved it in a rather nasty way. I did a forEach, to select only the tasks I wanted based on the name, and then applied the mapping only on that subset of tasks. Works.

Thank you anyway.
Previous Topic:objectsOfType problem in Mars release
Next Topic:[QVTo] Transform a unique element of the model
Goto Forum:
  


Current Time: Tue Sep 26 09:24:14 GMT 2017

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

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