Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » Non documented dependency for OCLinEcore(Problem using OCLinEcore through a metamodel API)
Non documented dependency for OCLinEcore [message #1723234] Fri, 12 February 2016 16:01 Go to next message
Elie Richa is currently offline Elie RichaFriend
Messages: 8
Registered: February 2016
Junior Member
Hello,

I'm trying to embed OCL invariants and OCL definitions for derived attributes in my metamodel. I encountered some issues with plugin dependencies but managed to fix them. I'm writing this post to explain what I did and maybe point out a bug/confusion in the OCL related plugin dependencies.

I used the OCLinEcore editor to embed the right EAnnotations at the right place in my metamodel. I generated my metamodel classes with a GenModel and got seemless [Live] validation with the standard reflective model editor.

However when I packaged and provided my metamodel plugin through an update site, things did not work out of the box. OCL validation did not work because the Pivot OCL evaluation delegate was not registered. Going back to the documentation, I found here that I needed the following dependencies in my plugin:

org.eclipse.ocl.pivot (for the execution delegate)
org.eclipse.ocl.xtext.completeocl (the rest of the plugins are for parsing the OCL expressions embedded in the metamodel)
org.eclipse.ocl.xtext.oclinecore
org.eclipse.ocl.xtext.oclstdlib

This helped, however now I had the following exception:

org.eclipse.ocl.pivot.internal.delegate.OCLDelegateException: Failed to create Xtext resource for '_dFM5ANF4EeW2U5NQBGUb7g.essentialocl'
	at org.eclipse.ocl.pivot.internal.delegate.SettingBehavior.getQueryOrThrow(SettingBehavior.java:67)
	at org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegate.get(OCLSettingDelegate.java:109)
	at org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegate$Changeable.get(OCLSettingDelegate.java:55)
	at org.eclipse.emf.ecore.util.BasicSettingDelegate$Stateless.dynamicGet(BasicSettingDelegate.java:185)
        ...
Caused by: org.eclipse.ocl.pivot.utilities.ParserException: Failed to create Xtext resource for '_dFM5ANF4EeW2U5NQBGUb7g.essentialocl'
	at org.eclipse.ocl.pivot.internal.context.AbstractParserContext.createBaseResource(AbstractParserContext.java:72)
	at org.eclipse.ocl.pivot.internal.context.AbstractParserContext.parse(AbstractParserContext.java:150)
	at org.eclipse.ocl.pivot.internal.manager.PivotMetamodelManager.parseSpecification(PivotMetamodelManager.java:2148)
	at org.eclipse.ocl.pivot.internal.delegate.SettingBehavior.getQueryOrThrow(SettingBehavior.java:65)
	... 26 more


This happened when the validation code was trying to parse the OCL expression corresponding to a derived attribute. By debugging I found that around AbstractParserContext.java:72 the code tries to create an XText resource based on the URI extension 'essentialocl', however the extension was not registered. So I had to find the plugin that should register that extension.

Digging further I found that the plugin that does that is org.eclipse.ocl.xtext.essentialocl.ui because its plugin.xml has the following extension point:
<extension point="org.eclipse.xtext.extension_resourceServiceProvider">
    <resourceServiceProvider
        class="org.eclipse.ocl.xtext.essentialocl.ui.EssentialOCLExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
        uriExtension="essentialocl">
    </resourceServiceProvider>
</extension>


I added this dependency to my plugin which made everything work out of the box: the simple installation of my metamodel plugin now triggers the installation of all OCL dependencies, including org.eclipse.ocl.xtext.essentialocl.ui.

What I find weird is that:
1. The documentation does not mention org.eclipse.ocl.xtext.essentialocl.ui as a dependency for parsing OCL expressions.
2. I find it weird to include a *.ui dependency even though I'm not developing any UI plugins.

Does that qualify as a bug? Smile
Could the registration of the 'essentialocl' URI extension be done in a more appropriate plugin?

Thanks.

--
Elie
Re: Non documented dependency for OCLinEcore [message #1723256 is a reply to message #1723234] Fri, 12 February 2016 18:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

[PivotStandalone.html was not updated for Mars, which was confusing, but
I think that oversight has now vanished from what is visible.]

You certainly should not need to have a *.ui dependency. It should be
sufficient to invoke |EssentialOCLStandaloneSetup.doSetup()|
as mentioned in the help. Have you invoked it?

If you are packaging for an update site, you may prefer to spare your
users the parsng cost of OCL by parsing the OCL while building using
CGed rather than delegated OCL execution. CGed execution is pure Java
and so has few and obvious dependencies; no need for any Xtext plugin.

Regards

Ed Willink



On 12/02/2016 17:26, Elie Richa wrote:
> Hello,
>
> I'm trying to embed OCL invariants and OCL definitions for derived
> attributes in my metamodel. I encountered some issues with plugin
> dependencies but managed to fix them. I'm writing this post to explain
> what I did and maybe point out a bug/confusion in the OCL related
> plugin dependencies.
>
> I used the OCLinEcore editor to embed the right EAnnotations at the
> right place in my metamodel. I generated my metamodel classes with a
> GenModel and got seemless [Live] validation with the standard
> reflective model editor.
>
> However when I packaged and provided my metamodel plugin through an
> update site, things did not work out of the box. OCL validation did
> not work because the Pivot OCL evaluation delegate was not registered.
> Going back to the documentation, I found
> http://help.eclipse.org/mars/topic/org.eclipse.ocl.doc/help/PivotStandalone.html?cp=53_6_2_1#XtextParsers
> that I needed the following dependencies in my plugin:
>
> org.eclipse.ocl.pivot (for the execution delegate)
> org.eclipse.ocl.xtext.completeocl (the rest of the plugins are for
> parsing the OCL expressions embedded in the metamodel)
> org.eclipse.ocl.xtext.oclinecore
> org.eclipse.ocl.xtext.oclstdlib
>
> This helped, however now I had the following exception:
>
>
> org.eclipse.ocl.pivot.internal.delegate.OCLDelegateException: Failed
> to create Xtext resource for '_dFM5ANF4EeW2U5NQBGUb7g.essentialocl'
> at
> org.eclipse.ocl.pivot.internal.delegate.SettingBehavior.getQueryOrThrow(SettingBehavior.java:67)
> at
> org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegate.get(OCLSettingDelegate.java:109)
> at
> org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegate$Changeable.get(OCLSettingDelegate.java:55)
> at
> org.eclipse.emf.ecore.util.BasicSettingDelegate$Stateless.dynamicGet(BasicSettingDelegate.java:185)
> ...
> Caused by: org.eclipse.ocl.pivot.utilities.ParserException: Failed to
> create Xtext resource for '_dFM5ANF4EeW2U5NQBGUb7g.essentialocl'
> at
> org.eclipse.ocl.pivot.internal.context.AbstractParserContext.createBaseResource(AbstractParserContext.java:72)
> at
> org.eclipse.ocl.pivot.internal.context.AbstractParserContext.parse(AbstractParserContext.java:150)
> at
> org.eclipse.ocl.pivot.internal.manager.PivotMetamodelManager.parseSpecification(PivotMetamodelManager.java:2148)
> at
> org.eclipse.ocl.pivot.internal.delegate.SettingBehavior.getQueryOrThrow(SettingBehavior.java:65)
> ... 26 more
>
>
> This happened when the validation code was trying to parse the OCL
> expression corresponding to a derived attribute. By debugging I found
> that around AbstractParserContext.java:72 the code tries to create an
> XText resource based on the URI extension 'essentialocl', however the
> extension was not registered. So I had to find the plugin that should
> register that extension.
>
> Digging further I found that the plugin that does that is
> org.eclipse.ocl.xtext.essentialocl.ui because its plugin.xml has the
> following extension point:
>
> <extension point="org.eclipse.xtext.extension_resourceServiceProvider">
> <resourceServiceProvider
> class="org.eclipse.ocl.xtext.essentialocl.ui.EssentialOCLExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
> uriExtension="essentialocl">
> </resourceServiceProvider>
> </extension>
>
>
> I added this dependency to my plugin which made everything work out of
> the box: the simple installation of my metamodel plugin now triggers
> the installation of all OCL dependencies, including
> org.eclipse.ocl.xtext.essentialocl.ui.
>
> What I find weird is that:
> 1. The
> http://help.eclipse.org/mars/topic/org.eclipse.ocl.doc/help/PivotStandalone.html?cp=53_6_2_1#XtextParsers
> does not mention org.eclipse.ocl.xtext.essentialocl.ui as a
> dependency for parsing OCL expressions.
> 2. I find it weird to include a *.ui dependency even though I'm not
> developing any UI plugins.
>
> Does that qualify as a bug? :)
> Could the registration of the 'essentialocl' URI extension be done in
> a more appropriate plugin?
>
> Thanks.
>
> --
> Elie
Re: Non documented dependency for OCLinEcore [message #1723259 is a reply to message #1723256] Fri, 12 February 2016 19:03 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

Your description confused me. PivotStandalone.html describes standalone
usage.

Sentence 1: "If you use Eclipse OCL within Eclipse, you should find that
the appropriate registrations are provided for you automatically by the
plugin registration mechanisms."

So if you choose to install an OCL subset, it is your problem. OCL users
are expected to install the OCL distribution, and this includes the UI
which is where Xtext provides its supported registration.

That said, you may still find CGed generation more streamlined.

Regards

Ed Willink


On 12/02/2016 18:33, Ed Willink wrote:
> Hi
>
> [PivotStandalone.html was not updated for Mars, which was confusing,
> but I think that oversight has now vanished from what is visible.]
>
> You certainly should not need to have a *.ui dependency. It should be
> sufficient to invoke |EssentialOCLStandaloneSetup.doSetup()|
> as mentioned in the help. Have you invoked it?
>
> If you are packaging for an update site, you may prefer to spare your
> users the parsng cost of OCL by parsing the OCL while building using
> CGed rather than delegated OCL execution. CGed execution is pure Java
> and so has few and obvious dependencies; no need for any Xtext plugin.
>
> Regards
>
> Ed Willink
>
>
>
> On 12/02/2016 17:26, Elie Richa wrote:
>> Hello,
>>
>> I'm trying to embed OCL invariants and OCL definitions for derived
>> attributes in my metamodel. I encountered some issues with plugin
>> dependencies but managed to fix them. I'm writing this post to
>> explain what I did and maybe point out a bug/confusion in the OCL
>> related plugin dependencies.
>>
>> I used the OCLinEcore editor to embed the right EAnnotations at the
>> right place in my metamodel. I generated my metamodel classes with a
>> GenModel and got seemless [Live] validation with the standard
>> reflective model editor.
>>
>> However when I packaged and provided my metamodel plugin through an
>> update site, things did not work out of the box. OCL validation did
>> not work because the Pivot OCL evaluation delegate was not
>> registered. Going back to the documentation, I found
>> http://help.eclipse.org/mars/topic/org.eclipse.ocl.doc/help/PivotStandalone.html?cp=53_6_2_1#XtextParsers
>> that I needed the following dependencies in my plugin:
>>
>> org.eclipse.ocl.pivot (for the execution delegate)
>> org.eclipse.ocl.xtext.completeocl (the rest of the plugins are
>> for parsing the OCL expressions embedded in the metamodel)
>> org.eclipse.ocl.xtext.oclinecore
>> org.eclipse.ocl.xtext.oclstdlib
>>
>> This helped, however now I had the following exception:
>>
>>
>> org.eclipse.ocl.pivot.internal.delegate.OCLDelegateException: Failed
>> to create Xtext resource for '_dFM5ANF4EeW2U5NQBGUb7g.essentialocl'
>> at
>> org.eclipse.ocl.pivot.internal.delegate.SettingBehavior.getQueryOrThrow(SettingBehavior.java:67)
>> at
>> org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegate.get(OCLSettingDelegate.java:109)
>> at
>> org.eclipse.ocl.pivot.internal.delegate.OCLSettingDelegate$Changeable.get(OCLSettingDelegate.java:55)
>> at
>> org.eclipse.emf.ecore.util.BasicSettingDelegate$Stateless.dynamicGet(BasicSettingDelegate.java:185)
>> ...
>> Caused by: org.eclipse.ocl.pivot.utilities.ParserException: Failed to
>> create Xtext resource for '_dFM5ANF4EeW2U5NQBGUb7g.essentialocl'
>> at
>> org.eclipse.ocl.pivot.internal.context.AbstractParserContext.createBaseResource(AbstractParserContext.java:72)
>> at
>> org.eclipse.ocl.pivot.internal.context.AbstractParserContext.parse(AbstractParserContext.java:150)
>> at
>> org.eclipse.ocl.pivot.internal.manager.PivotMetamodelManager.parseSpecification(PivotMetamodelManager.java:2148)
>> at
>> org.eclipse.ocl.pivot.internal.delegate.SettingBehavior.getQueryOrThrow(SettingBehavior.java:65)
>> ... 26 more
>>
>>
>> This happened when the validation code was trying to parse the OCL
>> expression corresponding to a derived attribute. By debugging I found
>> that around AbstractParserContext.java:72 the code tries to create an
>> XText resource based on the URI extension 'essentialocl', however the
>> extension was not registered. So I had to find the plugin that should
>> register that extension.
>>
>> Digging further I found that the plugin that does that is
>> org.eclipse.ocl.xtext.essentialocl.ui because its plugin.xml has the
>> following extension point:
>>
>> <extension point="org.eclipse.xtext.extension_resourceServiceProvider">
>> <resourceServiceProvider
>> class="org.eclipse.ocl.xtext.essentialocl.ui.EssentialOCLExecutableExtensionFactory:org.eclipse.xtext.ui.resource.IResourceUIServiceProvider"
>>
>> uriExtension="essentialocl">
>> </resourceServiceProvider>
>> </extension>
>>
>>
>> I added this dependency to my plugin which made everything work out
>> of the box: the simple installation of my metamodel plugin now
>> triggers the installation of all OCL dependencies, including
>> org.eclipse.ocl.xtext.essentialocl.ui.
>>
>> What I find weird is that:
>> 1. The
>> http://help.eclipse.org/mars/topic/org.eclipse.ocl.doc/help/PivotStandalone.html?cp=53_6_2_1#XtextParsers
>> does not mention org.eclipse.ocl.xtext.essentialocl.ui as a
>> dependency for parsing OCL expressions.
>> 2. I find it weird to include a *.ui dependency even though I'm not
>> developing any UI plugins.
>>
>> Does that qualify as a bug? :)
>> Could the registration of the 'essentialocl' URI extension be done in
>> a more appropriate plugin?
>>
>> Thanks.
>>
>> --
>> Elie
>
Re: Non documented dependency for OCLinEcore [message #1723437 is a reply to message #1723259] Mon, 15 February 2016 16:48 Go to previous messageGo to next message
Elie Richa is currently offline Elie RichaFriend
Messages: 8
Registered: February 2016
Junior Member
Hi Ed,

Thank you for the answers.

On 12/02/16 20:03, Ed Willink wrote:
> Hi
>
> Your description confused me. PivotStandalone.html describes standalone
> usage.
>
> Sentence 1: "If you use Eclipse OCL within Eclipse, you should find that
> the appropriate registrations are provided for you automatically by the
> plugin registration mechanisms."
>
> So if you choose to install an OCL subset, it is your problem. OCL users
> are expected to install the OCL distribution, and this includes the UI
> which is where Xtext provides its supported registration.

Understood. I wanted to avoid asking users to install OCL, but in
retrospect it's a pretty easy installation step so I might as well ask
them to do it.

> That said, you may still find CGed generation more streamlined.

I wasn't aware of the possibility of OCL->Java CG for metamodel
invariants since it's not the default. I think it's also less advertised
advertised than the default. I'll give it a try.

Thanks!
Re: Non documented dependency for OCLinEcore [message #1723439 is a reply to message #1723437] Mon, 15 February 2016 17:19 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 5573
Registered: July 2009
Senior Member
Hi

CG is not the default. It's still 'experimental' and I keep improving
it. There is a tutorial. It is used to generate the Java code from
Pivot.ocl that validates your OCL. It is increasingly used by the QVTd
project for generation of compiled transformation code. It is a true CG
with an intermediate model and optimizations and nominally 100% syntax
coverage, unlike some other OCL research CGs that inaccurately support a
Java-like OCL subset that is amenable to simple textual mapping.

The underlying CG API is relatively simple and stable from that point of
view, but it is nonetheless improving. Do not use the CG if you are
delivering code that you are not prepared to re-genmodel for each
Eclipse release.

Regards

Ed Willink


On 15/02/2016 16:48, Elie Richa wrote:
> Hi Ed,
>
> Thank you for the answers.
>
> On 12/02/16 20:03, Ed Willink wrote:
>> Hi
>>
>> Your description confused me. PivotStandalone.html describes standalone
>> usage.
>>
>> Sentence 1: "If you use Eclipse OCL within Eclipse, you should find that
>> the appropriate registrations are provided for you automatically by the
>> plugin registration mechanisms."
>>
>> So if you choose to install an OCL subset, it is your problem. OCL users
>> are expected to install the OCL distribution, and this includes the UI
>> which is where Xtext provides its supported registration.
>
> Understood. I wanted to avoid asking users to install OCL, but in
> retrospect it's a pretty easy installation step so I might as well ask
> them to do it.
>
>> That said, you may still find CGed generation more streamlined.
>
> I wasn't aware of the possibility of OCL->Java CG for metamodel
> invariants since it's not the default. I think it's also less
> advertised advertised than the default. I'll give it a try.
>
> Thanks!
Previous Topic:Problems with hierarchical/embedded model packages
Next Topic:How to add power operation to the primitive type Integer?
Goto Forum:
  


Current Time: Wed Jan 17 07:41:20 GMT 2018

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

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