Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » [OCLInEcore] Problem with OCL expressions containing type references from imported packages
[OCLInEcore] Problem with OCL expressions containing type references from imported packages [message #815247] Wed, 07 March 2012 07:17 Go to next message
Filip Krikava is currently offline Filip Krikava
Messages: 43
Registered: January 2012
Member
Hi,

I have a problem to use types from imported packages in OCL expressions. Quick example:

package a:

module _'A.ecore'
package a : a = 'http[:]//me.me/a'
{
	class System
	{
		property components : Component[*] { ordered composes };
	}
	class Component
	{
		attribute name : String[1] { ordered };
	}
}


a package b:

module _'B.ecore'
import a : 'A.ecore#/';

package b : b = 'http[:]//me.me/b'
{
	class Instance
	{
		attribute name : String[1] { ordered };
		property type : a::Component[1] { ordered };
		property parent : a::System[1] { derived readonly transient volatile }
		{
			derivation: type.oclContainer().oclAsType(a::System);
		}
	}
}


This works as long as I don't close and reopen the editor. When I do that it changes the OCL expression for the derived property to:

derivation: type.oclContainer().oclAsType(System);


which is invalid. It correctly preserves the property types like (a::Component[1], a::System[1]).

Is this a bug (I tried to look for it, but I only found problems regarding the type definition rather than embedded OCL expressions)? Is there any workaround (besides merging the packages)?
Re: [OCLInEcore] Problem with OCL expressions containing type references from imported packages [message #815258 is a reply to message #815247] Wed, 07 March 2012 07:33 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4008
Registered: July 2009
Senior Member
Hi

This looks like https://bugs.eclipse.org/bugs/show_bug.cgi?id=362620
which was fixed in Indigo SR2.

Regards

Ed Willink

On 07/03/2012 12:17, Filip Krikava wrote:
> Hi,
>
> I have a problem to use types from imported packages in OCL
> expressions. Quick example:
>
> package a:
>
> module _'A.ecore'
> package a : a = 'http[:]//me.me/a'
> {
> class System
> {
> property components : Component[*] { ordered composes };
> }
> class Component
> {
> attribute name : String[1] { ordered };
> }
> }
>
> a package b:
>
> module _'B.ecore'
> import a : 'A.ecore#/';
>
> package b : b = 'http[:]//me.me/b'
> {
> class Instance
> {
> attribute name : String[1] { ordered };
> property type : a::Component[1] { ordered };
> property parent : a::System[1] { derived readonly transient
> volatile }
> {
> derivation: type.oclContainer().oclAsType(a::System);
> }
> }
> }
>
> This works as long as I don't close and reopen the editor. When I do
> that it changes the OCL expression for the derived property to:
>
> derivation: type.oclContainer().oclAsType(System);
>
> which is invalid. It correctly preserves the property types like
> (a::Component[1], a::System[1]).
>
> Is this a bug (I tried to look for it, but I only found problems
> regarding the type definition rather than embedded OCL expressions)?
> Is there any workaround (besides merging the packages)?
>
Re: [OCLInEcore] Problem with OCL expressions containing type references from imported packages [message #815259 is a reply to message #815258] Wed, 07 March 2012 07:37 Go to previous messageGo to next message
Filip Krikava is currently offline Filip Krikava
Messages: 43
Registered: January 2012
Member
That is what I hoped, but I use: 3.1.2.v20120206-0606 and I think it is a different issue - my problem is not the model structure but the OCL expressions themselves.
Re: [OCLInEcore] Problem with OCL expressions containing type references from imported packages [message #815310 is a reply to message #815259] Wed, 07 March 2012 08:47 Go to previous messageGo to next message
Ed Willink is currently offline Ed Willink
Messages: 4008
Registered: July 2009
Senior Member
Hi

Sorry replied too quickly. This is a problem fixed in Juno for the Pivot
model only.

The problem is that OCL, as specified, provides no way of binding the
'a' alias to 'A.ecore'. For Juno, I've introduced an extension so that
package names can be URIs and so the OCL saved in Ecore is

<eAnnotations source="http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot">
<details key="derivation"
value="type.oclContainer().oclAsType(_'A.ecore'::a::System)"/>
</eAnnotations>

which is loadable by a compliant parser.

You will also need a compliant library to support the oclContainer()
function too.

So, your next question, how does this work in Acceleo? It doesn't.

This is an example of many corner case problems in the legacy code.
These are very hard to fix, hence the new pivot binding. It is very
unlikely that Acceleo will use the pivot model in Juno, so use of these
OCL fixes may have to wait for Kepler.
https://bugs.eclipse.org/bugs/show_bug.cgi?id=373518 raised to
investigate solutions.

Regards

Ed Willink

On 07/03/2012 12:37, Filip Krikava wrote:
> That is what I hoped, but I use: 3.1.2.v20120206-0606 and I think it
> is a different issue - my problem is not the model structure but the
> OCL expressions themselves.
Re: [OCLInEcore] Problem with OCL expressions containing type references from imported packages [message #815312 is a reply to message #815310] Wed, 07 March 2012 08:53 Go to previous message
Filip Krikava is currently offline Filip Krikava
Messages: 43
Registered: January 2012
Member
Hi Ed,

Thanks a lot for all this clarification, it has been extremely useful!

/cheers
Filip
Previous Topic:OCL for Extended ECORE model
Next Topic:CompleteOCL in the Console: what to do with .ocl file
Goto Forum:
  


Current Time: Mon Jul 28 14:46:43 EDT 2014

Powered by FUDForum. Page generated in 0.01985 seconds