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 |
C. Kopf 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.
[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 |
PBarendrecht 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 #521437 is a reply to message #519653] |
Wed, 17 March 2010 15:32 |
C. Kopf Messages: 37 Registered: November 2009 |
Member |
|
|
Hi P.,
thanks for your offer , 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.
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.
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?
|
|
|
Re: [QVTo] Transforming a relation to a already transformed Element [message #521814 is a reply to message #519653] |
Thu, 18 March 2010 19:17 |
PBarendrecht 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 .
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 .
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
|
|
|
Re: [QVTo] Transforming a relation to a already transformed Element [message #523525 is a reply to message #519653] |
Fri, 26 March 2010 17:10 |
C. Kopf 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
|
|
|
Goto Forum:
Current Time: Thu Mar 28 15:56:16 GMT 2024
Powered by FUDForum. Page generated in 0.04385 seconds
|