Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » Papyrus » Unable to Java round-trip(Unable to reverse engineer Java code generated from UML Class Diagram)
Unable to Java round-trip [message #1775978] Wed, 08 November 2017 18:15 Go to next message
Francesco Sibilla is currently offline Francesco SibillaFriend
Messages: 3
Registered: November 2017
Junior Member
I'm trying to do a round-trip with Papyrus and Java, generating Java code from UML Class Diagram model and back.
But the reverse Java code operation into existing model creates the objects in a different branch in the model tree, thus not updating the existing objects.

Basically operations are the following using default values:
1) create a new Papyrus project named Test with a Class Diagram
2) drop a new package in the diagram
3) drop a new class in the package
4) generate Java code
5) reverse engineer the just created Java class using Java Parser

The issue is that when reverse engineering the class gets back in the model with a different Qualified Name Test::Test::Package1::Class1 instead of Test::Package1::Class1.
So reverse is creating a copy of the class in the model and not updating the existing one.

Any help will be appreciated.

Thanks.
Re: Unable to Java round-trip [message #1776267 is a reply to message #1775978] Tue, 14 November 2017 16:11 Go to previous messageGo to next message
Shuai Li is currently offline Shuai LiFriend
Messages: 18
Registered: March 2016
Location: Paris Saclay, France
Junior Member
This is well-known issue and we really should definitely define a common policy for namespaces during generation and reverse.

In the meantime, you can apply the <<Project>> stereotype from [1] on your root element (the model) so it is not generated. You would then have Package1.Class1 in the Java code, rather than Test.Package1.Class1

During reverse, since there is not Test package in the Java code, the reverse will give you Package1::Class1, which is what you want.

Hope this helps.

[1] https://wiki.eclipse.org/Java_Code_Generation#Common_code_generation_profile
Re: Unable to Java round-trip [message #1776409 is a reply to message #1776267] Thu, 16 November 2017 09:19 Go to previous message
Francesco Sibilla is currently offline Francesco SibillaFriend
Messages: 3
Registered: November 2017
Junior Member
Thanks a lot, it worked.
Previous Topic:Q: How to change the reference of model element using hyperlink property in Papyrus
Next Topic:Imported C++ registered package
Goto Forum:
  


Current Time: Wed Jan 17 23:54:21 GMT 2018

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

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