Search in sources :

Example 11 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class Cy3SessionReaderImplTest method setUp.

@Before
public void setUp() {
    InputStream is = mock(InputStream.class);
    GroupUtil groupUtil = mock(GroupUtil.class);
    SUIDUpdater suidUpdater = mock(SUIDUpdater.class);
    CyNetworkReaderManager netReaderMgr = mock(CyNetworkReaderManager.class);
    CyPropertyReaderManager propReaderMgr = mock(CyPropertyReaderManager.class);
    VizmapReaderManager vizmapReaderMgr = mock(VizmapReaderManager.class);
    CSVCyReaderFactory csvCyReaderFactory = mock(CSVCyReaderFactory.class);
    CyNetworkTableManager netTblMgr = mock(CyNetworkTableManager.class);
    CyRootNetworkManager rootNetMgr = mock(CyRootNetworkManager.class);
    EquationCompiler compiler = mock(EquationCompiler.class);
    CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    when(serviceRegistrar.getService(CyNetworkTableManager.class)).thenReturn(netTblMgr);
    when(serviceRegistrar.getService(CyRootNetworkManager.class)).thenReturn(rootNetMgr);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    ReadCache cache = new ReadCache(serviceRegistrar);
    reader = new Cy3SessionReaderImpl(is, cache, groupUtil, suidUpdater, netReaderMgr, propReaderMgr, vizmapReaderMgr, csvCyReaderFactory, serviceRegistrar);
    tblTestSupport = new TableTestSupport();
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) InputStream(java.io.InputStream) CyNetworkReaderManager(org.cytoscape.io.read.CyNetworkReaderManager) ReadCache(org.cytoscape.io.internal.util.ReadCache) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) GroupUtil(org.cytoscape.io.internal.util.GroupUtil) VizmapReaderManager(org.cytoscape.io.read.VizmapReaderManager) CyPropertyReaderManager(org.cytoscape.io.read.CyPropertyReaderManager) TableTestSupport(org.cytoscape.model.TableTestSupport) SUIDUpdater(org.cytoscape.io.internal.util.SUIDUpdater) CSVCyReaderFactory(org.cytoscape.io.internal.read.datatable.CSVCyReaderFactory) EquationCompiler(org.cytoscape.equations.EquationCompiler) Before(org.junit.Before)

Example 12 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method restoreTables.

private void restoreTables(final CySession sess) {
    final Set<CyTable> allTables = new HashSet<>();
    // Register all tables sent through the CySession, if not already registered
    for (final CyTableMetadata metadata : sess.getTables()) {
        allTables.add(metadata.getTable());
    }
    // There may be other network tables in the CyNetworkTableManager that were not serialized in the session file
    // (e.g. Table Facades), so it's necessary to add them to CyTableManager as well
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    final CyRootNetworkManager rootNetMgr = serviceRegistrar.getService(CyRootNetworkManager.class);
    for (final CyNetwork net : sess.getNetworks()) {
        allTables.addAll(netTblMgr.getTables(net, CyNetwork.class).values());
        allTables.addAll(netTblMgr.getTables(net, CyNode.class).values());
        allTables.addAll(netTblMgr.getTables(net, CyEdge.class).values());
        if (!(net instanceof CyRootNetwork)) {
            final CyRootNetwork root = rootNetMgr.getRootNetwork(net);
            allTables.addAll(netTblMgr.getTables(root, CyNetwork.class).values());
            allTables.addAll(netTblMgr.getTables(root, CyNode.class).values());
            allTables.addAll(netTblMgr.getTables(root, CyEdge.class).values());
        }
    }
    // Register all tables sent through the CySession, if not already registered
    final CyTableManager tblMgr = serviceRegistrar.getService(CyTableManager.class);
    for (final CyTable tbl : allTables) {
        if (tblMgr.getTable(tbl.getSUID()) == null)
            tblMgr.addTable(tbl);
    }
}
Also used : CyTable(org.cytoscape.model.CyTable) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyRootNetworkManager(org.cytoscape.model.subnetwork.CyRootNetworkManager) CyTableManager(org.cytoscape.model.CyTableManager) CyTableMetadata(org.cytoscape.model.CyTableMetadata) CyNetwork(org.cytoscape.model.CyNetwork) HashSet(java.util.HashSet) CyRootNetwork(org.cytoscape.model.subnetwork.CyRootNetwork)

Example 13 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method createNetworkTablesMetadata.

