[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Newsgroup Home]
|
[news.eclipse.modeling.m2m] Re: [QVTO] How to handle optional attributes with primitive types?
|
Hi Mark,
The current QVTO provides a limited set of reflective operations, as
defined
by OMG spec in 8.3.4 section.
Though in MOF there is Element::isSet(Property) operation, which is an
analog
of ecore's eIsSet(...), it's not available to the transformation writer
currently.
The spec is actually not very clear about what can be used from MOF
reflection in QVT, see http://www.omg.org/issues/issue11056.txt.
The only workaround that comes into my mind for now, is to define an
operation in
a java black-box library, which delegates to ecore, something like:
@Operation(contextual=true)
public static boolean isPropertySet(Object self, String featureName);
Applicable in QVT like bellow (after the library is imported):
obj.isPropertySet(myOptionalAttribute);
At the moment, there is no standard way to perform such a check.
I have to review the behavior you have used for some of the attribute types
checking.
Regards,
/Radek
On Mon, 14 Sep 2009 22:52:33 +0200, Mark Br?oerkens <broerkens@xxxxxx>
wrote:
Dear all,
I am using QVTO with a metamodel that contains optional (0..1
multiplicity) attributes which are of type EBoolean.
In order to be able to distinguish between 'true', 'false' (the default)
and '<not set>' the property 'unsettable' is set to 'true'.
In Java I can find out if the attribute is set by calling 'eIsSet()'.
In QVTO I tried the following expression to check if the value of an
optional attribute was set:
obj.myOptionalAttribute->notEmpty()
This worked fine for most attributes. Unfortunately, it doesn't work for
attributes of type EBoolean (or enumerations).
Did I find a bug in QVTO/OCL or is there another way for finding out if
an optional attribute is set in QVTO?
Thank you very much in advance.
Kind regards
Mark