Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    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 14:11 Go to next message
Nicolas   is currently offline Nicolas Friend
Messages: 38
Registered: October 2014
Member
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 14:40 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
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


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Can't access to a reference in Sirius [message #1744702 is a reply to message #1744698] Thu, 29 September 2016 14:48 Go to previous messageGo to next message
Nicolas   is currently offline Nicolas Friend
Messages: 38
Registered: October 2014
Member
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 14:52 Go to previous messageGo to next message
Nicolas   is currently offline Nicolas Friend
Messages: 38
Registered: October 2014
Member
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 14:58 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
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


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Can't access to a reference in Sirius [message #1744708 is a reply to message #1744706] Thu, 29 September 2016 15:03 Go to previous messageGo to next message
Nicolas   is currently offline Nicolas Friend
Messages: 38
Registered: October 2014
Member
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 15:12 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
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


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Can't access to a reference in Sirius [message #1744710 is a reply to message #1744708] Thu, 29 September 2016 15:17 Go to previous messageGo to next message
Nicolas   is currently offline Nicolas Friend
Messages: 38
Registered: October 2014
Member
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 15:24 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
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.

Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: Can't access to a reference in Sirius [message #1744724 is a reply to message #1744711] Thu, 29 September 2016 16:38 Go to previous messageGo to next message
Nicolas   is currently offline Nicolas Friend
Messages: 38
Registered: October 2014
Member
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 17:07 Go to previous message
Nicolas   is currently offline Nicolas Friend
Messages: 38
Registered: October 2014
Member
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: Sat Apr 27 04:23:20 GMT 2024

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

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

Back to the top