Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [CDO] OCL Query Syntax, Package reference
[CDO] OCL Query Syntax, Package reference [message #990869] Fri, 14 December 2012 10:26 Go to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
Hello,

I am trying to execute this in OCL:

Value.allInstances()->select(v:Value|v.belongsTo=self)

I get an exception:

Caused by: org.eclipse.ocl.SemanticException: Unrecognized variable: (Value)
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:352)


It seems, as EPackage information is missing, how do I specify it in the query?
thank you, Christophe




Re: [CDO] OCL Query Syntax, Package reference [message #990876 is a reply to message #990869] Fri, 14 December 2012 10:37 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

There is an OCL newsgroup for OCL discussions.

If Value is in the same package as the context object's class then you
should not need to navigate.

Otherwise you can navigate as X::Y::Value.

Beyond that you needx the forthcoming OCL to support nsURI-based navigation.

But I suspect you have just got an inappropriate context object.

Regards

Ed Willink


On 14/12/2012 15:26, Christophe Bouhier wrote:
> Hello,
> I am trying to execute this in OCL:
> Value.allInstances()->select(v:Value|v.belongsTo=self)
>
> I get an exception:
> Caused by: org.eclipse.ocl.SemanticException: Unrecognized variable:
> (Value)
> at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:352)
>
>
> It seems, as EPackage information is missing, how do I specify it in
> the query? thank you, Christophe
>
>
>
>
>
Re: [CDO] OCL Query Syntax, Package reference [message #990879 is a reply to message #990876] Fri, 14 December 2012 10:58 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
Thanks Ed,

Indeed Value is in another package as the context.
I have tried with [PackageName]::Value so 'Y' = Generics

What would the value of 'X' be?

that didn't help, I now get this exception:

Caused by: org.eclipse.ocl.SemanticException: Unknown type ([Generics, Value])
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:352)
at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:322)


