Java programming with uml - java

I'm a java developer new with uml modeling. I wanna create a complete web application (backend+db+jms+security +ui) deployable to an application server by using only UML. Despite I didn't understand what really is meta-modeling I started using Umbrello, visual paradigm and eclipse emf.
I've read just a little about omg's xmi standard.
So supponing to have an xmi file I didn't understand how to generate java code. Eclipse emf for example would generate "strange" java code.
Do I need to
write my own xmi parser?

Do I need to write my own xmi parser?
No.

Eclipse EMF generator generates code for saving and loading your model, so there is no need to write your own parser or serializer.
EMF allows you to generate a maximum of four different plugins for a defined model:
Model: The model contains all entities, packages and factories to create instances of the model.
Edit: The edit plugin contains providers to display a model in a UI. For example, the providers offer a label for every model element, which can be used to display an entity showing an icon and a name.
Editor: The editor plugin is a generated example editor to create and modify instances of a model.
Test: The test plugin contains templates to write tests for a model.
This is a good article if you need any help with EMF:
What every Eclipse developer should know about EMF.
http://eclipsesource.com/blogs/tutorials/emf-tutorial/

Related

Generate XML file from UML Model in Java

I want to make a java application that take UML Model and it's output is a XML File.
I want to know what is the library/API can i use in Java ? - and i want to know if there is any application that do this job ?
Most (if not all) UML tools will export to XMI, you can learn more at
Wikipedia MOF. If you are really interested in code generation (rather than just parsing XML) there are eclipse related projects such as eclipse emf. Good luck w/your journey.

AST for UML Activity diagram

I am currently doing a project to convert uml diagrams to java code,in one of the step I have to create an ast for general activity diagram and write a java code for the ast. The problem is I am not sure how to represent it in java code to accept any activity diagram as an input. Please need some help.
This is the meta-model of a general activity diagram, I want to represent this diagram as a java code to accept inputs.
Activity Diagram Metamodel
The first diagram on the second page of the pdf
What tool are you using to create your activity diagrams? Most will provide an API to query models and/or an XMI export*. In either case you don't get an AST as such, more an Object structure of your model. But it's still pretty easy to iterate that structure and generate code.
One option worth considering is the Eclipse Modeling Framework (EMF). There are tools available for both creating diagrams (e.g. Papyrus) and a multitude of options for generating code from models (e.g. Acceleo) - have a look at the 'Model to Text' (M2T) sub-project.
Even if you decide to use another tool for diagram creation, it's possible to use Eclipse M2T for code generation; most tools will export XMI in the eclipse dialect.
hth.
--
*XMI is the 'standard' for UML model interchange. It was plagued with inconsistency in interpretation originally, and there are still some problems among tools today. However: it is an XML dialect so even if tool B can't directly import XMI from tool A, it's usually possible to convert between the two.

Class diagram generation from java/groovy code and exporting

I'm in the need of a eclipse plugin / or tool which can generate
class diagrams from my java/groovy code and vice versa. Actually it is a
groovy/grails project. The actual requirements are:
I should be able to draw class diagram and generate code and generate class diagram
from existing code
(Important) I have to export the generated class diagram in some format to share it
with my teammates, so they can generate code from it.
Please suggest me a good solution.
Thanks in advance.
You can use visual paradigm for uml. Using Visual Paradign you generate UML diagrams of your and generate code, using UML diagrams
You can create diagrams, share it on CVS or by email but it is only possible with the java code. I don't think it exist for both groovy and java.
You have two options today which is to use a live code and model synchronization tool which is more integration level or a model driven tool which will generate all the code once the model has been completed.
I personally prefer the first live synchronization option because if the code is updated then my model will also be. It is painful to produce diagrams and then realize that at the implementation stage the development team has changed the code and that my diagrams are not anymore relevant !!

Represent UML2 Stereotypes in EMF Ecore format to generate Java code via JET

working with Eclipse EMF, i am trying to convert a uml2-model (i.e. defined as xmi) with applied profiles to ecore to be able to manipulate the code generation. Anyone has an idea on how this could be done nicely?
As it is not possible out of the box I would figure that I would need to find a way to manipulate the way the xmi gets tranformed to ecore to represent the stereotypes in some 'ecore'-way, so that I can read them in my JET-Template...
Thanks a lot for pointing me in the right direction!
PS: This post is very related to what I want to achieve How to generate 'java code with annotations' from emf model
I have not done this before, but I think what you need to do is use the eclipse MDT/UML2 project, which helps read in your UML model file to produce an EMF model. From there, you can use the typical EMF code generation features to generate the code or templating features to generate your own custom code. There is an FAQ entry which addresses how to do this:
The UML2 project provides an Ecore importer that can be used to create Ecore (.ecore) and generator (.genmodel) models from a UML (.uml) model via the EMF project wizard ... Ultimately, UML2 uses the code generation facilities provided by EMF.
It is not possible to generate annotation from EMF directly you need to use an UML tool.

From Java code in eclipse to UML class diagrams in Omnigraffle

Is there a way to get reversed engineered uml diagrams into Omnigraffle?
I got a bunch of eclipse plugins that can create UML class diagrams, but not in a format that Omnigraffle can handle.
Is there any way to get my project from eclipse to Omnigraflle?
Thanks!
I've created a little plugin for Eclipse in order to create an OmniGraffle UML-like class diagram from a Java package. It does not create files, but instead uses AppleScript to direcly draw the diagram in an opened OmniGraffle drawing. The plugin provides some options in order to control the diagram creation, e.g., show or hide private attributes etc. Parameterized collections are transformed into associations, however there is room for improvement. The plugin is described at
http://jpilgrim.github.com/eclipsetools/j2og/
where you will also find a link to the update site in order to easily install the plugin.
Yes, this is strange but no XMI export to Omnigraffe is available from UML 2.3.
I don't think this is a big job to be done so you can do it by yourself. You need to take the EclipseUML2 metamodel or the EMF model then manually identify each model element (e.g a class in UML 2.3 is .....in Omnigraffe, etc....)
Once all the elements have been identify then code a xml mapper. It would work.
A good mapper is about 18 months work for one engineer, but if you are 5 of you you can do it in less than 3-6 months (2months for codding and 4 months for testing).
Good luck for this potential project.
My question could be why the Omni Group has not done the xml export ?

Categories