Author: kono
Date: 2012-09-19 11:40:54 -0700 (Wed, 19 Sep 2012)
New Revision: 30383
Modified:
core3/impl/trunk/core-task-impl/pom.xml
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/table/JoinTablesTask.java
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/JoinTablesTaskTest.java
Log:
Code cleanup only.
Modified: core3/impl/trunk/core-task-impl/pom.xml
===================================================================
--- core3/impl/trunk/core-task-impl/pom.xml 2012-09-19 01:19:04 UTC (rev
30382)
+++ core3/impl/trunk/core-task-impl/pom.xml 2012-09-19 18:40:54 UTC (rev
30383)
@@ -182,7 +182,6 @@
<artifactId>equations-api</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.cytoscape</groupId>
<artifactId>ding-presentation-impl</artifactId>
Modified:
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/table/JoinTablesTask.java
===================================================================
---
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/table/JoinTablesTask.java
2012-09-19 01:19:04 UTC (rev 30382)
+++
core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/table/JoinTablesTask.java
2012-09-19 18:40:54 UTC (rev 30383)
@@ -1,4 +1,3 @@
-
package org.cytoscape.task.internal.table;
import java.util.ArrayList;
@@ -26,83 +25,99 @@
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-public class JoinTablesTask extends AbstractTask{
+public class JoinTablesTask extends AbstractTask {
+
enum TableType {
- NODE_ATTR("Node Attributes", CyNode.class), EDGE_ATTR("Edge
Attributes", CyEdge.class), NETWORK_ATTR("Network Attributes", CyNetwork.class);
+ NODE_ATTR("Node Attributes", CyNode.class),
+ EDGE_ATTR("Edge Attributes", CyEdge.class),
+ NETWORK_ATTR("Network Attributes", CyNetwork.class);
private final String name;
- private final Class<? extends CyIdentifiable> type;
+ private final Class<? extends CyIdentifiable> type;
private TableType(final String name, Class<? extends
CyIdentifiable> type) {
this.name = name;
this.type = type;
}
- public Class<? extends CyIdentifiable> getType(){
+ public Class<? extends CyIdentifiable> getType() {
return this.type;
}
- @Override
+ @Override
public String toString() {
return name;
}
};
- private static Logger logger =
LoggerFactory.getLogger(MapTableToNetworkTablesTask.class);
- private static String NO_NETWORKS = "No Networks Found";
- private boolean byReader;
+ private static final Logger logger =
LoggerFactory.getLogger(MapTableToNetworkTablesTask.class);
+ private static final String NO_NETWORKS = "No Networks Found";
+
+ private boolean byReader;
private CyTableReader reader;
private CyTable globalTable;
private CyRootNetworkManager rootNetworkManager;
private CyNetworkManager networkManager;
private Map<String, CyNetwork> name2NetworkMap;
private Map<String, CyRootNetwork> name2RootMap;
- private Map<String,String> source2targetColumnMap;
+ private Map<String, String> source2targetColumnMap;
- //********tunables********************
public ListSingleSelection<TableType> dataTypeOptions;
+
@Tunable(description = "Import Data as:")
- public ListSingleSelection<TableType> getDataTypeOptions(){
+ public ListSingleSelection<TableType> getDataTypeOptions() {
return dataTypeOptions;
}
- public void setDataTypeOptions(ListSingleSelection<TableType> options ){
- columnList =
getColumns(name2RootMap.get(rootNetworkList.getSelectedValue()) ,
dataTypeOptions.getSelectedValue(), CyRootNetwork.SHARED_ATTRS);
+
+ public void setDataTypeOptions(ListSingleSelection<TableType> options) {
+ columnList =
getColumns(name2RootMap.get(rootNetworkList.getSelectedValue()),
+ dataTypeOptions.getSelectedValue(),
CyRootNetwork.SHARED_ATTRS);
}
public ListSingleSelection<String> rootNetworkList;
- @Tunable(description = "Network Collection List",groups="Select a
Network Collection",dependsOn="SelectedNetworksOnly=false", params =
"displayState=uncollapsed")
- public ListSingleSelection<String> getRootNetworkList(){
+
+ @Tunable(description = "Network Collection List", groups = "Select a
Network Collection", dependsOn = "SelectedNetworksOnly=false", params =
"displayState=uncollapsed")
+ public ListSingleSelection<String> getRootNetworkList() {
return rootNetworkList;
}
- public void setRootNetworkList (ListSingleSelection<String> roots){
- columnList =
getColumns(name2RootMap.get(rootNetworkList.getSelectedValue()) ,
dataTypeOptions.getSelectedValue(), CyRootNetwork.SHARED_ATTRS);
+
+ public void setRootNetworkList(ListSingleSelection<String> roots) {
+ columnList =
getColumns(name2RootMap.get(rootNetworkList.getSelectedValue()),
+ dataTypeOptions.getSelectedValue(),
CyRootNetwork.SHARED_ATTRS);
}
public ListSingleSelection<String> columnList;
- @Tunable(description = "Key Column for Network:",groups="Select a
Network Collection", listenForChange={"DataTypeOptions",
"RootNetworkList"},dependsOn="SelectedNetworksOnly=false", params =
"displayState=uncollapsed")
- public ListSingleSelection<String> getColumnList(){
+
+ @Tunable(description = "Key Column for Network:", groups = "Select a
Network Collection", listenForChange = {
+ "DataTypeOptions", "RootNetworkList" }, dependsOn =
"SelectedNetworksOnly=false", params = "displayState=uncollapsed")
+ public ListSingleSelection<String> getColumnList() {
return columnList;
}
- public void setColumnList(ListSingleSelection<String> colList){
+
+ public void setColumnList(ListSingleSelection<String> colList) {
this.columnList = colList;
}
public boolean selectedNetworksOnly = false;
+
@Tunable(description = "Or apply to selected networks only")
- public boolean getSelectedNetworksOnly (){
+ public boolean getSelectedNetworksOnly() {
return selectedNetworksOnly;
}
- public void setSelectedNetworksOnly(boolean selectedOnly){
+
+ public void setSelectedNetworksOnly(boolean selectedOnly) {
this.selectedNetworksOnly = selectedOnly;
}
-
+
public ListMultipleSelection<String> networkList;
- @Tunable(description = "Network List",groups="Select
Networks",dependsOn="SelectedNetworksOnly=true", params =
"displayState=collapsed")
- public ListMultipleSelection<String> getNetworkList(){
+
+ @Tunable(description = "Network List", groups = "Select Networks",
dependsOn = "SelectedNetworksOnly=true", params = "displayState=collapsed")
+ public ListMultipleSelection<String> getNetworkList() {
return networkList;
}
- public void setNetworkList (ListMultipleSelection<String> list){
+
+ public void setNetworkList(ListMultipleSelection<String> list) {
this.networkList = list;
}
@@ -111,69 +126,58 @@
return "Import Data ";
}
- //************************************
- public JoinTablesTask(CyTableReader reader, CyRootNetworkManager
rootNetworkManeger, CyNetworkManager networkManager){
+ public JoinTablesTask(CyTableReader reader, CyRootNetworkManager
rootNetworkManeger, CyNetworkManager networkManager) {
this.reader = reader;
this.byReader = true;
this.globalTable = null;
-
- this.rootNetworkManager = rootNetworkManeger;
- this.networkManager = networkManager;
- this.name2NetworkMap = new HashMap<String, CyNetwork>();
- this.name2RootMap = new HashMap<String, CyRootNetwork>();
- this.source2targetColumnMap = new HashMap<String, String>();
-
-
- initTunable(networkManager);
+ init(rootNetworkManeger, networkManager);
}
- public JoinTablesTask(CyTable globalTable, CyRootNetworkManager
rootNetworkManeger, CyNetworkManager networkManager){
+ public JoinTablesTask(CyTable globalTable, CyRootNetworkManager
rootNetworkManeger, CyNetworkManager networkManager) {
this.reader = null;
this.byReader = false;
this.globalTable = globalTable;
-
+ init(rootNetworkManeger, networkManager);
+ }
+
+ private final void init(CyRootNetworkManager rootNetworkManeger,
CyNetworkManager networkManager) {
this.rootNetworkManager = rootNetworkManeger;
this.networkManager = networkManager;
this.name2NetworkMap = new HashMap<String, CyNetwork>();
this.name2RootMap = new HashMap<String, CyRootNetwork>();
this.source2targetColumnMap = new HashMap<String, String>();
-
initTunable(networkManager);
}
+ private final void initTunable(CyNetworkManager networkManage) {
- private void initTunable(CyNetworkManager networkManage){
-
selectedNetworksOnly = false;
final List<TableType> options = new ArrayList<TableType>();
- for(TableType type: TableType.values())
+ for (TableType type : TableType.values())
options.add(type);
dataTypeOptions = new ListSingleSelection<TableType>(options);
dataTypeOptions.setSelectedValue(TableType.NODE_ATTR);
-
-
- for(CyNetwork net: networkManage.getNetworkSet()){
+ for (CyNetwork net : networkManage.getNetworkSet()) {
String netName = net.getRow(net).get(CyNetwork.NAME,
String.class);
name2NetworkMap.put(netName, net);
}
List<String> names = new ArrayList<String>();
names.addAll(name2NetworkMap.keySet());
- if(names.isEmpty())
+ if (names.isEmpty())
networkList = new
ListMultipleSelection<String>(NO_NETWORKS);
else
networkList = new ListMultipleSelection<String>(names);
-
- for (CyNetwork net : networkManager.getNetworkSet()){
+ for (CyNetwork net : networkManager.getNetworkSet()) {
final CyRootNetwork rootNet =
rootNetworkManager.getRootNetwork(net);
- if (!name2RootMap.containsValue(rootNet ) )
+ if (!name2RootMap.containsValue(rootNet))
name2RootMap.put(rootNet.getRow(rootNet).get(CyRootNetwork.NAME, String.class),
rootNet);
}
List<String> rootNames = new ArrayList<String>();
@@ -181,16 +185,15 @@
rootNetworkList = new ListSingleSelection<String>(rootNames);
rootNetworkList.setSelectedValue(rootNames.get(0));
-
-
- columnList = getColumns(
name2RootMap.get(rootNetworkList.getSelectedValue()) ,
dataTypeOptions.getSelectedValue(), CyRootNetwork.SHARED_ATTRS);
+ columnList =
getColumns(name2RootMap.get(rootNetworkList.getSelectedValue()),
+ dataTypeOptions.getSelectedValue(),
CyRootNetwork.SHARED_ATTRS);
}
- public ListSingleSelection<String> getColumns (CyNetwork network,
TableType tableType, String namespace){
- CyTable selectedTable = getTable(network , tableType,
CyRootNetwork.SHARED_ATTRS);
+ public ListSingleSelection<String> getColumns(CyNetwork network,
TableType tableType, String namespace) {
+ CyTable selectedTable = getTable(network, tableType,
CyRootNetwork.SHARED_ATTRS);
List<String> colNames = new ArrayList<String>();
- for(CyColumn col: selectedTable.getColumns())
+ for (CyColumn col : selectedTable.getColumns())
colNames.add(col.getName());
ListSingleSelection<String> columns = new
ListSingleSelection<String>(colNames);
@@ -202,47 +205,43 @@
TableType tableType = dataTypeOptions.getSelectedValue();
- if (!checkKeys()){
+ if (!checkKeys()) {
throw new IllegalArgumentException("Types of keys
selected for tables are not matching.");
}
if (!selectedNetworksOnly)
- mapTableToDefaultAttrs (tableType);
+ mapTableToDefaultAttrs(tableType);
else
- mapTableToLocalAttrs (tableType);
+ mapTableToLocalAttrs(tableType);
-
}
-
-
private void mapTableToLocalAttrs(TableType tableType) {
List<CyNetwork> networks = new ArrayList<CyNetwork>();
if (networkList.getSelectedValues().isEmpty())
return;
- if(!networkList.getSelectedValues().get(0).equals(NO_NETWORKS))
- for(String netName: networkList.getSelectedValues())
+ if (!networkList.getSelectedValues().get(0).equals(NO_NETWORKS))
+ for (String netName : networkList.getSelectedValues())
networks.add(name2NetworkMap.get(netName));
- for (CyNetwork network: networks){
+ for (CyNetwork network : networks) {
CyTable targetTable = getTable(network, tableType,
CyNetwork.LOCAL_ATTRS);
if (targetTable != null)
applyMapping(targetTable);
}
}
-
- private void mapTableToDefaultAttrs(TableType tableType) {
- CyTable targetTable =
getTable(name2RootMap.get(rootNetworkList.getSelectedValue()) , tableType,
CyRootNetwork.SHARED_DEFAULT_ATTRS);
- if (targetTable != null){
+ private void mapTableToDefaultAttrs(TableType tableType) {
+ CyTable targetTable =
getTable(name2RootMap.get(rootNetworkList.getSelectedValue()), tableType,
+ CyRootNetwork.SHARED_DEFAULT_ATTRS);
+ if (targetTable != null) {
applyMapping(targetTable);
}
}
-
- private CyTable getTable(CyNetwork network, TableType tableType, String
namespace){
+ private CyTable getTable(CyNetwork network, TableType tableType, String
namespace) {
if (tableType == TableType.NODE_ATTR)
return network.getTable(CyNode.class, namespace);
if (tableType == TableType.EDGE_ATTR)
@@ -250,40 +249,39 @@
if (tableType == TableType.NETWORK_ATTR)
return network.getTable(CyNetwork.class, namespace);
- logger.warn("The selected table type is not valie. \nTable
needs to be one of these types: " +TableType.NODE_ATTR +", " +
TableType.EDGE_ATTR + ", "+ TableType.NETWORK_ATTR +".");
+ logger.warn("The selected table type is not valie. \nTable
needs to be one of these types: "
+ + TableType.NODE_ATTR + ", " +
TableType.EDGE_ATTR + ", " + TableType.NETWORK_ATTR + ".");
return null;
}
+ private void applyMapping(CyTable targetTable) {
+ if (byReader) {
+ if (reader.getTables() != null &&
reader.getTables().length > 0) {
+ for (CyTable sourceTable : reader.getTables()) {
- private void applyMapping(CyTable targetTable){
- if(byReader){
- if (reader.getTables() != null &&
reader.getTables().length >0){
- for(CyTable sourceTable : reader.getTables()){
-
- copyColumns (sourceTable, targetTable);
+ copyColumns(sourceTable, targetTable);
copyRows(sourceTable, targetTable);
}
}
- }else{
- copyColumns (globalTable, targetTable);
+ } else {
+ copyColumns(globalTable, targetTable);
copyRows(globalTable, targetTable);
}
}
- private CyColumn getJoinTargetColumn (CyTable targetTable){
+ private CyColumn getJoinTargetColumn(CyTable targetTable) {
String joinKeyName = CyNetwork.NAME;
if (!selectedNetworksOnly)
joinKeyName = columnList.getSelectedValue();
return targetTable.getColumn(joinKeyName);
}
-
private void copyRows(CyTable sourceTable, CyTable targetTable) {
CyColumn targetKeyColumn = getJoinTargetColumn(targetTable);
- for (CyRow targetRow: targetTable.getAllRows()){
- Object key = targetRow.get(targetKeyColumn.getName(),
targetKeyColumn.getType()) ;
+ for (CyRow targetRow : targetTable.getAllRows()) {
+ Object key = targetRow.get(targetKeyColumn.getName(),
targetKeyColumn.getType());
if (!sourceTable.rowExists(key))
continue;
@@ -293,7 +291,7 @@
if (sourceRow == null)
continue;
- for(CyColumn col: sourceTable.getColumns()){
+ for (CyColumn col : sourceTable.getColumns()) {
if (col == sourceTable.getPrimaryKey())
continue;
@@ -307,14 +305,12 @@
}
}
-
-
}
private void copyColumns(CyTable sourceTable, CyTable targetTable) {
- for(CyColumn col: sourceTable.getColumns()){
- if (col== sourceTable.getPrimaryKey())
+ for (CyColumn col : sourceTable.getColumns()) {
+ if (col == sourceTable.getPrimaryKey())
continue;
String targetColName = getUniqueColumnName(targetTable,
col.getName());
@@ -326,7 +322,6 @@
}
}
-
private String getUniqueColumnName(CyTable table, final String
preferredName) {
if (table.getColumn(preferredName) == null)
return preferredName;
@@ -345,18 +340,18 @@
Class<?> joinTargetColumnType = String.class;
if (!selectedNetworksOnly)
- joinTargetColumnType =
getJoinTargetColumn(getTable(name2RootMap.get(rootNetworkList.getSelectedValue())
, dataTypeOptions.getSelectedValue(), CyNetwork.DEFAULT_ATTRS)).getType();
- if (byReader){
- for ( CyTable readerTable: reader.getTables())
+ joinTargetColumnType = getJoinTargetColumn(
+
getTable(name2RootMap.get(rootNetworkList.getSelectedValue()),
dataTypeOptions.getSelectedValue(),
+
CyNetwork.DEFAULT_ATTRS)).getType();
+ if (byReader) {
+ for (CyTable readerTable : reader.getTables())
if (readerTable.getPrimaryKey().getType() !=
joinTargetColumnType)
return false;
- }else
- if (globalTable.getPrimaryKey().getType() !=
joinTargetColumnType)
- return false;
+ } else if (globalTable.getPrimaryKey().getType() !=
joinTargetColumnType)
+ return false;
return true;
}
-
}
Modified:
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/JoinTablesTaskTest.java
===================================================================
---
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/JoinTablesTaskTest.java
2012-09-19 01:19:04 UTC (rev 30382)
+++
core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/JoinTablesTaskTest.java
2012-09-19 18:40:54 UTC (rev 30383)
@@ -1,19 +1,16 @@
package org.cytoscape.task.internal.table;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.mockito.Mockito.mock;
import java.util.ArrayList;
import java.util.List;
import java.util.Properties;
-import org.junit.Test;
-
-import static org.mockito.Mockito.mock;
-import static org.junit.Assert.*;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.assertFalse;
-import static org.junit.Assert.assertEquals;
-
import org.cytoscape.equations.internal.interpreter.InterpreterImpl;
import org.cytoscape.event.CyEventHelper;
import org.cytoscape.event.DummyCyEventHelper;
@@ -22,7 +19,6 @@
import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyRow;
import org.cytoscape.model.CyTable;
-import org.cytoscape.model.CyTableManager;
import org.cytoscape.model.NetworkTestSupport;
import org.cytoscape.model.SavePolicy;
import org.cytoscape.model.internal.CyNetworkManagerImpl;
@@ -32,153 +28,154 @@
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.TaskMonitor;
-import org.cytoscape.work.internal.sync.*;
+import org.cytoscape.work.internal.sync.SyncTunableHandlerFactory;
+import org.cytoscape.work.internal.sync.SyncTunableMutator;
+import org.cytoscape.work.internal.sync.SyncTunableMutatorFactory;
+import org.cytoscape.work.internal.sync.TunableRecorderManager;
+import org.cytoscape.work.internal.sync.TunableSetterImpl;
+import org.junit.Test;
public class JoinTablesTaskTest {
-private final NetworkTestSupport support = new NetworkTestSupport();
+ private final NetworkTestSupport support = new NetworkTestSupport();
-
private CyNetwork net1;
private CyRootNetwork root;
-
+
private CyNode node1;
private CyNode node2;
-
+
private String node1Name = "node1";
private String node2Name = "node2";
-
- private CyTableImpl table1;
private static CyEventHelper eventHelper = new DummyCyEventHelper();
- private static CyNetworkManagerImpl netMgr = new
CyNetworkManagerImpl(eventHelper);
+ private static CyNetworkManagerImpl netMgr = new
CyNetworkManagerImpl(eventHelper);
private static CyRootNetworkManagerImpl rootNetMgr = new
CyRootNetworkManagerImpl();
-
+
private static SyncTunableMutator stm = new SyncTunableMutator();
private static SyncTunableHandlerFactory syncTunableHandlerFactory =
new SyncTunableHandlerFactory();
- private static TunableSetterImpl ts =new TunableSetterImpl(new
SyncTunableMutatorFactory(syncTunableHandlerFactory), new
TunableRecorderManager());
+ private static TunableSetterImpl ts = new TunableSetterImpl(
+ new
SyncTunableMutatorFactory(syncTunableHandlerFactory), new
TunableRecorderManager());
Properties syncFactoryProp = new Properties();
-
+
+
@Test
- public void testJoinTableToRootNetwork() throws Exception{
-
+ public void testJoinTableToRootNetwork() throws Exception {
+
stm.addTunableHandlerFactory(syncTunableHandlerFactory,
syncFactoryProp);
creatNetwork();
- table1 = (CyTableImpl) createTable("col1", "listCol1");
+ final CyTableImpl table1 = (CyTableImpl) createTable("col1",
"listCol1");
+
join(table1, net1, root,
root.getDefaultNodeTable().getColumn(CyRootNetwork.SHARED_NAME), false);
-
+
testJoinTableToRootNetworkColumn();
testJoinTableToRootNetworkListColumn();
-
+
testSubnetworkAfterJointoRoot();
-
}
-
- public void testJoinTableToRootNetworkColumn(){
+
+ @Test
+ public void testJoinTableToSubNetwork() throws Exception {
+
+ stm.addTunableHandlerFactory(syncTunableHandlerFactory,
syncFactoryProp);
+ creatNetwork();
+
+ final CyTable table2 = createTable("col2", "listCol2");
+
+ join(table2, net1, null,
net1.getDefaultNodeTable().getColumn(CyNetwork.NAME), true);
+ testJoinTableToSubNetworkColumns();
+ testJoinTableToSubNetworkListColumns();
+
+ testSubnetworkAfterJointoSub();
+ }
+
+
+ public void testJoinTableToRootNetworkColumn() {
assertNotNull(net1.getDefaultNodeTable().getColumn("col1"));
- assertEquals("col1 row1", net1.getRow(node1).get("col1",
String.class) );
+ assertEquals("col1 row1", net1.getRow(node1).get("col1",
String.class));
assertTrue(net1.getDefaultNodeTable().getColumn("col1").getVirtualColumnInfo().isVirtual());
-
+
}
-
- public void testJoinTableToRootNetworkListColumn(){
+
+ public void testJoinTableToRootNetworkListColumn() {
assertNotNull(net1.getDefaultNodeTable().getColumn("listCol1"));
- assertEquals("listRow1-1",
net1.getRow(node1).getList("listCol1", String.class).get(0) );
+ assertEquals("listRow1-1",
net1.getRow(node1).getList("listCol1", String.class).get(0));
assertTrue(net1.getDefaultNodeTable().getColumn("listCol1").getVirtualColumnInfo().isVirtual());
-
+
}
-
private void testSubnetworkAfterJointoRoot() {
List<CyNode> nodes = new ArrayList<CyNode>();
nodes.add(node1);
nodes.add(node2);
-
+
CyNetwork subNet = root.addSubNetwork(nodes, null);
-
+
assertNotNull(subNet.getDefaultNodeTable().getColumn("col1"));
- assertEquals("col1 row1", subNet.getRow(node1).get("col1",
String.class) );
+ assertEquals("col1 row1", subNet.getRow(node1).get("col1",
String.class));
assertTrue(subNet.getDefaultNodeTable().getColumn("col1").getVirtualColumnInfo().isVirtual());
}
-
- @Test
- public void testJoinTableToSubNetwork() throws Exception{
-
- stm.addTunableHandlerFactory(syncTunableHandlerFactory,
syncFactoryProp);
- creatNetwork();
- CyTable table2 = createTable("col2", "listCol2");
-
- join(table2, net1, null,
net1.getDefaultNodeTable().getColumn(CyNetwork.NAME), true);
- testJoinTableToSubNetworkColumns();
- testJoinTableToSubNetworkListColumns();
-
- testSubnetworkAfterJointoSub();
- }
-
- public void testJoinTableToSubNetworkColumns(){
+ public void testJoinTableToSubNetworkColumns() {
assertNotNull(net1.getDefaultNodeTable().getColumn("col2"));
- assertEquals("col1 row1", net1.getRow(node1).get("col2",
String.class) );
+ assertEquals("col1 row1", net1.getRow(node1).get("col2",
String.class));
assertFalse(net1.getDefaultNodeTable().getColumn("col2").getVirtualColumnInfo().isVirtual());
}
-
- public void testJoinTableToSubNetworkListColumns(){
+
+ public void testJoinTableToSubNetworkListColumns() {
assertNotNull(net1.getDefaultNodeTable().getColumn("listCol2"));
- assertEquals("listRow1-1",
net1.getRow(node1).getList("listCol2", String.class).get(0) );
+ assertEquals("listRow1-1",
net1.getRow(node1).getList("listCol2", String.class).get(0));
assertFalse(net1.getDefaultNodeTable().getColumn("listCol2").getVirtualColumnInfo().isVirtual());
-
+
}
-
+
private void testSubnetworkAfterJointoSub() {
List<CyNode> nodes = new ArrayList<CyNode>();
nodes.add(node1);
nodes.add(node2);
-
+
CyNetwork subNet = root.addSubNetwork(nodes, null);
-
assertNull(subNet.getDefaultNodeTable().getColumn("col1"));
-
}
-
- public void creatNetwork(){
+ private final void creatNetwork() {
net1 = support.getNetwork();
-
- node1 = net1.addNode();
- node2 = net1.addNode();
+
+ node1 = net1.addNode();
+ node2 = net1.addNode();
net1.addEdge(node1, node2, true);
-
+
net1.getDefaultNodeTable().getRow(node1.getSUID()).set(CyRootNetwork.SHARED_NAME,
node1Name);
net1.getDefaultNodeTable().getRow(node2.getSUID()).set(CyRootNetwork.SHARED_NAME,
node2Name);
-
+
net1.getDefaultNodeTable().getRow(node1.getSUID()).set(CyNetwork.NAME,
node1Name);
net1.getDefaultNodeTable().getRow(node2.getSUID()).set(CyNetwork.NAME,
node2Name);
-
-
+
net1.getRow(net1).set(CyNetwork.NAME, "net1");
-
+
netMgr.addNetwork(net1);
-
- //check root network
+
+ // check root network
root = rootNetMgr.getRootNetwork(net1);
assertEquals(2, root.getSharedNodeTable().getAllRows().size());
}
-
- public CyTable createTable(String col, String listCol ){
- CyTable table1 = new CyTableImpl("dummy table", "ID",
String.class, true, true,
- SavePolicy.DO_NOT_SAVE , eventHelper, new
InterpreterImpl(), 2);
+
+
+ private final CyTable createTable(String col, String listCol) {
+ CyTable table1 = new CyTableImpl("dummy table", "ID",
String.class, true, true, SavePolicy.DO_NOT_SAVE,
+ eventHelper, new InterpreterImpl(), 2);
table1.createColumn(col, String.class, false);
-
+
CyRow row1 = table1.getRow(node1Name);
row1.set(col, "col1 row1");
CyRow row2 = table1.getRow(node2Name);
row2.set(col, "col1 row2");
-
+
List<String> s = new ArrayList<String>();
s.add("listRow1-1");
s.add("listRow1-2");
@@ -186,24 +183,24 @@
s2.add("listRow2-1");
s2.add("listRow2-2");
-
- table1.createListColumn(listCol, String.class , false);
+ table1.createListColumn(listCol, String.class, false);
CyRow listRow1 = table1.getRow(node1Name);
listRow1.set(listCol, s);
CyRow listRow2 = table1.getRow(node2Name);
listRow2.set(listCol, s2);
-
+
return table1;
}
-
- public static void join(CyTable table, CyNetwork net, CyRootNetwork
rootNet, CyColumn col, boolean selectedOnly) throws Exception{
+
+ public static void join(CyTable table, CyNetwork net, CyRootNetwork
rootNet, CyColumn col, boolean selectedOnly)
+ throws Exception {
JoinTablesTaskTaskFactoryImpl joinTableTF = new
JoinTablesTaskTaskFactoryImpl(netMgr, ts, rootNetMgr);
List<CyNetwork> nets = new ArrayList<CyNetwork>();
nets.add(net);
-
- TaskIterator ti = joinTableTF.createTaskIterator(table,
selectedOnly, nets, rootNet, col , CyNode.class);
+
+ TaskIterator ti = joinTableTF.createTaskIterator(table,
selectedOnly, nets, rootNet, col, CyNode.class);
assertNotNull("task iterator is null", ti);
-
+
assertTrue(ti.hasNext());
Task t = ti.next();
assertNotNull("task is null", t);
--
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.