Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Im new with EMF and need some help
Im new with EMF and need some help [message #1697151] Tue, 02 June 2015 00:21 Go to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Hi , sorry for my bad english..

Im currently reading de EMF book edition 2. I underttand that you model your program and then EMF framework generates code from it. But i have some questions.

1) Can i use EMF to develop an Business aplication?
2) How i model the BD conections??
3) How i model the UI of my program??

Thanks you, Your help would be appreciated, i really need it.

Re: Im new with EMF and need some help [message #1697212 is a reply to message #1697151] Tue, 02 June 2015 13:14 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

Comments below.

On 02/06/2015 3:04 PM, Matias munoz wrote:
> Hi , sorry for my bad english..
>
> Im currently reading de EMF book edition 2. I underttand that you
> model your program and then EMF framework generates code from it. But
> i have some questions.
>
> 1) Can i use EMF to develop an Business aplication?
I'm not sure specifically what that means, but you can use EMF to help
develop any application.
>
> 2) How i model the BD conections??
Sorry, I don't know what a BD connection is...
> 3) How i model the UI of my program??
Maybe you'd use https://www.eclipse.org/ecp/emfforms/
>
> Thanks you, Your help would be appreciated, i really need it.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1697213 is a reply to message #1697212] Tue, 02 June 2015 13:21 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Thanks you!!

Sorry i wrote in spanish BD

BD= Database connection. Should i model the db conections? or just add the code into the generated code.


Re: Im new with EMF and need some help [message #1697218 is a reply to message #1697213] Tue, 02 June 2015 13:34 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

There are https://wiki.eclipse.org/Teneo and
https://wiki.eclipse.org/Texo that would help.

On 02/06/2015 3:21 PM, Matias munoz wrote:
> Thanks you!!
>
> Sorry i wrote in spanish BD
>
> BD= Database connection. Should i model the db conections? or just
> add the code into the generated code.
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1697221 is a reply to message #1697218] Tue, 02 June 2015 13:45 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
thanks you so much!!!
Re: Im new with EMF and need some help [message #1697715 is a reply to message #1697221] Sat, 06 June 2015 20:27 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Hi ed,

I have another question. If im going to develop a simple application, about a hotel. I have some classes in EMF, like room class, client class,etc.
Can you enumerate the steps to have mi final application running (.jar file)??
1) I modeled the program.
2) generate code from it.
3) i will have to manually add some code, right? And regenerate mi model if needed
3)and now? I have tu use emf forms, to build an UI form, i think.
4) which other tool from Eclipse modeling project do i have to use, to finish my program? I also want a mysql database to store al the hotel information

Im asking this to learn the way model driven development is approached in eclipse.
Im new in this, im looking at tutorials. Also i bought your book about EMF, im still reading.
there are not any good book about this, either tutorials
Sorry my bad english.
appreciate your response on this Smile

Matias.
Re: Im new with EMF and need some help [message #1697716 is a reply to message #1697715] Sun, 07 June 2015 05:17 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

Comments below.

On 06/06/2015 10:27 PM, Matias munoz wrote:
> Hi ed,
>
> I have another question. If im going to develop a simple application,
> about a hotel. I have some classes in EMF, like room class, client
> class,etc.
Be sure to give them names that will also look nice in Java, e.g.,
RoomClass.
> Can you enumerate the steps to have mi final application running (.jar
> file)?? 1) I modeled the program.
Well, you modeled the data representation...
> 2) generate code from it.
Including the editor, that's a complete sample application.
> 3) i will have to manually add some code, right? And regenerate mi
> model if needed
Not necessarily.
> 3)and now? I have tu use emf forms, to build an UI form, i think.
If you want it to be pretty, otherwise you'll get something basic like
the Sample Ecore Editor.
> 4) which other tool from Eclipse modeling project do i have to use, to
> finish my program? I also want a mysql database to store al the hotel
> information
Teneo or CDO will be of interest.
>
> Im asking this to learn the way model driven development is approached
> in eclipse.
> Im new in this, im looking at tutorials. Also i bought your book about
> EMF, im still reading.
> there are not any good book about this, either tutorials
No, but it's all open source, so you can always look at how other things
that look cool have been implemented.
> Sorry my bad english.
> appreciate your response on this :)
>
> Matias.
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1697813 is a reply to message #1697151] Mon, 08 June 2015 15:03 Go to previous messageGo to next message
Lorenzo Bettini is currently offline Lorenzo BettiniFriend
Messages: 1812
Registered: July 2009
Location: Firenze, Italy
Senior Member
On 02/06/2015 15:04, Matias munoz wrote:
> Hi , sorry for my bad english..
>
> Im currently reading de EMF book edition 2. I underttand that you model
> your program and then EMF framework generates code from it. But i have
> some questions.
>
> 1) Can i use EMF to develop an Business aplication?
> 2) How i model the BD conections??
> 3) How i model the UI of my program??

