Author: pwang
Date: 2011-01-21 17:29:17 -0800 (Fri, 21 Jan 2011)
New Revision: 23563

Modified:
   
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/AttributeLineParser.java
   
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/AttributeMappingParameters.java
   
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/DefaultAttributeTableReader.java
   
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportTextTableDialog.java
Log:
Updated

Modified: 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/AttributeLineParser.java
===================================================================
--- 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/AttributeLineParser.java
      2011-01-22 01:27:49 UTC (rev 23562)
+++ 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/AttributeLineParser.java
      2011-01-22 01:29:17 UTC (rev 23563)
@@ -34,12 +34,7 @@
 */
 package org.cytoscape.tableimport.internal.reader;
 
-//import cytoscape.Cytoscape;
 
-//import cytoscape.data.CyAttributes;
-
-//import cytoscape.giny.CytoscapeRootGraph;
-
 import org.cytoscape.tableimport.internal.reader.TextTableReader.ObjectType;
 
 import org.cytoscape.model.CyEdge;
@@ -80,6 +75,9 @@
         * @param parts entries in a line.
         */
        public void parseAll(String[] parts) {
+               
+               System.out.println("AttributeLineParser.parseAll()...");
+               
                // Get key
                final String primaryKey = parts[mapping.getKeyIndex()].trim();
                final int partsLen = parts.length;

Modified: 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/AttributeMappingParameters.java
===================================================================
--- 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/AttributeMappingParameters.java
       2011-01-22 01:27:49 UTC (rev 23562)
+++ 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/AttributeMappingParameters.java
       2011-01-22 01:29:17 UTC (rev 23563)
@@ -35,9 +35,7 @@
 package org.cytoscape.tableimport.internal.reader;
 
 import org.cytoscape.model.CyNetwork;
-//import cytoscape.Cytoscape;
 
-//import cytoscape.data.CyAttributes;
 //import cytoscape.data.CyAttributesUtils;
 
 //import cytoscape.data.synonyms.Aliases;
@@ -58,8 +56,8 @@
 import java.util.Set;
 import org.cytoscape.tableimport.internal.util.AttributeTypes;
 import org.cytoscape.tableimport.internal.util.CytoscapeServices;
+import org.cytoscape.model.CyTable;
 
-
 /**
  * Parameter object for text table <---> CyAttributes mapping.<br>
  * <p>
@@ -75,7 +73,7 @@
        /**
         *
         */
-       public static final String ID = "ID";
+       public static final String ID = "name";
        private static final String DEF_LIST_DELIMITER = PIPE.toString();
        private static final String DEF_DELIMITER = TAB.toString();
        private final ObjectType objectType;
@@ -89,7 +87,7 @@
        private String listDelimiter;
        private boolean[] importFlag;
        private Map<String, List<String>> attr2id;
-       //private CyAttributes attributes;
+       private CyTable attributes;
        //private Aliases existingAliases;
        private Map<String, String> networkTitle2ID = null;
 
@@ -176,7 +174,7 @@
                        
                        for (CyNetwork net : networkSet) {
                                //networkTitle2ID.put(net.getTitle(), 
net.getIdentifier());
-                               
networkTitle2ID.put(net.getDefaultNetworkTable().getTitle(), 
Long.toString(net.getSUID()));
+                               
//networkTitle2ID.put(net.getDefaultNetworkTable().getTitle(), 
Long.toString(net.getSUID()));
                        }
                } else {
                        networkTitle2ID = null;
@@ -186,7 +184,7 @@
                 * If attribute mapping is null, use ID for mapping.
                 */
                if (mappingAttribute == null) {
-                       this.mappingAttribute = ID;
+                       this.mappingAttribute = ID; // Note: ID = 'name'
                } else {
                        this.mappingAttribute = mappingAttribute;
                }
@@ -248,8 +246,11 @@
                switch (objectType) {
                        case NODE:
                                //attributes = Cytoscape.getNodeAttributes();
+                               CyNetwork network = 
CytoscapeServices.appMgr.getCurrentNetwork();
+                               attributes = 
CytoscapeServices.tblMgr.getTableMap(CyNode.class, 
network).get(CyNetwork.DEFAULT_ATTRS);
+
                                //existingAliases = 
Cytoscape.getOntologyServer().getNodeAliases();
-                               //it = Cytoscape.getRootGraph().nodesIterator();
+                               it = network.getNodeList().iterator(); 
//Cytoscape.getRootGraph().nodesIterator();
 
                                break;
 
@@ -441,7 +442,6 @@
                // Mapping from attribute value to object ID.
                attr2id = new HashMap<String, List<String>>();
 
-               //String objectID = null;
                String objectID = null;
                Object valObj = null;
 
@@ -458,6 +458,8 @@
                                        //      valObj = 
attributes.getAttribute(objectID, mappingAttribute);
                                        //}
 
+                                       valObj = 
node.getCyRow(mappingAttribute);                                               
+
                                        break;
 
                                case EDGE:
@@ -493,17 +495,9 @@
                                                }
                                        }
                                } else {
-                                       //putAttrValue(valObj.toString(), 
objectID);
+                                       putAttrValue(valObj.toString(), 
objectID);
                                }
 
