Skip to main content



      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] Wed, 08 January 2014 20:11 Go to next message
Eclipse UserFriend
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: Wed, 08 January 2014 21:28] by Moderator

Re: using includes and excludes returns unexpected result [message #1229248 is a reply to message #1229231] Wed, 08 January 2014 21:21 Go to previous messageGo to next message
Eclipse UserFriend
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 03:04 Go to previous messageGo to next message
Eclipse UserFriend
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 14:20 Go to previous message
Eclipse UserFriend
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: Fri Nov 07 15:00:10 EST 2025

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

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

Back to the top