Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTo] Setting the parent (owner) of a new element
[QVTo] Setting the parent (owner) of a new element [message #654866] Thu, 17 February 2011 13:30 Go to next message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
Hi,

Let's say I'm adding a new element to an activity diagram in a UML model via a transformation. The structure might look like this:

Model (top level element) contains Activity which contains some diagram elements

When I add a new element, it is owned by the Model element but not the Activity element and the owner property is read only so I can't set it explicitly. How can I set the Activity element as the parent of the new element?
Re: [QVTo] Setting the parent (owner) of a new element [message #655043 is a reply to message #654866] Fri, 18 February 2011 07:11 Go to previous messageGo to next message
Dennis HendriksFriend
Messages: 66
Registered: January 2010
Location: The Netherlands
Member
Let me be clear upfront: I don't know anything about UML Activity diagrams.

However, usually, one sets the owner (container) X of an element Y by
including Y in a feature of X. For your case, (in the mapping) for the
Activity class, I would expect the Activity class to have some containment
feature that is called something like 'elements' or 'diagramElements' orso.
If you then create a diagram element and include it in the 'elements'
feature, it would be contained (owned by) the instance of the Activity class.

Hope this helps,
Dennis


Haffi wrote:
> Hi,
>
> Let's say I'm adding a new element to an activity diagram in a UML model
> via a transformation. The structure might look like this:
>
> Model (top level element) contains Activity which contains some diagram
> elements
>
> When I add a new element, it is owned by the Model element but not the
> Activity element and the owner property is read only so I can't set it
> explicitly. How can I set the Activity element as the parent of the new
> element?
Re: [QVTo] Setting the parent (owner) of a new element [message #655131 is a reply to message #655043] Fri, 18 February 2011 13:04 Go to previous messageGo to next message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
The Activity container has a property called 'ownedElements' which is also read only like the 'owner' so I'm stumped. (The mapping itself is actually working with an element in the activity diagram but not the diagram itself, but I guess that shouldn't matter)

Via debugging I've found a property of the Activity container which is called node and is a set of the nodes, but it's hidden because if I try to do something like:
activityContainer.node := something...

the editor gives me an error that 'node' is not a variable.
Re: [QVTo] Setting the parent (owner) of a new element [message #655491 is a reply to message #655131] Mon, 21 February 2011 12:14 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: koen.yskout.cs.kuleuven.be

The properties you have tried to set (e.g., ownedElements) are derived
as the union of several other properties, so you can't set/modify it.

Activity does have a (non-derived) property 'node' which contains the
ActivityNodes of that activity, so it should be possible to set or
modify this. Probably, there is an error in your syntax (or in the
things that supposedly don't matter :p), so I guess you'd need to
provide more specific information to solve that particular problem.

Btw, an easy way to explore the UML metamodel is by using the Metamodel
Explorer view that ships with QVTo, to find out which properties exist
and are (or aren't) derived. To me, this is easier than using the
debugger :)

Regards,
Koen


On 18/02/11 14:04, Haffi wrote:
> The Activity container has a property called 'ownedElements' which is
> also read only like the 'owner' so I'm stumped. (The mapping itself is
> actually working with an element in the activity diagram but not the
> diagram itself, but I guess that shouldn't matter)
>
> Via debugging I've found a property of the Activity container which is
> called node and is a set of the nodes, but it's hidden because if I try
> to do something like:
> activityContainer.node := something... the editor gives me an error that
> 'node' is not a variable.
Re: [QVTo] Setting the parent (owner) of a new element [message #655507 is a reply to message #655491] Mon, 21 February 2011 13:54 Go to previous messageGo to next message
Haffi is currently offline HaffiFriend
Messages: 39
Registered: November 2010
Member
Thank you for pointing out the metamodel explorer, it's very helpful. I still can't find a way to change or set the node property, the list of possible methods on the object doesn't seem to contain anything to influence this. Is it possible that I might somehow have to change this through Java code?
Re: [QVTo] Setting the parent (owner) of a new element [message #655669 is a reply to message #655507] Tue, 22 February 2011 09:17 Go to previous message
Eclipse UserFriend
Originally posted by: koen.yskout.cs.kuleuven.be

Haffi,

No, you should not need Java code to do this.
The following simple transformation works for me without any problems,
so I'm not sure what causes the problems you are having...


modeltype UML "strict"
uses uml("http://www.eclipse.org/uml2/3.0.0/UML");

transformation SampleTransformation(inout model : UML);

main() {
model.rootObjects()[Model]->map testAddActivity();
}

mapping inout UML::Model::testAddActivity() {
self.packagedElement += map newActivityWithFlowFinalNode();
}

mapping newActivityWithFlowFinalNode() : UML::Activity {
name := "testActivity";
node += object FlowFinalNode {
name := "flowFinal";
}
}


On 21/02/11 14:54, Haffi wrote:
> Thank you for pointing out the metamodel explorer, it's very helpful. I
> still can't find a way to change or set the node property, the list of
> possible methods on the object doesn't seem to contain anything to
> influence this. Is it possible that I might somehow have to change this
> through Java code?
Previous Topic:[ATL] 3rd International Workshop on Model Transformation with ATL (MtATL2011)
Next Topic:[ATL] automatic copy of a model
Goto Forum:
  


Current Time: Thu Feb 25 09:27:25 GMT 2021

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

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

Back to the top