Skip to main content



      Home
Home » Modeling » M2T (model-to-text transformation) » generating java code out of uml activity diagrams with Xpand2
generating java code out of uml activity diagrams with Xpand2 [message #55310] Tue, 13 January 2009 08:15 Go to next message
Eclipse UserFriend
Hi,

I am currently working on a code generator, generating Java code out
UML2 activity diagrams. The diagrams are currently modeled with
MagicDraw 16 and afterwards exported as EMF UML2 (v2.x) XMI. Now the
faced problem is that the whole diagram is exported, but in fact the
internal activities of the diagram are not sorted anymore in flow order.

For example, the diagram may be:

action1 -> assertion1 -> action2 -> assertion2

now after exporting the tree structure looks something like:

action1 -> action2 -> assertion1 -> assertion2

The problem now is to generate proper Java code, I have to follow the
references. Has anyone ever faced a similar problem like that with
XPand2 or probably knows a solution which already solves the problem at
the exporting step (probably with another tool or a programmatic approach)?

Thanks in advance,

Philipp
Re: generating java code out of uml activity diagrams with Xpand2 [message #55337 is a reply to message #55310] Wed, 14 January 2009 03:57 Go to previous messageGo to next message
Eclipse UserFriend
Philipp,

note that a *diagram* is only a view on the model. The order of
activities in the model does not really matter. What does matter are the
ActivityEdges connect the ActivityNodes in the order you expect. In
other words: You should not evaluate the ActivitieNodes only, but also
the flow (outgoing / incoming relations).
See UML2 Superstructure, p. 290, Figure 12.5.

Kind regards,
~Karsten

On 13.01.2009 14:15 Uhr, Philipp Zech wrote:
> Hi,
>
> I am currently working on a code generator, generating Java code out
> UML2 activity diagrams. The diagrams are currently modeled with
> MagicDraw 16 and afterwards exported as EMF UML2 (v2.x) XMI. Now the
> faced problem is that the whole diagram is exported, but in fact the
> internal activities of the diagram are not sorted anymore in flow order.
>
> For example, the diagram may be:
>
> action1 -> assertion1 -> action2 -> assertion2
>
> now after exporting the tree structure looks something like:
>
> action1 -> action2 -> assertion1 -> assertion2
>
> The problem now is to generate proper Java code, I have to follow the
> references. Has anyone ever faced a similar problem like that with
> XPand2 or probably knows a solution which already solves the problem at
> the exporting step (probably with another tool or a programmatic approach)?
>
> Thanks in advance,
>
> Philipp
Re: generating java code out of uml activity diagrams with Xpand2 [message #55468 is a reply to message #55337] Wed, 14 January 2009 18:38 Go to previous messageGo to next message
Eclipse UserFriend
Karsten Thoms schrieb:
> Philipp,
>
> note that a *diagram* is only a view on the model. The order of
> activities in the model does not really matter. What does matter are the
> ActivityEdges connect the ActivityNodes in the order you expect. In
> other words: You should not evaluate the ActivitieNodes only, but also
> the flow (outgoing / incoming relations).
> See UML2 Superstructure, p. 290, Figure 12.5.
>
> Kind regards,
> ~Karsten
>
> On 13.01.2009 14:15 Uhr, Philipp Zech wrote:
>> Hi,
>>
>> I am currently working on a code generator, generating Java code out
>> UML2 activity diagrams. The diagrams are currently modeled with
>> MagicDraw 16 and afterwards exported as EMF UML2 (v2.x) XMI. Now the
>> faced problem is that the whole diagram is exported, but in fact the
>> internal activities of the diagram are not sorted anymore in flow order.
>>
>> For example, the diagram may be:
>>
>> action1 -> assertion1 -> action2 -> assertion2
>>
>> now after exporting the tree structure looks something like:
>>
>> action1 -> action2 -> assertion1 -> assertion2
>>
>> The problem now is to generate proper Java code, I have to follow the
>> references. Has anyone ever faced a similar problem like that with
>> XPand2 or probably knows a solution which already solves the problem at
>> the exporting step (probably with another tool or a programmatic
>> approach)?
>>
>> Thanks in advance,
>>
>> Philipp
>
Hi Karsten,

thanks for the hints. That's in fact what I expected (following the
references).
Nevertheless this still somehow, does not solve problem, as I think that
XPand2 is not mighty enough to help me out of this dilemma. Does there
exist another M2T framework, not a template based but a visitor based
approach, as I think this would solve the problem and would relieve a
burden of work.

Thanks!

cheers,

Philipp
Re: generating java code out of uml activity diagrams with Xpand2 [message #55495 is a reply to message #55468] Thu, 15 January 2009 02:44 Go to previous messageGo to next message
Eclipse UserFriend
Philipp,

I disagree that Xpand2 would not be mighty enough. Until now I have
solved anything with this framework. The problem is that I cannot follow
your problem in more detail since I do not know the details. I cannot
imagine that the export is faulty, it would always represent your actual
model. I think you mix up what's in the diagram and what it looks like
in the model. A diagram is only a view on the model.

~Karsten

On 15.01.2009 0:38 Uhr, Philipp Zech wrote:
> Karsten Thoms schrieb:
>> Philipp,
>>
>> note that a *diagram* is only a view on the model. The order of
>> activities in the model does not really matter. What does matter are
>> the ActivityEdges connect the ActivityNodes in the order you expect.
>> In other words: You should not evaluate the ActivitieNodes only, but
>> also the flow (outgoing / incoming relations).
>> See UML2 Superstructure, p. 290, Figure 12.5.
>>
>> Kind regards,
>> ~Karsten
>>
>> On 13.01.2009 14:15 Uhr, Philipp Zech wrote:
>>> Hi,
>>>
>>> I am currently working on a code generator, generating Java code out
>>> UML2 activity diagrams. The diagrams are currently modeled with
>>> MagicDraw 16 and afterwards exported as EMF UML2 (v2.x) XMI. Now the
>>> faced problem is that the whole diagram is exported, but in fact the
>>> internal activities of the diagram are not sorted anymore in flow order.
>>>
>>> For example, the diagram may be:
>>>
>>> action1 -> assertion1 -> action2 -> assertion2
>>>
>>> now after exporting the tree structure looks something like:
>>>
>>> action1 -> action2 -> assertion1 -> assertion2
>>>
>>> The problem now is to generate proper Java code, I have to follow the
>>> references. Has anyone ever faced a similar problem like that with
>>> XPand2 or probably knows a solution which already solves the problem at
>>> the exporting step (probably with another tool or a programmatic
>>> approach)?
>>>
>>> Thanks in advance,
>>>
>>> Philipp
>>
> Hi Karsten,
>
> thanks for the hints. That's in fact what I expected (following the
> references).
> Nevertheless this still somehow, does not solve problem, as I think that
> XPand2 is not mighty enough to help me out of this dilemma. Does there
> exist another M2T framework, not a template based but a visitor based
> approach, as I think this would solve the problem and would relieve a
> burden of work.
>
> Thanks!
>
> cheers,
>
> Philipp
Re: generating java code out of uml activity diagrams with Xpand2 [message #55687 is a reply to message #55310] Mon, 19 January 2009 04:47 Go to previous messageGo to next message
Eclipse UserFriend
Sorting in flow order would be difficult, as there is no order in a
graph such as an activity diagram. Note that it can have multiple
initial nodes, multiple end nodes and might even fork into several
parallel flows. So what would be the ordering of such a complex flow?

The UML spec is aware of that and defines the Activity.nodes reference
as unordered, so elements are stored in a set, whose iterator can return
elements in any order.

So if you want an ordering, you'll have to define the algorithm
yourself. Xpand allows you to use Xtexd, a powerful, strongly typed,
functional language to define such extensions. It can even delegate to
Java if you feel better writing stuff there.

If you have just one initial node and no forks and decisions you might
consider the following algorithm

1) find the initial node
2) find the next node by navigating the first outgoing edge and recurse.

In Xtend, that is very simple to write.

Best regards
Jan


Philipp Zech schrieb:
> Hi,
>
> I am currently working on a code generator, generating Java code out
> UML2 activity diagrams. The diagrams are currently modeled with
> MagicDraw 16 and afterwards exported as EMF UML2 (v2.x) XMI. Now the
> faced problem is that the whole diagram is exported, but in fact the
> internal activities of the diagram are not sorted anymore in flow order.
>
> For example, the diagram may be:
>
> action1 -> assertion1 -> action2 -> assertion2
>
> now after exporting the tree structure looks something like:
>
> action1 -> action2 -> assertion1 -> assertion2
>
> The problem now is to generate proper Java code, I have to follow the
> references. Has anyone ever faced a similar problem like that with
> XPand2 or probably knows a solution which already solves the problem at
> the exporting step (probably with another tool or a programmatic approach)?
>
> Thanks in advance,
>
> Philipp
Re: generating java code out of uml activity diagrams with Xpand2 [message #56137 is a reply to message #55310] Fri, 23 January 2009 06:46 Go to previous messageGo to next message
Eclipse UserFriend
Philipp Zech schrieb:
> Hi,
>
> I am currently working on a code generator, generating Java code out
> UML2 activity diagrams. The diagrams are currently modeled with
> MagicDraw 16 and afterwards exported as EMF UML2 (v2.x) XMI. Now the
> faced problem is that the whole diagram is exported, but in fact the
> internal activities of the diagram are not sorted anymore in flow order.
>
> For example, the diagram may be:
>
> action1 -> assertion1 -> action2 -> assertion2
>
> now after exporting the tree structure looks something like:
>
> action1 -> action2 -> assertion1 -> assertion2
>
> The problem now is to generate proper Java code, I have to follow the
> references. Has anyone ever faced a similar problem like that with
> XPand2 or probably knows a solution which already solves the problem at
> the exporting step (probably with another tool or a programmatic approach)?
>
> Thanks in advance,
>
> Philipp
Hi,

thanks a lot for all the answers I got so far, but I still got another
question: Does there exist any visitor based approach for generating
java code out of UML diagrams, in contradiction to the template ones,
like for example XPand2?

thanks a lot!

cheers,
Re: generating java code out of uml activity diagrams with Xpand2 [message #56375 is a reply to message #56137] Sun, 25 January 2009 02:31 Go to previous message
Eclipse UserFriend
Hi Philipp,

I don't know any, sorry. However, I come better along with template
based approaches anyway.

Best wishes,
~Karsten

On 23.01.2009 12:46 Uhr, Philipp Zech wrote:
> Philipp Zech schrieb:
> thanks a lot for all the answers I got so far, but I still got another
> question: Does there exist any visitor based approach for generating
> java code out of UML diagrams, in contradiction to the template ones,
> like for example XPand2?
>
> thanks a lot!
>
> cheers,
Previous Topic:[MTL] UML primitive type problems
Next Topic:generating java code from UML2 activity diagrams
Goto Forum:
  


Current Time: Sun Jul 13 10:26:47 EDT 2025

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

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

Back to the top