Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » QVT-OML » Access existing objects
Access existing objects [message #1851524] Thu, 07 April 2022 11:31 Go to next message
John Henbergs is currently offline John HenbergsFriend
Messages: 239
Registered: October 2020
Senior Member
Hi all,

I have a case as follows:

mapping A :: A2B() : B{
  self.ref1 -> forEach(ref1){
     if (not result.ref2 -> exists (O2 : Object2 | //condition)){
          var O2Object : object Object2{
               //assign all references and attributes
         };
     ref2 += O2Object;
    };
   else if(result.ref2 -> exists (O2 : Object2 | //condition)){
      ....
  }
}


Where I have the three dots, I want to be able to access this Object2 that fulfils this condition, and assign the references and attributes to it.

Thank you in advance!
John
Re: Access existing objects [message #1851537 is a reply to message #1851524] Thu, 07 April 2022 19:01 Go to previous message
Christopher Gerking is currently offline Christopher GerkingFriend
Messages: 116
Registered: April 2011
Senior Member
Hi

In general, OCL's select(...) operation is useful for obtaining a collection of multiple elements that satisfy a certain condition. You might also want to have a look at selectOne(...) and any(...) if you are interested in a single element rather than all elements (please note that in Eclipse QVTo, the signature of selectOne(...) violates the signature as specified by the OMG).

In case you need further help, please provide an example that is syntactically valid and compiles.


Kind regards
Christopher
Previous Topic:Change value of ENum attribute depending on type of class
Next Topic:Disjunction and inheritance
Goto Forum:
  


Current Time: Mon Sep 16 22:53:20 GMT 2024

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

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

Back to the top