private Set<CyTableMetadata> createNetworkTablesMetadata(final Set<CyNetwork> networks) {
    final Set<CyTableMetadata> result = new HashSet<>();
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    // Create the metadata object for each network table
    for (final CyNetwork network : networks) {
        for (final Class<? extends CyIdentifiable> type : TYPES) {
            final Map<String, CyTable> tableMap = netTblMgr.getTables(network, type);
            for (final Entry<String, CyTable> entry : tableMap.entrySet()) {
                final CyTable tbl = entry.getValue();
                if (tbl.getSavePolicy() == SavePolicy.SESSION_FILE) {
                    final String namespace = entry.getKey();
                    final CyTableMetadata metadata = new CyTableMetadataImpl.CyTableMetadataBuilder().setCyTable(tbl).setNamespace(namespace).setType(type).setNetwork(network).build();
                    result.add(metadata);
                }
            }
        }
    }
    return result;
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyTable(org.cytoscape.model.CyTable) CyTableMetadata(org.cytoscape.model.CyTableMetadata) CyNetwork(org.cytoscape.model.CyNetwork) HashSet(java.util.HashSet)

Example 14 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class CySessionManagerImpl method getSerializableNetworks.

private Set<CyNetwork> getSerializableNetworks() {
    final Set<CyNetwork> serializableNetworks = new HashSet<>();
    final CyNetworkTableManager netTblMgr = serviceRegistrar.getService(CyNetworkTableManager.class);
    final Set<CyNetwork> allNetworks = netTblMgr.getNetworkSet();
    for (final CyNetwork net : allNetworks) {
        if (net.getSavePolicy() == SavePolicy.SESSION_FILE)
            serializableNetworks.add(net);
    }
    return serializableNetworks;
}
Also used : CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyNetwork(org.cytoscape.model.CyNetwork) HashSet(java.util.HashSet)

Example 15 with CyNetworkTableManager

use of org.cytoscape.model.CyNetworkTableManager in project cytoscape-impl by cytoscape.

the class C2DEditor method setValue.

@Override
@SuppressWarnings({ "unchecked", "rawtypes" })
public void setValue(final Object value) {
    if (value instanceof ContinuousMapping == false)
        throw new IllegalArgumentException("Value should be ContinuousMapping: this is " + value);
    final CyApplicationManager appMgr = servicesUtil.get(CyApplicationManager.class);
    final CyNetwork currentNetwork = appMgr.getCurrentNetwork();
    if (currentNetwork == null)
        return;
    ContinuousMapping<?, ?> mTest = (ContinuousMapping<?, ?>) value;
    // TODO: error chekcing
    mapping = (ContinuousMapping<Number, V>) value;
    Class<? extends CyIdentifiable> type = (Class<? extends CyIdentifiable>) mapping.getVisualProperty().getTargetDataType();
    final CyNetworkTableManager netTblMgr = servicesUtil.get(CyNetworkTableManager.class);
    final CyTable attr = netTblMgr.getTable(appMgr.getCurrentNetwork(), type, CyNetwork.DEFAULT_ATTRS);
    final VisualMappingManager vmMgr = servicesUtil.get(VisualMappingManager.class);
    editorPanel = new C2DMappingEditorPanel(vmMgr.getCurrentVisualStyle(), mapping, attr, editorManager, servicesUtil);
}
Also used : ContinuousMapping(org.cytoscape.view.vizmap.mappings.ContinuousMapping) CyNetworkTableManager(org.cytoscape.model.CyNetworkTableManager) CyNetwork(org.cytoscape.model.CyNetwork) CyApplicationManager(org.cytoscape.application.CyApplicationManager) CyTable(org.cytoscape.model.CyTable) VisualMappingManager(org.cytoscape.view.vizmap.VisualMappingManager) CyIdentifiable(org.cytoscape.model.CyIdentifiable)

Aggregations

CyNetworkTableManager (org.cytoscape.model.CyNetworkTableManager)19 CyNetwork (org.cytoscape.model.CyNetwork)15 CyTable (org.cytoscape.model.CyTable)13 CyApplicationManager (org.cytoscape.application.CyApplicationManager)8 HashSet (java.util.HashSet)7 VisualMappingManager (org.cytoscape.view.vizmap.VisualMappingManager)6 CyIdentifiable (org.cytoscape.model.CyIdentifiable)5 CyRootNetworkManager (org.cytoscape.model.subnetwork.CyRootNetworkManager)4 CyNetworkViewManager (org.cytoscape.view.model.CyNetworkViewManager)4 ContinuousMapping (org.cytoscape.view.vizmap.mappings.ContinuousMapping)4 RowSetRecord (org.cytoscape.model.events.RowSetRecord)3 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)3 CyNetworkView (org.cytoscape.view.model.CyNetworkView)3 HashMap (java.util.HashMap)2 LinkedHashSet (java.util.LinkedHashSet)2 Set (java.util.Set)2 WeakHashMap (java.util.WeakHashMap)2 CyGroupFactory (org.cytoscape.group.CyGroupFactory)2 CyGroupManager (org.cytoscape.group.CyGroupManager)2 CyColumn (org.cytoscape.model.CyColumn)2