Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » [Acceleo] How to generate code from Actions in Activity diagram in control flow order?(How to generate code from Actions which are connected together with control flow arrows)
[Acceleo] How to generate code from Actions in Activity diagram in control flow order? [message #534798] Thu, 20 May 2010 11:35 Go to next message
Michal Jani is currently offline Michal JaniFriend
Messages: 3
Registered: May 2010
Location: Kosice
Junior Member
Hi, I want to generate a code for Actions in Activity diagram with Acceleo v3.0, IN ORDER which is affected by Control flow arrows (which are connecting the single Actions together between them)

For example if diagram looks like :
(Activity Initial Node) ---{control flow arrow}---> (Value Specification Action 1) ---{control flow arrow}---> (Value Specification Action 3) ---{control flow arrow}---> (Value Specification Action 2) ---{control flow arrow}---> (Activity Final Node)

Then I want to generate code from it in the same order, like :
generated code for Value Specification Action 1;
generated code for Value Specification Action 3;
generated code for Value Specification Action 2;


Thx for any help or advice Smile

(by the way, there is some solution described on http://www.acceleo.org/forum/read.php?11,881 , but its for older version of Acceleo and dont know how to make it works on Acceleo 3.0.... )
Re: [Acceleo] How to generate code from Actions in Activity diagram in control flow order? [message #535100 is a reply to message #534798] Fri, 21 May 2010 09:48 Go to previous messageGo to next message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------080401020305070908070406
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Michal,

I have no idea as to how this would be represented in an UML model, but
I do know UML has no "ordered" reference : everything is unordered (see
also my answer on
http://lists.gforge.enseeiht.fr/pipermail/topcased-users/201 0-May/003777.html
).

I believe your choices are to either use the "sortedBy" OCL operation in
order to properly order your ValueSpecifications (or ControlFlows) or
make use of recursive Acceleo Queries or Templates.

As I said earlier, I haven't got even the slightest idea as to how your
diagram would be represented in UML, so I can't really help with the OCL
you'd need.

Laurent Goubet
Obeo

Michal Jani wrote:
> Hi, I want to generate a code for Actions in Activity diagram with
> Acceleo v3.0, IN ORDER which is affected by Control flow arrows (which
> are connecting the single Actions together between them)
> For example if diagram looks like : (Activity Initial Node)
> ---{control flow arrow}---> (Value Specification Action 1) ---{control
> flow arrow}---> (Value Specification Action 3) ---{control flow
> arrow}---> (Value Specification Action 2) ---{control flow arrow}--->
> (Activity Final Node)
>
> Then I want to generate code from it in the same order, like :
> generated code for Value Specification Action 1;
> generated code for Value Specification Action 3;
> generated code for Value Specification Action 2;
>
>
> Thx for any help or advice :)
>
> (by the way, there is some solution described on
> http://www.acceleo.org/forum/read.php?11,881 , but its for older
> version of Acceleo and dont know how to make it works on Acceleo 3.0.... )


--------------080401020305070908070406
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------080401020305070908070406--
Re: [Acceleo] How to generate code from Actions in Activity diagram in control flow order? [message #535246 is a reply to message #535100] Fri, 21 May 2010 17:40 Go to previous messageGo to next message
Michal Jani is currently offline Michal JaniFriend
Messages: 3
Registered: May 2010
Location: Kosice
Junior Member
Hi Laurent,

Thank You for reply. Now I see that my question is quite confusing, but I dont know how to explain more exactly, what I d like to generate, so I rather made a picture:
http://img179.imageshack.us/img179/880/acceleoquestion.jpg

I know, that generator code should look something like:

[template public generateJavaFunctionsFromActivityDiagram(a : Activity)]
[file (a.name.concat('.java'), false)]
package [a.name/];
public class [a.name/] {

[for ( p:Action|a.ownedElement)]
[p.name/] ;
[/for]

}
[/file]
[/template]

But I have absolutely no clue how to order generated text for items "Action" by control flow. (by word "order" I mean order like on that picture http://img179.imageshack.us/img179/880/acceleoquestion.jpg , where items Action are connected with control flow)

Could you please tell me how to make recursive Acceleo Querie or "sortedBy" OCL operation for that? (or if is there some documentation with queries examples for activity diagram?)

Re: [Acceleo] How to generate code from Actions in Activity diagram in control flow order? [message #536500 is a reply to message #535246] Fri, 28 May 2010 14:07 Go to previous messageGo to next message
Michal Jani is currently offline Michal JaniFriend
Messages: 3
Registered: May 2010
Location: Kosice
Junior Member
After some finding and trying I finally understood, that generating code from activity diagram by control flow is not a good idea, cose Activity diagram is not designed and suitable for it. (or if you like, for way of use which I wanted)

In some very strict example, where is amount of control flow from one node to another restricted to one and number of nodes is restricted maximally to 8, the code for generator could look somehow like:

[template public generateJavaFunctionsFromActivityDiagram(a : Activity)]
[file (a.name.concat('.java'), false)]
package [a.name/];
public class [a.name/] {

[for (i : InitialNode | a.ownedElement)]
[i.outgoing.target.name/] ;
[i.outgoing.target.outgoing.target.name/] ;
[i.outgoing.target.outgoing.target.outgoing.target.name/] ;
[i.outgoing.target.outgoing.target.outgoing.target.outgoing. target.name/] ;
[i.outgoing.target.outgoing.target.outgoing.target.outgoing. target.outgoing.target.name/] ;
[i.outgoing.target.outgoing.target.outgoing.target.outgoing. target.outgoing.target.outgoing.target.name/] ;
[i.outgoing.target.outgoing.target.outgoing.target.outgoing. target.outgoing.target.outgoing.target.outgoing.target.name/ ] ;
[i.outgoing.target.outgoing.target.outgoing.target.outgoing. target.outgoing.target.outgoing.target.outgoing.target.outgo ing.target.name/] ;
[/for]

}
[/file]
[/template]



Its a pitty Razz

Re: [Acceleo] How to generate code from Actions in Activity diagram in control flow order? [message #536890 is a reply to message #536500] Mon, 31 May 2010 12:17 Go to previous message
Laurent Goubet is currently offline Laurent GoubetFriend
Messages: 1902
Registered: July 2009
Senior Member
This is a multi-part message in MIME format.
--------------050701090704050601080205
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit

Hi Michal,

Sorry, I realize I let one of your posts slip through last week.

Your code ... scared me :p.

Couldn't you at least use a recursive template such as

[for (i : InitialNode | a.ownedElement)]
[getNodeFlow(i)/]
[/for]

[template public getNodeFlow(node : InitialNode)]
node.outgoing.target.name;
[if (not outgoing.target.outgoing.oclIsUndefined())]
[getNodeFlow(outgoing.target)/]
[/if]
[/template]

Laurent Goubet
Obeo

Michal Jani wrote:
> After some finding and trying I finally understood, that generating code
> from activity diagram by control flow is not a good idea, cose Activity
> diagram is not designed and suitable for it. (or if you like, for way
> of use which I wanted)
>
> In some very strict example, where is amount of control flow from one
> node to another restricted to one and number of nodes is restricted
> maximally to 8, the code for generator could look somehow like:
>
> [template public generateJavaFunctionsFromActivityDiagram(a : Activity)]
> [file (a.name.concat('.java'), false)]
> package [a.name/];
> public class [a.name/] {
>
> [for (i : InitialNode | a.ownedElement)]
> [i.outgoing.target.name/] ;
> [i.outgoing.target.outgoing.target.name/] ;
> [i.outgoing.target.outgoing.target.outgoing.target.name/] ;
> [i.outgoing.target.outgoing.target.outgoing.target.outgoing.
> target.name/] ;
> [i.outgoing.target.outgoing.target.outgoing.target.outgoing.
> target.outgoing.target.name/] ;
> [i.outgoing.target.outgoing.target.outgoing.target.outgoing.
> target.outgoing.target.outgoing.target.name/] ;
> [i.outgoing.target.outgoing.target.outgoing.target.outgoing.
> target.outgoing.target.outgoing.target.outgoing.target.name/ ] ;
> [i.outgoing.target.outgoing.target.outgoing.target.outgoing.
> target.outgoing.target.outgoing.target.outgoing.target.outgo
> ing.target.name/] ;
> [/for]
>
> }
> [/file]
> [/template]
>
>
>
> Its a pitty :p
>
>


--------------050701090704050601080205
Content-Type: text/x-vcard; charset=utf-8;
name="laurent_goubet.vcf"
Content-Transfer-Encoding: base64
Content-Disposition: attachment;
filename="laurent_goubet.vcf"

YmVnaW46dmNhcmQNCmZuOkxhdXJlbnQgR291YmV0DQpuOkdvdWJldDtMYXVy ZW50DQpvcmc6
PGEgaHJlZj0iaHR0cDovL3d3dy5vYmVvLmZyIj5PYmVvPC9hPg0KZW1haWw7 aW50ZXJuZXQ6
bGF1cmVudC5nb3ViZXRAb2Jlby5mcg0KdXJsOmh0dHA6Ly93d3cub2Jlby5m cg0KdmVyc2lv
bjoyLjENCmVuZDp2Y2FyZA0KDQo=
--------------050701090704050601080205--
Previous Topic:[Check] Checks for Generic EMF Form Editor using Xtend in combination with Java method
Next Topic:[Xtend] Lists in JAVA extensions
Goto Forum:
  


Current Time: Fri Apr 19 20:56:02 GMT 2024

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

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

Back to the top