use of org.eclipse.sirius.viewpoint.DAnalysisSessionEObject in project InformationSystem by ObeoNetwork.
the class UIConfigurationServices method getSessionFromAnalysis.
/**
* Retrieves the session corresponding to the specified viewpoint analysis
* @param analysis Viewpoint analysis
* @return Viewpoint session or null if no corresponding session has been found
*/
private static Session getSessionFromAnalysis(DAnalysis analysis) {
// Retrieve the session using EObjectQuery
EObjectQuery query = new EObjectQuery(analysis);
Session existingSession = query.getSession();
if (existingSession != null) {
return existingSession;
}
// If it did not work, let's inspect the existing sessions
for (Session session : SessionManager.INSTANCE.getSessions()) {
if (session instanceof DAnalysisSessionEObject) {
DAnalysisSessionEObject analysisSession = (DAnalysisSessionEObject) session;
for (DAnalysis sessionAnalysis : analysisSession.getAnalyses()) {
if (EcoreUtil.equals(analysis, sessionAnalysis)) {
return session;
}
}
}
}
return null;
}
Aggregations