-                               //                              if 
(attr2id.containsKey(attributeValue)) {
-                               //                                      
objIdList = (List<String>) attr2id.get(attributeValue);
-                               //                              } else {
-                               //                                      
objIdList = new ArrayList<String>();
-                               //                              }
-                               //
-                               //                              
objIdList.add(objectID);
-                               //                              
attr2id.put(attributeValue, objIdList);
                        }
                }
        }

Modified: 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/DefaultAttributeTableReader.java
===================================================================
--- 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/DefaultAttributeTableReader.java
      2011-01-22 01:27:49 UTC (rev 23562)
+++ 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/reader/DefaultAttributeTableReader.java
      2011-01-22 01:29:17 UTC (rev 23563)
@@ -49,7 +49,6 @@
 import org.slf4j.LoggerFactory;
 
 import org.cytoscape.tableimport.internal.util.URLUtil;
-//import cytoscape.logger.CyLogger;
 
 
 /**
@@ -70,7 +69,6 @@
        private final URL source;
        private AttributeMappingParameters mapping;
        private final AttributeLineParser parser;
-       //private static CyLogger logger = 
CyLogger.getLogger(DefaultAttributeTableReader.class);
        private static final Logger logger = 
LoggerFactory.getLogger(DefaultAttributeTableReader.class);
        
        // Number of mapped attributes.
@@ -139,10 +137,10 @@
            throws Exception {
                this.source = source;
                this.startLineNumber = startLineNumber;
-               //this.mapping = new AttributeMappingParameters(objectType, 
delimiters, listDelimiter,
-                //                                             keyIndex, 
mappingAttribute, aliasIndexList,
-                 //                                            attributeNames, 
attributeTypes, null,
-                  //                                           importFlag);
+               this.mapping = new AttributeMappingParameters(objectType, 
delimiters, listDelimiter,
+                                                            keyIndex, 
mappingAttribute, aliasIndexList,
+                                                           attributeNames, 
attributeTypes, null,
+                                                          importFlag);
                this.parser = new AttributeLineParser(mapping);
        }
 

Modified: 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportTextTableDialog.java
===================================================================
--- 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportTextTableDialog.java
        2011-01-22 01:27:49 UTC (rev 23562)
+++ 
core3/table-import-impl/trunk/src/main/java/org/cytoscape/tableimport/internal/ui/ImportTextTableDialog.java
        2011-01-22 01:29:17 UTC (rev 23563)
@@ -211,7 +211,7 @@
                                        + 
"%AttributeTable%</table></p></body></html>";
        private static final String DEF_ANNOTATION_ITEM = "Please select an 
annotation data source...";
        private static final String[] keyTable = { "Alias?", "Column (Attribute 
Name)", "Data Type" };
-       private static final String ID = "ID";
+       private static final String ID = "name";
        private static final String GENE_ASSOCIATION = "gene_association";
 
        // Key column index
@@ -250,6 +250,8 @@
        private File[] inputFiles;
 
        private static final Logger logger = 
LoggerFactory.getLogger(ImportTextTableDialog.class);
+       
+       private CyNetwork network;
 
        /**
         * Creates new form ImportAttributesDialog
@@ -268,7 +270,8 @@
                // Default Attribute is node attr.
                //selectedAttributes = Cytoscape.getNodeAttributes();
                selectedAttributes = null;
-               CyNetwork network = 
CytoscapeServices.appMgr.getCurrentNetwork();
+               
+               network = CytoscapeServices.appMgr.getCurrentNetwork();
                if (network != null){
                        selectedAttributes = 
CytoscapeServices.tblMgr.getTableMap(CyNode.class, 
network).get(CyNetwork.DEFAULT_ATTRS);                  
                }
@@ -1710,7 +1713,7 @@
        private void importButtonActionPerformed(ActionEvent evt) throws 
Exception {
                if (checkDataSourceError() == false)
                        return;
-
+               
                boolean importAll = importAllCheckBox.isSelected();
 
                /*
@@ -1832,6 +1835,7 @@
                        }
                }
 
+                               
                /*
                 * Switch readers based on the dialog type.
                 */
