Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Calling an EMF Java function from OCL constraint(OCL invariant constraint fails to evaluate because it calls an EMF Java function)
Calling an EMF Java function from OCL constraint [message #1847976] Mon, 15 November 2021 22:37 Go to next message
Hyacinth Ali is currently offline Hyacinth AliFriend
Messages: 4
Registered: January 2020
Junior Member
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 #1847981 is a reply to message #1847976] Tue, 16 November 2021 05:54 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

You present a filleted half-of-the-story so it is impossible to see what you are wrongly assuming. I can only comment that there is a huge amount missing. e.g. a leading "i" in the first import and package/class/function declarations in the Java, and a context in the OCL.
You need to provide something much closer to a repro. See https://wiki.eclipse.org/OCL/ForumNetiquette

Regards

Ed Willink
Re: Calling an EMF Java function from OCL constraint [message #1848073 is a reply to message #1847981] Fri, 19 November 2021 03:57 Go to previous message
Hyacinth Ali is currently offline Hyacinth AliFriend
Messages: 4
Registered: January 2020
Junior Member
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!
Previous Topic:OCL expression not evaluated
Next Topic:Getting invalid for the evaluation of OCL on XMI
Goto Forum:
  


Current Time: Sun May 05 09:06:19 GMT 2024

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

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

Back to the top