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();
}
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);
}
}
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;
}
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;
}
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);
}
Aggregations