Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

fixes #1402 mapping the virtual columns to local tables of subnetwork…

…s for selected only condition and to default attrs of root network for map to all condition.

git-svn-id: http://chianti.ucsd.edu/svn@30291 0ecc0d97-ab19-0410-9704-bfe1a75892f5
  • Loading branch information...
commit 2c3cdf6ad5befcc63c56a1511ce83a2fb3de5555 1 parent 7c02c23
rozagh authored
Showing with 155 additions and 80 deletions.
  1. +4 −4 core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/CyActivator.java
  2. +7 −6 ...unk/core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
  3. +6 −3 ...runk/core-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/AbstractLoadAttributesTask.java
  4. +3 −2 ...unk/core-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/CombineReaderAndMappingTask.java
  5. +4 −2 ...pl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesFileTask.java
  6. +5 −2 ...re-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesFileTaskFactoryImpl.java
  7. +4 −2 ...mpl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesURLTask.java
  8. +6 −2 ...ore-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesURLTaskFactoryImpl.java
  9. +84 −46 .../impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/table/MapTableToNetworkTablesTask.java
  10. +5 −2 .../core-task-impl/src/main/java/org/cytoscape/task/internal/table/MapTableToNetworkTablesTaskFactoryImpl.java
  11. +5 −1 ...ask-impl/src/test/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesFileTaskFactoryImplTest.java
  12. +5 −1 ...task-impl/src/test/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesURLTaskFactoryImplTest.java
  13. +4 −2 ...pl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/MapTableToNetworkTableTaskTest.java
  14. +8 −3 core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/MappingIntegrationTest.java
  15. +5 −2 ...unk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/UpdateAddedNetworkAttributeTaskTest.java
