Class CySession

java.lang.Object
org.cytoscape.session.CySession

public final class CySession extends Object
A session is an immutable snapshot of the data contents of Cytoscape. Sessions are only meant for saving and restoring the state of Cytoscape and are not meant to be used interactively for anything besides writing, reading, and restoring from session files.
Using the data returned from the various methods in a CySession object should be sufficient to recreate all aspects of Cytoscape at the time the session was created.
Creating an instance of CySession is done following the builder pattern. For example, the following code creates a session that only includes a list of networkViews and Cytoscape properties, but nothing else.
 CySession session = new CySession.Builder().networkViews(viewList).cytoscapeProperties(cyProps).build();
 


Cytoscape Backwards Compatibility (Final Class): This class is final and therefore can't be extended by users. This means that we may add methods for minor version updates. Methods will only be removed for major version updates.

Module: session-api

To use this in your app, include the following dependency in your POM:

<dependency>
    <groupId>org.cytoscape</groupId>
    <artifactId>session-api</artifactId>
</dependency>
  • Method Details

    • getNetworks

      public Set<CyNetwork> getNetworks()
      Returns a set of all CyNetwork objects contained in this Session.
      Returns:
      A set of all CyNetwork objects contained in this Session.
    • getNetworkViews

      public Set<CyNetworkView> getNetworkViews()
      Returns a set of all CyNetworkView objects contained in this Session.
      Returns:
      A set of all CyNetworkView objects contained in this Session.
    • getTableViews

      public Set<CyTableViewMetadata> getTableViews()
      Returns a set of all CyTableView objects contained in this Session.
      Returns:
      A set of all CyTableView objects contained in this Session.
    • getTables

      public Set<CyTableMetadata> getTables()
      Returns a set of all CyTable objects contained in this Session.
      Returns:
      A set of all CyTable objects contained in this Session.
    • getViewVisualStyleMap

      public Map<CyNetworkView,String> getViewVisualStyleMap()
      Returns a map of CyNetworkViews to the names of the VisualStyle applied to that network view in this session.
      Returns:
      A map of CyNetworkViews to the names of the VisualStyle applied to that network view in this session.
    • getProperties

      public Set<CyProperty<?>> getProperties()
      Note: This is NOT the correct way for Apps to access CyProperty settings. Creating a CySession object is very resource intensive and is not required for accessing CyProperty objects. Instead acquire the CyPropery object as a service in the CyActivator, eg...
       CyProperty<Properties> cyProperty = getService(bc, CyProperty.class, "(cyPropertyName=cytoscape3.props)");
       
      Returns a set of CyProperty objects defined for this session.
      Returns:
      A set of session related CyProperty objects. defined for this session.

      Cytoscape Backwards Compatibility (DO NOT USE): This method may change or be removed in future minor version upgrades of Cytoscape. It is not safe for Apps to call or override this method.
    • getVisualStyles

      public Set<VisualStyle> getVisualStyles()
      Returns a set containing all network VisualStyles defined for this session.
      Returns:
      A Set of VisualStyle objects
    • getTableStyles

      public Set<VisualStyle> getTableStyles()
      Returns a set containing all table VisualStyles defined for this session.
      Returns:
      A Set of VisualStyle objects
    • getColumnStyleAssociations

      public Set<StyleAssociation> getColumnStyleAssociations()
      Returns a set containing all column style associations defined for this session.
      Returns:
      A Set of StyleAssociation objects
    • getAppFileListMap

      public Map<String,List<File>> getAppFileListMap()
      Returns a map of app names to lists of File objects that are stored as part of the session for the specified app.
      Returns:
      A map of app names to lists of File objects that are stored as part of the session for the specified app.
    • getObject

      public <T extends CyIdentifiable> T getObject(Long oldSUID, Class<T> type)
      When a session is restored, Cytoscape automatically generates new SUIDs. This method returns an object (CyNode, CyEdge, CyNetwork or CyNetworkView) given its former SUID.
      Use this method if the version of the loaded session is 3.0 or higher.
      Parameters:
      oldSUID - The former SUID.
      type - The Class of the object to be returned (CyNode, CyEdge, CyNetwork or CyNetworkView).
      Returns:
      An object (CyNode, CyEdge, CyNetwork or CyNetworkView) given its former SUID.
    • getObject

      public <T extends CyIdentifiable> T getObject(String oldId, Class<T> type)
      When a session is restored, Cytoscape automatically generates new SUIDs. This method returns an object (CyNode, CyEdge, CyNetwork or CyNetworkView) given its former identifier.
      Use this method if the version of the loaded session is 2.x, because older versions of Cytoscape save String IDs, such as node names and the network titles.
      Parameters:
      oldId - The former ID, from Cytocape versions prior than 3.0.
      type - The Class of the object to be returned (CyNode, CyEdge, CyNetwork or CyNetworkView).
      Returns:
      An object (CyNode, CyEdge, CyNetwork or CyNetworkView) given its former identifier.