Search in sources :

Example 6 with CyNetworkTableManagerImpl

use of org.cytoscape.model.internal.CyNetworkTableManagerImpl in project cytoscape-impl by cytoscape.

the class TestCyNetworkFactory method getPrivateRootInstance.

public static CyRootNetwork getPrivateRootInstance(SavePolicy policy) {
    DummyCyEventHelper deh = new DummyCyEventHelper();
    CyServiceRegistrar serviceRegistrar = mockCyServiceRegistrar(deh);
    CyNetworkTableManagerImpl ntm = new CyNetworkTableManagerImpl();
    CyTableManagerImpl tm = new CyTableManagerImpl(ntm, new CyNetworkManagerImpl(serviceRegistrar), serviceRegistrar);
    CyRootNetworkImpl ar = new CyRootNetworkImpl(deh, tm, ntm, new CyTableFactoryImpl(deh, serviceRegistrar), serviceRegistrar, false, policy);
    return ar;
}
Also used : CyTableFactoryImpl(org.cytoscape.model.internal.CyTableFactoryImpl) CyNetworkManagerImpl(org.cytoscape.model.internal.CyNetworkManagerImpl) CyNetworkTableManagerImpl(org.cytoscape.model.internal.CyNetworkTableManagerImpl) CyRootNetworkImpl(org.cytoscape.model.internal.CyRootNetworkImpl) DummyCyEventHelper(org.cytoscape.event.DummyCyEventHelper) CyTableManagerImpl(org.cytoscape.model.internal.CyTableManagerImpl) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar)

Example 7 with CyNetworkTableManagerImpl

use of org.cytoscape.model.internal.CyNetworkTableManagerImpl in project cytoscape-impl by cytoscape.

the class CyTableManagerTest method setUp.

@Before
public void setUp() {
    final Interpreter interpreter = new InterpreterImpl();
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    when(serviceRegistrar.getService(Interpreter.class)).thenReturn(interpreter);
    networkTableMgr = new CyNetworkTableManagerImpl();
    networkManager = new CyNetworkManagerImpl(serviceRegistrar);
    mgr = new CyTableManagerImpl(networkTableMgr, networkManager, serviceRegistrar);
    assertNotNull(mgr);
    assertEquals(0, mgr.getAllTables(true).size());
    final CyServiceRegistrar serviceRegistrar = mock(CyServiceRegistrar.class);
    final CyTableFactoryImpl tableFactory = new CyTableFactoryImpl(eventHelper, serviceRegistrar);
    goodNetwork = new CyRootNetworkImpl(eventHelper, (CyTableManagerImpl) mgr, networkTableMgr, tableFactory, serviceRegistrar, true, SavePolicy.DO_NOT_SAVE).getBaseNetwork();
    networkManager.addNetwork(goodNetwork);
    globalTable = tableFactory.createTable("test table", CyIdentifiable.SUID, Long.class, true, true);
    assertNotNull(globalTable);
    assertNotNull(goodNetwork);
    assertEquals(1, networkManager.getNetworkSet().size());
}
Also used : CyTableFactoryImpl(org.cytoscape.model.internal.CyTableFactoryImpl) Interpreter(org.cytoscape.equations.Interpreter) CyNetworkManagerImpl(org.cytoscape.model.internal.CyNetworkManagerImpl) CyNetworkTableManagerImpl(org.cytoscape.model.internal.CyNetworkTableManagerImpl) CyRootNetworkImpl(org.cytoscape.model.internal.CyRootNetworkImpl) InterpreterImpl(org.cytoscape.equations.internal.interpreter.InterpreterImpl) CyTableManagerImpl(org.cytoscape.model.internal.CyTableManagerImpl) CyServiceRegistrar(org.cytoscape.service.util.CyServiceRegistrar) Before(org.junit.Before)

Example 8 with CyNetworkTableManagerImpl

use of org.cytoscape.model.internal.CyNetworkTableManagerImpl in project cytoscape-impl by cytoscape.

the class TableTestSupportTest method setUp.

