Skip to main content



      Home
Home » Eclipse Projects » Sirius » Can't access to a reference in Sirius
Can't access to a reference in Sirius [message #1744693] Thu, 29 September 2016 10:11 Go to next message
Eclipse UserFriend
Hello all,

I'm building a graphical editor to create different views of Petrinets, but I'm facing a problem with the creation of element related edges because I can't get certain properties of some elements in the model file. The problem is that I've defined in my metamodel the concept Arc from which OutputArc and InputArc extend, in each of this classes I've the concept source and destination; however, when I tried to do something like this (being on the concept Petrinet):

[self.elements->select(s | s.oclIsKindOf(petrinet::Arc))->collect(s | s.source)/]

I'm getting errors because source cannot be recognized, the strange part is that I've tried changing source with name and checking in Acceleo and it's working just fine, but when I try source, destination or even testing (a property I've defined to verify) Acceleo cannot recognized and therefore Sirius can't either.

I've attached an screenshot of the error and also from the definition of both types of arcs. Any assistance is highly appreciated!
Re: Can't access to a reference in Sirius [message #1744698 is a reply to message #1744693] Thu, 29 September 2016 10:40 Go to previous messageGo to next message
Eclipse UserFriend
Hello Nicolas,

the service oclIsKindOf returns a boolean as it checks if the element is of the given type (or inherits it). I think that you want to use oclAsType that will effectively cast your element "s" in an "Arc".

Regards,
Steve
Re: Can't access to a reference in Sirius [message #1744702 is a reply to message #1744698] Thu, 29 September 2016 10:48 Go to previous messageGo to next message
Eclipse UserFriend
Hello Steve,

I'm using isKindOf there because the select operator is expecting a boolean value to decide if each element should be returned in the reply or not, I think that using oclAsType won't work there as that shouldn't be giving the select operator any information about including or not the element on the final set. Please correct me if I'm wrong.
Re: Can't access to a reference in Sirius [message #1744704 is a reply to message #1744702] Thu, 29 September 2016 10:52 Go to previous messageGo to next message
Eclipse UserFriend
I've made a little EOL script:

var sys = pnet!System.all.first();

for (element in sys.petrinets.collect(s | s.elements.select(e | e.isKindOf(pnet!Arc))))
{
	element.source.println();
}


And that script is actually working, I can get the reference using EOL but not OCL directly on Sirius nor Acceleo.
Re: Can't access to a reference in Sirius [message #1744706 is a reply to message #1744702] Thu, 29 September 2016 10:58 Go to previous messageGo to next message
Eclipse UserFriend
Oh right I read it to fast and did not see the "select". I think you should use the "filter" service instead of "select" which would give the following expression:
[self.elements->filter(petrinet::Arc).source/]

If I am not wrong, the result of your select effectively trimmed the "elements" to only have Arc element, but it did not cast it as a Collection of Arc, you need the filter service for that.

Regards,
Steve
Re: Can't access to a reference in Sirius [message #1744708 is a reply to message #1744706] Thu, 29 September 2016 11:03 Go to previous messageGo to next message
Eclipse UserFriend
Here's an screenshot of the metamodel in case it helps.

I've tried your solution Steve, but I've the same problem (source is not recognized), i tried two solutions:

[self.elements->filter(petrinet::Arc).source/]

[self.elements->filter(petrinet::Arc).first().source/]
Re: Can't access to a reference in Sirius [message #1744709 is a reply to message #1744708] Thu, 29 September 2016 11:12 Go to previous messageGo to next message
Eclipse UserFriend
Ok I was confused with your first screenshot with the interpreter view where the expression was on an OutputArc.

The reference source, is not defined on an Arc but only on the subtypes InputArc or OutputArc therefore it is normal that source is not reconized. You either need to filter using InputArc and OutputArc -> [self.elements->filter(petrinet::InputArc).source/]

If you have to keep filtering on Arc, you can also change your metamodel to have source and destination references on arc, but it will have to point Node, which means you will have to customized the source and destination setter methods in InputArc and OutputArc to only accept transition or place elements. This is less elegant than the first solution in my opinion.

Regards,
Steve
Re: Can't access to a reference in Sirius [message #1744710 is a reply to message #1744708] Thu, 29 September 2016 11:17 Go to previous messageGo to next message
Eclipse UserFriend
This is the error thrown by Sirius when I attemp to use that query:

!ENTRY org.eclipse.acceleo.parser 4 0 2016-09-29 10:19:38.717
!MESSAGE Compilation error for expression [self.elements->select(e | e.oclIsKindOf(petrinet::Arc))->collect(c |c.destination)/] : Unrecognized variable: (destination)
Re: Can't access to a reference in Sirius [message #1744711 is a reply to message #1744710] Thu, 29 September 2016 11:24 Go to previous messageGo to next message
Eclipse UserFriend
This is a different query. There is the same issue with "destination" that is not declared in Arc. Use [self.elements->filter(petrinet::InputArc).destination/] instead.
Re: Can't access to a reference in Sirius [message #1744724 is a reply to message #1744711] Thu, 29 September 2016 12:38 Go to previous messageGo to next message
Eclipse UserFriend
Steve I've tried both approaches, using isKindOf(Arc) and isTypeOf(InputArc), both have the same result. The weirdest part is that choosing the arc directly on acceleo and doing a query: [self.destination/] it shows the proper element.
Re: Can't access to a reference in Sirius [message #1744725 is a reply to message #1744724] Thu, 29 September 2016 13:07 Go to previous message
Eclipse UserFriend
I've downloaded Eclipse Neon and Sirius 4.0, re-did the entire process and I've managed to get the query that resolves it:

[self.elements->selectByType(petrinet::InputArc)->collect(s | s.to.eContainer())->reject(s | s = self)/]

It's working great, I just need to merge outputarc and I'll get what I was needing.

Thanks a lot Steve!
Previous Topic:Cannot find the class file for org.eclipse.sirius.ui.business.api.dialect.DialectEditor
Next Topic:Sub Node vs. Bordered Node
Goto Forum:
  


Current Time: Mon Apr 14 19:20:08 EDT 2025

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

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

Back to the top