Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Eclipse Projects » Sirius » Loading Representation File(s)(This topic is about creating sirius sesssions.)
Loading Representation File(s) [message #1781806] Tue, 13 February 2018 12:13 Go to next message
Muhammad Abbas is currently offline Muhammad AbbasFriend
Messages: 5
Registered: January 2018
Junior Member
Hi,
I want to generate documentation for my Capella project using my own code. I created a plugin project which loads the Capella semantic File (.melodymodeller). The fact is I only have access to elements of the model with no mapping information to relate the element to a diagram. For the above mentioned reason I need to load the representation file.
I am using the following code to create Session:

name=projectName; // value is coming from UI
	airdFile=projectName+".aird";
	melodyFile=projectName+".melodymodeller";
	metaFile=projectName+".afm";
	Object capellaModelObj=loadModel("/"+projectName+"/"+melodyFile); // this method loads semantic file correctly
	ProjectImpl capellaProject=(ProjectImpl) capellaModelObj;
	System.out.println("[DocGenerator] Melody File Loaded for: "+ capellaProject.getName());
        Session session = SessionManager.INSTANCE.getSession(URI.createURI(projectName+"/"+airdFile), new NullProgressMonitor());
	DAnalysis root=(DAnalysis)session.getSessionResource().getContents().get(0);
	DView dView = root.getOwnedViews().get(0);


The code above returns a session but the following line causes NullPointerException:

DView dView = root.getOwnedViews().get(0);


I debugged the code and found that the session object returns a resource with empty DAnalysis Object. I have attached my representation and semantic files to the post.


Do anyone know how can I have a resource with complete representation data?
Re: Loading Representation File(s) [message #1781821 is a reply to message #1781806] Tue, 13 February 2018 15:05 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 482
Registered: July 2009
Location: Nantes, France
Senior Member
Hi Muhammad,

You should load only the Sirius session, it will load all the necessaray resources (semantic, representation, ... ) in the same resource set (and in the same way than Capella if you open the aird by double clic or with the contextual menu)

After calling
Session session = SessionManager.INSTANCE.getSession(URI.createURI(projectName+"/"+airdFile), new NullProgressMonitor());

You need to call session.open()

Note that you do not need to call your loadModel method (it would load the semantic model in your own resourceSet without any reference to/from the session)

Note also that if your Capella project is open, SessionManager.INSTANCE.getSession() will return the loaded session, and you will manipulate the same object than the workbench. In this case, calling session.open will do nothing, but you should avoid to close it at the end of your generation to keep the session in the same state than before your action.

Regards


Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

Join the Sirius community at SiriusCon. Register for free: Nov. 9th Paris
http://www.siriuscon.org/
Re: Loading Representation File(s) [message #1781845 is a reply to message #1781821] Tue, 13 February 2018 20:19 Go to previous messageGo to next message
Muhammad Abbas is currently offline Muhammad AbbasFriend
Messages: 5
Registered: January 2018
Junior Member
Hey Thank you so much for your reply. I did what you said and still I have empty views. As you can see in my debugger (Attached image).

index.php/fa/32087/0/

Here is the resultant code.

name=projectName;
	airdFile=projectName+".aird";
	melodyFile=projectName+".melodymodeller";
	metaFile=projectName+".afm";
	//Object capellaModelObj=loadModel("/"+projectName+"/"+melodyFile);
	//ProjectImpl capellaProject=(ProjectImpl) capellaModelObj;
	//System.out.println("[TestGenerator] Melody File Loaded for: "+ capellaProject.getName());
	Session session = SessionManager.INSTANCE.getSession(URI.createURI(projectName+"/"+airdFile), new NullProgressMonitor());
	session.open(new NullProgressMonitor());
	DAnalysis root=(DAnalysis)session.getSessionResource().getContents().get(0);
	DView dView = root.getOwnedViews().get(0);
  • Attachment: debugger.png
    (Size: 152.18KB, Downloaded 335 times)
Re: Loading Representation File(s) [message #1781900 is a reply to message #1781845] Wed, 14 February 2018 12:32 Go to previous messageGo to next message
Maxime Porhel is currently offline Maxime PorhelFriend
Messages: 482
Registered: July 2009
Location: Nantes, France
Senior Member
Hi,

Note that you will have a DView for each activated Viewpoint and then each DView will contain a DRepresentation or a DRepresentationDescriptor regarding the Sirius version used to create the aird.

Note that the current behavior of the SessionFactory is to create the aird file if the uri you pass to the session manager does not exits. As the aird your provide is not empty and as in debug you see a DAnalysis with an empty DView collection, it seems that the uri you give to the session manager is not the one you expect : you should check the construction of the aird file uri. You should look at org.eclipse.emf.common.util.URI.createPlatformResourceURI(String, boolean) instead of createURI.

For example, with file an org.eclipse.core.resources.IFile:
String path = file.getFullPath().toOSString();
URI uri = URI.createPlatformResourceURI(path, true);


Regards



Maxime Porhel - Obeo

Need training or professional services for Sirius?
http://www.obeodesigner.com/sirius

Join the Sirius community at SiriusCon. Register for free: Nov. 9th Paris
http://www.siriuscon.org/
Re: Loading Representation File(s) [message #1781950 is a reply to message #1781900] Thu, 15 February 2018 04:02 Go to previous message
Muhammad Abbas is currently offline Muhammad AbbasFriend
Messages: 5
Registered: January 2018
Junior Member
Thanks a lot, it worked. The URI I was passing to the SessionManager was not a platform URI.

Regards,
Previous Topic:Unable to assign a Domain Class
Next Topic:Duplicate
Goto Forum:
  


Current Time: Thu Apr 09 21:49:06 GMT 2020

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

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

Back to the top