Concerning 3) you may want to have a look at

https://www.eclipse.org/emf-parsley/


--
Lorenzo Bettini, PhD in Computer Science, DI, Univ. Torino
HOME: http://www.lorenzobettini.it
Xtext Book:
http://www.packtpub.com/implementing-domain-specific-languages-with-xtext-and-xtend/book


Re: Im new with EMF and need some help [message #1697824 is a reply to message #1697813] Mon, 08 June 2015 16:22 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
thanks you !!! Ed and Lorenzo.
Re: Im new with EMF and need some help [message #1698351 is a reply to message #1697824] Sun, 14 June 2015 20:24 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
hi !!

I have some questions.
1) Can i use this EMF framework to generate Python or C Code, for example? Can i use a transformation plugin like acceleo or ATL to do this job?
2) What is the difference between Codegen and Genmodel.

Thanks you so much!!!!
Im doing a work about EMF for my university, and you helped me a lot!
Re: Im new with EMF and need some help [message #1698362 is a reply to message #1698351] Mon, 15 June 2015 06:31 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

Comments below.

On 14/06/2015 10:24 PM, Matias munoz wrote:
> hi !!
> I have some questions.
> 1) Can i use this EMF framework to generate Python or C Code, for
> example?
Yes.
> Can i use a transformation plugin like acceleo or ATL to do this job?
I suppose so.
> 2) What is the difference between Codegen and Genmodel.
The former is basically the support for JET templates and some Java
helper utilities, e.g., merge support for Java. The later knows about
Ecore and how to generate code specifically from an Ecore model; it uses
the utilities in codegen.
> Thanks you so much!!!!
> Im doing a work about EMF for my university, and you helped me a lot!
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1699246 is a reply to message #1698362] Mon, 22 June 2015 22:45 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Thanks again Ed!!!

So, how can i generate C code or Python code from EMF models? Is there any EMF tool for that? I thought only java code could be generated

[Updated on: Mon, 22 June 2015 22:47]

Report message to a moderator

