Author: pwang
Date: 2011-07-11 11:56:34 -0700 (Mon, 11 Jul 2011)
New Revision: 26139

Modified:
   
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportAttributeTableTask.java
Log:
use attribute as table key

Modified: 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportAttributeTableTask.java
===================================================================
--- 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportAttributeTableTask.java
     2011-07-11 18:54:20 UTC (rev 26138)
+++ 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportAttributeTableTask.java
     2011-07-11 18:56:34 UTC (rev 26139)
@@ -35,6 +35,7 @@
 import org.cytoscape.model.CyNode;
 import org.cytoscape.model.CyTable;
 import org.cytoscape.model.CyTableEntry;
+import org.cytoscape.tableimport.internal.reader.AttributeMappingParameters;
 import org.cytoscape.tableimport.internal.reader.TextTableReader;
 import org.cytoscape.tableimport.internal.reader.TextTableReader.ObjectType;
 import org.cytoscape.tableimport.internal.util.CytoscapeServices;
@@ -78,12 +79,36 @@
                
                final Class<? extends CyTableEntry> type = getMappingClass();
                
+               
+               String primaryKey = 
reader.getMappingParameter().getAttributeNames()[reader.getMappingParameter().getKeyIndex()];
+               String mappingKey = 
reader.getMappingParameter().getMappingAttribute();
+               
+               
//System.out.println("ImportAttributrTableTask.run()...primaryKey="+ 
primaryKey);
+               
//System.out.println("ImportAttributrTableTask.run()...mappingKey="+ 
mappingKey);
+
                if (CytoscapeServices.netMgr.getNetworkSet().size() > 0 && type 
!= null) {
-                       System.out.println("$$$$$$$ Mapping inserted.");
-                       final MapNetworkAttrTask task = new 
MapNetworkAttrTask(type, table,
-                                       CytoscapeServices.netMgr, 
CytoscapeServices.appMgr);
-                       insertTasksAfterCurrentTask(task);
+                       /*
+                        * Case 1: use node ID as the key
+                        */
+                       if 
(reader.getMappingParameter().getMappingAttribute().equals(AttributeMappingParameters.ID))
 {
+                                       final MapNetworkAttrTask task = new 
MapNetworkAttrTask(type, table,
+                                                       
CytoscapeServices.netMgr, CytoscapeServices.appMgr);
+                                       insertTasksAfterCurrentTask(task);
+                       }
+                       else {
+                               /*
+                                *  Case 2: use an attribute as the key.
+                                */
+                               System.out.println("\tuse attribute as key");
+                               final MapNetworkAttrTask task = new 
MapNetworkAttrTask(type, table, primaryKey, mappingKey,
+                                               CytoscapeServices.netMgr, 
CytoscapeServices.appMgr);
+                               insertTasksAfterCurrentTask(task);
+               
+                               
+                       }
                }
+                               
+               
 
                this.reader.readTable(table);
                // loadAttributesInternal(table);

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