Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Change value of ENum attribute depending on type of class
Change value of ENum attribute depending on type of class [message #1850614] Thu, 10 March 2022 08:46 Go to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi,

In the source metamodel I have two classes; OnlineWorker and AwayWorker.
In the target metamodel I have an class "Worker" which has an attribute "status" with EType "Status", where Status is an Enum with two possible values: "Online" and "Away".

Now, when I transform the class OnlineWorker to Worker I want the value of the status (i.e., Enum) in the class Worker to be Online, and when I transform from AwayWorker to Worker I want the value of the status (i.e., Enum) in the class Worker to be Away.

However, I am not sure, how to change or select the right value that should be on the status attribute that has an Enum as Type, depending ono the type of class that is transformed.

Any suggestions would be appreciated!

Thank you!
Re: Change value of ENum attribute depending on type of class [message #1850618 is a reply to message #1850614] Thu, 10 March 2022 11:38 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

Within a single mapping you may use oclIsKindOf as part of an if expression that selects the required enumeration literal.

Alternatively you may have distinct, ossibly disjuncted, OnlineWorker2Worker and AwayWorker2Worker that differ at least in regard to the enumeration literal.

Which approach you take may depend on the readability and more complex aspects of your problem.

Regards

Ed Willink
Re: Change value of ENum attribute depending on type of class [message #1850623 is a reply to message #1850618] Thu, 10 March 2022 13:33 Go to previous messageGo to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi Ed,

My idea was to proceed with the second approach that you suggested with two distinct mappings.

However, more specifically, my issue is on how to select a specific enumeration literal.

So if I was to have this mapping:

mapping OnlineWorker :: OnlineWorker2Worker : Worker {
result.status := // here I am not sure how to select the Online enumeration literal
}


Thank you in advance!
Re: Change value of ENum attribute depending on type of class [message #1850628 is a reply to message #1850623] Thu, 10 March 2022 19:36 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

The syntax for an enumeration literal is e.g. CollectionKind::SET

Regards

Ed Willink
Previous Topic:Wrong output model structure
Next Topic:Access existing objects
Goto Forum:
  


Current Time: Thu Apr 25 18:55:14 GMT 2024

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

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

Back to the top