wood burning stoves 2.0*
The moose likes OO, Patterns, UML and Refactoring and the fly likes EMF + UML 2 Tools [model to java code] Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Engineering » OO, Patterns, UML and Refactoring
Bookmark "EMF + UML 2 Tools [model to java code]" Watch "EMF + UML 2 Tools [model to java code]" New topic
Author

EMF + UML 2 Tools [model to java code]

Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Hello all.

I'm trying to use EMF with UML 2 Tools to generate java code based in a class diagram model.
But with EMF when I start generating code from a class diagram, I've got a lot of undesirable stuff to my project.
I don't want to create Factories, Tests, Interfaces when generating code for a simple domain model.
There are also some ecore classes and interfaces being used when I use the generate java code from my model.

I'd like to know if anybody knows a way of creating a simple java code from an uml model diagram within EMF project.

Any help will be appreciated.

Thanks in advance.


Adolfo Eloy
Software Developer
OCPJP 6
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
How did you generate the code from a Class diagram? It seems like you are not using the EMF correctly. If you don't want the EMF implementation, then simply don't use EMF. Very simple.
Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Frank Bennett wrote:If you don't want the EMF implementation, then simply don't use EMF. Very simple.


That's the point. I don't want to use the EMF implementation that ships on EMF generated code.
But if I don't use it, I can't generate my code simply by using the uml 2 tools, because the role to generate code belongs to EMF.

Is there another way of generating model based java code without using EMF? (with uml 2 tools).

Thanks.

Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Many UML-based editors have a feature for generating code from diagrams, e.g. ArgoUML, JUDE

Which editor did you create the Class diagrams with?

Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Frank,

I'm using UML 2 Tools that is an EMF-based implementation of the Unified Modeling Language (UMLTM) 2.x OMG metamodel for the Eclipse platform.
I'd like to use an EMF based implementation because of the interoperability that it enables.

If I can't do it by now, I'd like to know another tool that can be used with eclipse, and have no such bugs like argouml and also have any free license.

Thank you.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Your answer is very confusing. Are you saying that you have created the Class diagrams with Eclipse?
Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Yes Frank!
I've created my class diagram with eclipse plugin.
Take a look at this url http://wiki.eclipse.org/MDT-UML2.

This tool, is integrated with eclipse and EMF framework.
UML 2 Tools being EMF based, enables the interoperability between another EMF based tools.
So using the UML 2 Tools I'd like to be provided with:
-> eclipse integrated tool
-> code generation from the model created
-> interoperability between EMF based tools

Thanks.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Try using JUDE for generating your simple Java objects from Class diagrams.

If you do not want to create a EMF-based model, then don't use these EMF-based tools. Since the plugin that you are using is EMF-based, then common sense says that you should not use it if you don't want an EMF model.

I currently use JUDE and it has code generation features....and they are not EMF-based.

I never encountered any bugs in ArgoUML either.
Oleg Boshakov
Greenhorn

Joined: Aug 02, 2010
Posts: 3
I'm not confused with some special code generated from EMF model but I can't understand why assosiations are not generated to EMF (.ecore) from UML (.uml). I have Eclipse Galileo with UML2Tools installed and use UML2 2.2.0 Generator File for generating EMF model from a UML diagram (.genmodel file). The assosiations from .uml file are not generated to .ecore (though I can create them by hand in the .ecore file). What can be the reason of such behaviour? Unfortunately, Eclipse forums are disabled now...
Jan Cumps
Bartender

Joined: Dec 20, 2006
Posts: 2491
    
    8

Welcome to JavaRanch, Oleg


OCUP UML fundamental and ITIL foundation
youtube channel
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
The EMF was originally design to only work with UML diagrams created with Rational Rose. As it evolves, you may be only working with test code or experimental versions when using the Eclipse-based UML tool.
Oleg Boshakov
Greenhorn

