Skip to main content



      Home
Home » Eclipse Projects » Sirius » Example for Element Based Edge needed
Example for Element Based Edge needed [message #1742786] Wed, 07 September 2016 10:54 Go to next message
Eclipse UserFriend
Hello everyone,

unfortunately I got stuck in my definition of the *.odesign. I don't know how to use Element Bades Edges and the creation tool for them properly for my ecore model.
I attached my domain model which I implemented in ecore. My Model exists out of ModelElements, so this is a containment reference in ecore. ModelElements (instances of Class1, Class2, Class3) are connected using concrete connections (instances of ConnectionA, ConnectionC, ConnectionB). So every instance of connection got two attributes of ModelElement in the roles of sourceModelElement and targetModelelement (and vice versa, but resp. a list of connections). There are no ModelElements which have only one incoming connection and no outgoing. This is what the diagram shows so far.
Since I got a special domain object which represents a connection, I have chosen to use Element-Based Edges (I hope this decision is correct).

Now I tried to define the edges in odesign. I created a Element-Based Edge with the
- id: MyFirstConnection
- domain class: ConnectionA
- source mapping: Class1, Class2, Class3
- source finder expression: feature:sourceModelElement
- target mapping: Class1, Class2, Class3
- target finder expression: feature:targetModelElement
- no semantic candidate expression

Afterwards I created a section containing an Edge Creation element. It is defined as follows:
- Id: someid
- edge mappings: MyFirstConnection
- connection complete precondition: aql:preTarget.differs(preSource) <- I don't want to allow self-relations
All the other properties are either false/unchecked or empty.

I hope it was defined correctly so far. If not, please give me a hint.
Now I srsly don't know what I should define in the Begin part of the Edge Creation. I think I have to define, that an Instance of my ConnectionA class should be created and within the two attributes should be set. Am I right? - Can someone please provide me a hint according to my domain scenario?

Thank you very much in advance. In case you need any further information, please let me know.

Thanks
Alex

[Updated on: Wed, 07 September 2016 11:28] by Moderator

Re: Example for Element Based Edge needed [message #1742847 is a reply to message #1742786] Thu, 08 September 2016 04:28 Go to previous messageGo to next message
Eclipse UserFriend
hello

Alex B. wrote on Wed, 07 September 2016 14:54

I hope it was defined correctly so far. If not, please give me a hint.
Now I srsly don't know what I should define in the Begin part of the Edge Creation. I think I have to define, that an Instance of my ConnectionA class should be created and within the two attributes should be set. Am I right?


What you did in the odesign seems corrected. Perhaps you could set you source and target mapping to Class and not Class1, Class2 depending if you want restrictive mapping or nor.

The first thing to do is to test your mapping Element Based Edge. To do so, edit your model in the reflexive editor and create some model element (ModelElement, connection and Class).

About you creation tool, yes, indeed, you have to define some tasks under the begin node. Add a "Create Instance" operation with Type Name=youmetamodel.Connection1 for example. Then add "Set" operation.

Nevertheless, Note that in you meta model, the Connection seems to be not contained by any other class. If it is the case, the "Create Instance" won't work because that operation add an instance for a given feature.
To solve that, instead of using a "Create Instance" operation, you can call a service [1] that will do the job. You can call the service through a "Change context operation"

Regards
Laurent

[1] https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods

Re: Example for Element Based Edge needed [message #1742899 is a reply to message #1742847] Thu, 08 September 2016 09:01 Go to previous message
Eclipse UserFriend
Laurent Fasani wrote on Thu, 08 September 2016 08:28

What you did in the odesign seems corrected. Perhaps you could set you source and target mapping to Class and not Class1, Class2 depending if you want restrictive mapping or nor.

Unfortunately I have to differentiate on the concrete type-level, so this won't be possible...

Laurent Fasani wrote on Thu, 08 September 2016 08:28

The first thing to do is to test your mapping Element Based Edge. To do so, edit your model in the reflexive editor and create some model element (ModelElement, connection and Class).

I tested it and it worked, but I was unable to create connection elements, because of the definition problems in odesign I pointed out in my last post.

Laurent Fasani wrote on Thu, 08 September 2016 08:28

About you creation tool, yes, indeed, you have to define some tasks under the begin node. Add a "Create Instance" operation with Type Name=youmetamodel.Connection1 for example. Then add "Set" operation.

Okay, what I did now was to create a Edge Creation having in the Begin field the following elements:
- Change Context var:container (since I want to Connection instance to be part of the container)
-- Create Instance model.ConnectionA: Reference Name: connections; Type Name: model.ConnectionA; Variable Name: instance
--- Set Feature Name: sourceModelElement; Value Expression: var:source
--- Set Feature Name: targetModelElement; Value Expression: var:target
When I try to execute the odesign instance everytime I try to establish a connection between the classes A, B or C, I run into an exception which says that classA does not contain the feature connections. Yes, it cannot contain the feature, because classA does not derive from Connection or Model. But how can I solve this in another way?

Please consider the modified class diagram (according to your recommendations) I attached on this post.

Laurent Fasani wrote on Thu, 08 September 2016 08:28

Nevertheless, Note that in you meta model, the Connection seems to be not contained by any other class. If it is the case, the "Create Instance" won't work because that operation add an instance for a given feature.
To solve that, instead of using a "Create Instance" operation, you can call a service [1] that will do the job. You can call the service through a "Change context operation"

Okay, so I change the context to var:container and call a service having the variables source and target? Could you maybe provide a working example for the odesign and the service implemented in Java?

Thank you for your help in advance!

Regards
Alex
Previous Topic:Validation inside tree and table diagram
Next Topic:Problem with reference to the metamodel when implementing Java Service
Goto Forum:
  


Current Time: Sat Mar 22 12:52:46 EDT 2025

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

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

Back to the top