Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] Transforming a relation to a already transformed Element(How to transform a relation to an already transformed element.)
[QVTo] Transforming a relation to a already transformed Element [message #519653] Tue, 09 March 2010 15:32 Go to next message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
Hello everybody.

It is a bit tricky to explain my issue, I hope you will understand what I mean:

lets say we have a model looking like this:

A Package contains several Elements via the relation elements. Element is an abstract type and one of its generalizations is ComInterface another one is Cluster. A Cluster may have several ComPorts, this is done via the relation ports. Each ComPort has exactly one ComInterface via the relation interface. The interface of a ComPort is defined in the same Package as the ComPort's Cluster.
So as we see, the relation interface links to a ComInterface which is also reachable via Package->elements->

Now we make a transformation wheere almost one-to-one mapping is possible (just for simplification).
we map as follows:

Package -> Pack
---elements -> contains
---ComInterface -> Port
---Cluster -> Component
------ports -> comParts
------ComPort -> PortDef
---------interface -> uses
---------ComInterface -> Port

well and now I get the problem:
lets say a ComInterface named "xyz" was defined as an element under some package, and the same ComInterface was defined to be the interface used by a ComPort of a Cluster in the same Package. How can I ensure that my tranformation maps this identification-information as well. in such a way that in the 'output-model' "xyz" is a Port defined in a package and a PortDef 'within' the same Package uses "xyz"?

The mapping-table as above creates some unneccessary Port and the identification, saying that a used Port is the one already mapped and contained in the Package, is lost. Sad

[Updated on: Tue, 09 March 2010 15:53]

Report message to a moderator

Re: [QVTo] Transforming a relation to a already transformed Element [message #519677 is a reply to message #519653] Tue, 09 March 2010 16:47 Go to previous messageGo to next message
PBarendrecht is currently offline PBarendrechtFriend
Messages: 36
Registered: November 2009
Location: Eindhoven, Netherlands
Member
Hi,

It seems to me you're trying to resolve an already mapped object.
If you have already mapped something, and later on see a reference to the already mapped object, the reference must be resolved.

You can do this in several ways:

Return multiple objects (if the source object was mapped to multiple target objects):
.resolve( result_type)
.resolveIn ( specific_mapping, result_type )

Used more often, return single object (the source object was mapped to only one target object):
.resolveOne (result_type )

If you look it up in the OMG specs, there might be some more info.
You might be interested in my QVTo Tutorial. I'm still working on it, I've yet to write the "resolving" chapter and other stuff, but the introduction is finished.

http://redpanda.nl/index.php?p=qvt and click on Tutorial.

Have fun with QVT!
Re: [QVTo] Transforming a relation to a already transformed Element [message #519963 is a reply to message #519653] Wed, 10 March 2010 16:26 Go to previous messageGo to next message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
First of all: Thanks a lot for your help.

Your tutorial is pretty nice, wish I found it earlier, it would have made thinks much easier. Poorly it is just as far as I am into QVTo, but I am looking forward to the upcomming pages. It is realy nice thanks a lot.

Now I tried out all the following:

type:=self.interface.oclAsType(ComInterface).late 
resolveoneIn(ARSEP::ComInterface::comInterface2port, TCN::Port);

// using 'late' just for the case that propably the transition was not already made (actually it should ;o)


type:=self.interface.oclAsType(ComInterface)
resolveoneIn(ARSEP::ComInterface::comInterface2port, TCN::Port);

// just as used in some cases in the SimpleUml2RDB example


type := self.interface.oclAsType(ComInterface).resolveone(p:Port|p.name.match(self.interface.shortName));

// this seems to me to fit best in syntax syntax



All three do not work as wished.
Now no additional Ports are generated, but also nothing is places at the end of the type relation. Although the necessary Port exists in the output model.
I think there is something wrong in the way a use the resolve expressions, but even in the tutorials i did not get any idea on how to use them. in the QVT specification also no additional information can be found according to this.

Does anybody see what I am doing wrong or does anybody know how to use the resolve expressions?
Re: [QVTo] Transforming a relation to a already transformed Element [message #520009 is a reply to message #519963] Wed, 10 March 2010 18:44 Go to previous messageGo to next message
PBarendrecht is currently offline PBarendrechtFriend
Messages: 36
Registered: November 2009
Location: Eindhoven, Netherlands
Member
Thanks Smile

You wrote:
Each ComPort has exactly one ComInterface via the relation interface.

Now you would like to transform this reference to uses, right?
I think it should be something like this:

uses := self.interface.resolveone(TCN::Port);


If the ComInterface hasn't been mapped to a Port yet, add "late".
Re: [QVTo] Transforming a relation to a already transformed Element [message #520852 is a reply to message #519653] Mon, 15 March 2010 15:25 Go to previous messageGo to next message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
Yeah thanks P.,

this was just a stupid copy-paste-failure.

you are right it should be uses instead of type, but it does not work anyway.

here is the line as I expect it to be right:

uses := self.interface.oclAsType(ComInterface).resolveone(p:Port|p.name.match(self.interface.shortName));


Does anyone find a mistake in the syntax?
The condition is used to identify the Port, because more than one port may be transformed before. This is neccessary, isn't it?

BTW.: I read your tutorial again (especially the added parts) - thanks, it is very good, and all the best for your BSc-Theses
Re: [QVTo] Transforming a relation to a already transformed Element [message #520865 is a reply to message #519653] Mon, 15 March 2010 15:51 Go to previous messageGo to next message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
I expect the problem to be already in the emf-files or even further a matter of the rich-client-platform I am using. If I find some possibility to solve it I will let you know.
Re: [QVTo] Transforming a relation to a already transformed Element [message #521105 is a reply to message #519653] Tue, 16 March 2010 13:40 Go to previous messageGo to next message
PBarendrecht is currently offline PBarendrechtFriend
Messages: 36
Registered: November 2009
Location: Eindhoven, Netherlands
Member
Hi, I'm glad you like the tutorial.
Would it be possible for you to e-mail me the entire project? Maybe I can figure it out.

Recently I noticed the conditional resolvings don't work like they should (when I use it, I always get the same results, no matter what condition I use).
icon7.gif  Re: [QVTo] Transforming a relation to a already transformed Element [message #521437 is a reply to message #519653] Wed, 17 March 2010 15:32 Go to previous messageGo to next message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
Hi P.,

thanks for your offer Smile , but I do not think that I am allowed to send the whole project or even just a single complete file to anyone outside the consortium, even so I would like to, sorry. Neutral

However, as written before there is a chance that the problem is already located either in the source model, the metamodel-xml-description (ecore, emf and all this) or in the rich-client-plattform (some problems with saving changes in both, the source- and the target-model) i am using. I shall inspect the source code of all three to find out what is not working as wished. This will take some time, but if I find anything of interest I will let you know.

Arrow
Your notices about conditional resolvings match my observations. I simply get the same result when using the statement without any condition clause.
If this is a bug of the QVTo-Implementation it is somehow significant. As I already mentioned I need to realize a one-on-one resolve where there exist several objects of the Type Port. To identify the "correct" one, I need some kind of condition, don't I?
Question
Re: [QVTo] Transforming a relation to a already transformed Element [message #521814 is a reply to message #519653] Thu, 18 March 2010 19:17 Go to previous messageGo to next message
PBarendrecht is currently offline PBarendrechtFriend
Messages: 36
Registered: November 2009
Location: Eindhoven, Netherlands
Member
Hi C,

Quote:
...but I do not think that I am allowed to send the whole project or even just a single complete file to anyone outside the consortium, even so I would like to, sorry.

I understand it, I know the problem Wink.

Yep, a thorough inspection of your input model could be useful. Do you get any results at all when you run the transformation? You can test whether the transformation reaches certain mappings by adding log("text").
If there are no results, the problem could be the URI of the metamodel in the input model, see page 9 of the tutorial Smile.

Hmm, I just tested the conditional resolvings again, they suddenly work. Maybe I configured something wrong last time, weird.
However, if it still doesn't work you could add some OCL commands like ->select or ->selectOne. It seems this last function only needs a condition, like this:

targetMode := self.targetLocation.resolve(Mode)->selectOne(m|m.Name.startsWith("S"));


I think there is actually a difference between selectOne and resolveOne with a condition: resolveOne returns the last object of a list, while selectOne returns the first (I think):

targetMode := self.targetLocation.resolveone(m:Mode | m.Name.startsWith("S"));


Well, good luck figuring out the problem Smile
Re: [QVTo] Transforming a relation to a already transformed Element [message #523525 is a reply to message #519653] Fri, 26 March 2010 17:10 Go to previous message
C. Kopf is currently offline C. KopfFriend
Messages: 37
Registered: November 2009
Member
Hi P.,

thanks for your input.
I had to work in a different project for a week, so this answer is pretty late, sorry.

I figured out that there was a problem in the rich-client-platform I am using, some issue with saving changes in models and so on. This is fixed now.

But still, none of the resolve functions returns the needed result.

I also tried your idea with using the selectOne-function, still no result at all, the resolve did not work which actually means that there is nothing to select.
I also expect I need a late resolving, but this does not work with the selectOne-function does it?

when using the following code a get a warning, which says:
Quote:
The result of ''late resolve'' must be assigned to a property or non-local variable to execute as deferred assignment


here is the code used:
uses := self.interface.oclAsType(ComInterface).late resolve(Port)->selectOne(p|p.name.match(self.interface.shortName));


I am still checking the metamodels but i do not expect that there is an issue with them.
I also found out that all other mappings etc. work pretty fine (via logs and stuff like this).
by the way, is there a possibility to call late resolved values/objects in a log-statement? When simply calling a resolve function in a log-statement the warning, as seen above, occures, and here I understand what it means but anyway it would be very helpful, so probably anyone knows a way to do it?

Thanks again and have a nice weekend.

Cheers,

Chris
Previous Topic:[ATL] Helper def with super-imposition
Next Topic:ATL URGENT - Reading programmatically Input and Output Models
Goto Forum:
  


Current Time: Tue Oct 22 15:01:20 GMT 2019

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

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

Back to the top