@Before
public void setUp() {
    eventHelper = support.getDummyCyEventHelper();
    EquationCompiler compiler = new EquationCompilerImpl(new EquationParserImpl(serviceRegistrar));
    when(serviceRegistrar.getService(CyEventHelper.class)).thenReturn(eventHelper);
    when(serviceRegistrar.getService(CyNetworkNaming.class)).thenReturn(namingUtil);
    when(serviceRegistrar.getService(EquationCompiler.class)).thenReturn(compiler);
    table = factory.createTable(Integer.toString(rand.nextInt(10000)), CyIdentifiable.SUID, Long.class, false, true);
    table2 = factory.createTable(Integer.toString(rand.nextInt(10000)), CyIdentifiable.SUID, Long.class, false, true);
    attrs = table.getRow(1l);
    CyTableManagerImpl tblMgr = new CyTableManagerImpl(new CyNetworkTableManagerImpl(), new CyNetworkManagerImpl(serviceRegistrar), serviceRegistrar);
    tblMgr.addTable(table);
    ((CyTableImpl) table).handleEvent(new TableAddedEvent(tblMgr, table));
    tblMgr.addTable(table2);
    ((CyTableImpl) table2).handleEvent(new TableAddedEvent(tblMgr, table2));
}
Also used : EquationParserImpl(org.cytoscape.equations.internal.EquationParserImpl) EquationCompilerImpl(org.cytoscape.equations.internal.EquationCompilerImpl) CyNetworkManagerImpl(org.cytoscape.model.internal.CyNetworkManagerImpl) CyNetworkTableManagerImpl(org.cytoscape.model.internal.CyNetworkTableManagerImpl) TableAddedEvent(org.cytoscape.model.events.TableAddedEvent) EquationCompiler(org.cytoscape.equations.EquationCompiler) CyTableManagerImpl(org.cytoscape.model.internal.CyTableManagerImpl) CyTableImpl(org.cytoscape.model.internal.CyTableImpl) Before(org.junit.Before)

Example 9 with CyNetworkTableManagerImpl

use of org.cytoscape.model.internal.CyNetworkTableManagerImpl in project cytoscape-impl by cytoscape.

the class CyNetworkTableManagerTest method testWeakReferences.

/*
	 * Once network key has no strong reference, it should be marked for GC.
	 */
// @Test
public void testWeakReferences() throws Exception {
    mgr = new CyNetworkTableManagerImpl();
    final CyNetwork[] keys = new CyNetwork[2];
    final String tableName1 = "sample1";
    final String tableName2 = "sample2";
    // Store keys in external array
    keys[0] = mock(CyNetwork.class);
    keys[1] = mock(CyNetwork.class);
    CyTable sampleT1 = tableFactory.createTable(tableName1, CyNetwork.NAME, String.class, true, true);
    CyTable sampleT2 = tableFactory.createTable(tableName2, CyNetwork.NAME, String.class, true, true);
    mgr.setTable(keys[0], CyNetwork.class, tableName1, sampleT1);
    mgr.setTable(keys[1], CyNetwork.class, tableName2, sampleT2);
    assertNotNull(mgr.getTable(keys[0], CyNetwork.class, tableName1));
    assertNotNull(mgr.getTable(keys[1], CyNetwork.class, tableName2));
    assertEquals(2, mgr.getNetworkSet().size());
    // remove the key and run GC
    keys[0] = null;
    System.gc();
    Thread.sleep(100);
    assertEquals(1, mgr.getNetworkSet().size());
    // remove the key and run GC again
    keys[1] = null;
    System.gc();
    Thread.sleep(100);
    assertEquals(0, mgr.getNetworkSet().size());
}
Also used : CyNetworkTableManagerImpl(org.cytoscape.model.internal.CyNetworkTableManagerImpl)

Aggregations

CyNetworkTableManagerImpl (org.cytoscape.model.internal.CyNetworkTableManagerImpl)9 CyNetworkManagerImpl (org.cytoscape.model.internal.CyNetworkManagerImpl)8 CyTableManagerImpl (org.cytoscape.model.internal.CyTableManagerImpl)8 CyTableFactoryImpl (org.cytoscape.model.internal.CyTableFactoryImpl)6 Before (org.junit.Before)6 Interpreter (org.cytoscape.equations.Interpreter)5 InterpreterImpl (org.cytoscape.equations.internal.interpreter.InterpreterImpl)5 EquationCompilerImpl (org.cytoscape.equations.internal.EquationCompilerImpl)4 EquationParserImpl (org.cytoscape.equations.internal.EquationParserImpl)4 DummyCyEventHelper (org.cytoscape.event.DummyCyEventHelper)4 CyRootNetworkImpl (org.cytoscape.model.internal.CyRootNetworkImpl)4 CyServiceRegistrar (org.cytoscape.service.util.CyServiceRegistrar)4 EquationCompiler (org.cytoscape.equations.EquationCompiler)3 TableAddedEvent (org.cytoscape.model.events.TableAddedEvent)2 CyNetworkFactoryImpl (org.cytoscape.model.internal.CyNetworkFactoryImpl)2 CyTableImpl (org.cytoscape.model.internal.CyTableImpl)2 CyEventHelper (org.cytoscape.event.CyEventHelper)1 CyNetworkNaming (org.cytoscape.session.CyNetworkNaming)1