Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » MoDisco » How to manipulate java models once parsed JavaDiscoverer
How to manipulate java models once parsed JavaDiscoverer [message #670986] Mon, 16 May 2011 13:02 Go to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi to all,

I want to implement a converter from junit 3 to junit 4.
So I have discoverd a model and can step through ist.
Now I want to to some modifications with my model.

For example, I want to add some annotations, but don't know how to add this programmatically, because not knowing how I get the type itself from a FQN, to add thisone to the EList afterwards.

Can you please help me?

Thanks in advance

Markus

[Updated on: Mon, 16 May 2011 17:16]

Report message to a moderator

Re: How to manipulate java models once parsed JavaDiscoverer [message #671075 is a reply to message #670986] Mon, 16 May 2011 17:28 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Mark,

thank you for your interest in MoDisco tools.
You may retrieve the "org.eclipse.gmt.modisco.java.internal.util.JavaUtil" class from SVN. It is an internal API, but you can have a look into the implementation of the service "getNamedElementByQualifiedName" for retrieving on type from its fqn.

Migration from JUnit 3 to JUnit 4 was one demo subject at eclipsecon 2010 for MoDisco (http://www.slideshare.net/fmadiot/modisco-eclipsecon2010). Just like your approach, the demo component proposes a 3-step process : discover one Java model, transform the model (adding annotations) and generating new Java code. Unfortunately, the code was not contributed into MoDisco SVN and it is now a little bit deprecated (frameworks have evolved). However if you are interested we may give some access to this demo code.

Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Re: How to manipulate java models once parsed JavaDiscoverer [message #671153 is a reply to message #671075] Mon, 16 May 2011 22:23 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi Fabien,

thank you for your quick answer.
This junit3->junit4 is only the first usecase we'll need modisco for, because in the near feature we want to replace our own persistence layer with JPA, I think we'll use it again Smile

OK, thanks for your hint on JavaUtil, that's exactly what I need

But it would be evennice, if you could give me access to the demo code, til I think it's even faster to adapt this code than implement it from stratch....

Thanks in advance,

Markus
Re: How to manipulate java models once parsed JavaDiscoverer [message #671383 is a reply to message #671153] Tue, 17 May 2011 16:57 Go to previous messageGo to next message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Markus,

is it possible for you to enable private messaging on your forum account settings ?

Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Re: How to manipulate java models once parsed JavaDiscoverer [message #671948 is a reply to message #671383] Thu, 19 May 2011 12:34 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Ok, done,

Markus
Re: How to manipulate java models once parsed JavaDiscoverer [message #691480 is a reply to message #671948] Fri, 01 July 2011 14:28 Go to previous messageGo to next message
Gregoire Dupe is currently offline Gregoire DupeFriend
Messages: 75
Registered: September 2009
Location: France
Member
Hello,

The JUnit example source code is available at http://www.mia-software.com/html/miaStudio/indexOfMiaStudio.php?lang=en&theme=download-modisco-examples

Regards,
Gregoire
Re: How to manipulate java models once parsed JavaDiscoverer [message #788138 is a reply to message #691480] Wed, 01 February 2012 11:48 Go to previous messageGo to next message
Markus Oley is currently offline Markus OleyFriend
Messages: 304
Registered: July 2009
Location: Germany
Senior Member
Hi Gregoire,

a lot of time gone by, but now I have to finish my task to convert junit3 to junit4.

I migrated to eclipse indigo, and all is working fine,
only one thing I have to fix....

The formatting of the java-code, that results from generating the migrated model is completely different to the origin format....




Before:

/**
* Transferiert eine Workflowsession von User2 auf Frontend2 zu User1 auf Frontend1.
* @throws Exception wenn es doch nicht geklappt hat.
*/
public void testTransfer() throws Exception {
// Sessions erstellen
final FrontendSessionIF fs1 = sessionService.newFrontendSession("fs1");
final FrontendSessionIF fs2 = sessionService.newFrontendSession("fs2");
final UserSessionIF us1 = sessionService.newUserSession(fs1, "rs1");


Afterwards:

/**
* Transferiert eine Workflowsession von User2 auf Frontend2 zu User1 auf Frontend1.
* @throws Exception wenn es doch nicht geklappt hat.
*/
@Test
public void testTransfer() throws Exception{
// Sessions erstellen
final FrontendSessionIF
fs1
=sessionService.newFrontendSession("fs1");
final FrontendSessionIF
fs2



Could you give me please an advice, how to reduce the differences between both?
Best solution would be, that the format is identical beside the changes done from converting.
If this is not possible, I want to format it in a way, that is better than the formatting done.

Would be very kind, if you could help me
Best regards
Markus
Re: How to manipulate java models once parsed JavaDiscoverer [message #789818 is a reply to message #788138] Fri, 03 February 2012 12:54 Go to previous message
Fabien Giquel is currently offline Fabien GiquelFriend
Messages: 147
Registered: July 2009
Senior Member
Hi Markus,

"Best solution would be, that the format is identical beside the changes done from converting.
If this is not possible, I want to format it in a way, that is better than the formatting done. "


In fact, java model does not contain orginal format (spaces, tab, line feed) informations, and is not linked to original java files (whereas
However the java generation module (from org.eclipse.gmt.modisco.java.generation) has been completed in order to automatically apply some eclipse jdt/java format (see GenerateJavaExtended class and related) at the end of generation. Obviously in your case it did not work. It may happen for instance if you use an acceleo generation launch configuration with "Java Application" runner instead of "Acceleo plugin Application" one (problem of classpath not completed with the required related java libraries).

Hoping it will help you.
Fabien.


----------------------------------------------------
Fabien GIQUEL
R&D Engineer
Mia-Software
rue Nina Simone
44000 NANTES
----------------------------------------------------
Previous Topic:Generate JSP/HTML from JSP Model
Next Topic:where can I learn ATL for handling java metamodel
Goto Forum:
  


Current Time: Thu Apr 25 01:49:28 GMT 2024

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

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

Back to the top