Skip to main content

Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Evaluating pivot OCL programmatically
Evaluating pivot OCL programmatically [message #1710720] Thu, 08 October 2015 16:02
Jens Bürger is currently offline Jens BürgerFriend
Messages: 51
Registered: October 2012
Hello everyone,
as a kind of follow up to I want to do the evaluations discussed there programmatically.

I have working code for evaluations using the old OCL implementation. But as I need to query stereotypes, I am requested to switch to the pivot implementation.

The old code looks like this:
EObject root=modelGraph().getRoots().get(0); // eGraph containing the UML model
EClass oclContext=modelGraph().getRoots().get(0).eClass()
String oclStatement="here goes my OCL statement";

OCL ocl = org.eclipse.ocl.ecore.OCL.newInstance();

BooleanOCLCondition<EClassifier, EClass, EObject> condition = new BooleanOCLCondition<EClassifier, EClass, EObject>(

	HashSet<EObject> result=(HashSet<EObject>) condition.evaluate(root);

After consulting the OCL documentation of Eclipse Mars, I adapted the example:
org.eclipse.ocl.pivot.utilities.OCL ocl=org.eclipse.ocl.pivot.utilities.OCL.newInstance();
org.eclipse.ocl.pivot.ExpressionInOCL query;
try {
	query = ocl.createQuery(modelGraph().getRoots().get(0).eClass(),
	org.eclipse.ocl.pivot.utilities.Query queryEval = ocl.createQuery(query);	
	Object t=queryEval.evaluateUnboxed(modelGraph().getRoots().get(0));
			} catch (org.eclipse.ocl.pivot.utilities.ParserException e) {
				// TODO Auto-generated catch block

But the ocl.createQuery(...) call actually throws a
org.eclipse.ocl.pivot.utilities.SemanticException: The 'UML::Model' constraint is invalid: 'Transition.allInstances().extension_ensureRole->excluding(null).role'
1: Unresolved Property 'Set(UML::Transition[*|1])::extension_ensureRole'
at org.eclipse.ocl.pivot.utilities.PivotUtil.checkResourceErrors(

I also tried instantiating ocl by passing on the existing resourceSet, but this makes no difference.

What am I missing?
Previous Topic:Eclipse Issue with Editor
Next Topic:Announce: Additional Luna maintenance release
Goto Forum:

Current Time: Sun May 31 14:37:34 GMT 2020

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

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

Back to the top