Home » Modeling » OCL » OCL Validation outside of eclipse
OCL Validation outside of eclipse [message #1102170] |
Thu, 05 September 2013 13:12 |
Jean-Baptiste Guillois Messages: 33 Registered: August 2011 |
Member |
|
|
Hello,
I am trying to programmatically trigger OCL validation of my EMF model. Everything works well using the Eclipse environment (EMF model editor and instance viewer)
I use this code in my unit tests. After reading some posts in this forum, I added the following OCL initialization code in my setUp() method:
String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI;
Operation.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());
Then, in my test method i use the following:
// Validate this domain
Diagnostic diag = Diagnostician.INSTANCE.validate(myDomain);
assertNotNull(diag.getChildren());
for (Diagnostic subDiag : diag.getChildren()) {
System.out.println(subDiag.getMessage());
}
I get the following validation diagnostics, which are both correct but the second one reveals that my OCL constraint has not been evaluated:
The feature 'environments' of 'com.xxx.root.impl.DomainImpl@35b57d0b{#//}' with 0 values must have at least 1 values
Unable to find delegate to evaluate the 'atLeastOneFlow' constraint on 'com.xxx.interaction.impl.InteractionTemplateImpl@27cb4b33{#///@interactionTemplates.0}': http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot
Any idea?
Many thanks for your help,
Best Regards,
-- Jean-Baptiste
PS: I am using org.eclipse.ocl-3.2.1, org.eclipse.ocl.ecore-3.2.0, org.eclipse.ocl.common-1.0.2
|
|
|
Re: OCL Validation outside of eclipse [message #1102205 is a reply to message #1102170] |
Thu, 05 September 2013 14:03 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
You've only provided only half a problem; no repro.
So I can only provide a half a reply; no solution.
Regards
Ed Willink
On 05/09/2013 14:12, Missing name Mising name wrote:
> Hello,
>
> I am trying to programmatically trigger OCL validation of my EMF
> model. Everything works well using the Eclipse environment (EMF model
> editor and instance viewer)
>
> I use this code in my unit tests. After reading some posts in this
> forum, I added the following OCL initialization code in my setUp()
> method:
>
> String oclDelegateURI = OCLDelegateDomain.OCL_DELEGATE_URI;
>
> Operation.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());
>
> Then, in my test method i use the following:
>
> // Validate this domain
> Diagnostic diag = Diagnostician.INSTANCE.validate(myDomain);
> assertNotNull(diag.getChildren());
>
> for (Diagnostic subDiag : diag.getChildren()) {
> System.out.println(subDiag.getMessage());
> }
>
>
> I get the following validation diagnostics, which are both correct but
> the second one reveals that my OCL constraint has not been evaluated:
> The feature 'environments' of
> 'com.xxx.root.impl.DomainImpl@35b57d0b{#//}' with 0 values must have
> at least 1 values
> Unable to find delegate to evaluate the 'atLeastOneFlow' constraint on
> 'com.xxx.interaction.impl.InteractionTemplateImpl@27cb4b33{#///@interactionTemplates.0}':
> http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot
>
>
> Any idea?
>
> Many thanks for your help,
>
> Best Regards,
> -- Jean-Baptiste
> PS: I am using org.eclipse.ocl-3.2.1, org.eclipse.ocl.ecore-3.2.0,
> org.eclipse.ocl.common-1.0.2
>
>
|
|
| |
Re: OCL Validation outside of eclipse [message #1125392 is a reply to message #1125211] |
Fri, 04 October 2013 13:07 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
If you set a breakpoint on BasicDiagnostic, you can see that the "An
exception occurred while delegating evaluation of the" occurred because of a
java.lang.NoClassDefFoundError:
org/eclipse/ocl/examples/domain/utilities/DomainUtil
which is nearly the same as
org/eclipse/ocl/examples/domain/elements/DomainElement
Try fixing the classpath.
Regards
Ed Willink
On 04/10/2013 05:19, Jean-Baptiste Guillois wrote:
> Hi Ed,
>
> I am sorry for not getting back to you earlier.
>
> Please find attached a zip file containing a minimal project with a main class that:
> - create an instance of a Test class
> - triggers the validation of this instance
>
> After execution, you will have in the console something like:
> Diagnostic ERROR source=root code=0 An exception occurred while delegating evaluation of the 'check1' constraint on 'root.impl.TestImpl@3890c1ee{#//}': org/eclipse/ocl/examples/domain/elements/DomainElement data=[root.impl.TestImpl@3890c1ee (att1: 1, att2: 123)]
>
> This is what i am struggling at...
>
> If you can provide any help/hint regarding this error, that would be great,
>
> Thx,
>
> Best regards,
|
|
|
Re: OCL Validation outside of eclipse [message #1125408 is a reply to message #1125392] |
Fri, 04 October 2013 13:25 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
https://bugs.eclipse.org/bugs/show_bug.cgi?id=418677 raised.
Regards
Ed Willink
On 04/10/2013 09:07, Ed Willink wrote:
> Hi
>
> If you set a breakpoint on BasicDiagnostic, you can see that the "An
> exception occurred while delegating evaluation of the" occurred
> because of a
>
> java.lang.NoClassDefFoundError:
> org/eclipse/ocl/examples/domain/utilities/DomainUtil
>
> which is nearly the same as
> org/eclipse/ocl/examples/domain/elements/DomainElement
>
> Try fixing the classpath.
>
> Regards
>
> Ed Willink
>
> On 04/10/2013 05:19, Jean-Baptiste Guillois wrote:
>> Hi Ed,
>>
>> I am sorry for not getting back to you earlier.
>>
>> Please find attached a zip file containing a minimal project with a
>> main class that:
>> - create an instance of a Test class
>> - triggers the validation of this instance
>>
>> After execution, you will have in the console something like:
>> Diagnostic ERROR source=root code=0 An exception occurred while
>> delegating evaluation of the 'check1' constraint on
>> 'root.impl.TestImpl@3890c1ee{#//}':
>> org/eclipse/ocl/examples/domain/elements/DomainElement
>> data=[root.impl.TestImpl@3890c1ee (att1: 1, att2: 123)]
>>
>> This is what i am struggling at...
>>
>> If you can provide any help/hint regarding this error, that would be
>> great,
>>
>> Thx,
>>
>> Best regards,
>
|
|
| | | | | | |
Re: OCL Validation outside of eclipse [message #1129603 is a reply to message #1129300] |
Tue, 08 October 2013 20:21 |
Jean-Baptiste Guillois Messages: 33 Registered: August 2011 |
Member |
|
|
Hi Ed,
Thx for your email.
I have carefully read the ForumNetiquette as you suggested.
Nevertheless, I have provided you with a zipped project containing the required files for demonstrating my problem which, since the beginning, is about getting some help on how to initialize the OCL framework. I am still struggling at this and was hoping to find some help in doing such an initialization (which, in my opinion, does not seem to be that special) in this forum.
I have added the two previous screenshots for illustrating the exception I have encountered as no stacktrace is being printed anywhere (as far as I know). By the way, there wasn't any stacktrace printed neither for the missing classpath entries and I thank you for creating and commenting the bug your created.
Regarding my initial problem, and as I still would like to use OCL in my project, would it be better (not to waste your time or other contributors' time) to ask for help specifically on a code snippet regarding OCL usage outside of Eclipse ?
If you want me to ask this question in another thread/forum, please feel free.
Thx for your time and help,
With my best regards,
|
|
|
Re: OCL Validation outside of eclipse [message #1129631 is a reply to message #1129603] |
Tue, 08 October 2013 20:55 |
Ed Willink Messages: 7655 Registered: July 2009 |
Senior Member |
|
|
Hi
Perthaps I should add "Don't ask follow on question".
When you write "Thanks to your answer, i discovered that many jars were
missing. I attached my updated project zip." I regard the thread as
complete and assu me that nsibnce you have resolved your problem you can
resolve your next one.
You cannot expect me to reread multiple levels of the thread.
Regards
Ed Willink
On 08/10/2013 21:21, Jean-Baptiste Guillois wrote:
> Hi Ed,
>
> Thx for your email.
> I have carefully read the ForumNetiquette as you suggested.
> Nevertheless, I have provided you with a zipped project containing the
> required files for demonstrating my problem which, since the
> beginning, is about getting some help on how to initialize the OCL
> framework. I am still struggling at this and was hoping to find some
> help in doing such an initialization (which, in my opinion, does not
> seem to be that special) in this forum.
> I have added the two previous screenshots for illustrating the
> exception I have encountered as no stacktrace is being printed
> anywhere (as far as I know). By the way, there wasn't any stacktrace
> printed neither for the missing classpath entries and I thank you for
> creating and commenting the bug your created.
>
> Regarding my initial problem, and as I still would like to use OCL in
> my project, would it be better (not to waste your time or other
> contributors' time) to ask for help specifically on a code snippet
> regarding OCL usage outside of Eclipse ?
>
> If you want me to ask this question in another thread/forum, please
> feel free.
>
> Thx for your time and help,
>
> With my best regards,
|
|
| | | |
Goto Forum:
Current Time: Sat Apr 27 00:45:43 GMT 2024
Powered by FUDForum. Page generated in 0.04248 seconds
|