closure operation [message #1073764] |
Thu, 25 July 2013 08:58  |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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   |
Eclipse User |
|
|
|
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  |
Eclipse User |
|
|
|
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.
|
|
|
Powered by
FUDForum. Page generated in 0.06531 seconds