Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Finding the target of the edge for setting the label
Finding the target of the edge for setting the label [message #1250793] Wed, 19 February 2014 11:05 Go to next message
Wilbert Alberts is currently offline Wilbert Alberts
Messages: 88
Registered: June 2010
Member
Hi,

I have a problem defining the expression that gives the correct label for an relation based edge.

Suppose that my meta model contains the following entities: Component and Interface.

Components define and provide Interfaces by containing them. Furthermore, Components might depend on Interfaces provided by other Components. (A simple dependsOn property of a Component.)

Suppose that I want to provide a diagram only containing Components. If a Component depends on one ore more Interfaces provided by another Component, I want to draw an edge. The label of that edge should consist of the names of the interfaces representing the relationship between the components.

For example: Three components, A, B, C. B provides interface IB1 and IB2 and C provides interface IC1 and IC2. A depends on IB1, IB2 and IC1.

Then I want to have diagram consisting of three nodes representing A, B and C. Between A and B, an edge should be drawn with the label '[IB1 IB2]' and between A and C, an edge should be drawn labeled '[IC1]'.

In order to draw the edge between two components, I used a target finder expression like: [self.dependsOn.eContainer()/] This results in the component providing the interface self depends on.

However, if I want to provide an expression that generates the label of the edge, I'm running into problems: [self.dependsOn.name/] clearly is wrong. That one will result in all interface names (including IC2 where A is not depending on).

I'm looking for an expression like: [self.dependsOn->select(i | target.provides->includes(i)).name/]

However, 'target' is not available as a variable.

How can I solve this?

Greetings,
Wilbert



Re: Finding the target of the edge for setting the label [message #1250846 is a reply to message #1250793] Wed, 19 February 2014 12:04 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles David
Messages: 111
Registered: July 2009
Senior Member
Le 19/02/2014 17:05, Wilbert Alberts a écrit :
> Hi,

Hi.

> I have a problem defining the expression that gives the correct label
> for an relation based edge.
[snip]
> I'm looking for an expression like: [self.dependsOn->select(i |
> target.provides->includes(i)).name/]
>
> However, 'target' is not available as a variable.
>
> How can I solve this?

I've just tried to reproduce the same kind of structure using Ecore, and
it is indeed possible, but definitely not trivial. You were on the right
track, the structure of your expression is correct and you need the
equivalent of "target", i.e. a pointer to the element "at the other end"
of the specific edge for which you are computing the label.

The expression you need to put instead of the non-existing "target"
variable is the following:

view.oclAsType(DEdge).targetNode.oclAsType(DDiagramElement).target.oclAsType(Component)

It is verbose because OCL needs explicit casting at each navigation
step. Removing these casts for readability we get:

view.targetNode.target

It works like this:
1. It starts from the "view" variable that Sirius supplies. This points
to the model element used by Sirius to represent the graphical edge
itself (it is of type DEdge, from the Sirius metamodel).
2. From there, it find the edge's targetNode. This gives use another
Sirius model element, the one representing the other end of the edge
(the shape representing your component). It is still an element from the
Sirius metamodel (so we need to cast it to DDiagramElement, another
Sirius metamodel type).
3. All Sirius model elements which "stand for" a domain element in your
diagram have a "target" reference to get this semantic element, so we
follow this "target" reference and get the actual Component at the end
of the edge.

So in the end, because your label must be different for each edge, you
can not simply navigate at the level of the domain model but need to
navigate one level "above" in the Sirius model part, from the "view"
variable, and at the end go back to you domain.

I have tried to be clear but I understand that it needs some knowledge
of how Sirius works underneath, so don't hesitate if you need more
explanations.

Regards,
Pierre-Charles David
Re: Finding the target of the edge for setting the label [message #1250874 is a reply to message #1250846] Wed, 19 February 2014 12:39 Go to previous messageGo to next message
Wilbert Alberts is currently offline Wilbert Alberts
Messages: 88
Registered: June 2010
Member
Hi Pierre Charles,

Thanks for your quick and greate response. The answer is perfectly clear to me but I have to wait until tomorrow in order to try it out.

My remaining question is whether the Sirius meta model has been documented somewhere?

I already suspected that I had to go from there but I could not find a reference (that quick).

Greetings,
Wilbert.
Re: Finding the target of the edge for setting the label [message #1251469 is a reply to message #1250874] Thu, 20 February 2014 03:49 Go to previous messageGo to next message
Pierre-Charles David is currently offline Pierre-Charles David
Messages: 111
Registered: July 2009
Senior Member
Le 19/02/2014 18:39, Wilbert Alberts a écrit :
> My remaining question is whether the Sirius meta model has been
> documented somewhere?

No, not yet. I agree that it should be, at least enough to allow
specifiers to create this kind of queries. I've created
https://bugs.eclipse.org/bugs/show_bug.cgi?id=428614 for this.

In the meantime the only source is the metamodel itself, i.e. the
viewpoint.ecore, diagram.ecore, table.ecore and tree.ecore files (note
that we are currently reorganizing things in this area, but it should be
only moving existing stuff in different locations).
Re: Finding the target of the edge for setting the label [message #1251473 is a reply to message #1250874] Thu, 20 February 2014 03:50 Go to previous message
Alex Lagarde is currently offline Alex Lagarde
Messages: 177
Registered: May 2010
Senior Member

Hi Wilbert,

we created the bugzilla 428614
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=428614) to properly
document the representation meta-models.

For the time being, most of the important concepts are described in the
Specifier Manual (mostly in the "Viewpoints", "Diagrams", "Sequence
Diagrams", "Tables" and "Trees" sections)
http://www.eclipse.org/sirius/doc/specifier/Sirius%20Specifier%20Manual.html


Thanks a lot for your feedback, and please keep us in tuch if you have
other questions.

Regards,
Alex
Previous Topic:String concatenation using Accelo
Next Topic:Custom Language for Queries
Goto Forum:
  


Current Time: Mon Jul 28 04:32:58 EDT 2014

Powered by FUDForum. Page generated in 0.02311 seconds