Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL closure operation: org.eclipse.ocl.SemanticException: Usage of non-standard "closure"
OCL closure operation: org.eclipse.ocl.SemanticException: Usage of non-standard "closure" [message #1070958] Fri, 19 July 2013 03:09 Go to next message
Archevo tarek is currently offline Archevo tarekFriend
Messages: 21
Registered: July 2013
Junior Member
Hi,
I'm using the following code from a java project, to test some OCL expressions on BPEL process instance, and i'm using the org.eclipse.ocl (V 1.3.0) API:

public void testquery(Process process) throws ParserException {

OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject> ocl = null;

ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);

OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint> helper = (OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint>) ocl.createOCLHelper();
helper.setContext(BPELPackage.Literals.PROCESS);
OCLExpression<EClassifier> query = helper.createQuery("self.activity.oclAsType(Sequence).activities->closure(a:Activity | a.oclIsKindOf(Assign))");

Query queryEval = ocl.createQuery(query);

String categories = (String) queryEval.evaluate(process).toString();

System.out.println(categories.toString()+ " in testquery");
}


I got the following exception:

org.eclipse.ocl.SemanticException: Usage of non-standard "closure" iterator

The problem is in the closure operation, but i don't know how to fix it?

second, is the use of the closure operation in my expression correct?
Thanks in advance.
Re: OCL closure operation: org.eclipse.ocl.SemanticException: Usage of non-standard &quot;closu [message #1070968 is a reply to message #1070958] Fri, 19 July 2013 03:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi

1.3.0 was a long time ago.

The closure operator is now standard so that the severity of usuing it
is now OK.

You can do.

BasicEnvironment benv =
OCLUtil.getAdapter(ocl.getEnvironment(), BasicEnvironment.class);
benv.setOption(ProblemOption.CLOSURE_ITERATOR,
ProblemHandler.Severity.OK);

You can't excpect me to tell you that your program is correct.

However, in

..oclAsType(Sequence) is very smelly. Why have you got the wrong
collection type? What is wrong with asSequence().

..activities is very smelly. It is an implicit collect of
->collect(activities) giving you a Bag.

closure(a:Activity | a.oclIsKindOf(Assign)) is very smelly since there
is no navigation involved, so nothing to be transitive over.

You are strongly recommended to use the OCL Console to practice your OCL
before you embed it in Java.

The newer Xtext support gives you useful hovertext type analysis.

Regards

Ed Willink



On 19/07/2013 04:09, Archevo tarek wrote:
> Hi,
> I'm using the following code from a java project, to test some OCL
> expressions on BPEL process instance, and i'm using the
> org.eclipse.ocl (V 1.3.0) API:
>
> public void testquery(Process process) throws ParserException {
>
> OCL<?, EClassifier, ?, ?, ?, ?, ?, ?, ?, Constraint, EClass, EObject>
> ocl = null;
>
> ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);
>
> OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint>
> helper = (OCLHelper<EClassifier, EOperation, EStructuralFeature,
> Constraint>) ocl.createOCLHelper();
> helper.setContext(BPELPackage.Literals.PROCESS);
> OCLExpression<EClassifier> query =
> helper.createQuery("self.activity.oclAsType(Sequence).activities->closure(a:Activity
> | a.oclIsKindOf(Assign))");
>
> Query queryEval = ocl.createQuery(query);
>
> String categories = (String) queryEval.evaluate(process).toString();
>
> System.out.println(categories.toString()+ " in testquery");
> }
>
> I got the following exception:
>
> org.eclipse.ocl.SemanticException: Usage of non-standard "closure"
> iterator
>
> The problem is in the closure operation, but i don't know how to fix it?
>
> second, is the use of the closure operation in my expression correct?
> Thanks in advance.
Re: OCL closure operation: org.eclipse.ocl.SemanticException: Usage of non-standard &quot;closu [message #1071257 is a reply to message #1070968] Fri, 19 July 2013 17:00 Go to previous messageGo to next message
Archevo tarek is currently offline Archevo tarekFriend
Messages: 21
Registered: July 2013
Junior Member
Hi,
Thanks for the code, the exception is gone.
For the OCL expression, well i'm testing the constraints on instances of the BPEL language meta-model. "Sequence" (it is not a OCL collection type) is a class in the meta-model which extends the class "Activity". So, it is an activity which can contain a sequence of activities (attribute of the class 'Sequence') like, 'Receive', 'Reply',,,etc. That's why i wrote :

self.activity.oclAsType(Sequence).activities

I used the following expression to get the number of 'Assign' activities having the name 'Assign3' in my BPEL process :
OCLExpression<EClassifier> query = helper.createQuery("self.activity.oclAsType(Sequence).activities->closure(a | a.oclAsType(Assign)->select(a.oclAsType(Assign).name='Assign3'))->size()");

It works! but not like it is expected from closure operation!!

When i put the 'Assign3' activity in another 'Sequence' activity in my process, it doesn't count it, which means that it doesn't look inside it or all the container activities in the process. Many activities in the BPEL language may contain other activities, and so on. I want to look deeply in the process tree where the activity is located, and get it, or get it's position (indexOf()) in the container activity,,,

How to do this?
Thanks in advance.
Re: OCL closure operation: org.eclipse.ocl.SemanticException: Usage of non-standard &amp;quot;c [message #1071290 is a reply to message #1071257] Fri, 19 July 2013 19:06 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4188
Registered: July 2009
Senior Member
Hi

There is an indexOf function.

If your souerce data is reall just List<EObject> then you might as well
clean it up once,

self.activity.oclAsType(Assign)->asSequence()...

so that you don't waste time in the closure recursion.

But your closure still has no navigation in. Study the example in the
specification.

You are making a lot of . -> mistakes. You'll find the hovertext in the
editors very helpful.

Regards

Ed Willink


On 19/07/2013 18:00, Archevo tarek wrote:
> Hi,
> Thanks for the code, the exception is gone.
> For the OCL expression, well i'm testing the constraints on instances
> of the BPEL language meta-model. "Sequence" (it is not a OCL
> collection type) is a class in the meta-model which extends the class
> "Activity". So, it is an activity which can contain a sequence of
> activities (attribute of the class 'Sequence') like, 'Receive',
> 'Reply',,,etc. That's why i wrote :
>
> self.activity.oclAsType(Sequence).activities
>
> I used the following expression to get the number of 'Assign'
> activities having the name 'Assign3' in my BPEL process :
> OCLExpression<EClassifier> query =
> helper.createQuery("self.activity.oclAsType(Sequence).activities->closure(a
> |
> a.oclAsType(Assign)->select(a.oclAsType(Assign).name='Assign3'))->size()");
>
> It works! but not like it is expected from closure operation!!
>
> When i put the 'Assign3' activity in another 'Sequence' activity in my
> process, it doesn't count it, which means that it doesn't look inside
> it or all the container activities in the process. Many activities in
> the BPEL language may contain other activities, and so on. I want to
> look deeply in the process tree where the activity is located, and get
> it, or get it's position (indexOf()) in the container activity,,,
>
> How to do this?
> Thanks in advance.
>
Previous Topic:INOUT parameters
Next Topic:allInstances OrderedSet
Goto Forum:
  


Current Time: Sat Dec 20 13:52:44 GMT 2014

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

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