@@ -1857,13 +1861,15 @@
                                } else {
                                        del = checkDelimiter();
                                }
+
+                               //TODO -- Need to fix problem in 
AttributeMappingParameters                             
                                mapping = new 
AttributeMappingParameters(objType, del,
                                                                                
                                 listDelimiter, keyInFile,
                                                                                
                                 mappingAttribute, aliasList,
                                                                                
                                 attributeNames, attributeTypes,
                                                                                
                                 listDataTypes, importFlag,
                                                                                
                                 caseSensitive);
-
+                               
                                if 
(source.toString().endsWith(SupportedFileType.EXCEL.getExtension()) || 
                                                
source.toString().endsWith(SupportedFileType.OOXML.getExtension())) {
                                        /*
@@ -2771,7 +2777,7 @@
         *
         */
        private void setKeyList() {
-               /*
+
                if (mappingAttributeComboBox.getSelectedItem() == null) {
                        return;
                }
@@ -2782,32 +2788,33 @@
 
                Set<Object> valueSet = new TreeSet<Object>();
 
+               //TODO -- setKeyList
                if (selectedKeyAttribute.equals(ID)) {
                        
                        if (objType == NODE) {
-                               it = Cytoscape.getRootGraph().nodesIterator();
-
+                               //it = Cytoscape.getRootGraph().nodesIterator();
+                               it = network.getNodeList().iterator();
                                while (it.hasNext()) {
                                        CyNode node = (CyNode) it.next();
-                                       valueSet.add(node.getIdentifier());
+                                       valueSet.add(node.getCyRow().get(ID, 
String.class)); // ID = "name"
                                }
                        } else if (objType == EDGE) {
-                               it = Cytoscape.getRootGraph().edgesIterator();
+                               //it = Cytoscape.getRootGraph().edgesIterator();
 
-                               while (it.hasNext()) {
-                                       valueSet.add(((CyEdge) 
it.next()).getIdentifier());
-                               }
+                               //while (it.hasNext()) {
+                               //      valueSet.add(((CyEdge) 
it.next()).getIdentifier());
+                               //}
                        } else {
-                               it = Cytoscape.getNetworkSet().iterator();
+                               //it = Cytoscape.getNetworkSet().iterator();
 
-                               while (it.hasNext()) {
-                                       valueSet.add(((CyNetwork) 
it.next()).getTitle());
-                               }
+                               //while (it.hasNext()) {
+                               //      valueSet.add(((CyNetwork) 
it.next()).getTitle());
+                               //}
                        }
+               } else {
                        
-                       
-                       
-               } else {
+                       //TODO
+                       /*
                        final byte attrType = 
selectedAttributes.getType(selectedKeyAttribute);
                        
                        Object value = null;
@@ -2869,13 +2876,14 @@
                                }
                                
                        }
-                       
+                       */
                }
 
+
                previewPanel.setKeyAttributeList(valueSet);
 
-               nodeKeyList.setListData(valueSet.toArray());
-               */
+               //nodeKeyList.setListData(valueSet.toArray());
+
        }
 
        private void updateAliasTableCell(String name, int columnIndex) {
@@ -2993,7 +3001,7 @@
        }
 
        private void updateMappingAttributeComboBox() {
-               /*
+               
                mappingAttributeComboBox.removeAllItems();
 
                final ListCellRenderer lcr = 
mappingAttributeComboBox.getRenderer();
@@ -3007,7 +3015,7 @@
                                        if (value.equals(ID)) {
                                                cmp.setIcon(ID_ICON.getIcon());
                                        } else {
-                                               
//cmp.setIcon(getDataTypeIcon(selectedAttributes.getType(value.toString())));
+                                               
//cmp.setIcon(getDataTypeIcon(selectedAttributes.getColumnTypeMap().get(value.toString())));
                                        }
 
                                        return cmp;
@@ -3016,14 +3024,32 @@
 
                mappingAttributeComboBox.addItem(ID);
 
-               for (String name : selectedAttributes.getAttributeNames()) {
-                       if ((selectedAttributes.getType(name) != 
AttributeTypes.TYPE_COMPLEX)
-                           && (selectedAttributes.getType(name) != 
AttributeTypes.TYPE_SIMPLE_MAP)
-                           && (selectedAttributes.getType(name) != 
AttributeTypes.TYPE_UNDEFINED)) {
-                               mappingAttributeComboBox.addItem(name);
+               Set<String> keySet = 
this.selectedAttributes.getColumnTypeMap().keySet();
+               
+               Iterator<String> it = keySet.iterator();
+               Map<String, Class<?>> columnTypeMap = 
this.selectedAttributes.getColumnTypeMap();
+               
+               while (it.hasNext()){
+                       String columnName = it.next();
+
+                       if (columnName.equalsIgnoreCase(ID)){
+                               continue;
                        }
+                       
+                       Class<?> type =columnTypeMap.get(columnName); 
+                       if ( type == String.class || type == Integer.class || 
type == Double.class || type == List.class){
+                               mappingAttributeComboBox.addItem(columnName);
+                       }
                }
-               */
+               
+               //for (String name : selectedAttributes.getAttributeNames()) {
+               //      if ((selectedAttributes.getColumnTypeMap().get(name) != 
AttributeTypes.TYPE_COMPLEX)
+               //          && (selectedAttributes.getColumnTypeMap().get(name) 
!= AttributeTypes.TYPE_SIMPLE_MAP)
+               //          && (selectedAttributes.getColumnTypeMap().get(name) 
!= AttributeTypes.TYPE_UNDEFINED)) {
+               //              mappingAttributeComboBox.addItem(name);
+               //      }
+               //}
+               
        }
 
        private TableCellRenderer getRenderer(FileTypes type) {
@@ -3067,22 +3093,11 @@
         */
        private void loadAnnotation(TextTableReader reader, String source) {
                
-               
System.out.println("\nImporttextTableDialog.loadAnnotation()....\n\n");
-               
-               /*
-               // Create LoadNetwork Task
+               // Create loadAnnotation Task
                ImportAttributeTableTask task = new 
ImportAttributeTableTask(reader, source);
+               ImportAttributeTableTaskFactory taskFactory = new 
ImportAttributeTableTaskFactory(task);
 
-               // Configure JTask Dialog Pop-Up Box
-               JTaskConfig jTaskConfig = new JTaskConfig();
-               jTaskConfig.setOwner(CytoscapeServices.desktop.getJFrame());
-               jTaskConfig.displayCloseButton(true);
-               jTaskConfig.displayStatus(true);
-               jTaskConfig.setAutoDispose(false);
-
-               // Execute Task in New Thread; pops open JTask Dialog Box.
-               TaskManager.executeTask(task, jTaskConfig);
-               */
+               CytoscapeServices.guiTaskManagerServiceRef.execute(taskFactory);
        }
 
        /**

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