Accessing extensions and tagged values in OCL constraints [message #66640] |
Thu, 05 February 2009 11:43  |
Eclipse User |
|
|
|
Hi,
I have created the following OCL query based on a user defined profile, where CallBehaviorAction has a stereotype Servicecall and a tagged value service which refers to an element whose type is itself a stereotype.
context CallBehaviorAction
def servicecallService:
servicecallService(): Profile::Service = self.extension_Servicecall->any(true).service
Eclipse OCL parses this definition but it is not evaluated right because it always returns org.eclipse.uml2.uml.internal.impl.InstanceSpecificationImpl @f73ca4 (name: OclInvalid, visibility: <unset>) for an CallBehaviorAction-element which indeed has a value set for service. I think that already the
extension_Servicecall returns an invalid value.
Is this the right way to access tagged values? Can this type of query principally be handled and how?
I am using org.eclipse.feature.group in version 1.3.0.v20081119 !
thanks in advance,
Michael Felderer
|
|
|
Re: Accessing extensions and tagged values in OCL constraints [message #66723 is a reply to message #66640] |
Fri, 06 February 2009 00:04  |
Eclipse User |
|
|
|
Originally posted by: cdamus.zeligsoft.com
Hi, Michael,
Is the Servicecall stereotype actually applied to the instance of
CallBehaviorAction on which you call this defined operation? If not,
then the "any" iterator will return null, and attempting to access the
"service" property of null results in a run-time exception, signaled by
the OclInvalid.
This is the general way to access the attributes of applied stereotypes,
yes.
Do you get a different result if you try this formulation?
context CallBehaviorAction
def servicecallService: Profile::Service =
if self.extension_Servicecall->isEmpty() then
null
else
self.extension_Servicecall->any(true).service
endif
The fact that the referenced Service is, itself, a stereotype instance
shouldn't matter.
One handy way to debug problems like this is to turn on evaluation
tracing. Enable the org.eclipse.ocl/debug/evaluation debug option and
see in the console output what is the first sub-expression that
evaluates to OclInvalid, and trace it back (usually to null values) to
see what is the cause.
HTH,
Christian
Michael Felderer wrote:
> Hi,
>
> I have created the following OCL query based on a user defined profile,
> where CallBehaviorAction has a stereotype Servicecall and a tagged value
> service which refers to an element whose type is itself a stereotype.
>
> context CallBehaviorAction
> def servicecallService:
> servicecallService(): Profile::Service =
> self.extension_Servicecall->any(true).service
>
> Eclipse OCL parses this definition but it is not evaluated right because
> it always returns
> org.eclipse.uml2.uml.internal.impl.InstanceSpecificationImpl @f73ca4
> (name: OclInvalid, visibility: <unset>) for an
> CallBehaviorAction-element which indeed has a value set for service. I
> think that already the extension_Servicecall returns an invalid value.
> Is this the right way to access tagged values? Can this type of query
> principally be handled and how?
>
>
> I am using org.eclipse.feature.group in version 1.3.0.v20081119 !
>
> thanks in advance,
> Michael Felderer
|
|
|
Powered by
FUDForum. Page generated in 0.05866 seconds