What am I doing wrong?
Thank you
Christophe
PS. thanks for pointing to the OCL forum, I am aware of it, will post there in the future.
Re: [CDO] OCL Query Syntax, Package reference [message #990901 is a reply to message #990879] Fri, 14 December 2012 13:17 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

PackageName should be the name as shown in the Sample Ecore Editor.

Have you ensured that this package is known to the

public EcoreEnvironmentFactory(EPackage.Registry reg)

constructor?

Regards

Ed Willink

On 14/12/2012 15:58, Christophe Bouhier wrote:
> Thanks Ed,
> Indeed Value is in another package as the context. I have tried with
> [PackageName]::Value so 'Y' = Generics
>
> What would the value of 'X' be?
> that didn't help, I now get this exception:
> Caused by: org.eclipse.ocl.SemanticException: Unknown type ([Generics,
> Value])
> at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:352)
> at org.eclipse.ocl.util.OCLUtil.checkForErrors(OCLUtil.java:322)
>
>
> What am I doing wrong? Thank you
> Christophe
> PS. thanks for pointing to the OCL forum, I am aware of it, will post
> there in the future.
Re: [CDO] OCL Query Syntax, Package reference [message #990952 is a reply to message #990901] Sat, 15 December 2012 06:12 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
Ed,

To be specific, this is handled by a CDO Query, would the packages not be resolved
from the CDO Package registry?

I see the following in the OCLQuery Handler:

CDOPackageRegistry packageRegistry = view.getSession().getPackageRegistry();
EcoreEnvironmentFactory envFactory = new EcoreEnvironmentFactory(packageRegistry);

Regarding naming, is it case sensitive ? In the ecore editor, my package name is not capitalized.

Thank you,
Christophe
Re: [CDO] OCL Query Syntax, Package reference [message #990954 is a reply to message #990952] Sat, 15 December 2012 06:31 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
Hi Ed,

I believe the type can now be resolved from the Package, however I struggle now to
deal with associations. I get an error on the "belongsTo" reference. Is this OCL syntax?

Do I need an opposite reference to navigate back to the parent of a contained object?
see the expression here:

generics::Value.allInstances()->select(v:generics::Value|v.=self)

self is MetricValueRange which has a contained EReference to the Value class.
Value itself has no reference back to the MetricValueRange class.

Thank You,
Christophe
Re: [CDO] OCL Query Syntax, Package reference [message #990956 is a reply to message #990952] Sat, 15 December 2012 06:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

Naming is most certainly case sensitive; however there is a wierd
misconceived capitalization for synthesized unnavigable property names.

I'm afraid that I cannot comment on how CDO resolves packages and
whether the CDO registrations are transferred to OCL appropriately. The
code snippet you provide looks promising.

Regards

Ed Willink



On 15/12/2012 11:12, Christophe Bouhier wrote:
> Ed,
> To be specific, this is handled by a CDO Query, would the packages not
> be resolved from the CDO Package registry?
> I see the following in the OCLQuery Handler:
> CDOPackageRegistry packageRegistry =
> view.getSession().getPackageRegistry();
> EcoreEnvironmentFactory envFactory = new
> EcoreEnvironmentFactory(packageRegistry);
>
> Regarding naming, is it case sensitive ? In the ecore editor, my
> package name is not capitalized.
> Thank you, Christophe
Re: [CDO] OCL Query Syntax, Package reference [message #990958 is a reply to message #990954] Sat, 15 December 2012 07:01 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

belongsTo is nothing to do with OCL; it must be a metamodel artefact.

Navigating unnavigable opposites is an OCL variation point. There is
support for opposites in the UML-binding, and there was no support in
the Ecore-binding. However the support for Impact Analysis has improved
the Ecore-binding in this respect by prividing
EcoreEnvironmentFactoryWithHiddenOpposites. This may be activated
programmatically or by an EAnnotation:

<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL">
<details key="hiddenOpposites" value="true"/>
</eAnnotations>

See
GIT\org.eclipse.ocl\tests\org.eclipse.ocl.ecore.tests\model\HiddenOpposites.ecore
or just search for hiddenOpposite in the OCL Documentation.

Regards

Ed Willink


On 15/12/2012 11:31, Christophe Bouhier wrote:
> Hi Ed,
> I believe the type can now be resolved from the Package, however I
> struggle now to deal with associations. I get an error on the
> "belongsTo" reference. Is this OCL syntax?
> Do I need an opposite reference to navigate back to the parent of a
> contained object? see the expression here:
> generics::Value.allInstances()->select(v:generics::Value|v.=self)
>
> self is MetricValueRange which has a contained EReference to the Value
> class. Value itself has no reference back to the MetricValueRange class.
> Thank You, Christophe
>
Re: [CDO] OCL Query Syntax, Package reference [message #990960 is a reply to message #990958] Sat, 15 December 2012 07:43 Go to previous messageGo to next message
Christophe Bouhier is currently offline Christophe Bouhier
Messages: 897
Registered: July 2009
Senior Member
Thanks for the pointer on hidden-Opposite.
This would need to be enabled in the OCL Query Handler for CDO, it seems?

rgds Christophe
Re: [CDO] OCL Query Syntax, Package reference [message #990962 is a reply to message #990960] Sat, 15 December 2012 08:12 Go to previous message
Ed Willink is currently offline Ed Willink
Messages: 4014
Registered: July 2009
Senior Member
Hi

Yes, it needs the appropriate CDO server-side enable abioyt which I know
nothing.

Of couese anything that directly or indirectly uses allInstances() may
have very poor performance.

It is often easy to relocate constraints from some global truth
statement about all class Xes to a much simpler invariant on (each)
class X. One day an OCL optimizing code generator might do this
automatically.

Regards

Ed Willink

On 15/12/2012 12:43, Christophe Bouhier wrote:
> Thanks for the pointer on hidden-Opposite. This would need to be
> enabled in the OCL Query Handler for CDO, it seems?
> rgds Christophe
Previous Topic:[CDO] Data Mapping/Schema Control
Next Topic:[xsd2ecore] mapping of sequence of xs:any and adding elements to it
Goto Forum:
  


Current Time: Thu Jul 31 05:28:37 EDT 2014

Powered by FUDForum. Page generated in 0.02284 seconds