Re: Im new with EMF and need some help [message #1699299 is a reply to message #1699246] Tue, 23 June 2015 09:52 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

We have examples of how to extend the GenModel's generator adapters, but
all this infrastructure is primarily focused on generated Eclipse
plugins containing mostly Java code. To generate other types of project
containing other types of artifacts is much more challenging. There are
no out-of-the-box examples for that.

On 23/06/2015 12:45 AM, Matias munoz wrote:
> Thanks again Ed!!!
>
> So, how can i generate C code or Python code from EMF models? Is there
> any EMF tool for that?
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1699866 is a reply to message #1699299] Sun, 28 June 2015 02:07 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Hi! i need some little help.

1- i built an Ecore model using the tree-based editor. But i want to edit my models using some kind of class diagram editor.
2- I tried the ecore_diagram diagram, but does not update my ecore model, the same is happening when i edit the .aird class editor.
I know this is a noob question, but I'm trying to solve this for hours. My tree-based editor doesn't Update with the classes On These editors

thanks you again!!!
Re: Im new with EMF and need some help [message #1699871 is a reply to message #1699866] Sun, 28 June 2015 08:08 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

Comments below.


On 28/06/2015 4:07 AM, Matias munoz wrote:
> Hi! i need some little help.
>
> 1- i built an Ecore model using the tree-based editor. But i want to
> edit my models using some kind of class diagram editor. 2- I tried the
> ecore_diagram diagram, but does not update my ecore model, the same is
> happening when i edit the .aird class editor.
Did you save the diagram? If you save it, close the Sample Ecore
Editor, and reopen it, are your changes not there?
> I know this is a noob question, but I'm trying to solve this for
> hours. My tree-based editor doesn't Update with the classes On These
> editors
>
> thanks you again!!!


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1700847 is a reply to message #1699871] Tue, 07 July 2015 14:45 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Hi !
Im working on a comic shop application. I have defined many Ecore classes like client, shop, purchase, item, etc. Should I make a constructor method (Eoperation) for every class, to set all attributes at once ? Or EMF provides something to do this automatically.
For example, in client class i have atributes like name, surname, adress. I want my main program to create a client object. using parameters. Something like
Client client= ComicFactory.eINSTANCE.createClient("matias", "munoz","Saavedra 565");
other way will be (but i want to know if the first example is possible before trying this)
Client client= ComicFactory.eINSTANCE.createClient();
client.setAllAtributes("matias","munoz","Saavedra 565");


Re: Im new with EMF and need some help [message #1700868 is a reply to message #1700847] Tue, 07 July 2015 17:58 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

Comments below.


On 07/07/2015 4:45 PM, Matias munoz wrote:
> Hi !
> Im working on a comic shop application. I have defined many Ecore
> classes like client, shop, purchase, item, etc. Should I make a
> constructor method (Eoperation) for every class, to set all attributes
> at once ?
There is no need, and certainly there's only a default constructor and
no automatic way to generate any other constructor.
> Or EMF provides something to do this automatically.
No.
> For example, in client class i have atributes like name, surname,
> adress. I want my main program to create a client object. using
> parameters. Something like Client client=
> ComicFactory.eINSTANCE.createClient("matias", "munoz","Saavedra 565");
You'd need to create such convenience methods manually.
> other way will be (but i want to know if the first example is possible
> before trying this)
> Client client= ComicFactory.eINSTANCE.createClient();
> client.setAllAtributes("matias","munoz","Saavedra 565");
Better just to use the individual setters, but of course you can
manually add whatever seems handy to you.

Keep in mind not to mess with the default constructor or the default
factory methods; those are needed to support things like deserialization
and copying.
>
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1701136 is a reply to message #1700868] Thu, 09 July 2015 13:39 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
thanks you Ed!!

I have a question. I have a Character class, and an Item Class, i have model a bi-directional reference between them.
Character has a "name" atribute, and Item has a "price" attribute

in my code i create a character and i can use mycharacter.setPrice(). why? that shouldnt be possible. The attribute "price" is defined in the Item class. This is not a super type association.
Or should i model two simple references between them instead of bidirectional reference.

Thanks you, i must send you a gift from argentina!!! you help me a lot
Re: Im new with EMF and need some help [message #1701144 is a reply to message #1701136] Thu, 09 July 2015 13:55 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

Comments below.

On 09/07/2015 3:39 PM, Matias munoz wrote:
> thanks you Ed!!
> I have a question. I have a Character class, and an Item Class, i have
> model a bi-directional reference between them.
> Character has a "name" atribute, and Item has a "price" attribute
>
> in my code i create a character and i can use mycharacter.setPrice().
> why?
What you describe as your model above and what you say here doesn't match.
> that shouldnt be possible.
Not according to what you describe above, but that suggests to me that
your model isn't actually as you described above.
> The attribute "price" is defined in the Item class. This is not a
> super type association.
> Or should i model two simple references between them instead of
> bidirectional reference.
That's not what would cause what you're seeing. What editor are you
using to create your model? What is the name of the reference from
Character to Item?
>
> Thanks you, i must send you a gift from argentina!!! you help me a lot
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1701154 is a reply to message #1701144] Thu, 09 July 2015 14:42 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Hi Ed,
i took a screenshoot.

http://i.imgur.com/KJtq55e.png
Re: Im new with EMF and need some help [message #1701168 is a reply to message #1701154] Thu, 09 July 2015 15:20 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

I suspected you were using the diagram editor. Keep in mind that when
you delete things you can delete it only from the diagram or delete it
from the model. So don't assume that if you don't see something in the
diagram, that it's therefore not actually there in your model. So be
sure to look at the outline of your model or open the *.ecore in the
Sample Ecore Editor. No doubt you'll find a price attribute in the
Ecore model itself. You'll want to delete it from the model if you
don't want it in the model.

On 09/07/2015 4:43 PM, Matias munoz wrote:
> Hi Ed,
> i took a screenshoot.
>
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1701323 is a reply to message #1701168] Sat, 11 July 2015 15:33 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Now works! thanks Ed!

I want to ask you a simple question. Im reading your book, and in one sentence (page 328, one-way references) you explained that a one-way reference has a get and a set method
But in mi code, only a get is generated. Maybe is because i can set using getaReference().add(); ?? Or maybe is because EMF was updated and now only a get method is generated
Re: Im new with EMF and need some help [message #1701325 is a reply to message #1701323] Sat, 11 July 2015 16:41 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

Yes a setter is generated only for a single-valued reference. For a
multi-valued reference an EList is returns so the full list API is
available for modifying the state, as well as the move methods provided
by EList.

On 11/07/2015 5:33 PM, Matias munoz wrote:
> Now works! thanks Ed!
>
> I want to ask you a simple question. Im reading your book, and in one
> sentence (page 328, one-way references) you explained that a one-way
> reference has a get and a set method
> But in mi code, only a get is generated. Maybe is because i can set
> using getaReference().add(); ?? Or maybe is because EMF was updated
> and now only a get method is generated
>


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1701338 is a reply to message #1701325] Sat, 11 July 2015 23:41 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
thanks you so much Ed,

I want to ask you something else,

1) When i model in EMF, i can add restrictions to my data model. For example, i can add a Reference with 0..2 multiplicity, if that reference has 3 elements instead of 2, is an invalid situation, or an error.
I Know that using the Ecore Sample Editor i can right click and validate, to know if there is something wrong. But how can i validate from my code? Is there any method that check all instances of my objects and references, and shows if something is invalid ?

2) Is possible to use my model and the Ecore sample editor, in a standalone application? I want to create a .jar file, that opens my editor, load and edit instances of my model, and finally save them, in a persistance file.



Sorry for my english
and thanks again for your time helping me

[Updated on: Sun, 12 July 2015 13:17]

Report message to a moderator

Re: Im new with EMF and need some help [message #1701356 is a reply to message #1701338] Sun, 12 July 2015 14:25 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33108
Registered: July 2009
Senior Member
Matias,

Comments below.

On 12/07/2015 1:41 AM, Matias munoz wrote:
> thanks you so much Ed,
>
> I want to ask you something else,
> When i model in EMF, i can add restrictions to my data model. For
> example, i can add a Reference with 0..2 multiplicity, if that
> reference has 3 elements instead of 2, is an invalid situation, or an
> error.
It's checked by the validator, it's not a state that's prevented from
existing.
> I Know that using the Ecore Sample Editor i can right click and
> validate, to know if there is something wrong. But how can i validate
> from my code?
org.eclipse.emf.ecore.util.Diagnostician.validate(EObject)
> Is there any method that check all instances of my objects and
> references, and shows if something is invalid ?
You can look at
org.eclipse.emf.edit.ui.action.ValidateAction.validate(IProgressMonitor)
to see how it visits multiple objects to validate them all.
>
> Sorry my ape english


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Im new with EMF and need some help [message #1701486 is a reply to message #1701356] Mon, 13 July 2015 15:57 Go to previous messageGo to next message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
Hi ed,

I dont know what im doing wrong. It keeps showing a null pointer excelption on resource.getcontents().add(unaremera)

http://i.imgur.com/0MF8VFy.png
Re: Im new with EMF and need some help [message #1701487 is a reply to message #1701486] Mon, 13 July 2015 16:08 Go to previous message
Matias munoz is currently offline Matias munozFriend
Messages: 15
Registered: June 2015
Junior Member
I solved this, i wass missing the

Resource.Factory.Registry.INSTANCE.getExtensionToFactoryMap().put("xml", new XMLResourceFactoryImpl());

Smile Very Happy
Previous Topic:[CDO] Finding commits matching specific predicate
Next Topic:[CDO] Authenticate against a LDAP server
Goto Forum:
  


Current Time: Tue Mar 19 10:25:07 GMT 2024

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

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

Back to the top