Home » Archived » M2M (model-to-model transformation) » Call helper inside a rule and overgive parameter
Call helper inside a rule and overgive parameter [message #548554] |
Thu, 22 July 2010 10:53 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
Hi all
Is it possible to call a helper in a rule? I need it to get the name attribute from another class.
My rule is:
-- Rule 13 / 11a with conditionalExpression
rule ConditionExpression {
from
e : EPK!ControlFlow (e.isConditionExpression())
to
b : BPMN!SequenceFlow
(
name <- e.name
conditionExpression <- con
),
con : BPMN!ConditionExpression(
name <- thisModule.getConditionName( overgive id, take back name)
)
}
My helper looks:
--Make two level - Rule 13 with conditionalExpression
helper context EPK!ControlFlow def: getConditionName(take id, give back name ) : Sequence(String) =
EPK!Event.allInstances()-> select(e | e.target=self.id)->collect(e | e.name);
but how can I overgive and get back this parameters?
Thanks for your help.
Cheers Roger
[Updated on: Thu, 22 July 2010 10:56] Report message to a moderator
|
|
| | |
Re: Call helper inside a rule and overgive parameter [message #548596 is a reply to message #548582] |
Thu, 22 July 2010 12:26 |
Vincent MAHE Messages: 129 Registered: July 2009 |
Senior Member |
|
|
Le 22/07/2010 14:06, Roger80 a écrit :
> I can provide you my meta models, but they are huge. My only problem is
> that I want to call a helper in a rule. Is that possible?
>
> If yes, is it also possible to hand over some parameters?
>
> Like:
>
> helper context... def (get parameter, hand over parameter)
> do something
>
>
> rule
> from
> ..
> to
> binding a <- call helper(hand over parameter, get back parameter)
a <- thisModule.helper(param1, param2, ...)
will put in a the return value of the helper (but only in match rules
and other helpers).
It seems you expect 2 return values from the helper???
If it is the case, then your helper should return a Tuple (x, y) so you
may call it and store the result in the "using" section. You could then
access to the parts of the Tuple in the "to" section.
>
> Thank you....cheers
> Roger
--
Cordialement
Vincent MAHÉ
Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
|
|
|
Re: Call helper inside a rule and overgive parameter [message #548641 is a reply to message #548596] |
Thu, 22 July 2010 14:44 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
>a <- thisModule.helper(param1, param2, ...)
>will put in a the return value of the helper (but only in match >rules
>and other helpers).
So, when I want to use a helper in a rule I have to use a matched rule, right?
Is it true that a match rule has a structure like below?
rule rule_name{
from in: MM1!MetaClass(<matching condition>)
using{<variable definitions>}
to out1: MM2!MetaClass1(
<bindings1>
),
out2: MM2!MetaClass2(
<bindings2>
)
do{<imperative block>}
What is the <matching condition>, the <variable definitions> and the <imperative block> for?
>It seems you expect 2 return values from the helper???
>If it is the case, then your helper should return a Tuple (x, y) so >you
>may call it and store the result in the "using" section. You could >then
>access to the parts of the Tuple in the "to" section.
No, I just want one return value.
Thanks and cheers
Roger
[Updated on: Thu, 22 July 2010 14:47] Report message to a moderator
|
|
| |
Re: Call helper inside a rule and overgive parameter [message #548676 is a reply to message #548554] |
Thu, 22 July 2010 15:57 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
These are my settings:
-- Helper:
helper context EPK!ControlFlow def: getConditionName(id : String) : Sequence(OclAny) =
EPK!Event.allInstances().debug()-> select(g | g.target=self.id)->collect(g | g.name);
-- Rule:
rule ConditionExpression {
from
e : EPK!ControlFlow (e.isConditionExpression()) -- and he.isConditionExpressionEvent() and not e.isStarter() and e.isNotEventEndEvent())
to
b : BPMN!SequenceFlow
(
name <- e.name
--conditionExpression <- con
),
con : BPMN!ConditionExpression(
name <- thisModule.getConditionName(e.id)
)
}
But when I execute, the following error occur. Do you understand it, what does it mean?
org.eclipse.m2m.atl.engine.vm.VMException: Could not find operation getConditionName on Module having supertypes: [OclAny]
at A.__applyConditionExpression(1 : NTransientLink;) : ??(EPL2BPMN.atl[218:11-218:44])
local variables = {b=OUT!<notnamedyet>, e=IN!<notnamedyet>, link=TransientLink {rule = 'ConditionExpression', sourceElements = {e = IN!<notnamedyet>}, targetElements = {con = OUT!<notnamedyet>, b = OUT!<notnamedyet>}, variables = {}}, self=EPL2BPMN : ASMModule, con=OUT!<notnamedyet>}
local stack = [OUT!<notnamedyet>, OUT!<notnamedyet>, EPL2BPMN : ASMModule]
Thank you very much for lookinf into it...
Cheers Roger
|
|
|
Re: Call helper inside a rule and overgive parameter [message #548684 is a reply to message #548676] |
Thu, 22 July 2010 16:15 |
Vincent MAHE Messages: 129 Registered: July 2009 |
Senior Member |
|
|
Le 22/07/2010 17:57, Roger80 a écrit :
> These are my settings:
>
>
> -- Helper:
> helper context EPK!ControlFlow def: getConditionName(id : String) :
> Sequence(OclAny) = EPK!Event.allInstances().debug()-> select(g |
> g.target=self.id)->collect(g | g.name);
> -- Rule:
> rule ConditionExpression {
> from
> e : EPK!ControlFlow (e.isConditionExpression()) -- and
> he.isConditionExpressionEvent() and not e.isStarter() and
> e.isNotEventEndEvent())
> to
> b : BPMN!SequenceFlow (
> name <- e.name
> --conditionExpression <- con ),
> con : BPMN!ConditionExpression(
> name <- thisModule.getConditionName(e.id)
name <- e.getConditionName(e.id)
because you defined your helper on the ControlFlow type
> )
> }
>
>
>
> But when I execute, the following error occur. Do you understand it,
> what does it mean?
>
> org.eclipse.m2m.atl.engine.vm.VMException: Could not find operation
> getConditionName on Module having supertypes: [OclAny]
> at A.__applyConditionExpression(1 : NTransientLink;) :
> ??(EPL2BPMN.atl[218:11-218:44])
> local variables = {b=OUT!<notnamedyet>, e=IN!<notnamedyet>,
> link=TransientLink {rule = 'ConditionExpression', sourceElements = {e =
> IN!<notnamedyet>}, targetElements = {con = OUT!<notnamedyet>, b =
> OUT!<notnamedyet>}, variables = {}}, self=EPL2BPMN : ASMModule,
> con=OUT!<notnamedyet>}
> local stack = [OUT!<notnamedyet>, OUT!<notnamedyet>, EPL2BPMN : ASMModule]
>
> Thank you very much for lookinf into it...
>
> Cheers Roger
>
--
Cordialement
Vincent MAHÉ
Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
|
|
|
Re: Call helper inside a rule and overgive parameter [message #548695 is a reply to message #548684] |
Thu, 22 July 2010 16:47 |
Roger80 Messages: 79 Registered: May 2010 |
Member |
|
|
It still give me the same error, really, really strange.
When I just give back a String like 'Hello' it works.
But then I try with parameters or more complex statements he starts complaining and always with the same error.
This is the beginning of the error:
org.eclipse.m2m.atl.engine.vm.VMException: Could not find operation getConditionName on Module having supertypes: [OclAny]
SWhat does he talk about module and supertypes: [OclAny]. Should I provide the whole error?
Thank you, I feel close but I don't know...
Cheers Roger
Addition:
In the documentation I found a hint, but I don't know what to do with it. I added a 'do' part at the end of my rule, without any success.
ATL Called Rules Troubles
* Trouble: ERROR: could not find operation including on Module having supertypes: [OclAny]) on a called rule
Cause: Your called rule doesn't return the good type (problably any)
Solution: Add a return type on your called rule by adding the do clause
e.g.
rule myCalledRule() {
to
out : XML!Element -- ...
do {
out;
}
}
[Updated on: Thu, 22 July 2010 17:02] Report message to a moderator
|
|
| | |
Re: Call helper inside a rule and overgive parameter [message #548819 is a reply to message #548815] |
Fri, 23 July 2010 07:41 |
Vincent MAHE Messages: 129 Registered: July 2009 |
Senior Member |
|
|
Le 23/07/2010 09:34, Roger80 a écrit :
> Please help, *I am starring since hours on it*, but I do not find
> anything. I call my helper from:
>
> name <- e.getConditionName(e.target)
>
> e is the class ControlFlow with the attributes: id, name, source, target
as you write, "e" is a ControlFlow, but getConditionName is defined on Event
>
> I push the parameter target to the helper "getConditionName".
>
> ---------------------------------------------
>
> The helper: In the helper (getConditionName) I use the target
> (self.target) to identify the "id" of the event class and to get
> afterwards the "name" attribute of the event class. The name is then the
> result which should be used in the rule.
>
> Atributes of event: name and id
>
> helper context EPK!Event def: getConditionName(target : String) :
The way you wrote it, this helper applies only on Event instances!!!
> Sequence(String) =
> EPK!ControlFlow.allInstances()-> select(g |
> g.id=self.target.debug())->collect(g | g.name);
>
> -------------------------------------------
>
> Is everything correct, what do you think?
>
> Cheers Roger
--
Cordialement
Vincent MAHÉ
Ingénieur Expert - Projet IDM++ - Équipe AtlanMod
École des Mines de Nantes
La Chantrerie - 4, rue Alfred Kastler
B.P. 20722 - F-44307 NANTES Cedex 3
Tel: (33)2 51 85 81 00
|
|
| | |
Goto Forum:
Current Time: Fri Jan 03 01:30:50 GMT 2025
Powered by FUDForum. Page generated in 0.04423 seconds
|