Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » OCL » OCL constraint using Ecore classifiers - Unknow type exception
OCL constraint using Ecore classifiers - Unknow type exception [message #882818] Thu, 07 June 2012 09:07 Go to next message
Luc Touraille is currently offline Luc TourailleFriend
Messages: 3
Registered: June 2012
Junior Member
Hi,

I'm developing an Ecore model with some invariants defined in OCL, using the OCLinEcore editor. In my model, some elements have references to EClassifier; in some OCL constraints, I need to check if the EClassifier referred to is an EDataType or an EClass. Here is, in OCLinEcore, a model similar to the one I have:

import ecore : '<namespace_ecore>/Ecore#/';

package Foo : foo = 'some_namespace'
{
  class EndPoint
  {
    attribute name : String[1];
    property type : ecore::EClassifier[1];
  }

  class Coupling
  {
    invariant Compatibility:
      (destination.type.oclIsKindOf(ecore::EDataType) and source.type = destination.type) or
      let destinationClass : ecore::EClass = destination.type.oclAsType(ecore::EClass) in
      destinationClass.isSuperTypeOf(source.type.oclAsType(ecore::EClass));

    property source : EndPoint[1];
    property destination : EndPoint[1];
  }
}


However, when I try to validate a dynamic instance of my model, an exception occur with the following message:

An exception occured while delegating evaluation of the 'Compatibility' constraint on 'Coupling': Unknow type ([ecore, EDataType])


When I try the expression in the OCL interactive console, I obtain the correct result. Am I doing something wrong when defining my invariant? How can I write an invariant using Ecore types?

[Updated on: Thu, 07 June 2012 09:08]

Report message to a moderator

Re: OCL constraint using Ecore classifiers - Unknow type exception [message #882849 is a reply to message #882818] Thu, 07 June 2012 10:05 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 4154
Registered: July 2009
Senior Member
Hi

Naked OCL does not support the binding of ecore to something useful, so
the oclAsType(ecore::EClass) has an unresolved reference since each
ecxpression is an independent snippet in the ECore file.

The Juno release therefore adds an extension whereby a package qualifier
may be a URI, so that if you saw the above serialized it might be
oclAsType(_'http://www.eclipse.org/emf/2002/Ecore'::ecore::EClass).

The Juno release also adds flexibility as to whether you use the new
Pivot-binding with this extended functionality. In the
Window->Preferences->OCL page make sure that the selected executor for
the default delegate is http://www.eclipse.org/emf/2002/Ecore/OCL/Pivot.

HTH

Regards

Ed Willink


On 07/06/2012 10:07, Luc Touraille wrote:
> Hi,
>
> I'm developing an Ecore model with some invariants defined in OCL,
> using the OCLinEcore editor. In my model, some elements have
> references to EClassifier; in some OCL constraints, I need to check if
> the EClassifier referred to is an EDataType or an EClass. Here is, in
> OCLinEcore, a model similar to the one I have:
>
> import ecore : '<namespace_ecore>/Ecore#/';
>
> package Foo : foo = 'some_namespace'
> {
> class EndPoint
> {
> attribute name : String[1];
> property type : ecore::EClassifier[1];
> }
>
> class Coupling
> {
> invariant Compatibility:
> (destination.type.oclIsKindOf(ecore::EDataType) and source.type =
> destination.type) or
> let destinationClass : ecore::EClass =
> destination.type.oclAsType(ecore::EClass) in
>
> destinationClass.isSuperTypeOf(source.type.oclAsType(ecore::EClass));
>
> property source : EndPoint[1];
> property destination : EndPoint[1];
> }
> }
>
>
> However, when I try to validate a dynamic instance of my model, an
> exception occur with the following message:
>
> An exception occured while delegating evaluation of the
> 'Compatibility' constraint on 'Coupling': Unknow type ([ecore,
> EDataType])
>
> When I try the expression in the OCL interactive console, I obtain the
> correct result. Am I doing something wrong when defining my invariant?
> How can I write an invariant using Ecore types?
Re: OCL constraint using Ecore classifiers - Unknow type exception [message #882979 is a reply to message #882818] Thu, 07 June 2012 15:16 Go to previous message
Luc Touraille is currently offline Luc TourailleFriend
Messages: 3
Registered: June 2012
Junior Member
Ok, thank you very much for the swift reply!

Luc

[Updated on: Tue, 12 June 2012 09:14]

Report message to a moderator

Previous Topic:[Announce] Eclipse OCL 4.0.0 (Juno) RC3 is now available
Next Topic:[Announce] Eclipse OCL 4.0.0 (Juno) RC4 is now available
Goto Forum:
  


Current Time: Wed Nov 26 15:45:47 GMT 2014

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

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