Skip to main content


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 13:43 Go to next message
Kosala Yapa is currently offline Kosala YapaFriend
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 14:31 Go to previous message
Kosala Yapa is currently offline Kosala YapaFriend
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: Wed Apr 24 22:10:18 GMT 2024

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

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

Back to the top