Calling an EMF Java function from OCL constraint [message #1847976] |
Mon, 15 November 2021 17:37  |
Eclipse User |
|
|
|
Assuming that I have an Ecore meta-class "Foo", with a function "isFoo()". The body of the function is "return true". My OCL invariant constraint
if isFoo() then
true
else
false
endif
always fail to evaluate the generated Java function "isFoo()". Meanwhile, I followed the OCL guide (https://wiki.eclipse.org/OCL/OCLinEcore) to register OCL delegates as shown below, yet the problem persists.
mport org.eclipse.emf.ecore.EOperation;
import org.eclipse.emf.ecore.EStructuralFeature;
import org.eclipse.emf.ecore.EValidator;
import org.eclipse.ocl.ecore.delegate.OCLDelegateDomain;
import org.eclipse.ocl.ecore.delegate.OCLInvocationDelegateFactory;
import org.eclipse.ocl.ecore.delegate.OCLSettingDelegateFactory;
import org.eclipse.ocl.ecore.delegate.OCLValidationDelegateFactory;
String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI;
EOperation.Internal.InvocationDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
new OCLInvocationDelegateFactory.Global());
EStructuralFeature.Internal.SettingDelegate.Factory.Registry.INSTANCE.put(oclDelegateURI,
new OCLSettingDelegateFactory.Global());
EValidator.ValidationDelegate.Registry.INSTANCE.put(oclDelegateURI,
new OCLValidationDelegateFactory.Global());
My question is there anything I am missing or I am applying an inappropriate approach to use the helper function in my OCL constraint? Suggestion(s) with minimal a example(s) is highly appreciated.
|
|
|
|
Re: Calling an EMF Java function from OCL constraint [message #1848073 is a reply to message #1847981] |
Thu, 18 November 2021 22:57  |
Eclipse User |
|
|
|
Hi,
Thanks for this detailed response as well as a guide on how to better present the problem. Meanwhile, while I was trying to provide more details for the question, I discovered a bug in my code. Consequently, fixing the bug solved the problem.
Thanks for the quick response!
|
|
|
Powered by
FUDForum. Page generated in 0.04658 seconds