Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » closure operation
closure operation [message #1073764] Thu, 25 July 2013 08:58 Go to next message
Archevo tarek is currently offline Archevo tarek
Messages: 20
Registered: July 2013
Junior Member
Hi,
Can anyone help me here please, and tell me what is the problem with my OCL requests using closure operation i posted in my previous post.
I was trying different requests but without success, and i'm novice in OCL.

Thanks.
Re: closure operation [message #1073774 is a reply to message #1073764] Thu, 25 July 2013 09:07 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

In my earlier response I told you to use the console for practice

An expression such as

a: Activity| a.oclAsType(Sequence)

is guaranteed to give you nothing.

It's the same as in Java:

String s = "x";
(List(s)).size()

A CCE fopr suere. An invalid in OCL.

Regards

Ed Willink




On 25/07/2013 13:58, Archevo tarek wrote:
> Hi,
> Can anyone help me here please, and tell me what is the problem with
> my OCL requests using closure operation i posted in my previous post.
> I was trying different requests but without success, and i'm novice in
> OCL.
>
> Thanks.
Re: closure operation [message #1073834 is a reply to message #1073774] Thu, 25 July 2013 11:18 Go to previous messageGo to next message
Archevo tarek is currently offline Archevo tarek
Messages: 20
Registered: July 2013
Junior Member
Hi ed,
Thanks for your response.

Concerning the request, i don't really see how to do else. In my first request:

self.activity.oclAsType(Sequence).activities->closure(a:Activity| a.oclAsType(Activity))->asSequence()->size()

i cant access to the process activities without going through the sequence (of type Activity) activity and then get the "activities" property (a list of type Activity) of the Sequence class in the metamodel , then, in the closure navigate recursively for each element in the collection.
i have 13 activity in my example, it executes in my java code and it returns 12, it omitted an activity inside another sequence activity, which means that it doesn't navigate inside.

Second, when i test it, there are parsing errors, while in java code there's no exceptions:


Parsing failure

1: Unresolved Type 'Activity'
1: Ambiguous resolution:
Property : model::CompensationHandler.activity
Property : model::While.activity
Property : model::Process.activity
Property : model::TerminationHandler.activity
Property : model::CatchAll.activity
Property : model::ForEach.activity
Property : model::Source.activity
Property : model::OnAlarm.activity
Property : model::If.activity
Property : model::Catch.activity
Property : model::ElseIf.activity
Property : model::Target.activity
Property : model::Scope.activity
Property : model::OnMessage.activity
Property : model::RepeatUntil.activity
Property : model::OnEvent.activity
Property : model::Else.activity
1: Unresolved Property 'Sequence(T)::activities'
1: Unresolved Operation 'OclInvalid::oclAsType(Set(null::Activity))'

Sorry, but i don't understand
I'm just following the metamodel in the ecore file.

How to resolve this?

Thanks in advance.



Re: closure operation [message #1073864 is a reply to message #1073834] Thu, 25 July 2013 12:46 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

One of your problems is that "Sequence" is a restricted word in OCL so
you are casting to an ocl::Sequence rather than a model::Collection.

You can tell this because the Xtext OCL Console user a bold purple font
for special words.

The next problem is that you do no navigation, so you might try

self.activity.oclAsType(model::Sequence)

but that will bomb if have any non-activities ...

However the BPEL metamodel has main disparate activities containers so
you're probably better to escape from the metamodel and use

self->closure(oclContents()->select(oclIsKindOf(Activity)))->size()

Regards

Ed Willink


On 25/07/2013 16:18, Archevo tarek wrote:
> Hi ed,
> Thanks for your response.
>
> Concerning the request, i don't really see how to do else. In my first
> request:
>
> self.activity.oclAsType(Sequence).activities->closure(a:Activity|
> a.oclAsType(Activity))->asSequence()->size()
>
> i cant access to the process activities without going through the
> sequence (of type Activity) activity and then get the "activities"
> property (a list of type Activity) of the Sequence class in the
> metamodel , then, in the closure navigate recursively for each element
> in the collection.
> i have 13 activity in my example, it executes in my java code and it
> returns 12, it omitted an activity inside another sequence activity,
> which means that it doesn't navigate inside.
>
> Second, when i test it, there are parsing errors, while in java code
> there's no exceptions:
>
>
> Parsing failure
>
> 1: Unresolved Type 'Activity'
> 1: Ambiguous resolution:
> Property : model::CompensationHandler.activity
> Property : model::While.activity
> Property : model::Process.activity
> Property : model::TerminationHandler.activity
> Property : model::CatchAll.activity
> Property : model::ForEach.activity
> Property : model::Source.activity
> Property : model::OnAlarm.activity
> Property : model::If.activity
> Property : model::Catch.activity
> Property : model::ElseIf.activity
> Property : model::Target.activity
> Property : model::Scope.activity
> Property : model::OnMessage.activity
> Property : model::RepeatUntil.activity
> Property : model::OnEvent.activity
> Property : model::Else.activity
> 1: Unresolved Property 'Sequence(T)::activities'
> 1: Unresolved Operation 'OclInvalid::oclAsType(Set(null::Activity))'
>
> Sorry, but i don't understand
> I'm just following the metamodel in the ecore file.
>
> How to resolve this?
>
> Thanks in advance.
>
>
>
>
Re: closure operation [message #1073892 is a reply to message #1073864] Thu, 25 July 2013 14:02 Go to previous message
Archevo tarek is currently offline Archevo tarek
Messages: 20
Registered: July 2013
Junior Member
Hi Ed,
Thanks for your reply.
You are wright about the "Sequence" restricted word, i have noticed it, but i forget to tell you.
The Sequence class is declared like this in the ecore file:
class _'Sequence' extends Activity
{
property activities : Activity[+] { ordered composes };
}

Executing the request in the Xtext OCL Console on my gives this

Evaluating:
self->closure(oclContents()->select(oclIsKindOf(Activity)))->size()
Results:
Parsing failure

2: Unresolved Operation 'Set(OclElement)::oclIsKindOf(Set(null::Activity))'

In the query in java this:

org.eclipse.ocl.SemanticException: illegal operation signature: (oclContents())

There is a problem with oclContents!!!

In my java code, i would like to say that i'm using the BPEL API to read a bpel file, then apply these requests on it.

helper.setContext(BPELPackage.Literals.PROCESS);
(BPELPackage, org.eclipse.bpel.model.BPELPackage).

Thanks.
Previous Topic:Pb with closure operation
Next Topic:illegal operation signature: (oclContents())
Goto Forum:
  


Current Time: Wed Jul 30 21:25:43 EDT 2014

Powered by FUDForum. Page generated in 0.01791 seconds