Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Archived » M2M (model-to-model transformation) » [ATL] Problem with Helper in Rule
[ATL] Problem with Helper in Rule [message #537948] Fri, 04 June 2010 09:56 Go to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Please could you tell me what is wrong with the helper?
I try to find out the "id" of the Event. If the id = '1' then change to 'StartEvent' else let '1'

-- @path Families=/EPL2BPMN/EPK.ecore
-- @path Persons=/EPL2BPMN/BPMN.ecore

module EPL2BPMN;
create OUT : BPMN from IN : EPK;

helper context EPK!Event def: id : String =
	if self.Event.id = '1' then
		'StartEvent'
	else
		'1'
	endif;

rule Event {
from
	e : EPK!Event

to 
	b : BPMN!StartEvent
	 (
	 	id <- e.id,
	 	name <- e.name
	 	
 	)
 }

rule Flow {
from
	e : EPK!ControlFlow

to 
	b : BPMN!SequenceFlow
	 (
	 	sourceRef <- e.source,
	 	targetRef <- e.target
	 	
 	)
 }


Thank you.

[Updated on: Fri, 04 June 2010 09:56]

Report message to a moderator

Re: [ATL] Problem with Rule [message #537963 is a reply to message #537948] Fri, 04 June 2010 10:46 Go to previous messageGo to next message
Tassilo Horn is currently offline Tassilo HornFriend
Messages: 93
Registered: July 2009
Member
Roger80 <roger.boehlen@students.fhnw.ch> writes:

Hi Roger,

> Please could you tell me what is wrong with the helper?

If you don't tell us what exactly doesn't work, we can only use our
crystal balls... Do you get an exception or only different results as
you have expected?

> helper context EPK!Event def: id : String =
> if self.Event.id = '1' then
> 'StartEvent'
> else
> '1'
> endif;

Without knowing the EPK metamodel, the self.Event.id looks a bit
suspicious to me. Does the EPK!Event class have an Attribute id? If
yes, then this should most probably be "self.id".

And in that case, I'm not sure if defining an attribute helper with a
name equal to an attribute is a good idea.

I'm no ATL expert, but I'm interested what would happen then? Would ATL
prefer the helper over the attribute in rules, i.e. I could redefine
attributes using attribute helpers?

And how about using "id" in the "id" helper? Would that be a (infinite)
recursion, or is the id attribute used? And using id from other
helpers: attribute or helper?

Bye,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@uni-koblenz.de
Universitätsstr. 1, 56070 Koblenz, Germany |
Re: [ATL] Problem with Rule [message #537968 is a reply to message #537963] Fri, 04 June 2010 11:05 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Thanks for your answer.

The EPK metamodel has the classes "BaseElement" and "Event". The class base element has the attribute "id" and the class "Event" has the attribute "name". The class "Event" is a Generalization of "Base Element".

My target is that the OUT model get the id="StartEvent"
from the input model (IN) where the id= "1".

Input model
<event id="1">
				<name>Loan request</name>
			</event> 


I hope I explained it clearly, otherwise please ask me.
Thank you very much!

Cheers Roger
Re: [ATL] Problem with Rule [message #538047 is a reply to message #537968] Fri, 04 June 2010 16:24 Go to previous message
Tassilo Horn is currently offline Tassilo HornFriend
Messages: 93
Registered: July 2009
Member
Roger80 <roger.boehlen@students.fhnw.ch> writes:

> The EPK metamodel has the classes "BaseElement" and "Event". The class
> base element has the attribute "id" and the class "Event" has the
> attribute "name". The class "Event" is a Generalization of "Base
> Element".

Ok.

> My target is that the OUT model get the id="StartEvent"
> from the input model (IN) where the id= "1".

Are you sure? It seems to me that you really want to create a
BPMN!StartEvent for each EPK!Event with id = '1'. So your rule should
have a constraint on the input element.

--8<---------------cut here---------------start------------->8---
helper context EPK!Event def: isStartEvent : Boolean = self.id = '1';

rule Event {
from
e : EPK!Event (e.isStartEvent)
to b : BPMN!StartEvent
(
id <- e.id,
name <- e.name
)
}
--8<---------------cut here---------------end--------------->8---

I didn't test it, but at least in theory that should create a
BPMN!StartEvent for all EPK!Events with id set to '1'.

Bye,
Tassilo
--
Dipl.-Inform. Tassilo Horn | Room: B015
University of Koblenz-Landau, Campus Koblenz | Phone: +49 (261) 287-2745
Institute for Software Technology | Mail: horn@uni-koblenz.de
Universitätsstr. 1, 56070 Koblenz, Germany |
Previous Topic:[ATL] acces to string
Next Topic:Possible to reference to two helpers in the same rule
Goto Forum:
  


Current Time: Fri Apr 26 22:39:29 GMT 2024

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

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

Back to the top