Author: ruschein
Date: 2010-11-12 15:49:53 -0800 (Fri, 12 Nov 2010)
New Revision: 22833
Modified:
core3/model-api/trunk/src/main/java/org/cytoscape/model/CyNode.java
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNodeTest.java
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/ArrayGraph.java
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/CyNodeImpl.java
Log:
Added NESTED_NETWORK as well as HAS_NESTED_NETWORK node attrs.
Modified: core3/model-api/trunk/src/main/java/org/cytoscape/model/CyNode.java
===================================================================
--- core3/model-api/trunk/src/main/java/org/cytoscape/model/CyNode.java
2010-11-12 22:56:50 UTC (rev 22832)
+++ core3/model-api/trunk/src/main/java/org/cytoscape/model/CyNode.java
2010-11-12 23:49:53 UTC (rev 22833)
@@ -42,6 +42,10 @@
/** The column name for the nested network associated with a
<code>CyNode</code> in the user table. */
final static String NESTED_NETWORK_ATTR = "NestedNetwork";
+ /** The column name for the attribute that allows testing of whether a
<code>CyNode</code>
+ has an associated nested network or not. (Found in the user
table.) */
+ final static String HAS_NESTED_NETWORK_ATTR = "hasNestedNetwork";
+
/**
* An index of this node within this network. The index is guaranteed
to
* be between 0 and (the number of nodes in the network) - 1. This index
@@ -72,7 +76,8 @@
*
* Note that this if a previous nested network is being replaced or
nulled out, an
* {...@link UnsetNestedNetworkEvent} will be fired and if a new nested
network will be set a
- * {...@link SetNestedNetworkEvent} will be fired.
+ * {...@link SetNestedNetworkEvent} will be fired. Furthermore the
(@link NESTED_NETWORK_ATTR}
+ * column in the user table will be updated.
*/
void setNestedNetwork(CyNetwork nestedNetwork);
}
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-11-12 22:56:50 UTC (rev 22832)
+++
core3/model-api/trunk/src/test/java/org/cytoscape/model/AbstractCyNodeTest.java
2010-11-12 23:49:53 UTC (rev 22833)
@@ -1,14 +1,6 @@
-
/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
+ Copyright (c) 2008, 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
@@ -33,9 +25,9 @@
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;
@@ -53,9 +45,8 @@
import static org.mockito.Mockito.*;
-/**
- * DOCUMENT ME!
- */
+
+/** Base class for CyNode tests. */
public abstract class AbstractCyNodeTest extends TestCase {
protected CyNetwork net;
@@ -138,4 +129,20 @@
assertNull(net.getNode(0));
assertEquals(n1,net.getNode(1));
}
+
+ public void testNestedNetworkUserTableUpdates() {
+ CyNode n1 = net.addNode();
+ CyNetwork net2 = mock(CyNetwork.class);
+ when(net2.getSUID()).thenReturn(223L);
+ final CyRow row = n1.getCyRow();
+ assertFalse(row.isSet(CyNode.NESTED_NETWORK_ATTR,
String.class));
+ assertFalse(row.get(CyNode.HAS_NESTED_NETWORK_ATTR,
Boolean.class));
+ n1.setNestedNetwork(net2);
+ assertTrue(row.isSet(CyNode.NESTED_NETWORK_ATTR, String.class));
+ assertTrue(row.get(CyNode.HAS_NESTED_NETWORK_ATTR,
Boolean.class));
+ assertEquals("223", row.get(CyNode.NESTED_NETWORK_ATTR,
String.class));
+ n1.setNestedNetwork(null);
+ assertFalse(row.isSet(CyNode.NESTED_NETWORK_ATTR,
String.class));
+ assertFalse(row.get(CyNode.HAS_NESTED_NETWORK_ATTR,
Boolean.class));
+ }
}
Modified:
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/ArrayGraph.java
===================================================================
---
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/ArrayGraph.java
2010-11-12 22:56:50 UTC (rev 22832)
+++
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/ArrayGraph.java
2010-11-12 23:49:53 UTC (rev 22833)
@@ -1,14 +1,6 @@
-
/*
- Copyright (c) 2008, The Cytoscape Consortium (www.cytoscape.org)
+ Copyright (c) 2008, 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
@@ -33,9 +25,9 @@
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.internal;
+
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
@@ -134,15 +126,16 @@
nodeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyTableEntry.NAME,String.class);
nodeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyTableEntry.SELECTED,Boolean.class);
+
nodeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyNode.NESTED_NETWORK_ATTR,
String.class);
+
nodeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyNode.HAS_NESTED_NETWORK_ATTR,
Boolean.class);
edgeAttrMgr = new HashMap<String, CyTable>();
edgeAttrMgr.put(CyNetwork.DEFAULT_ATTRS,
tableFactory.createTable( suid + " edge", "SUID", Long.class, true));
edgeAttrMgr.put(CyNetwork.HIDDEN_ATTRS,
tableFactory.createTable( suid + " edge", "SUID", Long.class, false));
-
edgeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyTableEntry.NAME,String.class);
-
edgeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyTableEntry.SELECTED,Boolean.class);
-
edgeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyEdge.INTERACTION,String.class);
-
+
edgeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyTableEntry.NAME,
String.class);
+
edgeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyTableEntry.SELECTED,
Boolean.class);
+
edgeAttrMgr.get(CyNetwork.DEFAULT_ATTRS).createColumn(CyEdge.INTERACTION,
String.class);
eventHelper = eh;
subNetworks = new ArrayList<CySubNetwork>();
Modified:
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/CyNodeImpl.java
===================================================================
---
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/CyNodeImpl.java
2010-11-12 22:56:50 UTC (rev 22832)
+++
core3/model-impl/trunk/src/main/java/org/cytoscape/model/internal/CyNodeImpl.java
2010-11-12 23:49:53 UTC (rev 22833)
@@ -29,10 +29,11 @@
import org.cytoscape.event.CyEventHelper;
-import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNode;
+import org.cytoscape.model.CyRow;
+import org.cytoscape.model.CyTable;
import org.cytoscape.model.events.SetNestedNetworkEvent;
import org.cytoscape.model.events.UnsetNestedNetworkEvent;
@@ -50,6 +51,8 @@
index = ind;
nestedNet = null;
this.eventHelper = eventHelper;
+
+ getCyRow().set(HAS_NESTED_NETWORK_ATTR, Boolean.valueOf(false));
}
/**
@@ -75,7 +78,7 @@
return nestedNet;
}
- public synchronized void setNestedNetwork(CyNetwork n) {
+ public synchronized void setNestedNetwork(final CyNetwork n) {
if (n == nestedNet)
return;
@@ -84,6 +87,14 @@
if (n != null)
eventHelper.fireSynchronousEvent(new
SetNestedNetworkEvent(this, n));
nestedNet = n;
+
+ final CyRow row = getCyRow();
+ if (n == null) {
+ row.set(NESTED_NETWORK_ATTR, null);
+ row.set(HAS_NESTED_NETWORK_ATTR,
Boolean.valueOf(false));
+ } else {
+ row.set(NESTED_NETWORK_ATTR,
Long.valueOf(n.getSUID()).toString());
+ row.set(HAS_NESTED_NETWORK_ATTR, Boolean.valueOf(true));
+ }
}
-
}
--
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.