Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] Resvolving and query help please
[QVTO] Resvolving and query help please [message #500845] Sun, 29 November 2009 16:13 Go to next message
PBarendrecht is currently offline PBarendrechtFriend
Messages: 36
Registered: November 2009
Location: Eindhoven, Netherlands
Member
Hi all,
I'm still working on my test case, a "simple" QVTO transformation. I wrote all mappings down, but now I have to program some queries and "resolvings".

Suppose there are two metamodels of a simple automaton (only consisting of locations (with a name) which are connected by edges). In both metamodels, the locations are contained in the automaton.
However, in the first metamodel (mm1) the edges are contained in the location, in the second metamodel (mm2) in the automaton.

This means when I transform mm1 to mm2, I have to program a query to find the edges which belong to the automaton (in a more elaborate metamodel, there can be multiple automata, so it's not simply finding all edges - just the ones belonging to the specific automaton). I'm working on this query, but it would be nice if I had some examples.

Furthermore, each edge in mm2 obviously has a source location and a target location. In mm1 the edge only has a target location, because the source location is it's parent (it's contained in that location).
I have to find out how to find the source and target location in my mm2. I think I have to apply a "resolve" command, but I don't know how. After I read the M2M-QVTO .pdf file, I think it should be a resolveIn, but how do I use it?
Re: [QVTO] Resvolving and query help please [message #500860 is a reply to message #500845] Sun, 29 November 2009 20:05 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

Hi pieter,

As for queries, QVTO extends OCL and just comes with some syntactic
sugar, simplifications to existing OCL constructs.

You need to learn OCL to write queries. You can ask for help at
the 'eclipse.modeling.mdt.ocl' newsgroup.

I have taken the example below from the OMG spec for QVTO and
made a few corrections.
8.1.10 Updating Objects and Resolving Object References


transformation Uml2Java(in uml:UML,out java:JAVA)
main() {
uml->objectsOfType(Class)->map transformClass();
uml->objectsOfType(Class)->map transformClassInheritance();
}
mapping UML::Class::transformClass() : JAVA::Interface {
name := "Ifce".concat(self.name);
}
mapping UML::Class::transformClassInheritance() : JAVA:Interface {
base := self.superClass->resolveIn(UML::Class::transformClass,
JAVA::Interface);
}


The reference to the rule is given by a qualified identifier (context
class and name). As a limitation of the concrete syntax,
it is not possible to provide a reference to a rule if there is an
ambiguity (having the same name and context but different
parameters)

Note, the QVTO implementation requires a qualified identifier of a
mapping, though
the spec uses a simple name in a couple of examples.

I would like to encourage you, at least try to come up with a particular
mapping, perhaps
working differently from what you want or not working at all.
Then we can help.
It's hard to guess from a verbal descriptions of metamodels.
Just two classes with a mapping which need to be solved would be better.

I know QVTO seems hard initially, as many people who already got over the
initial
troubles can confirm. But it's just the begining ;).


Regards,
/Radek



On Sun, 29 Nov 2009 17:14:09 +0100, PBarendrecht <pieter@redpanda.nl>
wrote:

> Hi all,
> I'm still working on my test case, a "simple" QVTO transformation. I
> wrote all mappings down, but now I have to program some queries and
> "resolvings".
>
> Suppose there are two metamodels of a simple automaton (only consisting
> of locations (with a name) which are connected by edges). In both
> metamodels, the locations are contained in the automaton. However, in
> the first metamodel (mm1) the edges are contained in the location, in
> the second metamodel (mm2) in the automaton.
>
> This means when I transform mm1 to mm2, I have to program a query to
> find the edges which belong to the automaton (in a more elaborate
> metamodel, there can be multiple automata, so it's not simply finding
> all edges - just the ones belonging to the specific automaton). I'm
> working on this query, but it would be nice if I had some examples.
>
> Furthermore, each edge in mm2 obviously has a source location and a
> target location. In mm1 the edge only has a target location, because the
> source location is it's parent (it's contained in that location). I have
> to find out how to find the source and target location in my mm2. I
> think I have to apply a "resolve" command, but I don't know how. After I
> read the M2M-QVTO .pdf file, I think it should be a resolveIn, but how
> do I use it?
Re: [QVTO] Resvolving and query help please [message #500864 is a reply to message #500845] Sun, 29 November 2009 20:45 Go to previous message
PBarendrecht is currently offline PBarendrechtFriend
Messages: 36
Registered: November 2009
Location: Eindhoven, Netherlands
Member
Thanks again for your reply Radek.

About the queries, I'm looking into OCL at the moment. One thing I don't know how to do, is to find the grandparent of an object. In MM2 the edges are contained in an Automaton, I have to perform a check on all edges of MM1: I need to know whether the parent (i.e. the location containing the edge) is contained in the right Automaton, such that the name of that Automaton is the same as in MM2.

I understand it might be difficult to understand the metamodels just from a short description, so I made screenshots of my .ecorediags (MM1,MM2).

MM1:
http://www.redpanda.nl/MM1.png

MM2:
http://www.redpanda.nl/MM2.png

Here are some mappings of my qvto model:

mapping MM1::Automaton::toBody() : MM2::Automaton {
	Name := self.Name;
	locations += self.locations.map toLocation();
	--From here, contain the edges that belong to this automaton
	edges += Location.outgoingEdges.map toEdge(); --?
	--Above obvioulsy doesn't work, use query - but how
}

mapping MM1::Location::toLocation() : MM2::Location {
	Name := self.Name;
}

mapping MM1::Edge::toEdge() : MM2::Edge {
	--Edge transformation
	sourceLocation += self.sourceLocation.resolve --link to outgoingEdges?
	targetLocation += self.targetLocation --? ; 
	--No containmant but just a reference, so use resolve?
}


My question is, which type of resolve do I need to use to find the right sourceLocation in MM2?
And how can I link to the right targetLocation? At the moment, I assign a targetLocation from MM1 which doesn't work - it has to be a mapped location from MM2. I'm looking for a way to express an already mapped location Smile

[Edit]
All three points are solved now. I didn't write a query but
edges += self.locations.outgoingEdges.map toEdge();

Although self.locations is an orderedSet, I can yet ask for the outgoingEdges.

About the source- and targetLocations, I used a combination of container() and resolveone().

[Updated on: Mon, 30 November 2009 17:27]

Report message to a moderator

Previous Topic:QVT - how to programatically retrieve the model(AST) from the transformation script
Next Topic:[ATL] Is UML profile supported as output metamodel?
Goto Forum:
  


Current Time: Fri Aug 23 13:15:27 GMT 2019

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

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

Back to the top