Author: jm
Date: 2011-09-20 11:00:53 -0700 (Tue, 20 Sep 2011)
New Revision: 26881

Added:
   
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyNetworkTableManager.java
   
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyNetworkTableManagerTest.java
   
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkTableManagerImpl.java
   
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyNetworkTableManagerTest.java
Modified:
   
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyTableManager.java
   
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyTableMetadata.java
   
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyTableManagerTest.java
   
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/ArrayGraph.java
   
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkFactoryImpl.java
   
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
   
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableMetadataImpl.java
   
core3/impl/trunk/model-impl/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
   
core3/impl/trunk/model-impl/impl/src/main/resources/META-INF/spring/bundle-context.xml
   
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
   
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/NetworkTestSupport.java
   
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/TestCyNetworkFactory.java
   
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/subnetwork/CySubNetworkCyTableManagerTest.java
Log:
Ooops, forgot to commit changes to model-api and model-impl

Added: 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyNetworkTableManager.java
===================================================================
--- 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyNetworkTableManager.java
                              (rev 0)
+++ 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyNetworkTableManager.java
      2011-09-20 18:00:53 UTC (rev 26881)
@@ -0,0 +1,36 @@
+package org.cytoscape.model;
+
+import java.util.Map;
+
+/**
+ * Provides access to all network-table relationships.
+ */
+public interface CyNetworkTableManager {
+       /**
+        * Associates the given table to the network using the specified 
namespace and type.
+        */
+       void setTable(CyNetwork network, Class<? extends CyTableEntry> type, 
String namespace, CyTable table);
+       
+       /**
+        * Returns the table with the specified namespace and type from the
+        * network.
+        */
+       CyTable getTable(CyNetwork network, Class<? extends CyTableEntry> type, 
String namespace);
+       
+       /**
+        * Removes the table with the specified namespace and type from
+        * the network.
+        */
+       void removeTable(CyNetwork network, Class<? extends CyTableEntry> type, 
String namespace);
+       
+       /**
+        * Returns a read-only map of all of the tables for the specified type
+        * from the network.  Each table is keyed by its namespace.
+        */
+       Map<String, CyTable> getTables(CyNetwork network, Class<? extends 
CyTableEntry> type);
+       
+       /**
+        * Clears all the network-table relationships.
+        */
+       void reset();
+}


Property changes on: 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyNetworkTableManager.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyTableManager.java
===================================================================
--- 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyTableManager.java 
    2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyTableManager.java 
    2011-09-20 18:00:53 UTC (rev 26881)
@@ -28,7 +28,6 @@
 package org.cytoscape.model;
 
 
-import java.util.Map;
 import java.util.Set;
 
 
