Skip to main content



      Home
Home » Modeling » OCL » union two sets of different classifier
union two sets of different classifier [message #1231090] Mon, 13 January 2014 15:16 Go to next message
Eclipse UserFriend
I would like to union two sets of different classifier with OCL:

for the code below:

Class.allInstances()->union(Attribute.allInstances()) //Class and Attribute are two Classes defined in Ecore

it returns :
Unresolved Operation 'Set(myOO::myOO::Class)::union(Set(myOO::myOO::Attribute))'

How can I do this?



PS:
1- In other word, it seem that OCL treats SET as a SET<T>, unlike the concept of set in set theory in mathematic that the type of the set members is not concerned.

2- Ecore diagram is attached

Thanks
Re: union two sets of different classifier [message #1231097 is a reply to message #1231090] Mon, 13 January 2014 15:44 Go to previous messageGo to next message
Eclipse UserFriend
I found a solution to my problem!

my assumption that the sets are typed over their members in OCL is true. so it seems that OCL can not union two sets of different types!
so I cast two set to be of the same type and then union them.

In my example I cast them to the "Classifier" class and then union as below (you might need to see the ecore diagram file in my previous post to get this) :

Class.allInstances()->collect(oclAsType(Classifier))->union(Attribute.allInstances()->collect(oclAsType(Classifier))) //oclAsType do the casting and collect apply this operation to each member.

Thanks




Re: union two sets of different classifier [message #1231108 is a reply to message #1231097] Mon, 13 January 2014 16:15 Go to previous messageGo to next message
Eclipse UserFriend
HI

The specification is vague.

I presume you are using the old Ecore-based OCL that takes the source
type to be correct.

The new Pivot-based approach models source and argument indpeendently
and takes the most derived common super type of source and argument.

Regards

Ed Willink

On 13/01/2014 20:44, Hamid Gh wrote:
> I found a solution to my problem!
>
> my assumption that the sets are typed over their members in OCL is
> true. so it seems that OCL can not union two sets of different types!
> so I cast two set to be of the same type and then union them.
>
> In my example I cast them to the "Classifier" class and then union as
> below (you might need to see the ecore diagram file in my previous
> post to get this) :
>
> Class.allInstances()->collect(oclAsType(Classifier))->union(Attribute.allInstances()->collect(oclAsType(Classifier)))
> //oclAsType do the casting and collect apply this operation to each
> member.
>
> Thanks
>
>
>
>
>
Re: union two sets of different classifier [message #1231431 is a reply to message #1231108] Tue, 14 January 2014 12:01 Go to previous messageGo to next message
Eclipse UserFriend
Hi Ed

Thanks for your reply.
I am using:
Eclipse Version: 4.2.1,
OCL End user SDK 4.0.2 , as installed softwares ( I got these info from "about eclipse>installation details>installed softwares") and

EMF modeling framework runtime and tools 2.6.0
EMF Ecore 2.8.3
OCL for Ecore 3.2.0
OCL parser and interpreter 3.2.1 (I got these info from "about eclipse>installation details>plug-ins")

what you said does make sense that it takes the most derived common super type of source and argument and execute the query!
if it is so, according to above version numbers, which one , should I upgrade to get the desired result as you said.

(I assume in that case I would not require to cast my types to supper types explicitly. right?)

Thanks
Re: union two sets of different classifier [message #1231445 is a reply to message #1231431] Tue, 14 January 2014 12:48 Go to previous messageGo to next message
Eclipse UserFriend
Hi

OCL for Ecore 3.2.0 is the very longstanding Eclipse OCL that
unfortunately has a number of corner case issues that are really hard to
fix without significant difficulties, not least of which is
compatibility and lack of underlying models.

The new code is currently only of 'examples' quality so it is not forced
on to you; you must explicitly choose to use it, firstly by installing
the OCL Examples and Editors, then by changing your java package paths.
It is implicitly used by the newer tooling Xtext-based editors, Xtext
Console and OCL to java code generator.

Regards

Ed Willink



On 14/01/2014 17:01, Hamid Qartal wrote:
> Hi Ed
>
> Thanks for your reply.
> I am using: Eclipse Version: 4.2.1, OCL End user SDK 4.0.2 , as
> installed softwares ( I got these info from "about
> eclipse>installation details>installed softwares") and
> EMF modeling framework runtime and tools 2.6.0 EMF Ecore 2.8.3
> OCL for Ecore 3.2.0
> OCL parser and interpreter 3.2.1 (I got these info from "about
> eclipse>installation details>plug-ins")
>
> what you said does make sense that it takes the most derived common
> super type of source and argument and execute the query!
> if it is so, according to above version numbers, which one , should I
> upgrade to get the desired result as you said.
>
> (I assume in that case I would not require to cast my types to supper
> types explicitly. right?)
>
> Thanks
Re: union two sets of different classifier [message #1231465 is a reply to message #1231445] Tue, 14 January 2014 13:51 Go to previous message
Eclipse UserFriend
Hi

I installed the last version of Eclipse 4.3.1 and ocl for ecore 3.3.0

I tried to union two classes which are children of the same parent, but still I need to cast explicitly one of them to its parent (by using oclAsType operation) to have my OCL code running in OCL in xtext console.

I am wondering if this is the normal behaviour of the OCL?

to make my question more explicit, Does OCL treat SETs as pure SETs or it treats them as SET<T> where T is the type of the including members? I assume the latter is the case? right?

For more details, Please look at the attached screen shot; OCL codes and the Ecore diagram are visible in that picture: I highlighted the part I mean I need to write explicitly; As you see removing the oclAsType in the second query would result an error.

Thanks
Hamid
Previous Topic:Type casting of query.evaluate() and ocl.evaluate()
Next Topic:Query over association instead of the classes (classifiers) with OCL
Goto Forum:
  


Current Time: Fri Nov 07 15:00:08 EST 2025

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

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

Back to the top