OCL features, Acceleo and Sirius [message #1798136] |
Tue, 13 November 2018 08:01 |
Wilbert Alberts Messages: 209 Registered: June 2010 |
Senior Member |
|
|
Hi,
I created a metamodel with a number of concepts having derived OCL properties. Next, I created a graphical editor for that kind of models using Sirius. In the label expression, I referred to the derived properties. There I ran into some strange things.
With this property, everything works as expected:
property operatesOn1 : ADTO[?] { derived readonly transient volatile }
{
initial:
self.parameters->first().oclAsType(system::TypedParameter).typereference.type.oclAsType(dds::ADTO);
}
However, some dereference '.' operates might return null or undefined so I added som safe navigation:
property operatesOn : ADTO[?] { derived readonly transient volatile }
{
initial:
self?.parameters->first()?.oclAsType(system::TypedParameter)?.typereference?.type?.oclAsType(dds::ADTO);
}
This does not work. My suspicion in that the safe navigation is not supported when evaluating the OCL query via the Acceleo language.
OK, then I'll rewrite it.
property operatesOn2 : ADTO[?] { derived readonly transient volatile }
{
initial:
if (self.parameters->size()>0 and self.parameters->first().oclIsKindOf(system::TypedParameter))
then
let firstpar = self.parameters->first().oclAsType(system::TypedParameter)
in
if (firstpar.typereference.oclIsUndefined() or firstpar.typereference.type.oclIsUndefined())
then
null
else
let firstpartype = firstpar.typereference.type
in
if (firstpartype.oclIsKindOf(dds::ADTO))
then
firstpartype.oclAsType(dds::ADTO)
else
null
endif
endif
else
null
endif;
}
This one also does not work. Maybe the 'let' expression is in the way. Let's remove it:
property operatesOn3 : ADTO[?] { derived readonly transient volatile }
{
initial:
if (self.parameters->size()>0 and self.parameters->first().oclIsKindOf(system::TypedParameter))
then
if ((self.parameters->first().oclAsType(system::TypedParameter).typereference.oclIsUndefined()) or
(self.parameters->first().oclAsType(system::TypedParameter).typereference.type.oclIsUndefined()))
then
null
else
if (self.parameters->first().oclAsType(system::TypedParameter).typereference.type.oclIsKindOf(dds::ADTO))
then
self.parameters->first().oclAsType(system::TypedParameter).typereference.type.oclAsType(dds::ADTO)
else
null
endif
endif
else
null
endif;
}
This one works again. I verified using the semantic property vies in Sirius that each of the 'operatesOn' variants delivers the same result so the ocl expressions themselves seem to be correct.
Is this indeed caused by the fact that OCL code, invokved by the Acceleo interpreter, does not support 'let' and safe navigation?
Greetings,
Wilbert.
|
|
|
|
Powered by
FUDForum. Page generated in 0.02903 seconds