@@ -38,18 +37,6 @@
  */
 public interface CyTableManager {
        /**
-        * Returns a map of table names to tables, which contain the attributes 
-        * for the specified network.
-        * 
-        * @param type The type of map to retrieve: CyNode, CyEdge, or 
CyNetwork (for now).
-        * @param network The network associated with the map.
-        * 
-        * @return a map of table names to tables, which contain the attributes 
-        * for the specified network.
-        */
-       public Map<String, CyTable> getTableMap(Class<?> type, CyNetwork 
network);
-
-       /**
         * Returns a Set of all tables with the specified visibility.
         * @param includePrivate Whether to include private CyTables
         * in the list (i.e. all possible CyTables) or not.
@@ -57,7 +44,7 @@
         * including private CyTables (i.e. meaning all possible
         * CyTables) or just public CyTables.
         */
-       Set<CyTableMetadata> getAllTables(boolean includePrivate);
+       Set<CyTable> getAllTables(boolean includePrivate);
 
        /** Registers a new table with the manager and fires a TableAddedEvent 
event.
         *  @param table a non-null CyTable that will be added to the manager

Modified: 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyTableMetadata.java
===================================================================
--- 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyTableMetadata.java
    2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/api/trunk/model-api/src/main/java/org/cytoscape/model/CyTableMetadata.java
    2011-09-20 18:00:53 UTC (rev 26881)
@@ -1,10 +1,8 @@
 package org.cytoscape.model;
 
-import java.util.Set;
-
 /**
- * A snapshot of information about the relationships shared between a CyTable
- * instance and any associated CyNetworks.
+ * A snapshot of information about a relationship shared between a CyTable
+ * instance and an associated CyNetworks.
  */
 public interface CyTableMetadata {
        /**
@@ -25,7 +23,7 @@
         * Returns all the networks associated with this object's table.
         * @return all the networks associated with this object's table.
         */
-       Set<CyNetwork> getCyNetworks();
+       CyNetwork getCyNetwork();
        
        /**
         * Returns the namespace used as the key to this object's table in

Added: 
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyNetworkTableManagerTest.java
===================================================================
--- 
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyNetworkTableManagerTest.java
                          (rev 0)
+++ 
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyNetworkTableManagerTest.java
  2011-09-20 18:00:53 UTC (rev 26881)
@@ -0,0 +1,135 @@
+package org.cytoscape.model;
+
+import static org.junit.Assert.*;
+import static org.mockito.Mockito.mock;
+
+import java.util.Map;
+
+import org.junit.Before;
+import org.junit.Test;
+
+public abstract class AbstractCyNetworkTableManagerTest {
+       /**
+        * Must be supplied by implementer.
+        */
+       protected CyNetworkTableManager mgr;
+
+       /**
+        * Must be supplied by implementer.
+        */
+       protected CyNetwork goodNetwork;
+
+       private CyNetwork badNetwork;
+       private CyTable table1;
+       private CyTable table2;
+
+       @Before
+       public void setUp() {
+               badNetwork = mock(CyNetwork.class);
+               table1 = mock(CyTable.class);
+               table2 = mock(CyTable.class);
+       }
+
+       @Test
+       public void testGoodNetwork() {
+               assertNotNull( mgr.getTables(goodNetwork, CyNetwork.class) );
+               assertNotNull( mgr.getTables(goodNetwork, CyNode.class) );
+               assertNotNull( mgr.getTables(goodNetwork, CyEdge.class) );
+       }
+
+       @Test
+       public void testBadNetwork() {
+               assertEquals( 0, mgr.getTables(badNetwork, 
CyNetwork.class).size() );
+               assertEquals( 0, mgr.getTables(badNetwork, CyNode.class).size() 
);
+               assertEquals( 0, mgr.getTables(badNetwork, CyEdge.class).size() 
);
+       }
+
+       @Test
+       public void testNullNetwork() {
+               try {
+                       mgr.getTables(null, CyNetwork.class);
+                       fail();
+               } catch (IllegalArgumentException e) {
+               }
+               try {
+                       mgr.getTables(null, CyNode.class);
+                       fail();
+               } catch (IllegalArgumentException e) {
+               }
+               try {
+                       mgr.getTables(null, CyEdge.class);
+                       fail();
+               } catch (IllegalArgumentException e) {
+               }
+       }
+
+       @Test
+       public void testTableNetworkMapHasExpectedTables() throws Exception {
+               checkTableMap( mgr.getTables(goodNetwork, CyNetwork.class) );
+               checkTableMap( mgr.getTables(goodNetwork, CyNode.class) );
+               checkTableMap( mgr.getTables(goodNetwork, CyEdge.class) );
+       }
+
+       private void checkTableMap(Map<String,CyTable> tableMap) {
+               // we should have at least the two default, but others may exist
+               assertTrue(tableMap.size() >= 2);
+               assertTrue(tableMap.keySet().contains(CyNetwork.DEFAULT_ATTRS));
+               assertTrue(tableMap.keySet().contains(CyNetwork.HIDDEN_ATTRS));
+       }
+       
+       @Test
+       public void testSetTable() throws Exception {
+               String namespace = "foo";
+               mgr.setTable(goodNetwork, CyNode.class, namespace, table1);
+               CyTable other = mgr.getTable(goodNetwork, CyNode.class, 
namespace);
+               assertSame(table1, other);
+       }
+
+       @Test
+       public void testOverwriteTable() throws Exception {
+               String namespace = "foo";
+               mgr.setTable(goodNetwork, CyNode.class, namespace, table1);
+               mgr.setTable(goodNetwork, CyNode.class, namespace, table2);
+               CyTable other = mgr.getTable(goodNetwork, CyNode.class, 
namespace);
+               assertSame(table2, other);
+       }
+
+       @Test
+       public void testRemoveTable() throws Exception {
+               String namespace = "foo";
+               mgr.setTable(goodNetwork, CyNode.class, namespace, table1);
+               mgr.removeTable(goodNetwork, CyNode.class, namespace);
+               CyTable other = mgr.getTable(goodNetwork, CyNode.class, 
namespace);
+               assertNull(other);
+       }
+
+       @Test
+       public void testGetTables() throws Exception {
+               String namespace = "foo";
+               mgr.setTable(goodNetwork, CyNode.class, namespace, table1);
+               Map<String, CyTable> tables = mgr.getTables(goodNetwork, 
CyNode.class);
+               assertSame(table1, tables.get(namespace));
+       }
+       
+       @Test
+       public void testRemoveDefaultTables() throws Exception {
+               for (Class<? extends CyTableEntry> type : new Class[] { 
CyNetwork.class, CyNode.class, CyEdge.class }) {
+                       try {
+                               mgr.removeTable(goodNetwork, type, 
CyNetwork.DEFAULT_ATTRS);
+                               fail();
+                       } catch (IllegalArgumentException e) {
+                       }
+               }
+       }
+
+       @Test
+       public void testSetDefaultTables() throws Exception {
+               for (Class<? extends CyTableEntry> type : new Class[] { 
CyNetwork.class, CyNode.class, CyEdge.class }) {
+                       try {
+                               mgr.setTable(goodNetwork, type, 
CyNetwork.DEFAULT_ATTRS, table1);
+                               fail();
+                       } catch (IllegalArgumentException e) {
+                       }
+               }
+       }
+}


Property changes on: 
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyNetworkTableManagerTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: 
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyTableManagerTest.java
===================================================================
--- 
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyTableManagerTest.java
 2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/api/trunk/model-api/src/test/java/org/cytoscape/model/AbstractCyTableManagerTest.java
 2011-09-20 18:00:53 UTC (rev 26881)
@@ -28,15 +28,14 @@
 package org.cytoscape.model;
 
 
-import static org.mockito.Mockito.mock;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertTrue;
 
-import static org.junit.Assert.*;
 import org.junit.Before;
 import org.junit.Test;
 
-import java.util.Map;
 
-
 public abstract class AbstractCyTableManagerTest {
        /**
         * Must be supplied by implementer.
@@ -48,48 +47,11 @@
         */
        protected CyNetwork goodNetwork;
 
-       private CyNetwork badNetwork;
-
        @Before
        public void setUp() {
-               badNetwork = mock(CyNetwork.class);
        }
 
        @Test
-       public void testGoodNetwork() {
-               assertNotNull( mgr.getTableMap(CyNetwork.class, goodNetwork) );
-               assertNotNull( mgr.getTableMap(CyNode.class, goodNetwork) );
-               assertNotNull( mgr.getTableMap(CyEdge.class, goodNetwork) );
-       }
-
-       @Test
-       public void testBadNetwork() {
-               assertNull( mgr.getTableMap(CyNetwork.class,badNetwork) );
-               assertNull( mgr.getTableMap(CyNode.class,badNetwork) );
-               assertNull( mgr.getTableMap(CyEdge.class,badNetwork) );
-       }
-
-       @Test
-       public void testNullNetwork() {
-               assertNull( mgr.getTableMap(CyNetwork.class,null) );
-               assertNull( mgr.getTableMap(CyNode.class,null) );
-               assertNull( mgr.getTableMap(CyEdge.class,null) );
-       }
-
-       public void testTableNetworkMapHasExpectedTables() throws Exception {
-               checkTableMap( mgr.getTableMap(CyNetwork.class, goodNetwork) );
-               checkTableMap( mgr.getTableMap(CyNode.class, goodNetwork) );
-               checkTableMap( mgr.getTableMap(CyEdge.class, goodNetwork) );
-       }
-
-       private void checkTableMap(Map<String,CyTable> tableMap) {
-               // we should have at least the two default, but others may exist
-               assertTrue(tableMap.size() >= 2);
-               assertTrue(tableMap.keySet().contains(CyNetwork.DEFAULT_ATTRS));
-               assertTrue(tableMap.keySet().contains(CyNetwork.HIDDEN_ATTRS));
-       }
-
-       @Test
        public void testReset() {
                mgr.addTable(goodNetwork.getDefaultNodeTable());
                assertFalse(mgr.getAllTables(true).isEmpty());

Modified: 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/ArrayGraph.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/ArrayGraph.java
 2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/ArrayGraph.java
 2011-09-20 18:00:53 UTC (rev 26881)
@@ -88,6 +88,7 @@
        private final List<CySubNetwork> subNetworks;
        private final CySubNetwork base;
        private final CyTableManagerImpl tableMgr;
+       private final CyNetworkTableManagerImpl networkTableMgr;
        private final CyTableFactory tableFactory;
        private final CyServiceRegistrar serviceRegistrar;
 
@@ -98,10 +99,12 @@
         * @param eh The CyEventHelper used for firing events.
         */
        public ArrayGraph(final CyEventHelper eh, final CyTableManagerImpl 
tableMgr,
-                         final CyTableFactory tableFactory,
+                                         final CyNetworkTableManagerImpl 
networkTableMgr,
+                                         final CyTableFactory tableFactory,
                          final CyServiceRegistrar serviceRegistrar, final 
boolean publicTables)
        {
                this.tableMgr = tableMgr;
+               this.networkTableMgr = networkTableMgr;
                this.tableFactory = tableFactory;
                this.publicTables = publicTables;
                this.serviceRegistrar = serviceRegistrar;
@@ -119,9 +122,9 @@
                nodeTables = createNodeTables(suid); 
                edgeTables = createEdgeTables(suid); 
 
-        tableMgr.setTableMap(CyNetwork.class, this, netTables);
-        tableMgr.setTableMap(CyNode.class, this, nodeTables);
-        tableMgr.setTableMap(CyEdge.class, this, edgeTables);
+        networkTableMgr.setTableMap(CyNetwork.class, this, netTables);
+        networkTableMgr.setTableMap(CyNode.class, this, nodeTables);
+        networkTableMgr.setTableMap(CyEdge.class, this, edgeTables);
 
                eventHelper = eh;
 
@@ -917,9 +920,9 @@
                final ArraySubGraph sub = new 
ArraySubGraph(this,newSUID,newId,eventHelper,newNetTable,newNodeTable,newEdgeTable,tableMgr);
                serviceRegistrar.registerAllServices(sub, new Properties());
                subNetworks.add(sub);
-               tableMgr.setTableMap(CyNetwork.class, sub, newNetTable);
-               tableMgr.setTableMap(CyNode.class, sub, newNodeTable);
-               tableMgr.setTableMap(CyEdge.class, sub, newEdgeTable);
+               networkTableMgr.setTableMap(CyNetwork.class, sub, newNetTable);
+               networkTableMgr.setTableMap(CyNode.class, sub, newNodeTable);
+               networkTableMgr.setTableMap(CyEdge.class, sub, newEdgeTable);
                return sub;
        }
 

Modified: 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkFactoryImpl.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkFactoryImpl.java
       2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkFactoryImpl.java
       2011-09-20 18:00:53 UTC (rev 26881)
@@ -31,7 +31,6 @@
 import org.cytoscape.event.CyEventHelper;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNetworkFactory;
-import org.cytoscape.model.CyTableManager;
 import org.cytoscape.model.CyTableFactory;
 import org.cytoscape.service.util.CyServiceRegistrar;
 
@@ -44,6 +43,7 @@
        
        private final CyEventHelper help;
        private final CyTableManagerImpl mgr;
+       private final CyNetworkTableManagerImpl networkTableMgr;
        private final CyTableFactory tableFactory;
        private final CyServiceRegistrar serviceRegistrar;
 
@@ -53,6 +53,7 @@
         * @param help An instance of CyEventHelper. 
         */
        public CyNetworkFactoryImpl(final CyEventHelper help, final 
CyTableManagerImpl mgr,
+                                       final CyNetworkTableManagerImpl 
networkTableMgr,
                                    final CyTableFactory tableFactory,
                                    final CyServiceRegistrar serviceRegistrar)
        {
@@ -70,6 +71,7 @@
 
                this.help             = help;
                this.mgr              = mgr;
+               this.networkTableMgr  = networkTableMgr;
                this.tableFactory     = tableFactory;
                this.serviceRegistrar = serviceRegistrar;
        }
@@ -79,7 +81,7 @@
         */
        @Override
        public CyNetwork getInstance() {
-               ArrayGraph net = new ArrayGraph(help, mgr, tableFactory, 
serviceRegistrar, true);
+               ArrayGraph net = new ArrayGraph(help, mgr, networkTableMgr, 
tableFactory, serviceRegistrar, true);
                logger.info("CyNetwork w/ public tables created: ID = " +  
net.getSUID());
                logger.info("CyNetwork w/ public tables created: Base Graph ID 
= " +  net.getBaseNetwork().getSUID());
                return net.getBaseNetwork(); 
@@ -90,7 +92,7 @@
         */
        @Override
        public CyNetwork getInstanceWithPrivateTables() {
-               ArrayGraph net = new ArrayGraph(help, mgr, tableFactory, 
serviceRegistrar, false);
+               ArrayGraph net = new ArrayGraph(help, mgr, networkTableMgr, 
tableFactory, serviceRegistrar, false);
                logger.info("CyNetwork w/ private tables created: ID = " +  
net.getSUID());
                logger.info("CyNetwork w/ private tables created: Base Graph ID 
= " +  net.getBaseNetwork().getSUID());
                return net.getBaseNetwork(); 

Added: 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkTableManagerImpl.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkTableManagerImpl.java
                          (rev 0)
+++ 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkTableManagerImpl.java
  2011-09-20 18:00:53 UTC (rev 26881)
@@ -0,0 +1,178 @@
+package org.cytoscape.model.internal;
+
+import java.lang.ref.Reference;
+import java.lang.ref.WeakReference;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Map;
+import java.util.WeakHashMap;
+
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkTableManager;
+import org.cytoscape.model.CyTable;
+import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.model.events.NetworkAboutToBeDestroyedEvent;
+import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
+
+public class CyNetworkTableManagerImpl implements CyNetworkTableManager, 
NetworkAboutToBeDestroyedListener {
+
+       Map<CyNetwork, Map<Class<? extends CyTableEntry>, Reference<Map<String, 
CyTable>>>> tables;
+       
+       public CyNetworkTableManagerImpl() {
+               // Use WeakReferences for CyNetworks because we can't get 
notified
+               // when detached networks are no longer in use.  Use 
WeakReferences
+               // for the CyTable maps too because CyNetworks may be holding a
+               // reference to them.  This set up allows us to automatically 
clean
+               // up this map whenever CyNetworks get garbage collected.
+               tables = new WeakHashMap<CyNetwork, Map<Class<? extends 
CyTableEntry>, Reference<Map<String, CyTable>>>>();
+       }
+       
+       @Override
+       public void setTable(CyNetwork network, Class<? extends CyTableEntry> 
type,
+                       String namespace, CyTable table) {
+               if (network == null) {
+                       throw new IllegalArgumentException("network cannot be 
null");
+               }
+               if (type == null) {
+                       throw new IllegalArgumentException("type cannot be 
null");
+               }
+               if (namespace == null) {
+                       throw new IllegalArgumentException("namespace cannot be 
null");
+               }
+               if (table == null) {
+                       throw new IllegalArgumentException("table cannot be 
null");
+               }
+               
+               if (namespace.equals(CyNetwork.DEFAULT_ATTRS)) {
+                       throw new IllegalArgumentException("cannot overwrite 
default tables");
+               }
+               
+               Map<Class<? extends CyTableEntry>, Reference<Map<String, 
CyTable>>> byType = tables.get(network);
+               if (byType == null) {
+                       throw new IllegalStateException("network table maps are 
missing for network: " + network);
+               }
+               Reference<Map<String, CyTable>> reference = byType.get(type);
+               if (reference == null) {
+                       throw new IllegalStateException("network table maps are 
missing for network: " + network);
+               }
+               Map<String, CyTable> byNamespace = reference.get();
+               if (byNamespace == null) {
+                       throw new IllegalStateException("network table maps are 
missing for network: " + network);
+               }
+               byNamespace.put(namespace, table);
+       }
+
+       @Override
+       public CyTable getTable(CyNetwork network,
+                       Class<? extends CyTableEntry> type, String namespace) {
+               Map<Class<? extends CyTableEntry>, Reference<Map<String, 
CyTable>>> byType = tables.get(network);
+               if (network == null) {
+                       throw new IllegalArgumentException("network cannot be 
null");
+               }
+               if (type == null) {
+                       throw new IllegalArgumentException("type cannot be 
null");
+               }
+               if (namespace == null) {
+                       throw new IllegalArgumentException("namespace cannot be 
null");
+               }
+
+               if (byType == null) {
+                       return null;
+               }
+               Reference<Map<String, CyTable>> reference = byType.get(type);
+               if (reference == null) {
+                       return null;
+               }
+               Map<String, CyTable> byNamespace = reference.get();
+               if (byNamespace == null) {
+                       return null;
+               }
+               return byNamespace.get(namespace);
+       }
+
+       @Override
+       public void removeTable(CyNetwork network,
+                       Class<? extends CyTableEntry> type, String namespace) {
+               if (network == null) {
+                       throw new IllegalArgumentException("network cannot be 
null");
+               }
+               if (type == null) {
+                       throw new IllegalArgumentException("type cannot be 
null");
+               }
+               if (namespace == null) {
+                       throw new IllegalArgumentException("namespace cannot be 
null");
+               }
+
+               if (namespace.equals(CyNetwork.DEFAULT_ATTRS)) {
+                       throw new IllegalArgumentException("cannot remove 
default tables");
+               }
+               
+               Map<Class<? extends CyTableEntry>, Reference<Map<String, 
CyTable>>> byType = tables.get(network);
+               if (byType == null) {
+                       return;
+               }
+               Reference<Map<String, CyTable>> reference = byType.get(type);
+               if (reference == null) {
+                       return;
+               }
+               Map<String, CyTable> byNamespace = reference.get();
+               if (byNamespace == null) {
+                       return;
+               }
+               byNamespace.remove(namespace);
+       }
+
+       @Override
+       public Map<String, CyTable> getTables(CyNetwork network,
+                       Class<? extends CyTableEntry> type) {
+               if (network == null) {
+                       throw new IllegalArgumentException("network cannot be 
null");
+               }
+               if (type == null) {
+                       throw new IllegalArgumentException("type cannot be 
null");
+               }
+
+               Map<Class<? extends CyTableEntry>, Reference<Map<String, 
CyTable>>> byType = tables.get(network);
+               if (byType == null) {
+                       return Collections.emptyMap();
+               }
+               Reference<Map<String, CyTable>> reference = byType.get(type);
+               if (reference == null) {
+                       return Collections.emptyMap();
+               }
+               Map<String, CyTable> byNamespace = reference.get();
+               if (byNamespace == null) {
+                       return Collections.emptyMap();
+               }
+               return Collections.unmodifiableMap(byNamespace);
+       }
+
+       @Override
+       public void reset() {
+               tables.clear();
+       }
+
+       void setTableMap(Class<? extends CyTableEntry> type, CyNetwork network, 
Map<String, CyTable> tableMap) {
+               if (network == null) {
+                       throw new IllegalArgumentException("network cannot be 
null");
+               }
+               if (type == null) {
+                       throw new IllegalArgumentException("type cannot be 
null");
+               }
+               if (tableMap == null) {
+                       throw new IllegalArgumentException("table map cannot be 
null");
+               }
+
+               Map<Class<? extends CyTableEntry>, Reference<Map<String, 
CyTable>>> byType = tables.get(network);
+               if (byType == null) {
+                       byType = new HashMap<Class<? extends CyTableEntry>, 
Reference<Map<String,CyTable>>>();
+                       tables.put(network, byType);
+               }
+               byType.put(type, new 
WeakReference<Map<String,CyTable>>(tableMap));
+       }
+
+       @Override
+       public void handleEvent(NetworkAboutToBeDestroyedEvent e) {
+               tables.remove(e.getNetwork());
+       }
+}


Property changes on: 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyNetworkTableManagerImpl.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
 2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableManagerImpl.java
 2011-09-20 18:00:53 UTC (rev 26881)
@@ -27,31 +27,30 @@
 */
 package org.cytoscape.model.internal;
 
-import org.cytoscape.event.CyEventHelper;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Map;
+import java.util.Set;
 
+import org.cytoscape.event.CyEventHelper;
 import org.cytoscape.model.CyEdge;
 import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.CyNetworkTableManager;
 import org.cytoscape.model.CyNode;
 import org.cytoscape.model.CyTable;
 import org.cytoscape.model.CyTable.Mutability;
+import org.cytoscape.model.CyTableEntry;
 import org.cytoscape.model.CyTableManager;
-import org.cytoscape.model.CyTableMetadata;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedEvent;
 import org.cytoscape.model.events.NetworkAboutToBeDestroyedListener;
 import org.cytoscape.model.events.TableAboutToBeDeletedEvent;
 import org.cytoscape.model.events.TableAddedEvent;
 import org.cytoscape.model.events.TableDeletedEvent;
-
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.Map;
-import java.util.Map.Entry;
-import java.util.Set;
 
-
 /**
  * An interface describing a factory used for managing {@link CyTable} objects.
  * This class will be provided as a service through Spring/OSGi.
@@ -59,7 +58,8 @@
 public class CyTableManagerImpl implements CyTableManager, 
NetworkAboutToBeDestroyedListener {
        private static final Logger logger = 
LoggerFactory.getLogger(CyTableManagerImpl.class);
        private final CyEventHelper eventHelper;
-       private final Map<Class<?>, Map<CyNetwork, Map<String, CyTable>>> 
networkTableMap;
+       private final CyNetworkTableManager networkTableManager;
+       private final CyNetworkManager networkManager;
        private final Map<Long, CyTable> tables;
 
        /**
@@ -67,14 +67,11 @@
         *
         * @param eventHelper  DOCUMENT ME!
         */
-       public CyTableManagerImpl(final CyEventHelper eventHelper) {
+       public CyTableManagerImpl(final CyEventHelper eventHelper, 
CyNetworkTableManager networkTableManager, CyNetworkManager networkManager) {
                this.eventHelper = eventHelper;
-
-               networkTableMap = new HashMap<Class<?>, Map<CyNetwork, 
Map<String, CyTable>>>();
-               networkTableMap.put(CyNetwork.class, new HashMap<CyNetwork, 
Map<String, CyTable>>());
-               networkTableMap.put(CyNode.class, new HashMap<CyNetwork, 
Map<String, CyTable>>());
-               networkTableMap.put(CyEdge.class, new HashMap<CyNetwork, 
Map<String, CyTable>>());
-
+               this.networkTableManager = networkTableManager;
+               this.networkManager = networkManager;
+               
                tables = new HashMap<Long, CyTable>();
        }
 
@@ -83,100 +80,13 @@
         */
        @Override
        public synchronized void reset() {
-               networkTableMap.clear();
+//             networkTableMap.clear();
                tables.clear();
        }
 
        /**
         *  DOCUMENT ME!
         *
-        * @param graphObjectType DOCUMENT ME!
-        * @param network DOCUMENT ME!
-        *
-        * @return  DOCUMENT ME!
-        */
-       @Override
-       public synchronized Map<String, CyTable> getTableMap(final Class<?> 
graphObjectType,
-                                                            final CyNetwork 
network) {
-               if ((network == null) || (graphObjectType == null)) {
-                       return null;
-               }
-
-               Map<CyNetwork, Map<String, CyTable>> tmap = 
networkTableMap.get(graphObjectType);
-
-               if (tmap == null) {
-                       throw new IllegalArgumentException("no data tables of 
type: " + graphObjectType
-                                                          + " exist");
-               }
-
-               return tmap.get(network);
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param graphObjectType DOCUMENT ME!
-        * @param network DOCUMENT ME!
-        * @param table DOCUMENT ME!
-        */
-       public void addNetworkTable(Class<?> graphObjectType, final CyNetwork 
network,
-                                   final CyTable table) {
-               if (network == null) {
-                       throw new NullPointerException("CyNetwork is null");
-               }
-
-               if (graphObjectType == null) {
-                       throw new NullPointerException("Type is null");
-               }
-
-               if (table == null) {
-                       throw new NullPointerException("Table is null");
-               }
-
-               if (!networkTableMap.containsKey(graphObjectType)) {
-                       networkTableMap.put(graphObjectType, new 
HashMap<CyNetwork, Map<String, CyTable>>());
-               }
-
-               Map<CyNetwork, Map<String, CyTable>> tmap = 
networkTableMap.get(graphObjectType);
-               Map<String, CyTable> tm = new HashMap<String, CyTable>();
-               tm.put(CyNetwork.DEFAULT_ATTRS, table);
-
-               tmap.put(network, tm);
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param graphObjectType DOCUMENT ME!
-        * @param network DOCUMENT ME!
-        * @param tm DOCUMENT ME!
-        */
-       public synchronized void setTableMap(final Class<?> graphObjectType, 
final CyNetwork network,
-                                            final Map<String, CyTable> tm) {
-               if (network == null) {
-                       throw new NullPointerException("CyNetwork is null");
-               }
-
-               if (graphObjectType == null) {
-                       throw new NullPointerException("Type is null");
-               }
-
-               if (!networkTableMap.containsKey(graphObjectType)) {
-                       networkTableMap.put(graphObjectType, new 
HashMap<CyNetwork, Map<String, CyTable>>());
-               }
-
-               Map<CyNetwork, Map<String, CyTable>> tmap = 
networkTableMap.get(graphObjectType);
-
-               if (tm == null) {
-                       tmap.remove(network);
-               } else {
-                       tmap.put(network, tm);
-               }
-       }
-
-       /**
-        *  DOCUMENT ME!
-        *
         * @param t DOCUMENT ME!
         */
        public synchronized void addTable(final CyTable t) {
@@ -196,51 +106,18 @@
         * @return  DOCUMENT ME!
         */
        @Override
-       public synchronized Set<CyTableMetadata> getAllTables(final boolean 
includePrivate) {
-               Set<CyTableMetadata> res = new HashSet<CyTableMetadata>();
+       public synchronized Set<CyTable> getAllTables(final boolean 
includePrivate) {
+               Set<CyTable> res = new HashSet<CyTable>();
 
                for (Long key : tables.keySet()) {
                        if (includePrivate || tables.get(key).isPublic()) {
-                               res.add(createMetadata(tables.get(key)));
+                               res.add(tables.get(key));
                        }
                }
 
                return res;
        }
 
-       private CyTableMetadata createMetadata(CyTable cyTable) {
-               Class<?> entryType = null;
-               String entryNamespace = null;
-               Set<CyNetwork> networks = new HashSet<CyNetwork>();
-
-               for (Entry<Class<?>, Map<CyNetwork, Map<String, CyTable>>> 
mapEntry : networkTableMap
-                                                                               
                                                                                
                                                                 .entrySet()) {
-                       Class<?> type = mapEntry.getKey();
-                       Map<CyNetwork, Map<String, CyTable>> networkMap = 
mapEntry.getValue();
-
-                       for (Entry<CyNetwork, Map<String, CyTable>> entry : 
networkMap.entrySet()) {
-                               CyNetwork network = entry.getKey();
-
-                               for (Entry<String, CyTable> tableEntry : 
entry.getValue().entrySet()) {
-                                       String namespace = tableEntry.getKey();
-                                       CyTable table = tableEntry.getValue();
-
-                                       if (table.getSUID() == 
cyTable.getSUID()) {
-                                               entryType = type;
-                                               entryNamespace = namespace;
-                                               networks.add(network);
-                                       }
-                               }
-                       }
-               }
-
-               if (networks.size() > 0) {
-                       return new CyTableMetadataImpl(entryType, cyTable, 
networks, entryNamespace);
-               }
-
-               return new CyTableMetadataImpl(null, cyTable, networks, null);
-       }
-
        /**
         *  DOCUMENT ME!
         *
@@ -287,33 +164,37 @@
                table = null;
        }
 
-       private static final Class[] tableTypes = new Class[] {
-                                                     CyNetwork.class, 
CyNode.class, CyEdge.class
-                                                 };
-
        /**
         *  DOCUMENT ME!
         *
-        * @param e DOCUMENT ME!
+        * @param suid DOCUMENT ME!
         */
        @Override
+       public void deleteTable(long suid) {
+               deleteTableInternal(suid, false);
+       }
+       
+       @Override
        public void handleEvent(NetworkAboutToBeDestroyedEvent e) {
+               // Collect set of tables to dispose
                CyNetwork network = e.getNetwork();
-
-               for (Class<?> type : tableTypes) {
-                       for (CyTable table : getTableMap(type, 
network).values()) {
-                               deleteTableInternal(table.getSUID(), true);
+               Set<CyTable> tablesToDispose = new HashSet<CyTable>();
+               for (Class<? extends CyTableEntry> type : new Class[] { 
CyNetwork.class, CyNode.class, CyEdge.class }) {
+                       
tablesToDispose.addAll(networkTableManager.getTables(network, type).values());
+               }
+               
+               // Exclude tables that are being referenced by other networks
+               for (CyNetwork otherNetwork : networkManager.getNetworkSet()) {
+                       if (otherNetwork.getSUID() == network.getSUID()) {
+                               continue;
                        }
+                       for (Class<? extends CyTableEntry> type : new Class[] { 
CyNetwork.class, CyNode.class, CyEdge.class }) {
+                               
tablesToDispose.removeAll(networkTableManager.getTables(otherNetwork, 
type).values());
+                       }
                }
+               
+               for (CyTable table : tablesToDispose) {
+                       deleteTableInternal(table.getSUID(), true);
+               }
        }
-
-       /**
-        *  DOCUMENT ME!
-        *
-        * @param suid DOCUMENT ME!
-        */
-       @Override
-       public void deleteTable(long suid) {
-               deleteTableInternal(suid, false);
-       }
 }

Modified: 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableMetadataImpl.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableMetadataImpl.java
        2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/main/java/org/cytoscape/model/internal/CyTableMetadataImpl.java
        2011-09-20 18:00:53 UTC (rev 26881)
@@ -1,7 +1,5 @@
 package org.cytoscape.model.internal;
 
-import java.util.Set;
-
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyTable;
 import org.cytoscape.model.CyTableMetadata;
@@ -10,13 +8,13 @@
 
        private final Class<?> type;
        private final CyTable table;
-       private final Set<CyNetwork> networks;
+       private final CyNetwork network;
        private final String namespace;
 
-       public CyTableMetadataImpl(Class<?> type, CyTable table, Set<CyNetwork> 
networks, String namespace) {
+       public CyTableMetadataImpl(Class<?> type, CyTable table, CyNetwork 
network, String namespace) {
                this.type = type;
                this.table = table;
-               this.networks = networks;
+               this.network = network;
                this.namespace = namespace;
        }
        
@@ -31,8 +29,8 @@
        }
 
        @Override
-       public Set<CyNetwork> getCyNetworks() {
-               return networks;
+       public CyNetwork getCyNetwork() {
+               return network;
        }
 
        @Override

Modified: 
core3/impl/trunk/model-impl/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
 2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/main/resources/META-INF/spring/bundle-context-osgi.xml
 2011-09-20 18:00:53 UTC (rev 26881)
@@ -35,6 +35,13 @@
                </osgi:interfaces>
        </osgi:service>
        
+       <osgi:service id="cyNetworkTableManagerService"
+               ref="cyNetworkTableManager">
+               <osgi:interfaces>
+                       <value>org.cytoscape.model.CyNetworkTableManager</value>
+               </osgi:interfaces>
+       </osgi:service>
+
        <osgi:service id="cyNetworkManagerService"
                ref="cyNetworkManager" 
interface="org.cytoscape.model.CyNetworkManager">
        </osgi:service>

Modified: 
core3/impl/trunk/model-impl/impl/src/main/resources/META-INF/spring/bundle-context.xml
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/main/resources/META-INF/spring/bundle-context.xml
      2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/main/resources/META-INF/spring/bundle-context.xml
      2011-09-20 18:00:53 UTC (rev 26881)
@@ -17,8 +17,13 @@
        
        <bean id="cyTableManager" 
class="org.cytoscape.model.internal.CyTableManagerImpl">
                <constructor-arg ref="cyEventHelperServiceRef" />
+               <constructor-arg ref="cyNetworkTableManager" />
+               <constructor-arg ref="cyNetworkManager" />
        </bean>
 
+       <bean id="cyNetworkTableManager" 
class="org.cytoscape.model.internal.CyNetworkTableManagerImpl">
+       </bean>
+
        <bean id="cyTableFactory" 
class="org.cytoscape.model.internal.CyTableFactoryImpl">
                <constructor-arg ref="cyEventHelperServiceRef" />
                <constructor-arg ref="InterpreterRef" />
@@ -28,6 +33,7 @@
        <bean id="cyNetworkFactory" 
class="org.cytoscape.model.internal.CyNetworkFactoryImpl">
                <constructor-arg ref="cyEventHelperServiceRef" />
                <constructor-arg ref="cyTableManager" />
+               <constructor-arg ref="cyNetworkTableManager" />
                <constructor-arg ref="cyTableFactory" />
                <constructor-arg ref="cyServiceRegistrarServiceRef" />
        </bean>

Added: 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyNetworkTableManagerTest.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyNetworkTableManagerTest.java
                           (rev 0)
+++ 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyNetworkTableManagerTest.java
   2011-09-20 18:00:53 UTC (rev 26881)
@@ -0,0 +1,76 @@
+/*
+ Copyright (c) 2008, 2010-2011, The Cytoscape Consortium (www.cytoscape.org)
+
+ This library is free software; you can redistribute it and/or modify it
+ under the terms of the GNU Lesser General Public License as published
+ by the Free Software Foundation; either version 2.1 of the License, or
+ any later version.
+
+ This library is distributed in the hope that it will be useful, but
+ WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
+ MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE.  The software and
+ documentation provided hereunder is on an "as is" basis, and the
+ Institute for Systems Biology and the Whitehead Institute
+ have no obligations to provide maintenance, support,
+ updates, enhancements or modifications.  In no event shall the
+ Institute for Systems Biology and the Whitehead Institute
+ be liable to any party for direct, indirect, special,
+ incidental or consequential damages, including lost profits, arising
+ out of the use of this software and its documentation, even if the
+ Institute for Systems Biology and the Whitehead Institute
+ have been advised of the possibility of such damage.  See
+ the GNU Lesser General Public License for more details.
+
+ You should have received a copy of the GNU Lesser General Public License
+ along with this library; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
+*/
+package org.cytoscape.model;
+
+
+import static org.junit.Assert.*;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+
+import org.cytoscape.equations.Interpreter;
+import org.cytoscape.equations.internal.interpreter.InterpreterImpl;
+import org.cytoscape.event.CyEventHelper;
+import org.cytoscape.event.DummyCyEventHelper;
+import org.cytoscape.model.Identifiable;
+import org.cytoscape.model.CyTable.SavePolicy;
+import org.cytoscape.model.internal.ArrayGraph;
+import org.cytoscape.model.internal.CyNetworkTableManagerImpl;
+import org.cytoscape.model.internal.CyTableFactoryImpl;
+import org.cytoscape.model.internal.CyTableImpl;
+import org.cytoscape.model.internal.CyTableManagerImpl;
+import org.cytoscape.service.util.CyServiceRegistrar;
+
+import static org.mockito.Mockito.*;
+
+
+public class CyNetworkTableManagerTest extends 
AbstractCyNetworkTableManagerTest {
+       CyTableManagerImpl mgrImpl;
+       CyNetworkTableManagerImpl networkTableMgr;
+
+       @Before
+       public void setUp() {
+               super.setUp();
+               CyEventHelper eh = new DummyCyEventHelper();
+               mgrImpl = new CyTableManagerImpl(eh, networkTableMgr, null);
+               networkTableMgr = new CyNetworkTableManagerImpl();
+               mgr = networkTableMgr;
+               final Interpreter interpreter = new InterpreterImpl();
+               final CyServiceRegistrar serviceRegistrar = 
mock(CyServiceRegistrar.class);
+               goodNetwork =
+                       new ArrayGraph(eh, mgrImpl, networkTableMgr,
+                                      new CyTableFactoryImpl(eh, interpreter, 
serviceRegistrar),
+                                      serviceRegistrar, true).getBaseNetwork();
+       }
+
+       @After
+       public void tearDown() {
+               mgr = null;
+               goodNetwork = null;
+       }
+}


Property changes on: 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyNetworkTableManagerTest.java
___________________________________________________________________
Added: svn:mime-type
   + text/plain

Modified: 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
  2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/CyTableManagerTest.java
  2011-09-20 18:00:53 UTC (rev 26881)
@@ -40,6 +40,7 @@
 import org.cytoscape.model.Identifiable;
 import org.cytoscape.model.CyTable.SavePolicy;
 import org.cytoscape.model.internal.ArrayGraph;
+import org.cytoscape.model.internal.CyNetworkTableManagerImpl;
 import org.cytoscape.model.internal.CyTableFactoryImpl;
 import org.cytoscape.model.internal.CyTableImpl;
 import org.cytoscape.model.internal.CyTableManagerImpl;
@@ -50,17 +51,19 @@
 
 public class CyTableManagerTest extends AbstractCyTableManagerTest {
        CyTableManagerImpl mgrImpl;
+       CyNetworkTableManagerImpl networkTableMgr;
 
        @Before
        public void setUp() {
                super.setUp();
                CyEventHelper eh = new DummyCyEventHelper();
-               mgrImpl = new CyTableManagerImpl(eh);
+               networkTableMgr = new CyNetworkTableManagerImpl();
+               mgrImpl = new CyTableManagerImpl(eh, networkTableMgr, null);
                mgr = mgrImpl;
                final Interpreter interpreter = new InterpreterImpl();
                final CyServiceRegistrar serviceRegistrar = 
mock(CyServiceRegistrar.class);
                goodNetwork =
-                       new ArrayGraph(eh, mgrImpl,
+                       new ArrayGraph(eh, mgrImpl, networkTableMgr,
                                       new CyTableFactoryImpl(eh, interpreter, 
serviceRegistrar),
                                       serviceRegistrar, true).getBaseNetwork();
        }

Modified: 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/NetworkTestSupport.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/NetworkTestSupport.java
  2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/NetworkTestSupport.java
  2011-09-20 18:00:53 UTC (rev 26881)
@@ -6,9 +6,9 @@
 import org.cytoscape.event.DummyCyEventHelper;
 import org.cytoscape.model.CyNetwork;
 import org.cytoscape.model.CyNetworkFactory;
-import org.cytoscape.model.CyTableFactory;
 
 import org.cytoscape.model.internal.CyNetworkFactoryImpl;
+import org.cytoscape.model.internal.CyNetworkTableManagerImpl;
 import org.cytoscape.model.internal.CyTableFactoryImpl;
 import org.cytoscape.model.internal.CyTableManagerImpl;
 import org.cytoscape.service.util.CyServiceRegistrar;
@@ -21,15 +21,17 @@
        protected CyNetworkFactory networkFactory;
        protected CyEventHelper eventHelper;
        protected CyTableManagerImpl tableMgr;
+       protected CyNetworkTableManagerImpl networkTableMgr;
 
        public NetworkTestSupport() {
                eventHelper = new DummyCyEventHelper();
                tableMgr = mock(CyTableManagerImpl.class); 
+               networkTableMgr = mock(CyNetworkTableManagerImpl.class);
                final CyServiceRegistrar serviceRegistrar = 
mock(CyServiceRegistrar.class);
                final CyTableFactoryImpl tableFactory =
                        new CyTableFactoryImpl(eventHelper, 
mock(Interpreter.class), serviceRegistrar);
                networkFactory =
-                       new CyNetworkFactoryImpl(eventHelper, tableMgr, 
tableFactory,
+                       new CyNetworkFactoryImpl(eventHelper, tableMgr, 
networkTableMgr, tableFactory,
                                                 serviceRegistrar);
        }
 

Modified: 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/TestCyNetworkFactory.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/TestCyNetworkFactory.java
        2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/TestCyNetworkFactory.java
        2011-09-20 18:00:53 UTC (rev 26881)
@@ -28,21 +28,23 @@
 package org.cytoscape.model;
 
 
-import org.cytoscape.event.DummyCyEventHelper;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
+
 import org.cytoscape.equations.Interpreter;
 import org.cytoscape.equations.internal.interpreter.InterpreterImpl;
+import org.cytoscape.event.DummyCyEventHelper;
 import org.cytoscape.model.internal.ArrayGraph;
+import org.cytoscape.model.internal.CyNetworkTableManagerImpl;
+import org.cytoscape.model.internal.CyTableFactoryImpl;
 import org.cytoscape.model.internal.CyTableManagerImpl;
-import org.cytoscape.model.internal.CyTableFactoryImpl;
 import org.cytoscape.model.subnetwork.CyRootNetwork;
 import org.cytoscape.service.util.CyServiceRegistrar;
-
 import org.junit.Test;
-import static org.junit.Assert.*;
 
-import static org.mockito.Mockito.*;
 
-
 public class TestCyNetworkFactory {
        public TestCyNetworkFactory() { }
 
@@ -56,22 +58,24 @@
 
        public static CyRootNetwork getPublicRootInstance() {   
                DummyCyEventHelper deh = new DummyCyEventHelper();
-               CyTableManagerImpl tm = new CyTableManagerImpl(deh);
+               CyNetworkTableManagerImpl ntm = new CyNetworkTableManagerImpl();
+               CyTableManagerImpl tm = new CyTableManagerImpl(deh, ntm, null);
                Interpreter interp = new InterpreterImpl();
                final CyServiceRegistrar serviceRegistrar = 
mock(CyServiceRegistrar.class);
                ArrayGraph ar =
-                       new ArrayGraph(deh, tm, new CyTableFactoryImpl(deh, 
interp, serviceRegistrar),
+                       new ArrayGraph(deh, tm, ntm, new 
CyTableFactoryImpl(deh, interp, serviceRegistrar),
                                       serviceRegistrar, true);
                return ar; 
        }
 
        public static CyRootNetwork getPrivateRootInstance() {  
                DummyCyEventHelper deh = new DummyCyEventHelper();
-               CyTableManagerImpl tm = new CyTableManagerImpl(deh);
+               CyNetworkTableManagerImpl ntm = new CyNetworkTableManagerImpl();
+               CyTableManagerImpl tm = new CyTableManagerImpl(deh, ntm, null);
                Interpreter interp = new InterpreterImpl();
                final CyServiceRegistrar serviceRegistrar = 
mock(CyServiceRegistrar.class);
                ArrayGraph ar =
-                       new ArrayGraph(deh, tm, new CyTableFactoryImpl(deh, 
interp, serviceRegistrar),
+                       new ArrayGraph(deh, tm, ntm, new 
CyTableFactoryImpl(deh, interp, serviceRegistrar),
                                       serviceRegistrar, false);
                return ar; 
        }

Modified: 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/subnetwork/CySubNetworkCyTableManagerTest.java
===================================================================
--- 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/subnetwork/CySubNetworkCyTableManagerTest.java
   2011-09-20 17:50:48 UTC (rev 26880)
+++ 
core3/impl/trunk/model-impl/impl/src/test/java/org/cytoscape/model/subnetwork/CySubNetworkCyTableManagerTest.java
   2011-09-20 18:00:53 UTC (rev 26881)
@@ -28,23 +28,20 @@
 package org.cytoscape.model.subnetwork;
 
 
-import java.util.Map;
+import static org.mockito.Mockito.mock;
 
-import org.cytoscape.model.internal.CyTableManagerImpl;
-import org.cytoscape.model.internal.CyTableFactoryImpl;
-import org.cytoscape.model.internal.ArrayGraph;
 import org.cytoscape.equations.Interpreter;
 import org.cytoscape.equations.internal.interpreter.InterpreterImpl;
 import org.cytoscape.event.CyEventHelper;
 import org.cytoscape.event.DummyCyEventHelper;
 import org.cytoscape.model.AbstractCyTableManagerTest;
+import org.cytoscape.model.internal.ArrayGraph;
+import org.cytoscape.model.internal.CyNetworkTableManagerImpl;
+import org.cytoscape.model.internal.CyTableFactoryImpl;
+import org.cytoscape.model.internal.CyTableManagerImpl;
 import org.cytoscape.service.util.CyServiceRegistrar;
 
-import org.junit.Test;
 
-import static org.mockito.Mockito.*;
-
-
 /**
  * The purpose of this test is to validate that everything that holds true
  * for CyNetworks in CyTableManager also holds true for CySubNetworks!
@@ -53,12 +50,13 @@
        public void setUp() {
                super.setUp();
                CyEventHelper eh = new DummyCyEventHelper();
-               CyTableManagerImpl mgrImpl = new CyTableManagerImpl(eh);
+               CyNetworkTableManagerImpl networkMgrImpl = new 
CyNetworkTableManagerImpl();
+               CyTableManagerImpl mgrImpl = new CyTableManagerImpl(eh, 
networkMgrImpl, null);
                mgr = mgrImpl; 
                final Interpreter interpreter = new InterpreterImpl();
                final CyServiceRegistrar serviceRegistrar = 
mock(CyServiceRegistrar.class);
                ArrayGraph baseNet =
-                       new ArrayGraph(eh, mgrImpl,
+                       new ArrayGraph(eh, mgrImpl, networkMgrImpl,
                                       new CyTableFactoryImpl(eh, interpreter, 
serviceRegistrar),
                                       serviceRegistrar, true);
                // This is a different subnetwork and not "baseNetwork" in 
ArrayGraph.

-- 
You received this message because you are subscribed to the Google Groups 
"cytoscape-cvs" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/cytoscape-cvs?hl=en.

Reply via email to