Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » using includes and excludes returns unexpected result using interactive Xtext OCL
using includes and excludes returns unexpected result using interactive Xtext OCL [message #1229231] Thu, 09 January 2014 01:11 Go to next message
Hamid Qartal is currently offline Hamid QartalFriend
Messages: 33
Registered: December 2013
Member
Hi
I am using interactive Xtext OCL inside eclipse for evaluating OCL expressions

I use DB.ecore of the Epsilon project from this link here (see attached diagram plz)


I am trying to evaluate the following constraints over a table instance(context is table) for the instance created over this Ecore:

(self.columns->asSet())->includes(self.primaryKeys->asSet())

I am expecting that above expression return True for my instance as below:

Table Student:
column id
column name

and I choose the "column id" to be its primary key as well. But it returns false!!! Why?

The only difference I see in the ecore file for the "columns" and "primaryKeys" is that the former is byVale and the latter is byRef for the class Table. Does this cause this weird behaviour?

I attached the diagram of the ecore file for better presentation.

[Updated on: Thu, 09 January 2014 02:28]

Report message to a moderator

Re: using includes and excludes returns unexpected result [message #1229248 is a reply to message #1229231] Thu, 09 January 2014 02:21 Go to previous messageGo to next message
Hamid Qartal is currently offline Hamid QartalFriend
Messages: 33
Registered: December 2013
Member
Please look at the attachment of this post. I took the screenshot of the OCL queries and the results I am getting.

Am I doing something wrong here?!
Re: using includes and excludes returns unexpected result [message #1229331 is a reply to message #1229231] Thu, 09 January 2014 08:04 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you're using tjhe Epsilon project I would expect you would be using
EOL that is quite OCL-like but not actually OCL.

However I can see a problem anyway.

"includes" like Java's "contains" tests whether a Collection contains an
element.

You are passing an other Collection as the element, so the test
obviously returns false.

Perhaps you want

firstCollection->includesAll(secondCollection)->notEmpty() -- OCL 2.4
(since Kepler)

or

fiirstSet->intersection(secondSet)->notEmpty()

Regards

Ed Willink


On 09/01/2014 01:11, Hamid Gh wrote:
> Hi
> I am using OCL in text inside eclipse for evaluating OCL expressions
>
> I use DB.ecore of the Epsilon project from this link http://www.eclipse.org/epsilon/examples/index.php?example=org.eclipse.epsilon.examples.oo2db (see attached diagram plz)
>
>
> I am trying to evaluate the following constraints over a table instance(context is table) for the instance created over this Ecore:
>
> (self.columns->asSet())->includes(self.primaryKeys->asSet())
>
> I am expecting that above expression return True for my instance as below:
>
> Table Student:
> column id
> column name
>
> and I choose the "column id" to be its primary key as well. But it returns false!!! Why?
>
> The only difference I see in the ecore file for the "columns" and "primaryKeys" is that the former is byVale and the latter is byRef for the class Table. Does this cause this weird behaviour?
>
> I attached the diagram of the ecore file for better presentation.
>
>
Re: using includes and excludes returns unexpected result [message #1229584 is a reply to message #1229331] Thu, 09 January 2014 19:20 Go to previous message
Hamid Qartal is currently offline Hamid QartalFriend
Messages: 33
Registered: December 2013
Member
Thanks for your reply Ed

The names of the operations was misleading for me! that caused the problem at first place I think!!

to summarize then, OCL "includes" operation for Sets is equal to membership (i.e. "\in" in latex notation) and OCL "includesAll" is the subset operation for Sets (i.e. "\subset" in latex notation).

So what I expected was the subset operation, so I should have used "includesAll" instead of "Includes".

so I tried

(self.columns->asSet())->includesAll(self.primaryKeys->asSet())

for my example and it returns True as I am expecting Smile


Thanks
Hamid
Previous Topic:addHelperOperation/callOperation in pivot
Next Topic:oclinecore editor - removes genmodel annotation entries
Goto Forum:
  


Current Time: Thu Apr 25 16:22:23 GMT 2024

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

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

Back to the top