Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » oclIsTypeOf error with OCLinEcore
oclIsTypeOf error with OCLinEcore [message #701981] Mon, 25 July 2011 20:21 Go to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
Hi again,
I use a metamodel where a class A is composed of two eReferences : leftMember and rightMember. Those references can be of some types I created, let's say : T1, T2, T3...

when I test the trivial operation self.left_member=self.left_member in the OCLinEcore console, I get a response.

when I test self.right_member.oclIsTypeOf(T1), I also get a boolean answer.

but, when I test something like self.left_member.oclIsTypeOf(self.right_member) or even self.left_member.oclIsTypeOf(self.left_member), I am given the following error : Cannot find operation (oclIsTypeOf(T1)) for the type (T1).

Is it because of my class hierarchy ? How can I solve this ? thanks
Re: oclIsTypeOf error with OCLinEcore [message #702229 is a reply to message #701981] Tue, 26 July 2011 05:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

oclIsTypeOf takes a Type argument. Type Literals and Type Expressions
are ill-defined in the OCL specification and Eclipse OCL is prototyping
solutions to these problems.

self.left_member is not a type expression so your expression cannot work.

From the error message, it looks as if you're using the Helios release.
I think the Indigo release is more precise on the bad type.

In the Indigo, release oclType() has fully reflective semantics so you
could well find that

self.left_member.oclIsTypeOf(self.left_member.oclType())

works. (Did you perhaps mean oclIsKindOf which is more general?)

Regards

Ed Willink

On 25/07/2011 21:21, fafanellu wrote:
> Hi again, I use a metamodel where a class A is composed of two
> eReferences : leftMember and rightMember. Those references can be of
> some types I created, let's say : T1, T2, T3...
>
> when I test the trivial operation self.left_member=self.left_member in
> the OCLinEcore console, I get a response.
>
> when I test self.right_member.oclIsTypeOf(T1), I also get a boolean
> answer.
>
> but, when I test something like
> self.left_member.oclIsTypeOf(self.right_member) or even
> self.left_member.oclIsTypeOf(self.left_member), I am given the
> following error : Cannot find operation (oclIsTypeOf(T1)) for the type
> (T1).
>
> Is it because of my class hierarchy ? How can I solve this ? thanks
Re: oclIsTypeOf error with OCLinEcore [message #702408 is a reply to message #702229] Tue, 26 July 2011 10:21 Go to previous messageGo to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
Hi, thanks for your quick answer, I actually use the Helios release.
I understood my mistake, in fact I re-defined some basetypes so I got confused with that, for me self.left_member was a type (because of my metamodel !), but it is not.
I'll try to test it with indigo, because oclType() doesn't seem to be recognized by Helios.
Thanks again,

regards
Re: oclIsTypeOf error with OCLinEcore [message #702584 is a reply to message #702408] Tue, 26 July 2011 14:43 Go to previous messageGo to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
Hi again,
I tried self.left_member.oclIsTypeOf(self.left_member.oclType()) but the operation oclType() seems to be unknown (moreover, it is not proposed among the others operations I get after having typed the dot...).
I get the following error :
Cannot find operation (oclType()) for the type (T1)

The purpose of what I would like to do with this is just to check that both of the members linked to class A belong to the same type, I think you have guessed it Wink
I'm a little bit lost...how could I fix this ?

thanks
Re: oclIsTypeOf error with OCLinEcore [message #702646 is a reply to message #702408] Tue, 26 July 2011 16:02 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
> I'll try to test it with indigo, because oclType() doesn't seem to be
> recognized by Helios.
So which release are you now corresponding about?
Re: oclIsTypeOf error with OCLinEcore [message #702685 is a reply to message #702646] Tue, 26 July 2011 17:12 Go to previous messageGo to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
since you told me to test with the Indigo, I installed it and imported my ecore project inside. The OCL version is 3.1.0.

this message :

Quote:
Hi again,
I tried self.left_member.oclIsTypeOf(self.left_member.oclType()) but the operation oclType() seems to be unknown (moreover, it is not proposed among the others operations I get after having typed the dot...).
I get the following error :
Cannot find operation (oclType()) for the type (T1)

The purpose of what I would like to do with this is just to check that both of the members linked to class A belong to the same type, I think you have guessed it
I'm a little bit lost...how could I fix this ?

thanks


was written after having tested the code with the Indigo version

[Updated on: Tue, 26 July 2011 17:52]

Report message to a moderator

Re: oclIsTypeOf error with OCLinEcore [message #702709 is a reply to message #702685] Tue, 26 July 2011 17:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
On 26/07/2011 18:12, fafanellu wrote:
> since you told me to test with the Indigo, I installed it and imported
> my ecore project inside. The OCL version is 3.1.0
Something similar works fine for me. You give me very little to go on
apart from the clue that even you didn't understand left_member.

Regards

Ed Willink
Re: oclIsTypeOf error with OCLinEcore [message #702710 is a reply to message #702709] Tue, 26 July 2011 17:53 Go to previous messageGo to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
I'll try to send you a message with a diagram attached, so that you could see what I mean. Anyway, thanks for your help
Re: oclIsTypeOf error with OCLinEcore [message #702799 is a reply to message #702710] Tue, 26 July 2011 20:19 Go to previous messageGo to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
Here we are, I tried to make a very simple example to explain what I want.
Type is an abstract class with two children, T1 and T2.
Expression is a class with two eReferences, left_member and right_member, which can be T1 or T2.
When I create a dynamic instance of Expression, I give it its two members (left and right). My goal is to check with OCL if both of them belong to the same type (i.e, for instance, within the Expression context, self.left_member.oclIsTyeOf(T1)=true and self.right_member.oclIsTyeOf(T1)=true)

My problem is oclIsTypeOf() operation, as I said before...

self.left_member.oclIsTyeOf(T1) does work, it evaluates the type of left_member and writes it, but I can't compare it with the right_member type...

index.php/fa/3486/0/

thanks
  • Attachment: example.jpg
    (Size: 57.50KB, Downloaded 752 times)

[Updated on: Tue, 26 July 2011 20:23]

Report message to a moderator

Re: oclIsTypeOf error with OCLinEcore [message #703098 is a reply to message #702799] Wed, 27 July 2011 06:43 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

If you want me to help provide something I can work with. A JPEG is
pretty but unuseable.

self.left_member.oclIsTyeOf(T1)=true and self.right_member.oclIsTyeOf(T1)=true)

clearly doesn'tr work since it has a double typo.

Regards

Ed Willink

On 26/07/2011 21:19, fafanellu wrote:
> Here we are, I tried to make a very simple example to explain what I want.
> Type is an abstract class with two children, T1 and T2.
> Expression is a class with two eReferences, left_member and right_member, which can be T1 or T2.
> When I create a dynamic instance of Expression, I give it its two members (left and right). My goal is to check with OCL if both of them belong to the same type (i.e, for instance, within the Expression context, self.left_member.oclIsTyeOf(T1)=true and self.right_member.oclIsTyeOf(T1)=true)
>
>
Re: oclIsTypeOf error with OCLinEcore [message #703202 is a reply to message #703098] Wed, 27 July 2011 09:32 Go to previous messageGo to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
Hi,
here is what I have for my .ecore metamodel.

abstract class Type;
	class T1 extends Type;
	class T2 extends Type;
	class Expression
	{
		property left_member : Type[1] { ordered composes };
		property right_member : Type[1] { ordered composes };
	}


I meant that when I use the oclIsTypeOf() operation in a simple context, it works. I'll try to explain it clearly :

I instanciated the Expression class using the dynamic instance creation, then I gave it a left member and a right member, I chose to give to both of them the same type : T1.

As I said above, oclIsTypeOf() operation works fine if I use it in this way :


Evaluating:
self.left_member.oclIsTypeOf(T1)
Results:
true

Evaluating:
self.right_member.oclIsTypeOf(T2)
Results:
false

Evaluating:
self.right_member.oclIsTypeOf(T1)
Results:
true

But my problem is : what if I didn't use the same type for left_member and right_member ?

How can I check directly with OCL that both of them belong to the same type ? Do I use the right operation ? My problem, I think, is about what parameters I give to oclIsTypeOf().

regards

[Updated on: Wed, 27 July 2011 12:48]

Report message to a moderator

Re: oclIsTypeOf error with OCLinEcore [message #703566 is a reply to message #703202] Wed, 27 July 2011 17:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

self.left_member.oclIsTypeOf(self.right_member.oclType())

works for me.

Are you using the Interactive Xtext Console? the Interactive Console
uses the mature evaluator that has minimal support for oclType().

Regards

Ed Willink

On 27/07/2011 10:32, fafanellu wrote:
> Hi,
> here is what I have for my .ecore metamodel.
>
> abstract class Type;
> class T1 extends Type;
> class T2 extends Type;
> class Expression
> {
> property left_member : Type[1] { ordered composes };
> property right_member : Type[1] { ordered composes };
> }
>
> I meant that when I use the oclIsTypeOf() operation in a simple
> context, it works. I'll try to explain it clearly :
>
> I instanciated the Expression class using the dynamic instance
> creation, then I gave it a left member and a right member, both of
> them have the same type : T1.
> As I said above, oclIsTypeOf() operation works fine if I use it in
> this way :
>
>
> Evaluating:
> self.left_member.oclIsTypeOf(T1)
> Results:
> true
>
> Evaluating:
> self.right_member.oclIsTypeOf(T2)
> Results:
> false
>
> Evaluating:
> self.right_member.oclIsTypeOf(T1)
> Results:
> true
>
>
> But my problem is : what if I didn't use the same type for left_member
> and right_member ?
> How can I check directly with OCL that both of them belong to the same
> type ? Do I use the right operation ? My problem, I think, is about
> what parameters I give to oclIsTypeOf().
>
> regards
>
Re: oclIsTypeOf error with OCLinEcore [message #703567 is a reply to message #703202] Wed, 27 July 2011 17:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

self.left_member.oclIsTypeOf(self.right_member.oclType())

works for me.

Are you using the Interactive Xtext Console? the Interactive Console
uses the mature evaluator that has minimal support for oclType().

Regards

Ed Willink

On 27/07/2011 10:32, fafanellu wrote:
> Hi,
> here is what I have for my .ecore metamodel.
>
> abstract class Type;
> class T1 extends Type;
> class T2 extends Type;
> class Expression
> {
> property left_member : Type[1] { ordered composes };
> property right_member : Type[1] { ordered composes };
> }
>
> I meant that when I use the oclIsTypeOf() operation in a simple
> context, it works. I'll try to explain it clearly :
>
> I instanciated the Expression class using the dynamic instance
> creation, then I gave it a left member and a right member, both of
> them have the same type : T1.
> As I said above, oclIsTypeOf() operation works fine if I use it in
> this way :
>
>
> Evaluating:
> self.left_member.oclIsTypeOf(T1)
> Results:
> true
>
> Evaluating:
> self.right_member.oclIsTypeOf(T2)
> Results:
> false
>
> Evaluating:
> self.right_member.oclIsTypeOf(T1)
> Results:
> true
>
>
> But my problem is : what if I didn't use the same type for left_member
> and right_member ?
> How can I check directly with OCL that both of them belong to the same
> type ? Do I use the right operation ? My problem, I think, is about
> what parameters I give to oclIsTypeOf().
>
> regards
>
Re: oclIsTypeOf error with OCLinEcore [message #703598 is a reply to message #703566] Wed, 27 July 2011 18:33 Go to previous messageGo to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
Hi, I don't use the Xtext console, since it doesn't recognize the "." (dot).
So, I use the "normal" OCL console.

I always get the same thing...


Evaluating:
self.left_member.oclIsTypeOf(self.right_member.oclType())
Results:
Cannot find operation (oclType()) for the type (Type)

Damn...

Maybe it's because whent I first tried to do the tutorial, I clicked "Yes" when I was asked if I wanted to add the Xtext nature for the project ?

It was said "Click Yes to avoid answering the question in the future"...so I did it. Maybe I should try to cancel this (how?).

Anyway, my final goal is to add a constraint directly in the .ecore model...maybe oclType() will work in this case ?

thanks Smile
Re: oclIsTypeOf error with OCLinEcore [message #703712 is a reply to message #703598] Wed, 27 July 2011 20:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

As I wrote, the non-Xtext Console doesn't support oclType().

What do you mean by doesn't recognize the dot?

self.left_member.oclIsTypeOf(self.right_member.oclType())

which seems to be recognizing the dor four times.

Regards

Ed Willink



On 27/07/2011 19:33, fafanellu wrote:
> Hi, I don't use the Xtext console, since it doesn't recognize the "."
> (dot). So, I use the "normal" OCL console.
>
> I always get the same thing...
>
>
> Evaluating:
> self.left_member.oclIsTypeOf(self.right_member.oclType())
> Results:
> Cannot find operation (oclType()) for the type (Type)
> Damn...
>
> Maybe it's because whent I first tried to do the tutorial, I clicked
> "Yes" when I was asked if I wanted to add the Xtext nature for the
> project ?
>
> It was said "Click Yes to avoid answering the question in the
> future"...so I did it. Maybe I should try to cancel this (how?).
>
> Anyway, my final goal is to add a constraint directly in the .ecore
> model...maybe oclType() will work in this case ?
>
> thanks :)
Re: oclIsTypeOf error with OCLinEcore [message #704124 is a reply to message #703712] Thu, 28 July 2011 09:51 Go to previous messageGo to next message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
Well, when I start to type in the "normal" console "self.", I am proposed some things after the dot : left-member, right_member, and some OCL operations.
In the Xtext console, I am not, so I thought it didn't work.

But I've just tried to write my code "manually", and it works well !! Smile

Thanks !!

I'm now trying to integrate it in the .ecore metamodel, as a class invariant (is this a class invariant ?).

Again, I thank you for your help Smile
Re: oclIsTypeOf error with OCLinEcore [message #704416 is a reply to message #704124] Thu, 28 July 2011 15:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Xtext offers no completion after "." by default since the choice can be
massive. Customizing this is one of many
editor improvements that might happen for Juno. If you type "xxx.a" then
backup to the dot you do get
some completions; can't promise that they're accurate.

Regards

Ed Willink


On 28/07/2011 10:51, fafanellu wrote:
> Well, when I start to type in the "normal" console "self.", I am
> proposed some things after the dot : left-member, right_member, and
> some OCL operations.
> In the Xtext console, I am not, so I thought it didn't work.
>
> But I've just tried to write my code "manually", and it works well !! :)
>
> Thanks !!
>
> I'm now trying to integrate it in the .ecore metamodel, as a class
> invariant (is this a class invariant ?).
>
> Again, I thank you for your help :)
Re: oclIsTypeOf error with OCLinEcore [message #704427 is a reply to message #704416] Thu, 28 July 2011 16:02 Go to previous message
fafanellu  is currently offline fafanellu Friend
Messages: 37
Registered: July 2011
Member
Ok thanks, I'll try this out !
I'll be back soon for some help, I think...
Have a nice day

regards

Stephane
Previous Topic:[CompleteOCL] Problems with CompleteOCL editor
Next Topic:Is there a caching version of org.eclipse.ocl.AbstractEnvironment?
Goto Forum:
  


Current Time: Thu Mar 28 12:17:17 GMT 2024

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

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

Back to the top