Skip to main content



      Home
Home » Modeling » OCL » Using static variables in OCL constraints
Using static variables in OCL constraints [message #990466] Wed, 12 December 2012 10:41 Go to next message
Eclipse UserFriend
Hi,

I am trying to pass a static variable of a Java class that is not modeled with Ecore to an objects operation:

fixedPitchAngle._'in'(foo::bar::Units.m)


But I get the following error message:
java.lang.RuntimeException: org.eclipse.ocl.SemanticException: Unknown type ([foo, bar, Units])


Can I somehow import the namespace to use the variable or is it only possible to use Ecore-modeled data?

Regards,
Roland
Re: Using static variables in OCL constraints [message #990493 is a reply to message #990466] Wed, 12 December 2012 12:32 Go to previous message
Eclipse UserFriend
Hi

You're on very shaky ground trying to use static properties in OCL.

The OCL 2.2 specification added them without any indication as to what
their semantics might be.

As you observe, Ecore does not support them although UML does.

So that I suspect that the Ecore-based Eclipse OCL functionalitry is
limited to at best parsing the concrete syntax.

The Pivot-based Eclipse OCL may be a little better since static
properties are now used to reify stereotypes at M2 rather than M3, but
that is a post-Juno change.

Similarly code generation has motivated a little reflective support for
Java types, but again post-Juno and probably not addressing your problem.

It would seem that your requirement could be supported by:

fixedPitchAngle._'in'('java:/foo.bar'::Units.m)

Would that solve it?

Today, it is probably easiest to introduce a bogus EClass such as
UnitsHelper with a non-static getM operation that you can hand-code to
do the access.

Regards

Ed Willink


On 12/12/2012 15:41, Roland S. wrote:
> Hi,
>
> I am trying to pass a static variable of a Java class that is not
> modeled with Ecore to an objects operation:
>
> fixedPitchAngle._'in'(foo::bar::Units.m)
>
> But I get the following error message:
>
> java.lang.RuntimeException: org.eclipse.ocl.SemanticException: Unknown
> type ([foo, bar, Units])
>
>
> Can I somehow import the namespace to use the variable or is it only
> possible to use Ecore-modeled data?
>
> Regards,
> Roland
Re: Using static variables in OCL constraints [message #990694 is a reply to message #990466] Wed, 12 December 2012 12:32 Go to previous message
Eclipse UserFriend
Hi

You're on very shaky ground trying to use static properties in OCL.

The OCL 2.2 specification added them without any indication as to what
their semantics might be.

As you observe, Ecore does not support them although UML does.

So that I suspect that the Ecore-based Eclipse OCL functionalitry is
limited to at best parsing the concrete syntax.

The Pivot-based Eclipse OCL may be a little better since static
properties are now used to reify stereotypes at M2 rather than M3, but
that is a post-Juno change.

Similarly code generation has motivated a little reflective support for
Java types, but again post-Juno and probably not addressing your problem.

It would seem that your requirement could be supported by:

fixedPitchAngle._'in'('java:/foo.bar'::Units.m)

Would that solve it?

Today, it is probably easiest to introduce a bogus EClass such as
UnitsHelper with a non-static getM operation that you can hand-code to
do the access.

Regards

Ed Willink


On 12/12/2012 15:41, Roland S. wrote:
> Hi,
>
> I am trying to pass a static variable of a Java class that is not
> modeled with Ecore to an objects operation:
>
> fixedPitchAngle._'in'(foo::bar::Units.m)
>
> But I get the following error message:
>
> java.lang.RuntimeException: org.eclipse.ocl.SemanticException: Unknown
> type ([foo, bar, Units])
>
>
> Can I somehow import the namespace to use the variable or is it only
> possible to use Ecore-modeled data?
>
> Regards,
> Roland
Previous Topic:serialization of CompleteOCL document to XMI format
Next Topic:Define ArrayList of type ArraysList
Goto Forum:
  


Current Time: Thu Jul 10 09:48:09 EDT 2025

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

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

Back to the top