Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
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 Go to next message
Roger80  is currently offline Roger80 Friend
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 #548572 is a reply to message #548554] Thu, 22 July 2010 11:30 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Le 22/07/2010 12:53, Roger80 a écrit :
> 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
> ),
> 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
>

I am sorry but I understand lesser than ever what is your problem.
Can you present the types of the input and output metamodels, with their
containing attributes and contained types?
--
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 #548582 is a reply to message #548554] Thu, 22 July 2010 12:06 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
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)

Thank you....cheers

Roger
Re: Call helper inside a rule and overgive parameter [message #548596 is a reply to message #548582] Thu, 22 July 2010 12:26 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
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 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
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. Smile

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 #548667 is a reply to message #548641] Thu, 22 July 2010 14:52 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Le 22/07/2010 16:44, Roger80 a écrit :
> 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?
>
> Thanks and cheers
> Roger

You may have a look at some examples of ATL transformations.
--
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 #548676 is a reply to message #548554] Thu, 22 July 2010 15:57 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
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 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
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 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
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 #548806 is a reply to message #548695] Fri, 23 July 2010 06:33 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Le 22/07/2010 18:47, Roger80 a écrit :
> 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?
>
It means sometimes the getConditionName() is applied on something which
is not of the Type defined as its context.

--
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 #548815 is a reply to message #548806] Fri, 23 July 2010 07:34 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
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

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) : 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
Re: Call helper inside a rule and overgive parameter [message #548819 is a reply to message #548815] Fri, 23 July 2010 07:41 Go to previous messageGo to next message
Vincent MAHE is currently offline Vincent MAHEFriend
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
Re: Call helper inside a rule and overgive parameter [message #548845 is a reply to message #548819] Fri, 23 July 2010 09:38 Go to previous messageGo to next message
Roger80  is currently offline Roger80 Friend
Messages: 79
Registered: May 2010
Member
Hello Vincent

Thank you for your help... Smile I get now the correct information, but I know now, why I got the error, it is becasue something is wrong in my Meta model. You already told me that I have to check my Meta model and to adapt the references on my meta model. You also gave me advise how to do:

Class SequenceFlow
reference conditionExpressionLevel
containment = true
eType = ConditionExpression

I try to do it but still the same error occur:

2m.atl.engine.vm.VMException: Feature ConditionExpressionLevel does not exist on BPMN!SequenceFlow


Can you check my meta model settings? And tell me what is wrong? That would help me I think, here are the illustrations:

http://www.haar-em.ch/test/mm1.jpg

http://www.haar-em.ch/test/mm2.jpg

http://www.haar-em.ch/test/mm3.jpg

Thanks and cheers

Roger

[Updated on: Fri, 23 July 2010 09:39]

Report message to a moderator

Re: Call helper inside a rule and overgive parameter [message #548871 is a reply to message #548845] Fri, 23 July 2010 11:00 Go to previous message
Vincent MAHE is currently offline Vincent MAHEFriend
Messages: 129
Registered: July 2009
Senior Member
Le 23/07/2010 11:38, Roger80 a écrit :
> Hello Vincent
>
> Thank you for your help... :) I get now the correct information, but I
> know now, why I got the error, it is becasue something is wrong in my
> Meta model. You already told me that I have to check my Meta model and
> to adapt the references on my meta model. You also gave me advise how to
> do:
> Class SequenceFlow
> reference conditionExpressionLevel
> containment = true
> eType = ConditionExpression
>
> I try to do it but still the same error occur:
>
> 2m.atl.engine.vm.VMException: Feature ConditionExpressionLevel does not
'C' -> 'c'
> exist on BPMN!SequenceFlow
>
> Can you check my meta model settings? And tell me what is wrong? That
> would help me I think, here are the illustrations:
>
>
You get a wrong case in the feature name (see above)

--
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
Previous Topic:[ATL] Problem with UML property
Next Topic:AtlEMFModelHandler
Goto Forum:
  


Current Time: Fri Apr 23 09:35:56 GMT 2021

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

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

Back to the top