OCL constraint using Ecore classifiers - Unknow type exception [message #882818] |
Thu, 07 June 2012 09:07 |
Luc Touraille 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 |
Ed Willink Messages: 7655 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?
|
|
|
|
Powered by
FUDForum. Page generated in 0.01655 seconds