View
8 core3/impl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/CyActivator.java
@@ -221,7 +221,7 @@ public void start(BundleContext bc) {
CyTableWriterManager cyTableWriterManagerRef = getService(bc,CyTableWriterManager.class);
SynchronousTaskManager<?> synchronousTaskManagerServiceRef = getService(bc,SynchronousTaskManager.class);
TunableSetter tunableSetterServiceRef = getService(bc,TunableSetter.class);
-
+ CyRootNetworkManager rootNetworkManagerServiceRef = getService(bc, CyRootNetworkManager.class);
CyGroupManager cyGroupManager = getService(bc, CyGroupManager.class);
CyGroupFactory cyGroupFactory = getService(bc, CyGroupFactory.class);
@@ -300,8 +300,8 @@ public void start(BundleContext bc) {
registerService(bc, updateAddedNetworkAttributes, SessionLoadedListener.class, new Properties());
- LoadAttributesFileTaskFactoryImpl loadAttrsFileTaskFactory = new LoadAttributesFileTaskFactoryImpl(cyDataTableReaderManagerServiceRef, tunableSetterServiceRef,cyNetworkManagerServiceRef, cyTableManagerServiceRef, updateAddedNetworkAttributes);
- LoadAttributesURLTaskFactoryImpl loadAttrsURLTaskFactory = new LoadAttributesURLTaskFactoryImpl(cyDataTableReaderManagerServiceRef, tunableSetterServiceRef, cyNetworkManagerServiceRef, cyTableManagerServiceRef, updateAddedNetworkAttributes);
+ LoadAttributesFileTaskFactoryImpl loadAttrsFileTaskFactory = new LoadAttributesFileTaskFactoryImpl(cyDataTableReaderManagerServiceRef, tunableSetterServiceRef,cyNetworkManagerServiceRef, cyTableManagerServiceRef, updateAddedNetworkAttributes,rootNetworkManagerServiceRef );
+ LoadAttributesURLTaskFactoryImpl loadAttrsURLTaskFactory = new LoadAttributesURLTaskFactoryImpl(cyDataTableReaderManagerServiceRef, tunableSetterServiceRef, cyNetworkManagerServiceRef, cyTableManagerServiceRef, updateAddedNetworkAttributes, rootNetworkManagerServiceRef);
// Apply Visual Style Task
ApplyVisualStyleTaskFactoryimpl applyVisualStyleTaskFactory = new ApplyVisualStyleTaskFactoryimpl(visualMappingManagerServiceRef);
@@ -1067,7 +1067,7 @@ public void start(BundleContext bc) {
// TODO: remove from group...
- MapTableToNetworkTablesTaskFactoryImpl mapNetworkToTables = new MapTableToNetworkTablesTaskFactoryImpl(cyNetworkManagerServiceRef, tunableSetterServiceRef, updateAddedNetworkAttributes);
+ MapTableToNetworkTablesTaskFactoryImpl mapNetworkToTables = new MapTableToNetworkTablesTaskFactoryImpl(cyNetworkManagerServiceRef, tunableSetterServiceRef, updateAddedNetworkAttributes, rootNetworkManagerServiceRef);
Properties mapNetworkToTablesProps = new Properties();
registerService(bc, mapNetworkToTables, MapTableToNetworkTablesTaskFactory.class, mapNetworkToTablesProps);
View
13 .../core-task-impl/src/main/java/org/cytoscape/task/internal/creation/AbstractNetworkFromSelectionTask.java
@@ -115,10 +115,11 @@ public void run(TaskMonitor tm) {
// create subnetwork and add selected nodes and appropriate edges
final CySubNetwork newNet = rootNetworkManager.getRootNetwork(parentNetwork).addSubNetwork();
-
- addColumns(parentNetwork.getDefaultNodeTable(), newNet.getDefaultNodeTable() );
- addColumns(parentNetwork.getDefaultEdgeTable(), newNet.getDefaultEdgeTable() );
- addColumns(parentNetwork.getDefaultNetworkTable(), newNet.getDefaultNetworkTable());
+
+ //We need to cpy the columns to local tables, since copying them to default table will duplicate the virtual columns.
+ addColumns(parentNetwork.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyNode.class, CyNetwork.LOCAL_ATTRS));
+ addColumns(parentNetwork.getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyEdge.class, CyNetwork.LOCAL_ATTRS) );
+ addColumns(parentNetwork.getTable(CyNetwork.class, CyNetwork.LOCAL_ATTRS), newNet.getTable(CyNetwork.class, CyNetwork.LOCAL_ATTRS));
tm.setProgress(0.3);
@@ -174,13 +175,13 @@ private void addVirtualColumn (CyColumn col, CyTable subTable){
VirtualColumnInfo colInfo = col.getVirtualColumnInfo();
CyColumn checkCol= subTable.getColumn(col.getName());
if(checkCol == null)
- subTable.addVirtualColumn(col.getName(), colInfo.getSourceColumn(), colInfo.getSourceTable(), colInfo.getTargetJoinKey(), true);
+ subTable.addVirtualColumn(col.getName(), colInfo.getSourceColumn(), colInfo.getSourceTable(), colInfo.getTargetJoinKey(), col.isImmutable());
else
if(!checkCol.getVirtualColumnInfo().isVirtual() ||
!checkCol.getVirtualColumnInfo().getSourceTable().equals(colInfo.getSourceTable()) ||
!checkCol.getVirtualColumnInfo().getSourceColumn().equals(colInfo.getSourceColumn()))
- subTable.addVirtualColumn(col.getName(), colInfo.getSourceColumn(), colInfo.getSourceTable(), colInfo.getTargetJoinKey(), true);
+ subTable.addVirtualColumn(col.getName(), colInfo.getSourceColumn(), colInfo.getSourceTable(), colInfo.getTargetJoinKey(), col.isImmutable());
}
private void copyColumn(CyColumn col, CyTable subTable) {
View
9 ...k/core-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/AbstractLoadAttributesTask.java
@@ -7,6 +7,7 @@
import org.cytoscape.io.read.CyTableReaderManager;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.internal.table.MapTableToNetworkTablesTask;
import org.cytoscape.task.internal.table.MapTableToNetworkTablesTaskFactoryImpl;
import org.cytoscape.task.internal.table.UpdateAddedNetworkAttributes;
@@ -22,13 +23,15 @@
private final CyNetworkManager netMgr;
private final CyTableManager tableMgr;
private final UpdateAddedNetworkAttributes updateAddedNetworkAttributes;
-
+ private final CyRootNetworkManager rootNetMgr;
+
public AbstractLoadAttributesTask(final CyTableReaderManager mgr, final CyNetworkManager netMgr, final CyTableManager tabelMgr,
- final UpdateAddedNetworkAttributes updateAddedNetworkAttributes) {
+ final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetMgr) {
this.mgr = mgr;
this.netMgr = netMgr;
this.tableMgr = tabelMgr;
this.updateAddedNetworkAttributes = updateAddedNetworkAttributes;
+ this.rootNetMgr = rootNetMgr;
}
void loadTable(final String name, final URI uri, final TaskMonitor taskMonitor) throws Exception {
@@ -42,7 +45,7 @@ void loadTable(final String name, final URI uri, final TaskMonitor taskMonitor)
taskMonitor.setStatusMessage("Importing Data Table...");
- insertTasksAfterCurrentTask(new CombineReaderAndMappingTask( reader, netMgr, updateAddedNetworkAttributes) , new AddImportedTableTask(tableMgr, reader));
+ insertTasksAfterCurrentTask(new CombineReaderAndMappingTask( reader, netMgr, updateAddedNetworkAttributes, rootNetMgr) , new AddImportedTableTask(tableMgr, reader));
}
}
View
5 .../core-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/CombineReaderAndMappingTask.java
@@ -3,6 +3,7 @@
import org.cytoscape.io.read.CyTableReader;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTable;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.internal.table.MapTableToNetworkTablesTask;
import org.cytoscape.task.internal.table.UpdateAddedNetworkAttributes;
import org.cytoscape.work.AbstractTask;
@@ -27,9 +28,9 @@ public String getTitle() {
public CyTableReader readerTask;
- public CombineReaderAndMappingTask(CyTableReader readerTask , CyNetworkManager networkManager, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes){
+ public CombineReaderAndMappingTask(CyTableReader readerTask , CyNetworkManager networkManager, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetMgr){
this.readerTask = readerTask;
- this.mappingTask = new MapTableToNetworkTablesTask(networkManager, readerTask, updateAddedNetworkAttributes);
+ this.mappingTask = new MapTableToNetworkTablesTask(networkManager, readerTask, updateAddedNetworkAttributes, rootNetMgr);
}
@Override
View
6 ...trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesFileTask.java
@@ -6,6 +6,7 @@
import org.cytoscape.io.read.CyTableReaderManager;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.internal.table.UpdateAddedNetworkAttributes;
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.Tunable;
@@ -15,8 +16,9 @@
@Tunable(description="Attribute Table file", params="fileCategory=table;input=true")
public File file;
- public LoadAttributesFileTask(final CyTableReaderManager mgr, final CyNetworkManager netMgr, final CyTableManager tabelMgr, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes) {
- super(mgr, netMgr, tabelMgr, updateAddedNetworkAttributes);
+ public LoadAttributesFileTask(final CyTableReaderManager mgr, final CyNetworkManager netMgr, final CyTableManager tabelMgr,
+ final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetMgr) {
+ super(mgr, netMgr, tabelMgr, updateAddedNetworkAttributes, rootNetMgr);
}
/**
View
7 ...task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesFileTaskFactoryImpl.java
@@ -8,6 +8,7 @@
import org.cytoscape.io.read.CyTableReaderManager;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.internal.table.UpdateAddedNetworkAttributes;
import org.cytoscape.task.read.LoadTableFileTaskFactory;
import org.cytoscape.work.AbstractTaskFactory;
@@ -22,18 +23,20 @@
private final CyNetworkManager netMgr;
private final CyTableManager tableMgr;
private final UpdateAddedNetworkAttributes updateAddedNetworkAttributes;
+ private final CyRootNetworkManager rootNetMgr;
public LoadAttributesFileTaskFactoryImpl(CyTableReaderManager mgr, TunableSetter tunableSetter, final CyNetworkManager netMgr,
- final CyTableManager tabelMgr, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes) {
+ final CyTableManager tabelMgr, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetMgr) {
this.mgr = mgr;
this.tunableSetter = tunableSetter;
this.netMgr = netMgr;
this.tableMgr = tabelMgr;
this.updateAddedNetworkAttributes = updateAddedNetworkAttributes;
+ this.rootNetMgr = rootNetMgr;
}
public TaskIterator createTaskIterator() {
- return new TaskIterator(2, new LoadAttributesFileTask(mgr, netMgr, tableMgr, updateAddedNetworkAttributes));
+ return new TaskIterator(2, new LoadAttributesFileTask(mgr, netMgr, tableMgr, updateAddedNetworkAttributes, rootNetMgr));
}
@Override
View
6 .../trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesURLTask.java
@@ -6,6 +6,7 @@
import org.cytoscape.io.read.CyTableReaderManager;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.internal.table.UpdateAddedNetworkAttributes;
import org.cytoscape.work.TaskMonitor;
import org.cytoscape.work.Tunable;
@@ -16,8 +17,9 @@
@Tunable(description="Attribute Table URL", params="fileCategory=table;input=true")
public URL url;
- public LoadAttributesURLTask(final CyTableReaderManager mgr, final CyNetworkManager netMgr, final CyTableManager tableMgr, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes) {
- super(mgr, netMgr, tableMgr, updateAddedNetworkAttributes);
+ public LoadAttributesURLTask(final CyTableReaderManager mgr, final CyNetworkManager netMgr, final CyTableManager tableMgr,
+ final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetMgr) {
+ super(mgr, netMgr, tableMgr, updateAddedNetworkAttributes, rootNetMgr);
}
/**
View
8 ...-task-impl/src/main/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesURLTaskFactoryImpl.java
@@ -8,6 +8,7 @@
import org.cytoscape.io.read.CyTableReaderManager;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.internal.table.UpdateAddedNetworkAttributes;
import org.cytoscape.task.read.LoadTableFileTaskFactory;
import org.cytoscape.task.read.LoadTableURLTaskFactory;
@@ -24,17 +25,20 @@
private final CyNetworkManager netMgr;
private final CyTableManager tableMgr;
private final UpdateAddedNetworkAttributes updateAddedNetworkAttributes;
+ private final CyRootNetworkManager rootNetMgr;
+
public LoadAttributesURLTaskFactoryImpl(CyTableReaderManager mgr, TunableSetter tunableSetter, final CyNetworkManager netMgr,
- final CyTableManager tabelMgr, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes) {
+ final CyTableManager tabelMgr, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetMgr) {
this.mgr = mgr;
this.tunableSetter = tunableSetter;
this.netMgr = netMgr;
this.tableMgr = tabelMgr;
this.updateAddedNetworkAttributes = updateAddedNetworkAttributes;
+ this.rootNetMgr = rootNetMgr;
}
public TaskIterator createTaskIterator() {
- return new TaskIterator(2, new LoadAttributesURLTask(mgr, netMgr, tableMgr, updateAddedNetworkAttributes));
+ return new TaskIterator(2, new LoadAttributesURLTask(mgr, netMgr, tableMgr, updateAddedNetworkAttributes, rootNetMgr));
}
@Override
View
130 ...pl/trunk/core-task-impl/src/main/java/org/cytoscape/task/internal/table/MapTableToNetworkTablesTask.java
@@ -13,6 +13,8 @@
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyTable;
+import org.cytoscape.model.subnetwork.CyRootNetwork;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.ProvidesTitle;
import org.cytoscape.work.TaskMonitor;
@@ -23,45 +25,46 @@
import org.slf4j.LoggerFactory;
public final class MapTableToNetworkTablesTask extends AbstractTask {
-
+
enum TableType {
NODE_ATTR("Node Attributes", CyNode.class), EDGE_ATTR("Edge Attributes", CyEdge.class), NETWORK_ATTR("Network Attributes", CyNetwork.class), GLOBAL("Unassigned Tables", CyTable.class);
private final String name;
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(){
return this.type;
}
-
+
@Override
public String toString() {
return name;
}
};
-
+
private static Logger logger = LoggerFactory.getLogger(MapTableToNetworkTablesTask.class);
private static String NO_NETWORKS = "No Networks Found";
private final CyNetworkManager networkManager;
+ private final CyRootNetworkManager rootNetworkManager;
private final CyTable globalTable;
private final CyTableReader reader;
private final boolean byReader;
private Map<String, CyNetwork> name2NetworkMap;
private final UpdateAddedNetworkAttributes updateAddedNetworkAttributes;
-
-
+
+
@Tunable(description = "Import Data To:")
public ListSingleSelection<TableType> dataTypeOptions;
-
+
//******* we couldnt use the enum to check the dependency. So, update this line if you change the GLOBAL enum string
@Tunable(description = "Apply to Selected Networks Only",groups="Network Options", dependsOn="dataTypeOptions!=Unassigned Tables", params="displayState=collapsed")
public boolean selectedNetworksOnly = false;
-
+
@Tunable(description = "Network List",groups="Network Options",dependsOn="selectedNetworksOnly=true", params="displayState=collapsed")
public ListMultipleSelection<String> networkList;
@@ -71,36 +74,39 @@ public String getTitle() {
return "Import Data ";
}
-
- public MapTableToNetworkTablesTask(final CyNetworkManager networkManager, final CyTableReader reader, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes){
+
+ public MapTableToNetworkTablesTask(final CyNetworkManager networkManager, final CyTableReader reader, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetworkManager ){
this.reader = reader;
globalTable = null;
this.byReader = true;
this.networkManager = networkManager;
this.name2NetworkMap = new HashMap<String, CyNetwork>();
this.updateAddedNetworkAttributes = updateAddedNetworkAttributes;
-
+ this.rootNetworkManager = rootNetworkManager;
+
initTunable(networkManager);
-
+
}
-
- public MapTableToNetworkTablesTask(final CyNetworkManager networkManager, final CyTable globalTable, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes){
+
+ public MapTableToNetworkTablesTask(final CyNetworkManager networkManager, final CyTable globalTable, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetworkManager){
this.networkManager = networkManager;
this.globalTable = globalTable;
this.byReader = false;
this.reader = null;
this.name2NetworkMap = new HashMap<String, CyNetwork>();
this.updateAddedNetworkAttributes = updateAddedNetworkAttributes;
+ this.rootNetworkManager = rootNetworkManager;
+
initTunable(networkManager);
}
-
+
private void initTunable(CyNetworkManager networkManage){
final List<TableType> options = new ArrayList<TableType>();
for(TableType type: TableType.values())
options.add(type);
dataTypeOptions = new ListSingleSelection<TableType>(options);
dataTypeOptions.setSelectedValue(TableType.NODE_ATTR);
-
+
for(CyNetwork net: networkManage.getNetworkSet()){
String netName = net.getRow(net).get(CyNetwork.NAME, String.class);
name2NetworkMap.put(netName, net);
@@ -111,35 +117,23 @@ private void initTunable(CyNetworkManager networkManage){
networkList = new ListMultipleSelection<String>(NO_NETWORKS);
else
networkList = new ListMultipleSelection<String>(names);
-
+
}
-
-
+
+
public void run(TaskMonitor taskMonitor) throws Exception {
TableType tableType = dataTypeOptions.getSelectedValue();
- if (tableType != TableType.GLOBAL ){
- List<CyNetwork> networks = new ArrayList<CyNetwork>();
+ if (tableType == TableType.GLOBAL )
+ return;
- if (!selectedNetworksOnly)
- networks.addAll(networkManager.getNetworkSet());
- else{
- if(!networkList.getSelectedValues().get(0).equals(NO_NETWORKS))
- for(String netName: networkList.getSelectedValues())
- networks.add(name2NetworkMap.get(netName));
+ List<CyNetwork> networks = new ArrayList<CyNetwork>();
- }
- for (CyNetwork network: networks){
- CyTable targetTable = getTable(network, tableType);
- if (targetTable != null){
- if(byReader){
- if (reader.getTables() != null && reader.getTables().length >0){
- for(CyTable sourceTable : reader.getTables())
- mapTable(targetTable, sourceTable);
- }
- }else
- mapTable(targetTable, globalTable);
- }
- }
+ if (!selectedNetworksOnly)
+ mapTableToDefaultAttrs (tableType);
+ else
+ mapTableToLocalAttrs (tableType);
+
+
if(!selectedNetworksOnly){ //if table should be mapped to all of the tables
//add each mapped table to the list for mapping to networks going to be added later
if(byReader){
@@ -148,23 +142,67 @@ public void run(TaskMonitor taskMonitor) throws Exception {
updateAddedNetworkAttributes.addMappingToList(sourceTable, tableType.getType());
}else
updateAddedNetworkAttributes.addMappingToList(globalTable, tableType.getType());
+
}
+
+ }
+
+
+
+ private void mapTableToLocalAttrs(TableType tableType) {
+ List<CyNetwork> networks = new ArrayList<CyNetwork>();
+
+ if(!networkList.getSelectedValues().get(0).equals(NO_NETWORKS))
+ for(String netName: networkList.getSelectedValues())
+ networks.add(name2NetworkMap.get(netName));
+
+ for (CyNetwork network: networks){
+ CyTable targetTable = getTable(network, tableType, CyNetwork.LOCAL_ATTRS);
+ if (targetTable != null)
+ applyMapping(targetTable);
}
+
}
+ private void mapTableToDefaultAttrs(TableType tableType) {
+ List<CyRootNetwork> rootNetworkList = new ArrayList<CyRootNetwork>();
+ for (CyNetwork net : networkManager.getNetworkSet())
+ if (! rootNetworkList.contains(rootNetworkManager.getRootNetwork(net)))
+ rootNetworkList.add( rootNetworkManager.getRootNetwork(net));
+
+ for (CyRootNetwork root: rootNetworkList ){
+ CyTable targetTable = getTable(root, tableType, CyNetwork.DEFAULT_ATTRS);
+ if (targetTable != null){
+ applyMapping(targetTable);
+ }
+ }
+ }
+
- private CyTable getTable(CyNetwork network, TableType tableType){
+ private CyTable getTable(CyNetwork network, TableType tableType, String namespace){
if (tableType == TableType.NODE_ATTR)
- return network.getDefaultNodeTable();
+ return network.getTable(CyNode.class, namespace);
if (tableType == TableType.EDGE_ATTR)
- return network.getDefaultEdgeTable();
+ return network.getTable(CyEdge.class, namespace);
if (tableType == TableType.NETWORK_ATTR)
- return network.getDefaultNetworkTable();
+ 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 +" or "+TableType.GLOBAL +".");
return null;
}
-
+
+
+ private void applyMapping(CyTable targetTable){
+ if(byReader){
+ if (reader.getTables() != null && reader.getTables().length >0){
+ for(CyTable sourceTable : reader.getTables())
+ mapTable(targetTable, sourceTable);
+ }
+ }else
+ mapTable(targetTable, globalTable);
+ }
+
private void mapTable(final CyTable localTable, final CyTable globalTable) {
if (globalTable.getPrimaryKey().getType() != String.class)
throw new IllegalStateException("Local table's primary key should be type String.");
View
7 ...re-task-impl/src/main/java/org/cytoscape/task/internal/table/MapTableToNetworkTablesTaskFactoryImpl.java
@@ -9,6 +9,7 @@
import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTable;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.AbstractTableTaskFactory;
import org.cytoscape.task.edit.MapTableToNetworkTablesTaskFactory;
import org.cytoscape.task.internal.table.MapTableToNetworkTablesTask.TableType;
@@ -23,17 +24,19 @@
private final CyNetworkManager networkManager;
private final TunableSetter tunableSetter;
private final UpdateAddedNetworkAttributes updateAddedNetworkAttributes;
+ private final CyRootNetworkManager rootNetMgr;
- public MapTableToNetworkTablesTaskFactoryImpl( final CyNetworkManager networkManager, final TunableSetter tunableSetter, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes ){
+ public MapTableToNetworkTablesTaskFactoryImpl( final CyNetworkManager networkManager, final TunableSetter tunableSetter, final UpdateAddedNetworkAttributes updateAddedNetworkAttributes, final CyRootNetworkManager rootNetMgr ){
this.networkManager = networkManager;
this.tunableSetter = tunableSetter;
this.updateAddedNetworkAttributes = updateAddedNetworkAttributes;
+ this.rootNetMgr = rootNetMgr;
}
@Override
public TaskIterator createTaskIterator(CyTable globalTable) {
- return new TaskIterator(new MapTableToNetworkTablesTask(networkManager, globalTable, updateAddedNetworkAttributes));
+ return new TaskIterator(new MapTableToNetworkTablesTask(networkManager, globalTable, updateAddedNetworkAttributes, rootNetMgr));
}
@Override
View
6 ...-impl/src/test/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesFileTaskFactoryImplTest.java
@@ -10,6 +10,7 @@
import org.cytoscape.io.read.CyTableReaderManager;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.internal.table.UpdateAddedNetworkAttributes;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskIterator;
@@ -38,6 +39,9 @@
@Mock
UpdateAddedNetworkAttributes updateAddedNetworkAttributes;
+ @Mock
+ CyRootNetworkManager rootNetMgr;
+
@Before
public void initMocks() {
MockitoAnnotations.initMocks(this);
@@ -47,7 +51,7 @@ public void initMocks() {
@Test(expected = NullPointerException.class)
public void testLoadAttributesFileTaskFactory() throws Exception {
- final LoadAttributesFileTaskFactoryImpl factory = new LoadAttributesFileTaskFactoryImpl(rmgr, ts, netMgr, tabMgr, updateAddedNetworkAttributes);
+ final LoadAttributesFileTaskFactoryImpl factory = new LoadAttributesFileTaskFactoryImpl(rmgr, ts, netMgr, tabMgr, updateAddedNetworkAttributes, rootNetMgr);
TaskIterator ti = factory.createTaskIterator();
assertNotNull(ti);
View
6 ...k-impl/src/test/java/org/cytoscape/task/internal/loaddatatable/LoadAttributesURLTaskFactoryImplTest.java
@@ -9,6 +9,7 @@
import org.cytoscape.io.read.CyTableReaderManager;
import org.cytoscape.model.CyNetworkManager;
import org.cytoscape.model.CyTableManager;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.task.internal.table.UpdateAddedNetworkAttributes;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskIterator;
@@ -39,6 +40,9 @@
@Mock
UpdateAddedNetworkAttributes updateAddedNetworkAttributes;
+ @Mock
+ CyRootNetworkManager rootNetMgr;
+
@Before
public void initMocks() {
MockitoAnnotations.initMocks(this);
@@ -48,7 +52,7 @@ public void initMocks() {
@Test(expected = NullPointerException.class)
public void testLoadAttributesURLTaskFactory() throws Exception {
- final LoadAttributesURLTaskFactoryImpl factory = new LoadAttributesURLTaskFactoryImpl(rmgr, ts, netMgr, tabMgr, updateAddedNetworkAttributes);
+ final LoadAttributesURLTaskFactoryImpl factory = new LoadAttributesURLTaskFactoryImpl(rmgr, ts, netMgr, tabMgr, updateAddedNetworkAttributes, rootNetMgr);
final TaskIterator ti = factory.createTaskIterator();
assertNotNull(ti);
View
6 ...trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/MapTableToNetworkTableTaskTest.java
@@ -16,11 +16,11 @@
import org.cytoscape.model.NetworkTestSupport;
import org.cytoscape.model.SavePolicy;
import org.cytoscape.model.internal.CyNetworkManagerImpl;
+import org.cytoscape.model.internal.CyRootNetworkManagerImpl;
import org.cytoscape.model.internal.CyTableImpl;
import org.cytoscape.work.Task;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.TaskMonitor;
-import org.cytoscape.work.TunableHandlerFactory;
import org.junit.Test;
import static org.mockito.Mockito.mock;
@@ -48,6 +48,8 @@
private static CyEventHelper eventHelper = new DummyCyEventHelper();
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());
@@ -88,7 +90,7 @@ public void testMappingTableToNetwork() throws Exception{
public static void mapping(CyTable table, CyNetwork net, boolean selectedOnly) throws Exception{
UpdateAddedNetworkAttributes up = new UpdateAddedNetworkAttributes(new MapGlobalToLocalTableTaskFactoryImpl(mock(CyTableManager.class), netMgr, ts), new SyncTaskManager(stm));
- MapTableToNetworkTablesTaskFactoryImpl mappingTF = new MapTableToNetworkTablesTaskFactoryImpl(netMgr, ts, up);
+ MapTableToNetworkTablesTaskFactoryImpl mappingTF = new MapTableToNetworkTablesTaskFactoryImpl(netMgr, ts, up , rootNetMgr);
List<CyNetwork> nets = new ArrayList<CyNetwork>();
nets.add(net);
View
11 core3/impl/trunk/core-task-impl/src/test/java/org/cytoscape/task/internal/table/MappingIntegrationTest.java
@@ -26,9 +26,11 @@
import org.cytoscape.model.events.NetworkAddedEvent;
import org.cytoscape.model.internal.CyNetworkManagerImpl;
import org.cytoscape.model.internal.CyNetworkTableManagerImpl;
+import org.cytoscape.model.internal.CyRootNetworkManagerImpl;
import org.cytoscape.model.internal.CySubNetworkImpl;
import org.cytoscape.model.internal.CyTableImpl;
import org.cytoscape.model.internal.CyTableManagerImpl;
+import org.cytoscape.model.subnetwork.CyRootNetworkManager;
import org.cytoscape.session.CyNetworkNaming;
import org.cytoscape.task.internal.creation.NewNetworkSelectedNodesOnlyTask;
import org.cytoscape.view.model.CyNetworkViewManager;
@@ -56,6 +58,8 @@
private CyEventHelper eventHelper = new DummyCyEventHelper();
private CyNetworkManagerImpl netMgr = new CyNetworkManagerImpl(eventHelper);
+ private final CyRootNetworkManagerImpl rootNetMgr = new CyRootNetworkManagerImpl();
+
private SyncTunableMutator stm = new SyncTunableMutator();
SyncTunableHandlerFactory syncTunableHandlerFactory = new SyncTunableHandlerFactory();
@@ -142,6 +146,7 @@ public void mappingToAllNetworksWithSubNetwork() throws Exception{
((CySubNetworkImpl) subnet1).handleEvent(new NetworkAddedEvent(netMgr, subnet1));
+
assertEquals(2, subnet1.getNodeList().size());
assertNotNull(subnet1.getDefaultNodeTable().getColumn(table1sCol));
@@ -163,8 +168,8 @@ public void mappingToAllNetworksWithSubNetwork() throws Exception{
//check the mapping by task
assertNotNull(net1.getDefaultNodeTable().getColumn(table2sCol));
assertEquals(table2sRow1, net1.getDefaultNodeTable().getRow(node1.getSUID()).get(table2sCol, String.class) );
- // TODO!!!
- //assertNull(subnet1.getDefaultNodeTable().getColumn(table2sCol)); //subnet1 should not be mapped
+
+ assertNull(subnet1.getDefaultNodeTable().getColumn(table2sCol)); //subnet1 should not be mapped
//creating another subnetwork (subnet2) to check that bot virtual columns will be added
net1.getDefaultNodeTable().getRow(node1.getSUID()).set(CyNetwork.SELECTED, true);
@@ -201,7 +206,7 @@ public void mappingToAllNetworksWithSubNetwork() throws Exception{
public void mapping(CyTable table, CyNetwork net, boolean selectedOnly) throws Exception{
- MapTableToNetworkTablesTaskFactoryImpl mappingTF = new MapTableToNetworkTablesTaskFactoryImpl(netMgr, ts, up);
+ MapTableToNetworkTablesTaskFactoryImpl mappingTF = new MapTableToNetworkTablesTaskFactoryImpl(netMgr, ts, up, rootNetMgr);
List<CyNetwork> nets = new ArrayList<CyNetwork>();
nets.add(net);
View
7 .../core-task-impl/src/test/java/org/cytoscape/task/internal/table/UpdateAddedNetworkAttributeTaskTest.java
@@ -22,6 +22,7 @@
import org.cytoscape.model.events.NetworkAddedEvent;
import org.cytoscape.model.internal.CyNetworkManagerImpl;
import org.cytoscape.model.internal.CyNetworkTableManagerImpl;
+import org.cytoscape.model.internal.CyRootNetworkManagerImpl;
import org.cytoscape.model.internal.CySubNetworkImpl;
import org.cytoscape.model.internal.CyTableImpl;
import org.cytoscape.model.internal.CyTableManagerImpl;
@@ -47,7 +48,9 @@
private CyEventHelper eventHelper = new DummyCyEventHelper();
- private CyNetworkManagerImpl netMgr = new CyNetworkManagerImpl(eventHelper);
+ private CyNetworkManagerImpl netMgr = new CyNetworkManagerImpl(eventHelper);
+ private CyRootNetworkManagerImpl rootNetMgr = new CyRootNetworkManagerImpl();
+
private SyncTunableMutator stm = new SyncTunableMutator();
SyncTunableHandlerFactory syncTunableHandlerFactory = new SyncTunableHandlerFactory();
private TunableSetterImpl ts = new TunableSetterImpl(new SyncTunableMutatorFactory(syncTunableHandlerFactory), new TunableRecorderManager());
@@ -172,7 +175,7 @@ public void testUpdatingAddedNetwork() throws Exception{
public void mapping(CyTable table, CyNetwork net, boolean selectedOnly ) throws Exception{
- MapTableToNetworkTablesTaskFactoryImpl mappingTF = new MapTableToNetworkTablesTaskFactoryImpl(netMgr, ts, up);
+ MapTableToNetworkTablesTaskFactoryImpl mappingTF = new MapTableToNetworkTablesTaskFactoryImpl(netMgr, ts, up, rootNetMgr);
List<CyNetwork> nets = new ArrayList<CyNetwork>();
nets.add(net);
Please sign in to comment.
Something went wrong with that request. Please try again.