Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Valid OCL constraint - Validation Error in Editor
Valid OCL constraint - Validation Error in Editor [message #1775694] Fri, 03 November 2017 14:14 Go to next message
Nina Doschek is currently offline Nina DoschekFriend
Messages: 2
Registered: November 2017
Junior Member
Briefly my Model is defined as follows:
Model - Area - ComponentA - ComponentB
i want to check with an OCL constraint if ComponentA and Component B were definded in the same Area. ComponentB is defined in ComponentA as "target".

I wrote the following OCL constraint in my ecore-Model:

Quote:
invariant checkAreas: oclAsType(ecore::EObject).eContainer().toString() = target.oclAsType(ecore::EObject).eContainer().eContainer().toString();


Now i opened the editor to my created Model and created an example model instance. If i check my constraint in the OCL console, it delivers the expected result for my modeled components.

If i validate my model though, i get a problem caused by the diagnosis of my model:

org.eclipse.ocl.pivot.internal.delegate.OCLDelegateException: The 'Component::checkAreas' constraint result is invalid for 'MyModel::Area::Component'
 - Incompatible source type: 'my::Component' for oclAsType(ecore::EObject) 
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate$CheckingConstraintEvaluator.handleInvalidResult(OCLValidationDelegate.java:116)
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate$CheckingConstraintEvaluator.handleInvalidResult(OCLValidationDelegate.java:1)
	at org.eclipse.ocl.pivot.evaluation.AbstractConstraintEvaluator.evaluate(AbstractConstraintEvaluator.java:89)
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate$CheckingConstraintEvaluator.evaluate(OCLValidationDelegate.java:71)
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate$CheckingConstraintEvaluator.evaluate(OCLValidationDelegate.java:1)
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate.validateExpressionInOCL(OCLValidationDelegate.java:296)
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate.validatePivot(OCLValidationDelegate.java:316)
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate.validate(OCLValidationDelegate.java:239)
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegateFactory.validate(OCLValidationDelegateFactory.java:77)
	at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:227)
	at my.util.MyValidator.validateComponent_checkAreas(MyValidator.java:196)
	at my.util.MyValidator.validateComponent(MyValidator.java:174)
	at my.util.MyValidator.validate(MyValidator.java:97)
	at org.eclipse.emf.ecore.util.EObjectValidator.validate(EObjectValidator.java:324)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidate(Diagnostician.java:171)
	at org.eclipse.emf.edit.ui.action.ValidateAction$3.doValidate(ValidateAction.java:309)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:158)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:185)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.emf.ecore.util.Diagnostician.doValidateContents(Diagnostician.java:181)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:161)
	at org.eclipse.emf.ecore.util.Diagnostician.validate(Diagnostician.java:137)
	at org.eclipse.emf.edit.ui.action.ValidateAction.validate(ValidateAction.java:264)
	at org.eclipse.emf.edit.ui.action.ValidateAction$1.run(ValidateAction.java:176)
	at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119)
Caused by: org.eclipse.ocl.pivot.evaluation.EvaluationException: The 'Component::checkAreas' constraint result is invalid for 'MyModel::Area::Component'
 - Incompatible source type: 'my::Component' for oclAsType(ecore::EObject) 
	at org.eclipse.ocl.pivot.internal.delegate.OCLValidationDelegate$CheckingConstraintEvaluator.handleInvalidResult(OCLValidationDelegate.java:114)
	... 26 more
Caused by: org.eclipse.ocl.pivot.values.InvalidValueException: Incompatible source type: 'my::Component' for oclAsType(ecore::EObject) 
	at org.eclipse.ocl.pivot.library.oclany.OclAnyOclAsTypeOperation.evaluate(OclAnyOclAsTypeOperation.java:47)
	at org.eclipse.ocl.pivot.library.AbstractUntypedBinaryOperation.evaluate(AbstractUntypedBinaryOperation.java:75)
	at org.eclipse.ocl.pivot.internal.evaluation.AbstractExecutor.internalExecuteOperationCallExp(AbstractExecutor.java:407)
	at org.eclipse.ocl.pivot.internal.evaluation.BasicEvaluationVisitor.visitOperationCallExp(BasicEvaluationVisitor.java:630)
	at org.eclipse.ocl.pivot.internal.OperationCallExpImpl.accept(OperationCallExpImpl.java:532)
	at org.eclipse.ocl.pivot.internal.evaluation.BasicEvaluationVisitor.visitOperationCallExp(BasicEvaluationVisitor.java:584)
	at org.eclipse.ocl.pivot.internal.OperationCallExpImpl.accept(OperationCallExpImpl.java:532)
	at org.eclipse.ocl.pivot.internal.evaluation.BasicEvaluationVisitor.visitOperationCallExp(BasicEvaluationVisitor.java:584)
	at org.eclipse.ocl.pivot.internal.OperationCallExpImpl.accept(OperationCallExpImpl.java:532)
	at org.eclipse.ocl.pivot.internal.evaluation.BasicEvaluationVisitor.visitOperationCallExp(BasicEvaluationVisitor.java:584)
	at org.eclipse.ocl.pivot.internal.OperationCallExpImpl.accept(OperationCallExpImpl.java:532)
	at org.eclipse.ocl.pivot.evaluation.AbstractConstraintEvaluator.evaluate(AbstractConstraintEvaluator.java:86)
	... 24 more
Re: Valid OCL constraint - Validation Error in Editor [message #1775721 is a reply to message #1775694] Fri, 03 November 2017 22:52 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6044
Registered: July 2009
Senior Member
Hi

EObject is an implementation detail. Prior to Helios M4, EMF automatically modeled all elements as inheriting EObject. Subsequently they do not. This is correct. YOu must explicitly include an EOBject inheritance if you really want it.

Using the Pivot-based OCL, you may use OclElement as the ancestor of all elements.

For your exam[le, you will probably find that oclContainer() (emulating eContainer()) does what you need.

I cannot comment further without a repro.

Regards

Ed Willink
Re: Valid OCL constraint - Validation Error in Editor [message #1775742 is a reply to message #1775721] Sat, 04 November 2017 23:06 Go to previous messageGo to next message
Nina Doschek is currently offline Nina DoschekFriend
Messages: 2
Registered: November 2017
Junior Member
Thank you very much for you explanations!

My Ocl constraint works now properly with oclContainer():
Quote:
invariant checkAreas: self.oclContainer() = target.oclContainer().oclContainer();


But i do have a question:
If i try to evaluate my constraint on a instance of my model in the OCL console, i get the error, that the operation cannot be found.
If i do the Validation on my model, the constraints work as expected....

OCL console output:
Quote:
self.oclContainer() = source.oclContainer().oclContainer()
Results:
Cannot find operation (oclContainer()) for the type (MyModel)


Thank you in advance!

[Updated on: Sat, 04 November 2017 23:07]

Report message to a moderator

Re: Valid OCL constraint - Validation Error in Editor [message #1775746 is a reply to message #1775742] Sun, 05 November 2017 08:15 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6044
Registered: July 2009
Senior Member
Hi

Are you using the "Interactive OCL Console" or the "Interactive Xtext OCL Console"? Only the Xtext one supports the new Pivot-based OCL prototyping OCL '2.5' solutions.

Regards

Ed Willink
Previous Topic:Is is possible to install OCL without installing UML?
Next Topic:Using OCL to create a M2M ATL to UML2
Goto Forum:
  


Current Time: Tue Sep 25 07:08:57 GMT 2018

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

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

Back to the top