Search in sources :

Example 1 with DAnalysisSessionEObject

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;
}
Also used : EObjectQuery(org.eclipse.sirius.business.api.query.EObjectQuery) DAnalysisSessionEObject(org.eclipse.sirius.viewpoint.DAnalysisSessionEObject) DAnalysis(org.eclipse.sirius.viewpoint.DAnalysis) Session(org.eclipse.sirius.business.api.session.Session)

Aggregations

EObjectQuery (org.eclipse.sirius.business.api.query.EObjectQuery)1 Session (org.eclipse.sirius.business.api.session.Session)1 DAnalysis (org.eclipse.sirius.viewpoint.DAnalysis)1 DAnalysisSessionEObject (org.eclipse.sirius.viewpoint.DAnalysisSessionEObject)1