Skip to main content



      Home
Home » Modeling » EMF "Technology" (Ecore Tools, EMFatic, etc)  » [ECP] View validation with OCL constraints
[ECP] View validation with OCL constraints [message #1398681] Fri, 11 July 2014 08:21 Go to next message
Eclipse UserFriend
Hi,

I've enriched the makeithappen ecore model example with a simple OCL constraint and when the constraint is violated I get a following error:

Caused by: org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBoundsException: index=1, size=1
	at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:346)
	at org.eclipse.emf.ecp.view.internal.validation.ViewValidator.getDiagnosticForEObject(ViewValidator.java:287)
	at org.eclipse.emf.ecp.view.internal.validation.ViewValidator.validateAndNotifyControls(ViewValidator.java:127)
	at org.eclipse.emf.ecp.view.internal.validation.ViewValidator.validate(ViewValidator.java:109)
	at org.eclipse.emf.ecp.view.internal.validation.ViewValidator.validate(ViewValidator.java:234)
	at org.eclipse.emf.ecp.view.internal.validation.ValidationService.instantiate(ValidationService.java:279)
	at org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.instantiate(ViewModelContextImpl.java:132)
	at org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.<init>(ViewModelContextImpl.java:112)
	at org.eclipse.emf.ecp.view.spi.context.ViewModelContextFactory.createViewModelContext(ViewModelContextFactory.java:55)
	at org.eclipse.emf.ecp.ui.e4.editor.ECPE4Editor.setInput(ECPE4Editor.java:99)
	at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
	at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.lang.reflect.Method.invoke(Method.java:601)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	... 39 more


The OCLValidationDelegate checks the constraint and returns 'false' so this part works fine, then the EObjectValidator.reportConstraintDelegateViolation is executed which creates new Diagnostic with the violated EObject as data parameter.

When the control gets back to the ViewValidator the following code from getDiagnosticForEObject method is executed
final Map<EStructuralFeature, DiagnosticChain> diagnosticMap = new LinkedHashMap<EStructuralFeature, DiagnosticChain>();
for (final Diagnostic child : diagnostics.getChildren()) {
	if (DiagnosticChain.class.isInstance(child)) {
		diagnosticMap.put((EStructuralFeature) child.getData().get(1), (DiagnosticChain) child);
	}
}

The Diagnostic created in the EObjectValidator.reportConstraintDelegateViolation method has only one element in the data list, so it fails.

Is this a bug or maybe I am missing some configuration? If this is a bug, has it been reported and resolved in newer versions?
I am using eclipse kepler with ecp in version 1.2.0 and org.eclipse.ocl 3.3.0.

Regards,
Michal
Re: [ECP] View validation with OCL constraints [message #1398692 is a reply to message #1398681] Fri, 11 July 2014 08:44 Go to previous message
Eclipse UserFriend
Hi

I recall that things in this area have been evolving; my OCL unit tests
have to be tolerant to two different EMF layouts because EMF added an
extra value during Luna development.

IMHO Diagnostic code should be bomb-proof so

diagnosticMap.put((EStructuralFeature) child.getData().get(1),
(DiagnosticChain) child);

is really bad; there is no EMF convention that mandates two or more data
elements. Raise a Bugzilla.

ECP might use use two but it cannot be sure that everyone does.

Regards

Ed Willink

On 11/07/2014 13:21, Michal Sudra wrote:
> Hi,
>
> I've enriched the makeithappen ecore model example with a simple OCL
> constraint and when the constraint is violated I get a following error:
>
>
> Caused by:
> org.eclipse.emf.common.util.BasicEList$BasicIndexOutOfBoundsException:
> index=1, size=1
> at org.eclipse.emf.common.util.BasicEList.get(BasicEList.java:346)
> at
> org.eclipse.emf.ecp.view.internal.validation.ViewValidator.getDiagnosticForEObject(ViewValidator.java:287)
> at
> org.eclipse.emf.ecp.view.internal.validation.ViewValidator.validateAndNotifyControls(ViewValidator.java:127)
> at
> org.eclipse.emf.ecp.view.internal.validation.ViewValidator.validate(ViewValidator.java:109)
> at
> org.eclipse.emf.ecp.view.internal.validation.ViewValidator.validate(ViewValidator.java:234)
> at
> org.eclipse.emf.ecp.view.internal.validation.ValidationService.instantiate(ValidationService.java:279)
> at
> org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.instantiate(ViewModelContextImpl.java:132)
> at
> org.eclipse.emf.ecp.view.internal.context.ViewModelContextImpl.<init>(ViewModelContextImpl.java:112)
> at
> org.eclipse.emf.ecp.view.spi.context.ViewModelContextFactory.createViewModelContext(ViewModelContextFactory.java:55)
> at
> org.eclipse.emf.ecp.ui.e4.editor.ECPE4Editor.setInput(ECPE4Editor.java:99)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
> at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
> at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
> at java.lang.reflect.Method.invoke(Method.java:601)
> at
> org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
> ... 39 more
>
>
> The OCLValidationDelegate checks the constraint and returns 'false' so
> this part works fine, then the
> EObjectValidator.reportConstraintDelegateViolation is executed which
> creates new Diagnostic with the violated EObject as data parameter.
>
> When the control gets back to the ViewValidator the following code
> from getDiagnosticForEObject method is executed
>
> final Map<EStructuralFeature, DiagnosticChain> diagnosticMap = new
> LinkedHashMap<EStructuralFeature, DiagnosticChain>();
> for (final Diagnostic child : diagnostics.getChildren()) {
> if (DiagnosticChain.class.isInstance(child)) {
> diagnosticMap.put((EStructuralFeature) child.getData().get(1),
> (DiagnosticChain) child);
> }
> }
>
> The Diagnostic created in the
> EObjectValidator.reportConstraintDelegateViolation method has only one
> element in the data list, so it fails.
>
> Is this a bug or maybe I am missing some configuration? If this is a
> bug, has it been reported and resolved in newer versions?
> I am using eclipse kepler with ecp in version 1.2.0 and
> org.eclipse.ocl 3.3.0.
>
> Regards,
> Michal
Previous Topic:[EMFStore] IndexOutOfBoundsException when adding EClass object to EReference feature
Next Topic:Overriding the ListControl
Goto Forum:
  


Current Time: Mon Jul 14 04:28:34 EDT 2025

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

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

Back to the top