Skip to main content



      Home
Home » Eclipse Projects » Sirius » Problem in creating edge when classes in different packages in sirius
Problem in creating edge when classes in different packages in sirius [message #1794565] Mon, 03 September 2018 02:54 Go to next message
Eclipse UserFriend
Hi all, I have a model with multiple packages. And am trying to create a diagrammatic representation for them using sirius. I have an eClass in one package. And a class from other package is used to connect classes in first package. Can I do that?If so how can I create an edge between nodes using a class from other package.

For example like there are two packages Building and Books under a package Products .
In package Building I have a class called Shop
And in package Book there is a class called Pages. And one more class called Address which extends Pages class. And there is a Factory class called ProductFactory. Now is it possible to connect two shop class nodes with address class as an edge?

[Updated on: Wed, 05 September 2018 04:49] by Moderator

Re: Problem in creating edge [message #1794566 is a reply to message #1794565] Mon, 03 September 2018 02:57 Go to previous messageGo to next message
Eclipse UserFriend
I added all classes in meta model. And I specified correct domain class also. But I am not getting the value which I need to give for Reference name * in create instance while edge creation.

Can any one help me on this?
Re: Problem in creating edge [message #1794602 is a reply to message #1794566] Mon, 03 September 2018 11:39 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
May I ask why you are using many packages instead of only just one?
Reference name should indicate a reference from book that contains all the Adress instances. You should have something like adresses in your ecore. This should be used in the reference name.
You should first set the context to book instance so the reference adresses can be find and the adress instance added.
Then you should have some operations to associate the new adress instance with the shops instances by setting the right references.
In fact it depends of your metamodel.

Regards,

Re: Problem in creating edge [message #1794702 is a reply to message #1794602] Wed, 05 September 2018 02:49 Go to previous messageGo to next message
Eclipse UserFriend
Hi Pierre,

Thanks for replying..!!

There is no direct relation. I mean there is only pages reference(for page class). No adresses reference. Address is subclass of page. So it is getting difficult to create an edge. Then we can not do in that meta model?

May I know can we create the edge using the Java action? I tried using that also..

How can we pass the diagram as parameter to Java action.

If I use let diagram with value expression aql:diagram::DSemanticDiagram and pass that argument to Java action as parameter
DSemanticDiagram diagram = (DSemanticDiagram) parameters.get("diagram");
Iterator<DDiagramElement> it = new DDiagramQuery(diagram).getAllDiagramElements().iterator();

It gives class cast exception like this.

index.php/fa/33815/0/

We have already that model with many packages and in multi level. It takes time to recreate model in one package. So we are trying to apply for that model only!!

[Updated on: Wed, 05 September 2018 03:08] by Moderator

Re: Problem in creating edge [message #1794708 is a reply to message #1794702] Wed, 05 September 2018 05:57 Go to previous messageGo to next message
Eclipse UserFriend
Hi,
I think you are doing too much complicated things not needed.
To represent a connection, an edge between elements in a model you must have a way to retrieve those element from another element by using either references or at least eContainer/eContent/eResource relations.
If you are not familiar with aql expressions you can use a JAVA service in the target expression of the edge mappings. See https://www.eclipse.org/sirius/doc/specifier/general/Writing_Queries.html#service_methods
But keep in mind that if you cannot retrieve the element to connect to from another rather easily, then you may be missing references in your metamodel making it complex to use with Sirius.

Regards,

[Updated on: Wed, 05 September 2018 05:58] by Moderator

Re: Problem in creating edge [message #1794714 is a reply to message #1794708] Wed, 05 September 2018 06:49 Go to previous messageGo to next message
Eclipse UserFriend
Ok Pierre..

I tried with Aql expressions and Java service also.
But I did not get how we can pass target node as argument in service method. Because we will return expression based on that node right? What will be that method returning?

I will try with Java service. Thanks again
Re: Problem in creating edge [message #1794722 is a reply to message #1794714] Wed, 05 September 2018 08:55 Go to previous messageGo to next message
Eclipse UserFriend
To pass the source semantic element of an element based edge to the java service computing the target you just have to use self that is the source model element: aql:self.myMehtod()
your method will look like

EObject myMethod(EObject semantic element)

Regards,
Re: Problem in creating edge [message #1794838 is a reply to message #1794722] Fri, 07 September 2018 08:35 Go to previous messageGo to next message
Eclipse UserFriend
Hi Pierre,

I can create an edge without using service and java method.

If I create an instance of book i am able to create an edge. But an instance of book also getting created i.e., one book node also getting created in diagram. Can we get edge without creating an instance of book?

Instead of create instance I tried using by this expression in change context
aql:source.eContainer().eContainer().eContents(products::books)
but when I use this, edge is not getting created.


[Updated on: Fri, 07 September 2018 08:36] by Moderator

Re: Problem in creating edge [message #1794882 is a reply to message #1794838] Mon, 10 September 2018 05:19 Go to previous messageGo to next message
Eclipse UserFriend
HI can you give me pictures of you edge mapping in the odesign with the properties view on it?

Regards
Re: Problem in creating edge [message #1795180 is a reply to message #1794882] Mon, 17 September 2018 23:57 Go to previous message
Eclipse UserFriend
Hi Pierre,

The problem is solved by using a service method in change context.
Thank you :)

Previous Topic:[SOLVED] Adding specific nodes from palette
Next Topic:Edge creation based on source and target nodes
Goto Forum:
  


Current Time: Sun Apr 20 01:55:20 EDT 2025

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

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

Back to the top