Author: pwang
Date: 2011-07-11 16:30:54 -0700 (Mon, 11 Jul 2011)
New Revision: 26143

Modified:
   
core3/core-task-api/trunk/src/main/java/org/cytoscape/task/MapNetworkAttrTask.java
Log:
use alternative key to do table join

Modified: 
core3/core-task-api/trunk/src/main/java/org/cytoscape/task/MapNetworkAttrTask.java
===================================================================
--- 
core3/core-task-api/trunk/src/main/java/org/cytoscape/task/MapNetworkAttrTask.java
  2011-07-11 22:22:44 UTC (rev 26142)
+++ 
core3/core-task-api/trunk/src/main/java/org/cytoscape/task/MapNetworkAttrTask.java
  2011-07-11 23:30:54 UTC (rev 26143)
@@ -52,31 +52,27 @@
                        throw new IllegalArgumentException("\"type\" must be 
CyNode.class or CyEdge.class!");
        }
 
+       
        public void run(final TaskMonitor taskMonitor) throws Exception {
                taskMonitor.setTitle("Mapping virtual columns");
 
-               if (this.mappingKey == null){
-                       final List<CyTable> targetTables = new 
ArrayList<CyTable>();
-                       if (currentNetworkOnly) {
-                               final CyNetwork currentNetwork = 
applicationManager.getCurrentNetwork();
-                               targetTables.add(type == CyNode.class ? 
currentNetwork.getDefaultNodeTable()
-                                                                     : 
currentNetwork.getDefaultEdgeTable());
-                       } else {
-                               final Set<CyNetwork> networks = 
networkManager.getNetworkSet();
-                               for (final CyNetwork network : networks)
-                                       targetTables.add(type == CyNode.class ? 
network.getDefaultNodeTable()
-                                                                             : 
network.getDefaultEdgeTable());
-                       }
+               final List<CyTable> targetTables = new ArrayList<CyTable>();
 
-                       mapAll(targetTables);
+               if (currentNetworkOnly) {
+                       final CyNetwork currentNetwork = 
applicationManager.getCurrentNetwork();
+                       targetTables.add(type == CyNode.class ? 
currentNetwork.getDefaultNodeTable()
+                                                             : 
currentNetwork.getDefaultEdgeTable());
+               } else {
+                       final Set<CyNetwork> networks = 
networkManager.getNetworkSet();
+                       for (final CyNetwork network : networks)
+                               targetTables.add(type == CyNode.class ? 
network.getDefaultNodeTable()
+                                                                     : 
network.getDefaultEdgeTable());
                }
-               else{
-                       System.out.println("MapNetworkAttrTask.run(): do 
different mapping...");
-                       
-                       
-               }
+               
+               mapAll(targetTables);
        }
 
+       
        private void mapAll(final List<CyTable> targetTables) {
                if (targetTables.isEmpty())
                        return;
@@ -88,8 +84,15 @@
                for (final CyTable targetTable : targetTables) {
                        if (cancelled)
                                return;
-                       targetTable.addVirtualColumns(newGlobalTable, 
sourceTableJoinColumn,
+                       if (mappingKey == null){
+                               // use primary key to do table join
+                               targetTable.addVirtualColumns(newGlobalTable, 
sourceTableJoinColumn,
                                                      CyTableEntry.NAME, false);
+                       }
+                       else {
+                               // use alternative key
+                               targetTable.addVirtualColumns(newGlobalTable, 
sourceTableJoinColumn, mappingKey, false);                        
+                       }
                }
        }
 }
\ No newline at end of file

-- 
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