Author: mes
Date: 2010-08-10 13:01:56 -0700 (Tue, 10 Aug 2010)
New Revision: 21285
Added:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTableManager.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableManagerTest.java
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTableUtil.java
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyNetwork.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyEdgeTest.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNetworkTest.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNodeTest.java
Log:
changed how CyDataTables are managed for networks
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTableUtil.java
===================================================================
---
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTableUtil.java
2010-08-10 19:41:05 UTC (rev 21284)
+++
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyDataTableUtil.java
2010-08-10 20:01:56 UTC (rev 21285)
@@ -55,9 +55,6 @@
public static List<CyNode> getNodesInState(final CyNetwork net, final
String columnName, final boolean state) {
if ( net == null )
throw new NullPointerException("network is null");
- CyDataTable table =
net.getNodeCyDataTables().get(CyNetwork.DEFAULT_ATTRS);
- if ( table.getColumnTypeMap().get(columnName) != Boolean.class )
- throw new IllegalArgumentException("colunm name is not
a Boolean type");
List<CyNode> ret = new ArrayList<CyNode>();
for ( CyNode node : net.getNodeList() )
if ( node.attrs().get(columnName,Boolean.class) ==
state )
@@ -74,9 +71,6 @@
public static List<CyEdge> getEdgesInState(final CyNetwork net, final
String columnName, final boolean state) {
if ( net == null )
throw new NullPointerException("network is null");
- CyDataTable table =
net.getEdgeCyDataTables().get(CyNetwork.DEFAULT_ATTRS);
- if ( table.getColumnTypeMap().get(columnName) != Boolean.class )
- throw new IllegalArgumentException("colunm name is not
a Boolean type");
List<CyEdge> ret = new ArrayList<CyEdge>();
for ( CyEdge edge : net.getEdgeList() )
if ( edge.attrs().get(columnName,Boolean.class) ==
state )
Modified: core3/model-api/trunk/src/main/java/org/cytoscape/model/CyNetwork.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyNetwork.java
2010-08-10 19:41:05 UTC (rev 21284)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyNetwork.java
2010-08-10 20:01:56 UTC (rev 21285)
@@ -214,40 +214,4 @@
*/
List<CyEdge> getConnectingEdgeList(CyNode source, CyNode target,
CyEdge.Type edgeType);
- /**
- * TODO: We should remove this!
- *
- * Return the map of {...@link CyDataTable}s for this network. The map
is indexed by the
- * name of the data table (e.g. "USER")
- *
- * @return the map of {...@link CyDataTable}s for this network
- */
- Map<String,CyDataTable> getNetworkCyDataTables();
-
- /**
- * TODO: We should remove this!
- *
- * Return the map of {...@link CyDataTable}s for nodes in this network.
The map is indexed by the
- * name of the data table (e.g. "USER")
- *
- * @return the map of {...@link CyDataTable}s for nodes in this network
- */
- Map<String,CyDataTable> getNodeCyDataTables();
-
- /**
- * TODO: We should remove this!
- *
- * Return the map of {...@link CyDataTable}s for edges in this network.
The map is indexed by the
- * name of the data table (e.g. "USER")
- *
- * @return the map of {...@link CyDataTable}s for edges in this network
- */
- Map<String,CyDataTable> getEdgeCyDataTables();
-
- /**
- *
- * @param graphObjectType NODE, EDGE, or NETWORK
- * @return the map of {...@link CyDataTable}s for the given network
object.
- */
- Map<String,CyDataTable> getCyDataTables(String graphObjectType);
}
Added:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTableManager.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTableManager.java
(rev 0)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyTableManager.java
2010-08-10 20:01:56 UTC (rev 21285)
@@ -0,0 +1,53 @@
+
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ 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 java.util.Map;
+
+
+/**
+ *
+ */
+public interface CyTableManager {
+
+ /**
+ * @return The table containing network attributes for the specified
network.
+ */
+ Map<String,CyDataTable> getTableMap(String type, CyNetwork network);
+
+ void setTableMap(String type, CyNetwork network,
Map<String,CyDataTable> map);
+}
Modified:
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyEdgeTest.java
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyEdgeTest.java
2010-08-10 19:41:05 UTC (rev 21284)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyEdgeTest.java
2010-08-10 20:01:56 UTC (rev 21285)
@@ -148,15 +148,6 @@
public void testDefaultAttributes() {
defaultSetUp();
- CyDataTable def =
net.getEdgeCyDataTables().get(CyNetwork.DEFAULT_ATTRS);
- assertNotNull(def);
- assertNotNull(net.getEdgeCyDataTables().get(CyNetwork.HIDDEN_ATTRS));
- assertTrue(def.getColumnTypeMap().containsKey("name"));
- assertTrue(def.getColumnTypeMap().get("name") == String.class );
- assertTrue(def.getColumnTypeMap().containsKey("selected"));
- assertTrue(def.getColumnTypeMap().get("selected") == Boolean.class );
- assertTrue(def.getColumnTypeMap().containsKey("interaction"));
- assertTrue(def.getColumnTypeMap().get("interaction") == String.class );
CyNode n1 = net.addNode();
CyNode n2 = net.addNode();
@@ -166,5 +157,4 @@
assertEquals( Boolean.class, e1.attrs().contains("selected"));
assertEquals( String.class, e1.attrs().contains("interaction"));
}
-
}
Modified:
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNetworkTest.java
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNetworkTest.java
2010-08-10 19:41:05 UTC (rev 21284)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNetworkTest.java
2010-08-10 20:01:56 UTC (rev 21285)
@@ -958,26 +958,9 @@
}
/**
- * DOCUMENT ME!
- */
- public void testGetCyDataTables() {
- assertNotNull(net.getNetworkCyDataTables());
- assertNotNull(net.getNodeCyDataTables());
- assertNotNull(net.getEdgeCyDataTables());
-
- assertTrue(net.getNetworkCyDataTables() instanceof Map);
- assertTrue(net.getNodeCyDataTables() instanceof Map);
- assertTrue(net.getEdgeCyDataTables() instanceof Map);
- }
-
- /**
* Make sure the proper default attributes are created
*/
public void testDefaultAttributes() {
-
assertNotNull(net.getNetworkCyDataTables().get(CyNetwork.DEFAULT_ATTRS));
-
assertNotNull(net.getNetworkCyDataTables().get(CyNetwork.HIDDEN_ATTRS));
-
assertTrue(net.getNetworkCyDataTables().get(CyNetwork.DEFAULT_ATTRS).getColumnTypeMap().containsKey("name"));
-
assertTrue(net.getNetworkCyDataTables().get(CyNetwork.DEFAULT_ATTRS).getColumnTypeMap().get("name")
== String.class );
assertEquals(String.class,net.attrs().contains("name"));
}
Modified:
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNodeTest.java
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNodeTest.java
2010-08-10 19:41:05 UTC (rev 21284)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNodeTest.java
2010-08-10 20:01:56 UTC (rev 21285)
@@ -408,14 +408,6 @@
}
public void testDefaultAttributes() {
- CyDataTable def =
net.getNodeCyDataTables().get(CyNetwork.DEFAULT_ATTRS);
- assertNotNull(def);
-
assertNotNull(net.getNodeCyDataTables().get(CyNetwork.HIDDEN_ATTRS));
- assertTrue(def.getColumnTypeMap().containsKey("name"));
- assertTrue(def.getColumnTypeMap().get("name") == String.class );
- assertTrue(def.getColumnTypeMap().containsKey("selected"));
- assertTrue(def.getColumnTypeMap().get("selected") ==
Boolean.class );
-
CyNode n1 = net.addNode();
assertEquals( String.class, n1.attrs().contains("name"));
assertEquals( Boolean.class, n1.attrs().contains("selected"));
Added:
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableManagerTest.java
===================================================================
---
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableManagerTest.java
(rev 0)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyTableManagerTest.java
2010-08-10 20:01:56 UTC (rev 21285)
@@ -0,0 +1,115 @@
+
+/*
+ Copyright (c) 2010, The Cytoscape Consortium (www.cytoscape.org)
+
+ The Cytoscape Consortium is:
+ - Institute for Systems Biology
+ - University of California San Diego
+ - Memorial Sloan-Kettering Cancer Center
+ - Institut Pasteur
+ - Agilent Technologies
+
+ 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 junit.framework.Assert;
+import junit.framework.Test;
+import junit.framework.TestCase;
+import junit.framework.TestSuite;
+
+
+import java.lang.RuntimeException;
+
+import java.util.*;
+
+import static org.mockito.Mockito.*;
+
+
+/**
+ * DOCUMENT ME!
+ */
+public abstract class AbstractCyTableManagerTest extends TestCase {
+
+ protected CyTableManager mgr;
+ private CyNetwork n;
+
+ public void setUp() {
+ n = mock(CyNetwork.class);
+ }
+
+ // we want to return null if a table map has not been set
+ public void testGetEmptyTableMap() {
+ assertNull( mgr.getTableMap("NETWORK",n) );
+ assertNull( mgr.getTableMap("NODE",n) );
+ assertNull( mgr.getTableMap("EDGE",n) );
+ }
+
+ public void testGetSetTableMap() {
+ assertNotNull(n);
+ checkGetSet("NETWORK");
+ checkGetSet("NODE");
+ checkGetSet("EDGE");
+ }
+
+ private void checkGetSet(String type) {
+ assertNotNull(n);
+ Map<String, CyDataTable> map = new
HashMap<String,CyDataTable>();
+
+ mgr.setTableMap(type, n, map);
+
+ assertNotNull(mgr.getTableMap(type, n));
+ assertEquals(map,mgr.getTableMap(type, n));
+ }
+
+ // to clean up a table map
+ public void testSetNullTableMap() {
+ Map<String, CyDataTable> map = new
HashMap<String,CyDataTable>();
+
+ mgr.setTableMap("NETWORK", n, map);
+
+ assertNotNull(mgr.getTableMap("NETWORK", n));
+ assertEquals(map,mgr.getTableMap("NETWORK", n));
+
+ mgr.setTableMap("NETWORK", n, null);
+
+ assertNull(mgr.getTableMap("NETWORK", n));
+ }
+
+ public void testNullGetTableMap() {
+ assertNull(mgr.getTableMap("NETWORK", null));
+ }
+
+ public void testSetNullGraphObjectTableMap() {
+ Map<String, CyDataTable> map = new
HashMap<String,CyDataTable>();
+ try {
+ mgr.setTableMap("NETWORK", null, map);
+ } catch (NullPointerException npe) {
+ return;
+ }
+ fail("did not catch expected exception");
+ }
+}
--
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.