Loading Representation File(s) [message #1781806] |
Tue, 13 February 2018 07:13  |
Eclipse User |
|
|
|
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 10:05   |
Eclipse User |
|
|
|
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
|
|
|
|
|
|
Powered by
FUDForum. Page generated in 0.46238 seconds