Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » M2T (model-to-text transformation) » UML diagrams in XML + JET = Java?
UML diagrams in XML + JET = Java? [message #1814720] Tue, 17 September 2019 06:29 Go to next message
Clever Alves is currently offline Clever AlvesFriend
Messages: 101
Registered: August 2019
Senior Member
Hello!

I was wondering whether I could export UML diagrams in XML format and import them into a JET (Java Emitter Templates) platform to automatically generate Java code.

Based on your experience in this field, could you please tell me what you think of such an approach?

Thank you for your attention.

Regards,

Clever.
Re: UML diagrams in XML + JET = Java? [message #1814740 is a reply to message #1814720] Tue, 17 September 2019 10:12 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

I assume that you mean with the diagrams the elements and their relations, but not diagram layout? UML models are typically already XMI, more specifically EMF UML2. They can be read as UML resources and traversed with Java.

You may have a look at Xtend instead of JET for writing templates. The slides here could give you some starting points: https://de.slideshare.net/kthoms/recipes-to-build-code-generators-for-nonxtext-models-with-xtend

If you search you can find some sources in Git repos out there.
Re: UML diagrams in XML + JET = Java? [message #1814782 is a reply to message #1814740] Wed, 18 September 2019 05:07 Go to previous messageGo to next message
Clever Alves is currently offline Clever AlvesFriend
Messages: 101
Registered: August 2019
Senior Member
Danke für Ihre Antwort und herzlichen Glückwunsch für Ihre Präsentation, Karsten!

"I assume that you mean with the diagrams the elements and their relations, but not diagram layout?" => Well, I'd build the diagram layout on a UML tool and then export them in XMI/XML format.

What exactly do you mean by "traversed with Java"?

I think Xtend might be too code-based...I'm not a programmer, I don't want to build a code generator, but rather benefit from an existing one that converts UML diagrams (class and sequence and activity diagrams), in a suitable import format (say, XMI/XML), into Java code (stubs). Is it a dream?

Danke für Ihre Aufmerksamkeit.

Mit freundlichen Grüssen,

Clever.
Re: UML diagrams in XML + JET = Java? [message #1814787 is a reply to message #1814782] Wed, 18 September 2019 08:48 Go to previous messageGo to next message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Well, what code exactly would you expect to get when you draw a diagram. Let's take the simplest case, a class with attributes. The most trivial thing that could be done from that is to produce a Java bean with getters and setters. But what if you'd like to get more from that? Often you'd like to have some kind of persistence layer, and a class might be an Entity. Likely you would provide an UML profile and apply stereotypes on classes, attributes, relationships etc. What (Java) code would you expect from that?

The model based approach is usually different. You define a model and when using UML an appropriate profile, and have a target architecture. For that target architecture you create a reference implementation. From that reference code templates could be derived. And this is programmed in a code generator. This is typically a manual process and often project specific. And its no dream, that's common practice.

However, of course you can find tools that derive some Java code from UML diagrams. What you get is often not what you really want.

Besides that, using UML for model driven approaches is nowadays not that common anymore. Several years back UML was often used to define models from which code was produced. Nowadays often domain specific tools are created, be them textual (e.g. with Eclipse Xtext), visual (e.g. Eclipse Sirius), or projectional (e.g. Jetbrains MPS). They are much tighter aligned to the problem domain.

I don't want to get more philosophical and come back to your original question.

You want to design UML diagrams and want the models in XML/XMI. That's what the tools typically support. Either they are build directly on EMF UML2 (e.g. Papyrus), or they allow exporting to that (e.g. MagicDraw). These XMI models can be read with the EMF UML2 API. Then you have a Java object graph and process that programmatically to produce code.

But as said: What code to produce is highly dependent on the problem domain. You might find some existing transformations, but it usually won't fit what you actually need. The approach is vice versa: Define what you need, define how to model that in UML (usually with your own profile) and then derive the code generator between that.
UML diagrams in XML + JET = Java? [message #1814819 is a reply to message #1814787] Thu, 19 September 2019 07:27 Go to previous messageGo to next message
Clever Alves is currently offline Clever AlvesFriend
Messages: 101
Registered: August 2019
Senior Member
Danke für Ihre Antwort, Karsten!

"what code exactly would you expect to get when you draw a diagram" => At this embryonal stage, code stubs would be enough, but they should take into account class and sequence and activity diagrams altogether.

"Nowadays often domain specific tools are created, be them textual (e.g. with Eclipse Xtext), visual (e.g. Eclipse Sirius), or projectional (e.g. Jetbrains MPS). They are much tighter aligned to the problem domain." => Yeah, I do follow your point, a graphical notation is a must for my application, perhaps I should go for Sirius instead, however, I need to get nontechnical people involved in the modelling phase and UML, although still execution-based, sounds much more user-friendly and widely known, am I wrong?

"want the models in XML/XMI" => Not necessarily...These would be export format towards a code generation tool only...

"Either they are build directly on EMF UML2 (e.g. Papyrus), or they allow exporting to that (e.g. MagicDraw)" => What do you think of using UML Designer (http://www.umldesigner.org/) and then UMLGen (https://projects.eclipse.org/projects/modeling.umlgen)?

Danke für Ihre Aufmerksamkeit.

Viele Grüsse,

Clever.
Re: UML diagrams in XML + JET = Java? [message #1814823 is a reply to message #1814819] Thu, 19 September 2019 08:26 Go to previous message
Karsten Thoms is currently offline Karsten ThomsFriend
Messages: 762
Registered: July 2009
Location: Dortmund, Germany
Senior Member

Quote:
What do you think of using UML Designer (http://www.umldesigner.org/) and then UMLGen (https://projects.eclipse.org/projects/modeling.umlgen)?


I don't have an opinion on that. For several years now, no customer of me demanded UML anymore. I have built many DSL and code generation tools, though. The market speeks a clear language to me.

Make your own opinion on these tools. They are built on the right tech stack (EMF UML2). Obeo is behind umldesigner, they are also driving Sirius and an Sirius based UML tool sounds as the right way. For code generation UMLGen uses Acceleo, a mature template engine, also originated from Obeo.

Just try it and look for contact from the Obeo team.
Previous Topic:[Acceleo] allInstances operator not available?
Next Topic:Model to text transformation
Goto Forum:
  


Current Time: Sat Nov 09 03:07:46 GMT 2024

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

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

Back to the top