Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Running .ocl against a model
Running .ocl against a model [message #772404] Thu, 29 December 2011 17:38 Go to next message
Reinaldo Junior is currently offline Reinaldo Junior
Messages: 36
Registered: March 2011
Member

Sorry if the title is wrong.

I'm trying to use the "Royal and Loyal" example (http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FExamples.html) to learning OCL in Eclipse.

I created a .xmi to make a dynamic instance fo the RoyalAndLoyal metamodel, and I changed the .ocl file such a way it has a failling invariant:

context ServiceLevel
inv invariant_ServiceLevel15 :
	(OrderedSet{'a', 'b', 'c', 'd'}->insertAt(3, 'X')) = OrderedSet{'a', 'b', 'XY', 'c', 'd'}


But in the .xmi file, I Right-click the ServiceLevel instance and choose Validate and the validation succeeds.

Is the .ocl file automatically associated with the .ecore? How can I make it (with completeOCL)?

OR

Should I create a plugin Activator to my project and make put some custom code there?
Re: Running .ocl against a model [message #772424 is a reply to message #772404] Thu, 29 December 2011 18:48 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

This is one of the downsides of Complete OCL documents; they are
completely independent of the model, so a normal modeling tool is
unaware of the additional constraints.

Today, using the Ecore binding, you can use the Java API to manually
parse the Complete OCL document into your ResourceSet.

Or, you can do the same with the Pivot binding, for which you can also
use the Xtext OCL Console to load the Complete OCL Document as an
additional Resource, but then you will hit the outstanding Bugzilla that
the Console provides no Validate button to exploit it.

Or, again using the Pivot binding, you can use the
CompleteOCLEObjectValidator to have an extended validation capability.

'Tomorrow' the genmodel may support referencing Complete OCL documents
for code generation into you compiled model.

I am still considering whether there is a way to automatically integrate
a Complete OCL document into a dynamic model loaded by a nominally
OCL-unaware modeling tool. It's far from obvious that this can be done
safely, reliably and cheaply.

Regards

Ed Willink





On 29/12/2011 17:38, Reinaldo Junior wrote:
> Sorry if the title is wrong.
>
> I'm trying to use the "Royal and Loyal" example
> (http://help.eclipse.org/indigo/index.jsp?topic=%2Forg.eclipse.ocl.doc%2Fhelp%2FExamples.html)
> to learning OCL in Eclipse.
>
> I created a .xmi to make a dynamic instance fo the RoyalAndLoyal
> metamodel, and I changed the .ocl file such a way it has a failling
> invariant:
>
>
> context ServiceLevel
> inv invariant_ServiceLevel15 :
> (OrderedSet{'a', 'b', 'c', 'd'}->insertAt(3, 'X')) =
> OrderedSet{'a', 'b', 'XY', 'c', 'd'}
>
>
> But in the .xmi file, I Right-click the ServiceLevel instance and
> choose Validate and the validation succeeds.
>
> Is the .ocl file automatically associated with the .ecore? How can I
> make it (with completeOCL)?
>
> OR
>
> Should I create a plugin Activator to my project and make put some
> custom code there?
Re: Running .ocl against a model [message #779221 is a reply to message #772424] Sun, 15 January 2012 03:30 Go to previous messageGo to next message
Jörn Guy  Süß is currently offline Jörn Guy Süß
Messages: 83
Registered: July 2009
Location: Germany
Member

Ed,
Is there a boilerplate recipe for performing the following two tasks:


  1. Associate an existing metamodel with a CompleteOCL document, so it type-checks the OCL
  2. Associate an instance of a model (of any non-UML type, i.e. Ecore M1) with CompleteOCL so it validates


I have seen a large number of piece-meal documentation and API references. What I am looking for is a simple-most tutorial for these essential cases.

Thanks, JG

[Updated on: Sun, 15 January 2012 03:31]

Report message to a moderator

Re: Running .ocl against a model [message #779275 is a reply to message #779221] Sun, 15 January 2012 07:35 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4046
Registered: July 2009
Senior Member
Hi

Simple answer: No.

You are asking the question from the wrong direction (and without context).

An existing meta-model cannot know about its Complete OCL complements,
but a Complete OCL document can know what model it complements, so you
must start from a context that identifies the Complete OCL.

[If you want the existing meta-model to know about additional OCL, use
OCL delegates (probably using OCLinEcore) to embed the OCL.]

What tools know about both Complete OCL and your model? today - your
Java program can use the CompleteOCLEObjectValidator.

About a week ago I added a Validate button to the OCL Interactive
Console, so that in Juno you should be able to load your model with your
favourite tool, then load your Complete OCL document into the Console
and invoke Validate on the adaptable-to-EObject selection in your
favourite tool.

Hm. Just had an idea. Given that the current selection is
adaptable-to-EObject, this selection could allow an independent tool,
such as the OCL Console, to modify the ResourceSet within your favourite
tool, thereby installing a Complete OCL document so that your favourite
tool becomes Complete OCL aware. The extensibility of the Eclipse menu
system might even enable a menu option to be added to your favourite
tool so that Complete OCL loading can be performed without needing to
use the OCL Console at all.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=368612 raised.

Regards

Ed Willink



On 15/01/2012 03:30, Jörn Guy Sü Missing name wrote:
> Ed,
> Is there a boilerplate recipe for performing the following two tasks:
>
>
> Associate an existing metamodel with a CompleteOCL document, so it
> type-checks the OCL
> Associate an instance of an Ecore model with CompleteOCL so it validates
>
>
> I have seen a large number of piece-meal documentation and API
> references. What I am looking for is a simple-most tutorial for these
> essential cases.
>
> Thanks, JG
>
Previous Topic:Future Directions for MDT/OCL
Next Topic:Modify OCL Xtext Console plugin
Goto Forum:
  


Current Time: Tue Sep 23 00:37:31 GMT 2014

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

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