Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » ATL » Transforming model elements to model elements with next reference
Transforming model elements to model elements with next reference [message #1806730] Tue, 14 May 2019 13:02 Go to next message
Baris Tekin Tezel is currently offline Baris Tekin TezelFriend
Messages: 1
Registered: May 2019
Junior Member
index.php/fa/35563/0/

As you can see on the image up here, i want to transform the first pattern (plan and action with just containment relation) to the second pattern (plan and action with containment relation, actions with next reference). But, i couldn't handle to add next references between created actions via rules. I just want to build this next references in natural order which is seen in the source model.

Any help please?




rule Action2Action
{
	from
		s:saml!Action
	to
		t:masrl!Action
		(
			name <- s.name,
			uses <- s.uses,
		)

}


  • Attachment: ATL_Trans.png
    (Size: 23.17KB, Downloaded 300 times)
Re: Transforming model elements to model elements with next reference [message #1808727 is a reply to message #1806730] Sun, 30 June 2019 11:09 Go to previous message
Dennis Wagelaar is currently offline Dennis WagelaarFriend
Messages: 589
Registered: September 2012
Location: Belgium
Senior Member

You'll want something like this:
rule Plan2Plan {
  from
    s:saml!Plan
  to
    t:masrl!Plan
    (
      label <- s.label,
      hasActions <- s.hasActions,
      firstAction <-
        if s.hasActions->notEmpty() then
          s.hasActions->first()
        else
          OclUndefined
        endif
    )
}

rule Action2Action {
  from
    s:saml!Action
    (
      not s.refImmediateComposite().oclIsUndefined()
    )
  using {
    actions : Sequence(saml!Action) =
      if s.refImmediateComposite().oclIsUndefined() then
        Sequence{}
      else
        s.refImmediateComposite().hasActions
      endif;
  }
  to
    t:masrl!Action
    (
      name <- s.name,
      nextAction <-
        if actions->includes(s) and actions->indexOf(s) < actions->size() then
          actions->at(actions->indexOf(s) + 1)
        else
          OclUndefined
        endif
    )
}


Cheers,
Dennis
Previous Topic:Read data from text file
Next Topic:TXT document as input for ATL transformation
Goto Forum:
  


Current Time: Fri Mar 29 08:58:03 GMT 2024

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

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

Back to the top