Joined: Aug 02, 2010
Posts: 3
I managed to find the answer to my question. Now associations from .uml file are generated to .ecore. The problem was in using an old version of UML2Tools (they are better for Galileo and Helios) and also I had to set the property 'Class' of assiciation ends.
But There's another question now about associations' multiplicity:
Whether or not the multiplicity of EReference in EMF model (.ecore) has any effect on generated Java code?
For example multiplicity 0..3 let me in Java code in runtime add to EList more than 4 objects.
Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Hello Oleg

Oleg Boshakov wrote:I'm not confused with some special code generated from EMF model but I can't understand why assosiations are not generated to EMF (.ecore) from UML (.uml). I have Eclipse Galileo with UML2Tools installed and use UML2 2.2.0 Generator File for generating EMF model from a UML diagram (.genmodel file). The assosiations from .uml file are not generated to .ecore (though I can create them by hand in the .ecore file). What can be the reason of such behaviour? Unfortunately, Eclipse forums are disabled now...


Maybe I don't understand the purpose for EMF model, but could we use this model to create any valid enterprise application with all that stuff (EReference, E....)?

Thank you
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
Maybe I don't understand the purpose for EMF model, but could we use this model to create any valid enterprise application with all that stuff (EReference, E....)?


In order to build applications with EMF-based models, you need to significantly understand the EMF model. Simply generating code with its tools is not sufficient to understand it. Nor is briefly browsing its web pages sufficient.

If you study and learn how EMF works, then you can certainly create enterprise applications with it.

If you don't understand the details and how it works and how to take advantage of the benefits, you cannot create enterprise applications with it.
Oleg Boshakov
Greenhorn

Joined: Aug 02, 2010
Posts: 3
Frank Bennett wrote:
Maybe I don't understand the purpose for EMF model, but could we use this model to create any valid enterprise application with all that stuff (EReference, E....)?


In order to build applications with EMF-based models, you need to significantly understand the EMF model. Simply generating code with its tools is not sufficient to understand it. Nor is briefly browsing its web pages sufficient.

If you study and learn how EMF works, then you can certainly create enterprise applications with it.

If you don't understand the details and how it works and how to take advantage of the benefits, you cannot create enterprise applications with it.


My aim is to create an enterprise application with using UML projecting. So my choiсe was Eclipse UML2Tools. Unfortunately it's not enough to know the UML standards since the instruments used (UML2 Tools) make me deal with EMF to Java code generation. And my questions concerned the tool usibility (Now I found answers for that - for validating the boundaries I have to use EMF Validation Framework). And if I have two properties in UML editor "upper bound" and "lower bound" for an assosiation end so I used to suppose that they must be maintained in the code generated. So it looks weird when it doesn't happen. Of course we can make everything we want if we know assembler and all the computer system details we are programming at. But when we speak about high-level languages and tools (like UML) we mean that we neglect the realisation features and are concentrated on the logical part of the application. That is one of the advantages of using UML.
Jimmy Clark
Ranch Hand

Joined: Apr 16, 2008
Posts: 2187
It is possible to use EMF without using UML or any type of diagrams. However, it is a complex framework, more complex than Struts or Hibernate, in my opinion. Once you get a good understanding of the EMF object model, things flow very smoothly. It is a powerful framework and a good tool to understand.
Adolfo Eloy
Ranch Hand

Joined: Mar 21, 2009
Posts: 146

Frank Bennett wrote:It is possible to use EMF without using UML or any type of diagrams. However, it is a complex framework, more complex than Struts or Hibernate, in my opinion. Once you get a good understanding of the EMF object model, things flow very smoothly. It is a powerful framework and a good tool to understand.


People,
considering all this, I think that for not EMF based software, there is no way to use UML 2 Tools.
So If I don't want to learn all EMF, the best way is looking for any other UML tool.

Do you agree?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: EMF + UML 2 Tools [model to java code]
 
Similar Threads
STAR UML
Eclipse - XMI import of UML
What is EMF ?
A Big JavaRanch Welcome!
EMF Advantages?