Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » CompleteOCLEObjectValidator and UML meta model
CompleteOCLEObjectValidator and UML meta model [message #792104] Mon, 06 February 2012 11:10 Go to next message
Max Bureck is currently offline Max Bureck
Messages: 9
Registered: January 2012
Junior Member
Hello,

I have registered an CompleteOCLEObjectValidator for a sample OCL file with a rule on the UML meta model in the EValidator registry:

OCL file
import 'http[:]//www.eclipse.org/emf/2002/Ecore'
import 'http[:]//www.eclipse.org/emf/2002/GenModel'
import 'http[:]//www.eclipse.org/uml2/3.0.0/UML'

package uml

	context Classifier 
	inv NoInheritanceCycles('There is a cycle in the inheritence, one of the parents of class "'+self.name+'" is the class itself.') : 
	not self.allParents()->includes(self)

endpackage


plugin.xml
   <extension
         point="org.eclipse.ui.startup">
      <startup
            class="org.eclipse.ocl.validation.pivot.example.ExampleValidatorRegistration">
      </startup>
   </extension>


IStartup implementation
public class ExampleValidatorRegistration implements IStartup {

	private static final URI exampleURI = URI.createURI("platform:/plugin/org.eclipse.ocl.validation.pivot.example/constraints/sample.ocl");
	
	@Override
	public void earlyStartup() {
		UMLPackage _package = UMLPackage.eINSTANCE;
		// Register EValidator
		EValidator.Registry.INSTANCE.put(
				_package,
				new CompleteOCLEObjectValidator(_package,exampleURI));
	}

}


The evaluation of the query fails during validation. An Exception is thrown during evaluation of the query: org.eclipse.ocl.examples.pivot.InvalidEvaluationException: 'Boolean' value required.
I don't get it, the OCL Console doesn't have a problem with the query. Is this a bug in the CompleteOCLEObjectValidator or do I miss something?

P.S. I am not allowed to post links until I have 5 posts in the forum, so I replaced ":" by "[:]" in the URIs
Re: CompleteOCLEObjectValidator and UML meta model [message #792169 is a reply to message #792104] Mon, 06 February 2012 12:39 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi Max

Unfortunately the MDT/UML2 project does not provide an initialisation
routine for you comparable to Xtext's doSetup(). MDT/OCL partially
rectifies this in OCL.initializeResourceSet(). The Standalone
Initialisation section in the OCL Documentation (Help Contents) provides
more.

Regards

Ed Willink


On 06/02/2012 16:10, Max Bureck wrote:
> Hello,
>
> I have registered an CompleteOCLEObjectValidator for a sample OCL file
> with a rule on the UML meta model in the EValidator registry:
>
> OCL file
> import 'http[:]//www.eclipse.org/emf/2002/Ecore'
> import 'http[:]//www.eclipse.org/emf/2002/GenModel'
> import 'http[:]//www.eclipse.org/uml2/3.0.0/UML'
>
> package uml
>
> context Classifier inv NoInheritanceCycles('There is a cycle
> in the inheritence, one of the parents of class "'+self.name+'" is the
> class itself.') : not self.allParents()->includes(self)
>
> endpackage
>
> plugin.xml
> <extension
> point="org.eclipse.ui.startup">
> <startup
>
> class="org.eclipse.ocl.validation.pivot.example.ExampleValidatorRegistration">
> </startup>
> </extension>
>
> IStartup implementation
> public class ExampleValidatorRegistration implements IStartup {
>
> private static final URI exampleURI =
> URI.createURI("platform:/plugin/org.eclipse.ocl.validation.pivot.example/constraints/sample.ocl");
>
> @Override
> public void earlyStartup() {
> UMLPackage _package = UMLPackage.eINSTANCE;
> // Register EValidator
> EValidator.Registry.INSTANCE.put(
> _package,
> new CompleteOCLEObjectValidator(_package,exampleURI));
> }
>
> }
>
> The evaluation of the query fails during validation. An Exception is
> thrown during evaluation of the query:
> org.eclipse.ocl.examples.pivot.InvalidEvaluationException: 'Boolean'
> value required.
> I don't get it, the OCL Console doesn't have a problem with the query.
> Is this a bug in the CompleteOCLEObjectValidator or do I miss something?
>
> P.S. I am not allowed to post links until I have 5 posts in the forum,
> so I replaced ":" by "[:]" in the URIs
Re: CompleteOCLEObjectValidator and UML meta model [message #792612 is a reply to message #792169] Tue, 07 February 2012 02:25 Go to previous messageGo to next message
Max Bureck is currently offline Max Bureck
Messages: 9
Registered: January 2012
Junior Member
Hi Ed,

Thanks for your answer.
I don't see how this would help. I am in an Eclipse environment not in a standalone application, so the initialization is already done when the Validator gets registered and later when the validation actually gets invoked.
If you want I can attach the tiny plugin and the UML file to be validated. It's a very small example and I followed the OCL help sites exactly when defining it.

I already registered a validator for an OCL file on an own meta model in a different plugin, which worked. So it looks like it's somehow linked to the UML2 meta model or how it is implemented.
Re: CompleteOCLEObjectValidator and UML meta model [message #792620 is a reply to message #792612] Tue, 07 February 2012 02:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi
> If you want I can attach the tiny plugin and the UML file to be
> validated.
That would certainly help.
> It's a very small example and I followed the OCL help sites exactly
> when defining it.
Sometimes these have bugs in too.

Regards

Ed Willink
Re: CompleteOCLEObjectValidator and UML meta model [message #792688 is a reply to message #792620] Tue, 07 February 2012 04:31 Go to previous messageGo to next message
Max Bureck is currently offline Max Bureck
Messages: 9
Registered: January 2012
Junior Member
Hi,

I attached a zip containing the plugin project and a UML file violating the constraint.
  • Attachment: example.zip
    (Size: 4.97KB, Downloaded 88 times)
Re: CompleteOCLEObjectValidator and UML meta model [message #793994 is a reply to message #792688] Wed, 08 February 2012 15:15 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4035
Registered: July 2009
Senior Member
Hi

Thanks for the example; it exposed a few bugs for me in the current code.

On Indigo SR1 I could not reproduce your 'Boolean' problem. I get 3 OCL
Validation result ... is invalid. The problem is that thenon-OCL
implementation of allParents() is not accessed
(https://bugs.eclipse.org/bugs/show_bug.cgi?id=371002), but you didn't
need it anyway.

Your invariant is a composition cycle test. You want an inheritance
cycle test:

context Class
inv NoInheritanceCycles('There is a cycle in the inheritance, one
of the parents of class "'+self.name+'" is the class itself.') :
self->closure(superClass)->excludes(self)

Regards

Ed Willink


On 07/02/2012 09:31, Max Bureck wrote:
> Hi,
>
> I attached a zip containing the plugin project and a UML file violating the constraint.
Re: CompleteOCLEObjectValidator and UML meta model [message #794087 is a reply to message #793994] Wed, 08 February 2012 17:42 Go to previous message
Max Bureck is currently offline Max Bureck
Messages: 9
Registered: January 2012
Junior Member
Alright, thanks for taking care of this problem! The Exception with the message "'Boolean' value required" is raised inside of the validator, when query.accept(...) is called. To the outside the message "OCL validation result of ''...'' is invalid" will be shown.

Thanks again,
Max
Previous Topic:Problem OCL + Ecore Validation
Next Topic:OCL as query language for UML models?
Goto Forum:
  


Current Time: Sat Aug 30 14:36:54 EDT 2014

Powered by FUDForum. Page generated in 0.04504 seconds