Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [QVTO] How to handle optional attributes with primitive types?
[QVTO] How to handle optional attributes with primitive types? [message #485763] Mon, 14 September 2009 20:52 Go to next message
Eclipse UserFriend
Originally posted by: broerkens.web.de

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
Re: [QVTO] How to handle optional attributes with primitive types? [message #485925 is a reply to message #485763] Tue, 15 September 2009 14:21 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: dvorak.radek.gmail.com

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@web.de>
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
Re: [QVTO] How to handle optional attributes with primitive types? [message #486209 is a reply to message #485763] Wed, 16 September 2009 18:39 Go to previous message
Alex Mising name is currently offline Alex Mising nameFriend
Messages: 51
Registered: August 2009
Member
Depending on your use case (and level of control of the Ecore) you might also consider using attributes that are nullable instead of unsettable. These can be checked for null directly in QVT. For booleans use EBooleanObject instead of EBoolean, for enumerations this is done using an additional wrapper EDataType.

Alex
Previous Topic:[ATL] Launching (EMF) ATL programmatically and allow inter model references
Next Topic:how obtain a tree with rules
Goto Forum:
  


Current Time: Fri Apr 26 07:50:08 GMT 2024

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

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

Back to the top