Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Issues with oclIsKindOf in AQL expressions
Issues with oclIsKindOf in AQL expressions [message #1777270] Mon, 27 November 2017 19:40 Go to next message
Emilien Lavigne is currently offline Emilien LavigneFriend
Messages: 5
Registered: October 2017
Junior Member
Hello,

I start with Sirius (Obeo Designer 10.0.0)

I have an Ecore metamodel, named avs, with (among other) a "LeafCOmponent" class, a "WindSource" class which inherit from Leaf Component, and many other child class of LeafComponent.

In a Sirius diagram, I want to have a generic mapping for all LeafComponents, but a specific one for WindSources. I can create the specific mapping, but I should exclude WindSources from the generic one.

Detailing all the subtypes of LeafComponent (without WindSource) in the Domain Class of the generic mapping is not a satisfying solution (there are many and they can evolve), so I put "avs::LeafComponent" in the Domain Class of the generic mapping

I tried to use the precondition Expression of the generic mapping with:
aql:not self.oclIsKindOf(avs::WindSource)


I also tried to modify the Semantic Candidate Expression with:
aql:self.components->select(c | not c.oclIsKindOf(avs::WindSource))

instead of
feature:components

but none of those solution produce the expected result: I always have two nodes created for WindSources instances: one with the generic mapping, and the other with the specific one, so I guess that in those conditions, oclIsKindOf is always evaluated to false...

Am I doing something wrong?

Thanks for your help,

Emilien
Re: Issues with oclIsKindOf in AQL expressions [message #1777355 is a reply to message #1777270] Tue, 28 November 2017 18:59 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6985
Registered: July 2009
Senior Member
Hi

Your message was slow to appear. It may be the same problem a more recent thread;:



This kind of X not-equal-to X problem is often caused by metamodel schizophrenia. I have certainly reported related Acceleo bugs. You must make sure that you only have one variant of X. Always reference in the same way, e.g. as platform:/resource/my/x.ecore or only as http://my/X. Never mix the two in your models or in any model generated for you. If you allow your tool to load your metamodel twice with different URIs you can be in big trouble.

With Sirius you are probably always using OSGI and so most of the non-OSGI challenges that affect Acceleo should not affect you.

If you are also using Xtext you can use platform:/resource/ consistently after switching off the warnings in the project properties.

Regards

Ed Willink
Re: Issues with oclIsKindOf in AQL expressions [message #1777483 is a reply to message #1777355] Wed, 29 November 2017 15:49 Go to previous messageGo to next message
Julien Dupont is currently offline Julien DupontFriend
Messages: 172
Registered: July 2009
Senior Member
Hi Emilien,

If you use oclIsKindOf(WindSource) this is retrieve all descendant of WindSource. To retrieve only WindSource you should use oclIsTypeOf(WindSource).

In you case you can define 2 mappings.

One for genericMapping
Domain Class: avs::LeafComponent
Semantic Candidate Expression: aql:self.leafcomponents->reject(a | a.oclIsTypeOf(avs::WindSource))

One for WindSource mapping
Domain Class: avs::WindSource
SemanticCandidateExpression: aql:self.leafcomponents->select(a | a.oclIsTypeOf(avs::WindSource))

Regards
Re: Issues with oclIsKindOf in AQL expressions [message #1777549 is a reply to message #1777270] Thu, 30 November 2017 09:34 Go to previous messageGo to next message
Emilien Lavigne is currently offline Emilien LavigneFriend
Messages: 5
Registered: October 2017
Junior Member
Hi, and thanks for the answers

@Julien Dupont, I understand the difference between oclIsKindOf and oclIsTypeOf, but both are here evaluated to false when applied on objects that actually are WindSources

@Ed Willink, I think it's really a problem of metamodel schizophrenia, because when I use autocompletion (for example in a Domain Class field), each class of my metamodel appears twice, the first with the tooltip description:
ClassName
In http://com.my.avs

And the second with tooltip description:
ClassName
In http://com.my.avs
Located at platform:/resource/AVS/model/avs.ecore


However, I'm a little confused about the different way I can reference the metamodel, because I have no explicit references to it in my .design project:
I have created the metamodel with ecore tools, then I have generated all the associated code (generate>all on the ecore file), and then I have exported the 3 projects (AVS, AVS.edit and AVS.editor) as "deployable plug-ins and fragments"

I tried to create a new .odesign file in a new workspace (to avoid interferences between the metamodel in the plug-in and the one in the workspace): I have not the duplication of class with autocompletion anymore, but the "oclIsKindOf" function still doesn't work...

Furthermore, when I come back in the first workspace, I have a new kind of warning message when I try to use AQL expressions with the metamodel:
the following mapping semantic candidates expression could not be correctly evaluated : aql:self.components->select(c|c.oclIsKindOf(avs::WindSource))
org.eclipse.sirius.common.tools.api.interpreter.EvaluationException: An error has appeared during the evaluation of an expression:
Expression: aql:self.components->select(a|a.oclIsKindOf(avs::WindSource))
Diagnostic: Diagnostic ERROR source=org.eclipse.acceleo.query code=0 invalid type literal avs::WindSource data=[org.eclipse.acceleo.query.ast.impl.ErrorEClassifierTypeLiteralImpl@67a3ed4a (value: null, segments: [avs, WindSource], missingColon: false)]
Target URI Fragment: platform:/resource/AvsInstances/TestProject.avs#//@rootComponents.0/@components.2

It looks like the interpreter doesn't know the metamodel. When I try the same request directly in the Sirius interpreter, it produce the expected result.
So I'm a little confused about where and how I should add references to my metamodel...

Thanks for the help,
Regards

Emilien
Re: Issues with oclIsKindOf in AQL expressions [message #1777558 is a reply to message #1777549] Thu, 30 November 2017 10:23 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6985
Registered: July 2009
Senior Member
Hi

IMHO metamodel schizophrenia is one of the worst useability features of EMF; it is relatively obscure but once it bites it is hard to see the problem.

Again IMHO, it is the (internal) namespace URI of the metamodel content that should be unique not the accidental external filename/registration handle. OCL tooling attempts to unify diverse reads of the same content. Other tools seem to offer no help; they rely on consistent usage patterns so that the problems goes away.

For existing tools you can provide a good repro to pressure the toolsmiths in to resolving your novel style of usage.

But that does not help you today. To make progress you need to instrument EMF ResourceImpl construction so that you can understand where two variants are coming from. Then maybe you can make one of them re-use the other. From my experience you will probably find a careless wrong style of reference, probably contributed by you, but quite possibly by a confusing UI. You may need to instrument ResourceSetImpl as well since multiple resource sets can make for an inefficient and possibly even more interesting time

Regards

Ed Willink
Re: Issues with oclIsKindOf in AQL expressions [message #1777681 is a reply to message #1777558] Fri, 01 December 2017 12:39 Go to previous message
Julien Dupont is currently offline Julien DupontFriend
Messages: 172
Registered: July 2009
Senior Member
Emilien,

Did you reference your metamodel in the odesign? In the representation description tab metamodel?

Regards,
Previous Topic:Compartment as Bordered - Qualified Association
Next Topic:[ANN] Obeo Designer Community Edition 10.1
Goto Forum:
  


Current Time: Sun Jan 17 20:17:56 GMT 2021

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

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

Back to the top