Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » How to execute OCL constraint?
How to execute OCL constraint? [message #1058297] Mon, 13 May 2013 09:43 Go to next message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
Hi,

I created an OCL constraint:

// create OCL instance for Ecore
OCL ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);

// create OCL helper
OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint> helper = ocl
.createOCLHelper();

// set OCL context classifier
helper.setContext(ModelPackage.Literals.DEVICE);

Constraint invariant = helper.createInvariant("Modules.allInstances()->size()>=20");


How to execute this invariant nw?

Any help is appreciated.

Thanks
Kosala
Re: How to execute OCL constraint? [message #1058313 is a reply to message #1058297] Mon, 13 May 2013 10:31 Go to previous message
Kosala Yapa is currently offline Kosala Yapa
Messages: 159
Registered: September 2010
Senior Member
Hi,
Boolean res = false;

// create OCL instance for Ecore
OCL ocl = OCL.newInstance(EcoreEnvironmentFactory.INSTANCE);

// create OCL helper
OCLHelper<EClassifier, EOperation, EStructuralFeature, Constraint> helper = ocl
.createOCLHelper();

// set OCL context classifier
helper.setContext(ModelPackage.Literals.DEVICE);

102 Constraint invariant = helper.createInvariant("self.Modules.number <= 20");

Query eval = ocl.createQuery(invariant);
res = (Boolean) eval.evaluate(device);


This gives an error at line 102: Exception in thread "main" java.lang.AbstractMethodError: org.eclipse.ocl.ecore.impl.IntegerLiteralExpImpl.setLongSymbol(Ljava/lang/Long;)V


any help is appreciated.

cheers,

Previous Topic:createQuery() takes a considerable time?
Next Topic:How to read an OCL query and pass to an OCLExpression ?
Goto Forum:
  


Current Time: Mon Apr 21 05:58:27 EDT 2014

Powered by FUDForum. Page generated in 0.01419 seconds