Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Cannot find operation alloOwnedElements()(when trying to run the method oclHelper.createInvariant(<expression>) )
Cannot find operation alloOwnedElements() [message #531539] Wed, 05 May 2010 11:21 Go to next message
Shaman_Mahmoudi  is currently offline Shaman_Mahmoudi Friend
Messages: 16
Registered: February 2010
Junior Member
Hi,

When I run the method oclHelper.createInvariant(<expression>) I get Cannot find operation (allOwnedElements()).

I set the context of ocl to oclHelper.setContext(<stereotype>);

The stereotype is defined in an UML profile.

If I set the context to oclHelper.setContext(<UML Meta Model Stereotype>);

It parses fine. However, if i do this with all of my stereotypes I will eventually get the same error message but for different constraints on different stereotypes.

I thought allOwnedElements() should be in the context? Why isn't it?

Thanks in advance.

Re: Cannot find operation alloOwnedElements() [message #531811 is a reply to message #531539] Thu, 06 May 2010 09:18 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Shaman

My knowledge of the UML/profile side of OCL is very limited, so what you
are trying to do seems sensible.

You will need to be much clearer about exactly waht you are doing,
excatly what you do see in comparison to what you would like to see.

Some example files demonstrating whatever your problem is might help.

Regards

Ed Willink

On 05/05/2010 12:21, Shaman_Mahmoudi wrote:
> Hi,
>
> When I run the method oclHelper.createInvariant(<expression>) I get
> Cannot find operation (allOwnedElements()).
>
> I set the context of ocl to oclHelper.setContext(<stereotype>);
> The stereotype is defined in an UML profile.
>
> If I set the context to oclHelper.setContext(<UML Meta Model Stereotype>);
>
> It parses fine. However, if i do this with all of my stereotypes I will
> eventually get the same error message but for different constraints on
> different stereotypes.
>
> I thought allOwnedElements() should be in the context? Why isn't it?
>
> Thanks in advance.
>
>
Re: Cannot find operation alloOwnedElements() [message #531842 is a reply to message #531811] Thu, 06 May 2010 11:00 Go to previous messageGo to next message
Shaman_Mahmoudi  is currently offline Shaman_Mahmoudi Friend
Messages: 16
Registered: February 2010
Junior Member
Hi,

Thanks for the reply!

I am not the person who orignally created the UML profile and the applied OCL constraints on it. My colleague is on vacation until sometime next week.

So my knowledge of OCL is almost nonexistant. I just recently (this monday) had my first experience with OCL through the eclipse OCL project and its packages.

I am step debuggin and this is the data I am retrieving:

The OCL expression in question is

self.allOwnedElements()->select(e|e.oclIsTypeOf(Package))->collect(e|e.getAppliedStereotypes())->select(e|e.name='ManagedObject') ->size() > 0


and it is retrieving it properly, I double checked with the constraint written in the uml profile.

If I set the classifier context to the UML Meta Model Stereotype, creating the invariant works fine.

if I set the classifier context to the (on the one where the ocl constraint is actually applied on) stereotype, I get that the operation allownedElements() cannot be found for the type managedObject.

for this constraint

self.namespacePrefix <> "and not self.namespacePrefix.ocllsUndefined()


if I set the classifier context to the stereotype, I can create the invaraint.

The difference between allownedElements() and namespacePrefix that I see is that one is a method, the other is an attribute and namespacePrefix has been defined in our UML profile, however, allownedElements() is a method defined originaly in the UML meta model?
Is it possible to get my stereotype classifier context to be like a superset of the UML meta model stereotype classifier context? That is what I thought it would be automatically.

To get the stereotypes I do this:

element.getAppliedStereotypes()


Maybe it is me who has not understood OCL , and OCL classifier context in particular. So maybe the behaviour is as expected. How can I check what the classifier context should be? And how are the classifier contexts designed/created in the first place? Maybe that is the root of the problem? Right now, for me it is a guessing game. I orignally thought that setting the context classifier to the original stereotype would be sufficient, but it does not seem to be the case here.

Thanks in advance.

[Updated on: Thu, 06 May 2010 11:16]

Report message to a moderator

Re: Cannot find operation alloOwnedElements() [message #532019 is a reply to message #531842] Thu, 06 May 2010 18:42 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi Shaman

I'm sorry but you cannot expect me to join together hints from your two
emails and telepathically come up with a solution.

If you have a problem, please present it with sufficient context to
allow it to be understood.

You can set breakpoints at for instance
EvaluationVisitorImpl.visitOperationCallExp and watch every operation
happening, but it's not very pleasant. We hope to do better in the next
release.

If you have a test model available, the easiest debugging is to use the
OCL Console to practice steadily more complicated expressions. Otherwise
modify your code to execute steadily more complicated expressions until
inspiration strikes. It is unlikely that a novice, or many experts, will
get a quadruply nested loop spot on first time.

Regards

Ed Willink


On 06/05/2010 12:00, Shaman_Mahmoudi wrote:
> Hi,
>
> Thanks for the reply!
>
> I am not the person who orignally created the UML profile and the
> applied OCL constraints on it. My colleague is on vacation until
> sometime next week.
> So my knowledge of OCL is almost nonexistant. I just recently (this
> monday) had my first experience with OCL through the eclipse OCL project
> and its packages.
>
> I am step debuggin and this is the data I am retrieving:
>
> The OCL expression in question is
>
> self.allOwnedElements()->select(e|e.oclIsTypeOf(Package))->collect(e|e.getAppliedStereotypes())- >select(e|e.name='ManagedObject')
> ->size() > 0
>
>
> and it is retrieving it properly, I double checked with the constraint
> written in the uml profile.
>
> If I set the classifier context to the UML Meta Model Stereotype,
> creating the invariant works fine.
> if I set the classifier context to the stereotype, I get that the
> oepration allownedElements() cannot be found for the type managedObject.
>
> And to get the stereotypes I do this:
>
>
> element.getAppliedStereotypes()
>
>
> Maybe it is me who has not understood OCL , and OCL classifier context
> in particular. So maybe the behaviour is as expected. How can I check
> what the classifier context should be? And how are the classifier
> contexts designed/created in the first place? Maybe that is the root of
> the problem? Right now, for me it is a guessing game. I orignally
> thought that setting the context classifier to the original stereotype
> would be sufficient, but it does not seem to be the case here.
>
> Thanks in advance.
Re: Cannot find operation alloOwnedElements() [message #532027 is a reply to message #532019] Thu, 06 May 2010 19:57 Go to previous message
Shaman_Mahmoudi  is currently offline Shaman_Mahmoudi Friend
Messages: 16
Registered: February 2010
Junior Member
Hi Ed,

Thanks for fast reply!

You are right, my information is lacking in details. My understanding of the issue is vague at best.

I have this very simple model I am testing on. I will create some simpler constraints and see what really happens "behind the scenes". Hopefully I will grasp some of the concepts better.

Thanks for the suggestion!
Previous Topic:EMF Plugin
Next Topic:Re: [Ecore Tools] Integration with EMF Validation and/or MDT OCL
Goto Forum:
  


Current Time: Thu Apr 25 16:57:09 GMT 2024

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

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

Back to the top