[ATL] Problem with Helper in Rule [message #537948] |
Fri, 04 June 2010 05:56  |
Eclipse User |
|
|
|
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 05:56] by Moderator
|
|
|
Re: [ATL] Problem with Rule [message #537963 is a reply to message #537948] |
Fri, 04 June 2010 06:46   |
Eclipse User |
|
|
|
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 #538047 is a reply to message #537968] |
Fri, 04 June 2010 12:24  |
Eclipse User |
|
|
|
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 |
|
|
|
Powered by
FUDForum. Page generated in 0.04640 seconds