Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » How to access other instances in Sirius while defining semantic constraint ?
How to access other instances in Sirius while defining semantic constraint ? [message #1806596] Sat, 11 May 2019 09:29 Go to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
In Sirius when i am trying to add semantic contraint for my DSL.

I have to class'es which are connected to root element named "System".
I have two sub classes named "Tag" and "Platform".
I try to add validation rule for DSL. For example the Tag has Distance attribute. I can access it using "aql: self.distance <50" when in graphical editor if user inputs more than 50, error message is given.
Platform has EBoolean attribute named "Indoor" (by the way only and only if 1 Platform object can exist in the system).

What i want to do is "if indoor is true and distance is 50 show error "A" or if indoor is false and distance is 120 show error "B". I can arrange that self.Distance <50 or <120. However, i need to access the instance of Platform and its attribute Eboolean type Indoor.

I tried something like this. " aql: System::Platform.indoor=true and self.distance<120" it did not give any error however System::Platform.indoor did not return any result "false" or "true" just null.

How i can solve this?

Thanks for your help.
Re: How to access other instances in Sirius while defining semantic constraint ? [message #1806648 is a reply to message #1806596] Mon, 13 May 2019 08:53 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Hello,

System::Platform.indoor will not work as it would access the indoor field of the metaclass. It seems like you need a reference to access a Platform element from a Tag, or the Tag and Platform are unique element under the System and in that case you can just navigate to the System (eContainer) and then look for the Platform (econtents). Do you have a screenshot of your metamodel to confirm it?

Regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: How to access other instances in Sirius while defining semantic constraint ? [message #1806658 is a reply to message #1806648] Mon, 13 May 2019 12:14 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
Thanks for your reply. I uploaded my metamodel. I also try to eContent and eContainer, but i could not get it worked. Could you sugget something when you check metamodel?
  • Attachment: meta.jpg
    (Size: 276.88KB, Downloaded 53 times)

[Updated on: Mon, 13 May 2019 12:16]

Report message to a moderator

Re: How to access other instances in Sirius while defining semantic constraint ? [message #1806670 is a reply to message #1806658] Mon, 13 May 2019 14:24 Go to previous messageGo to next message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
On the screenshot, the reference betwen System and Platform is multivalued but as I read again your initial message you said that " (by the way only and only if 1 Platform object can exist in the system)". I am not sure if you mean that there can only be only one Platform object in the model. If that the case, from the context of a Tag, to access the Platform, you should have an expression like aql:self.eContainer().eContents()->Filter(Platform) or aql:self.eContainer().oclAsType(System).platform. If you can have multiple Platform then you will need a reference between Tag and Platform otherwise you would not know which Platform element to choose.

Regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Re: How to access other instances in Sirius while defining semantic constraint ? [message #1806680 is a reply to message #1806670] Mon, 13 May 2019 18:28 Go to previous messageGo to next message
Burak Karaduman is currently offline Burak KaradumanFriend
Messages: 84
Registered: July 2018
Member
It worked! Thank you so much!. Yes there is only one Platform object.
Re: How to access other instances in Sirius while defining semantic constraint ? [message #1806707 is a reply to message #1806680] Tue, 14 May 2019 09:00 Go to previous message
Steve Monnier is currently offline Steve MonnierFriend
Messages: 572
Registered: May 2011
Senior Member
Great! Then in your metamodel you can change the multiplicity of the reference platform between System and Platform to [0..1] and eventually add a validation rule checking that a Platform has been set.

Regards,
Steve


Steve Monnier - Obeo Canada
Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius
Previous Topic:Issue on adding meta model - Add from registry is not showing packages.
Next Topic:How to hide the semantic tab in Property View
Goto Forum:
  


Current Time: Thu Apr 25 19:59:19 GMT 2024

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

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

Back to the top