Author: kono
Date: 2011-01-19 17:12:41 -0800 (Wed, 19 Jan 2011)
New Revision: 23522
Removed:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BasicStringQuery.java
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTaskFactory.java
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartClient.java
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartQuery.java
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTask.java
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ShowBiomartGUIAction.java
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/ui/BiomartAttrMappingPanel.java
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/ui/BiomartMainDialog.java
Log:
Major update version of web service API. Biomart client still needs some
refactoring to use this new API.
Deleted:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BasicStringQuery.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BasicStringQuery.java
2011-01-20 01:12:20 UTC (rev 23521)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BasicStringQuery.java
2011-01-20 01:12:41 UTC (rev 23522)
@@ -1,25 +0,0 @@
-package org.cytoscape.io.webservice.biomart;
-
-import org.cytoscape.io.webservice.client.Query;
-
-
-/**
- * Most basic implementation of Query interface.
- * This is mainly for simple REST clients.
- *
- *
- */
-public class BasicStringQuery implements Query {
-
- private final String query;
-
- public BasicStringQuery(final String query) {
- this.query = query;
- }
-
- @Override
- public String getQueryAsString() {
- return query;
- }
-
-}
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartClient.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartClient.java
2011-01-20 01:12:20 UTC (rev 23521)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartClient.java
2011-01-20 01:12:41 UTC (rev 23522)
@@ -34,32 +34,36 @@
*/
package org.cytoscape.io.webservice.biomart;
-import java.io.BufferedReader;
-import java.io.IOException;
-import java.util.ArrayList;
import java.util.HashSet;
-import java.util.List;
import java.util.Set;
import javax.naming.ConfigurationException;
+import org.cytoscape.io.webservice.TableImportWebServiceClient;
import org.cytoscape.io.webservice.biomart.rest.BiomartRestClient;
+import org.cytoscape.io.webservice.biomart.task.ImportTableTask;
+import org.cytoscape.io.webservice.biomart.ui.BiomartAttrMappingPanel;
import org.cytoscape.io.webservice.client.AbstractWebServiceClient;
-import org.cytoscape.model.CyNetwork;
import org.cytoscape.model.CyNetworkManager;
-import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyTable;
import org.cytoscape.model.CyTableFactory;
+import org.cytoscape.work.TaskIterator;
/**
* Biomart Web Service Client.
*
*/
-public class BiomartClient extends AbstractWebServiceClient<BiomartRestClient>
{
-
+public class BiomartClient extends AbstractWebServiceClient implements
TableImportWebServiceClient {
private final CyTableFactory tableFactory;
private final CyNetworkManager manager;
+
+ private final BiomartRestClient restClient;
+
+ private BiomartAttrMappingPanel gui;
+
+ private ImportTableTask importTask;
+
/**
* Creates a new Biomart Client object.
@@ -71,221 +75,40 @@
final BiomartRestClient restClient,
final CyTableFactory tableFactory,
final CyNetworkManager manager) {
- super(restClient.getBaseURL(), displayName, description,
restClient);
+ super(restClient.getBaseURL(), displayName, description);
this.tableFactory = tableFactory;
this.manager = manager;
+ this.restClient = restClient;
// TODO: set optional parameters (Tunables?)
}
-
- /**
- * Based on the query given, execute the data fetching.
- *
- * @param query
- * @throws CyWebServiceException
- * @throws IOException
- * @throws Exception
- */
- public Set<CyTable> importAttributes(final BiomartQuery query) throws
IOException {
-
- final BufferedReader result =
clientStub.sendQuery(query.getQueryAsString());
-
- if (result.ready() == false)
- throw new IOException("Could not get result.");
-
- return mapping(result, query.getKeyColumnName());
-
+
+ public void setGUI(final BiomartAttrMappingPanel gui) {
+ this.gui = gui;
}
- private Set<CyTable> mapping(BufferedReader reader, String key) throws
IOException {
-
- final Set<CyTable> newTables = new HashSet<CyTable>();
-
- final CyTable table = tableFactory.createTable("Test Table
name", key, String.class, true);
-
- // Read result from reader
- String line = reader.readLine();
- System.out.println("Table Header: " + line);
- final String[] columnNames = line.split("\\t");
+ public BiomartRestClient getRestClient() {
+ return this.restClient;
+ }
- if (columnNames[0].contains("Query ERROR"))
- throw new IOException("Biomart service returns Querry
ERROR. ");
+ @Override
+ public Set<CyTable> getTables() {
+ // Return empty task if not executed yet.
+ if(importTask == null)
+ return new HashSet<CyTable>();
+ else
+ return importTask.getCyTables();
+ }
- // For status report
- int recordCount = 0;
- List<String> report = new ArrayList<String>();
-
- // final int rowCount = result.size();
- final int colSize = columnNames.length;
- int keyIdx = 0;
-
- // Search column index of the key
- for (int i = 0; i < colSize; i++) {
- table.createListColumn(columnNames[i], String.class);
-
- if (columnNames[i].equals(key))
- keyIdx = i;
- }
-
- //byte attrDataType =
Cytoscape.getNodeAttributes().getType(keyAttrName);
- final List<String> nodeIdList = new ArrayList<String>();
-
- // Prepare list of nodes FROM ALL NETWORKS.
+ @Override
+ public TaskIterator getTaskIterator() {
+ if(gui == null)
+ throw new IllegalStateException("Could not build query
because Query Builder GUI is null.");
- final Set<CyNetwork> allNetworks = manager.getNetworkSet();
+ final BiomartQuery query = this.gui.getTableImportQuery();
- for(final CyNetwork network: allNetworks) {
- final List<CyNode> nodes = network.getNodeList();
- for(CyNode node: nodes) {
-
- }
- }
-
-
-// String[] row;
-// String val;
-//
-// List<List<Object>> listOfValList;
-// List<String> ids = null;
-//
-// List<Object> testList;
-// String keyVal = null;
-// int rowLength = 0;
-//
-// int hitCount = 0;
-//
-// long start = System.currentTimeMillis();
-// while ((line = reader.readLine()) != null) {
-// // Cancel the job.
-// if (cancelImport) {
-// cancelImport = false;
-// return null;
-// }
-//
-// row = line.split("\\t");
-//
-// // Ignore invalid length entry.
-// if ((row.length <= keyIdx) || (row.length == 0))
-// continue;
-//
-// recordCount++;
-// keyVal = row[keyIdx];
-//
-// // System.out.println("Key ====>" + keyVal + "<==");
-// // for(String s: entry)
-// // System.out.println("ENT ======>" + s + "<===");
-// rowLength = row.length;
-//
-// for (int j = 0; j < rowLength; j++) {
-// val = row[j];
-//
-// if ((val != null) && (val.length() != 0) && (j
!= keyIdx)) {
-// listOfValList = new
ArrayList<List<Object>>();
-//
-// if (keyAttrName.equals("ID")) {
-// testList = attr
-//
.getListAttribute(keyVal, columnNames[j]);
-//
-// if (testList != null)
-//
listOfValList.add(testList);
-// } else {
-// ids =
getIdFromAttrValue(attrDataType, keyAttrName,
-// keyVal,
nodeIdList, attr);
-//
-// if (ids.size() == 0)
-// continue;
-//
-// for (String id : ids)
-//
listOfValList.add(attr.getListAttribute(id,
-//
columnNames[j]));
-// }
-//
-// if (listOfValList.size() == 0) {
-// List<Object> valList = new
ArrayList<Object>();
-// listOfValList.add(valList);
-// }
-//
-// int index = 0;
-// for (List<Object> valList :
listOfValList) {
-// if (valList == null)
-// valList = new
ArrayList<Object>();
-//
-// if (valList.contains(row[j]) ==
false)
-// valList.add(row[j]);
-//
-// if (keyAttrName.equals("ID")) {
-//
attr.setListAttribute(keyVal, columnNames[j],
-//
valList);
-//
attr.setAttribute(keyVal, columnNames[j] + "-TOP",
-//
valList.get(0).toString());
-// } else {
-//
attr.setListAttribute(ids.get(index),
-//
columnNames[j], valList);
-//
attr.setAttribute(ids.get(index), columnNames[j]
-// +
"-TOP", valList.get(0).toString());
-//
-// }
-// hitCount++;
-// index++;
-// }
-// }
-// }
-// }
-//
-// // System.out.println("Time =====> " +
-// // (System.currentTimeMillis()-start));
-//
-// reader.close();
-// reader = null;
-//
-// report.add("Number of Records (Rows) from BioMart = " +
recordCount
-// + "\n");
-// report.add("Number of Terms Mapped = " + hitCount + "\n");
-// report.add("The following node attributes are created:" + "\n");
-// for (String s : columnNames) {
-// report.add(s + ", " + s + "-TOP");
-// }
-// report.add("\nAttributes name ends with \'TOP\' contains first
entry of the list");
-// return report;
-
- return newTables;
+ importTask = new ImportTableTask(restClient, query,
tableFactory, manager);
+ return new TaskIterator(importTask);
}
-
-// private List<String> getIdFromAttrValue(final byte attrDataType,
-// final String attrName, Object attrValue, List<String>
nodeIdList,
-// CyAttributes attr) {
-// final List<String> idList = new ArrayList<String>();
-//
-// String value;
-//
-// List<Object> l = null;
-//
-// if (attrDataType == CyAttributes.TYPE_SIMPLE_LIST) {
-// for (String id : nodeIdList) {
-// l = attr.getListAttribute(id, attrName);
-//
-// if ((l != null) && (l.size() > 0)) {
-// for (Object obj : l) {
-// if ((obj != null) &&
obj.equals(attrValue)) {
-// idList.add(id);
-//
-// break;
-// }
-// }
-// }
-// }
-// } else if (attrDataType == CyAttributes.TYPE_STRING) {
-// for (String id : nodeIdList) {
-// // Extract attribute value from ID
-// value = attr.getStringAttribute(id, attrName);
-//
-// if ((value != null) && value.equals(attrValue))
-// idList.add(id);
-// }
-// }
-//
-// return idList;
-// }
-
}
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartQuery.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartQuery.java
2011-01-20 01:12:20 UTC (rev 23521)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/BiomartQuery.java
2011-01-20 01:12:41 UTC (rev 23522)
@@ -1,8 +1,7 @@
package org.cytoscape.io.webservice.biomart;
-import org.cytoscape.io.webservice.client.Query;
-public final class BiomartQuery implements Query {
+public final class BiomartQuery {
private final String xmlQuery;
private final String keyColumnName;
@@ -16,8 +15,8 @@
return this.keyColumnName;
}
- @Override
- public String getQueryAsString() {
+
+ public String getQueryString() {
return xmlQuery;
}
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTask.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTask.java
2011-01-20 01:12:20 UTC (rev 23521)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTask.java
2011-01-20 01:12:41 UTC (rev 23522)
@@ -1,35 +1,211 @@
package org.cytoscape.io.webservice.biomart.task;
+import java.io.BufferedReader;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.HashSet;
+import java.util.List;
import java.util.Set;
-import org.cytoscape.io.webservice.biomart.BiomartClient;
import org.cytoscape.io.webservice.biomart.BiomartQuery;
-import org.cytoscape.io.webservice.client.CyTableImportTask;
+import org.cytoscape.io.webservice.biomart.rest.BiomartRestClient;
+import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNetworkManager;
+import org.cytoscape.model.CyNode;
import org.cytoscape.model.CyTable;
+import org.cytoscape.model.CyTableFactory;
import org.cytoscape.work.AbstractTask;
import org.cytoscape.work.TaskMonitor;
-public class ImportTableTask extends AbstractTask implements CyTableImportTask
{
+public class ImportTableTask extends AbstractTask {
- private final BiomartClient client;
+ private final BiomartRestClient client;
private final BiomartQuery query;
+ private final CyTableFactory tableFactory;
+ private final CyNetworkManager manager;
+
private Set<CyTable> tables;
-
- public ImportTableTask(final BiomartClient client, final BiomartQuery
query) {
+
+ public ImportTableTask(final BiomartRestClient client,
+ final BiomartQuery query, final CyTableFactory
tableFactory,
+ final CyNetworkManager manager) {
+
this.client = client;
this.query = query;
+ this.tableFactory = tableFactory;
+ this.manager = manager;
}
-
+
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
- if(query == null)
+ if (query == null)
throw new NullPointerException("Query is null");
-
- tables = client.importAttributes(query);
+
+ final BufferedReader result =
client.sendQuery(query.getQueryString());
+
+ if (result.ready() == false)
+ throw new IOException("Could not get result.");
+
+ tables = mapping(result, query.getKeyColumnName());
}
- @Override
+ private Set<CyTable> mapping(BufferedReader reader, String key)
+ throws IOException {
+
+ final Set<CyTable> newTables = new HashSet<CyTable>();
+
+ final CyTable table = tableFactory.createTable("Test Table
name", key,
+ String.class, true);
+
+ // Read result from reader
+ String line = reader.readLine();
+ System.out.println("Table Header: " + line);
+ final String[] columnNames = line.split("\\t");
+
+ if (columnNames[0].contains("Query ERROR"))
+ throw new IOException("Biomart service returns Querry
ERROR. ");
+
+ // For status report
+ int recordCount = 0;
+ List<String> report = new ArrayList<String>();
+
+ // final int rowCount = result.size();
+ final int colSize = columnNames.length;
+ int keyIdx = 0;
+
+ // Search column index of the key
+ for (int i = 0; i < colSize; i++) {
+ table.createListColumn(columnNames[i], String.class);
+
+ if (columnNames[i].equals(key))
+ keyIdx = i;
+ }
+
+ // byte attrDataType =
+ // Cytoscape.getNodeAttributes().getType(keyAttrName);
+ final List<String> nodeIdList = new ArrayList<String>();
+
+ // Prepare list of nodes FROM ALL NETWORKS.
+
+ final Set<CyNetwork> allNetworks = manager.getNetworkSet();
+
+ for (final CyNetwork network : allNetworks) {
+ final List<CyNode> nodes = network.getNodeList();
+ for (CyNode node : nodes) {
+
+ }
+ }
+
+ // String[] row;
+ // String val;
+ //
+ // List<List<Object>> listOfValList;
+ // List<String> ids = null;
+ //
+ // List<Object> testList;
+ // String keyVal = null;
+ // int rowLength = 0;
+ //
+ // int hitCount = 0;
+ //
+ // long start = System.currentTimeMillis();
+ // while ((line = reader.readLine()) != null) {
+ // // Cancel the job.
+ // if (cancelImport) {
+ // cancelImport = false;
+ // return null;
+ // }
+ //
+ // row = line.split("\\t");
+ //
+ // // Ignore invalid length entry.
+ // if ((row.length <= keyIdx) || (row.length == 0))
+ // continue;
+ //
+ // recordCount++;
+ // keyVal = row[keyIdx];
+ //
+ // // System.out.println("Key ====>" + keyVal + "<==");
+ // // for(String s: entry)
+ // // System.out.println("ENT ======>" + s + "<===");
+ // rowLength = row.length;
+ //
+ // for (int j = 0; j < rowLength; j++) {
+ // val = row[j];
+ //
+ // if ((val != null) && (val.length() != 0) && (j != keyIdx)) {
+ // listOfValList = new ArrayList<List<Object>>();
+ //
+ // if (keyAttrName.equals("ID")) {
+ // testList = attr
+ // .getListAttribute(keyVal, columnNames[j]);
+ //
+ // if (testList != null)
+ // listOfValList.add(testList);
+ // } else {
+ // ids = getIdFromAttrValue(attrDataType, keyAttrName,
+ // keyVal, nodeIdList, attr);
+ //
+ // if (ids.size() == 0)
+ // continue;
+ //
+ // for (String id : ids)
+ // listOfValList.add(attr.getListAttribute(id,
+ // columnNames[j]));
+ // }
+ //
+ // if (listOfValList.size() == 0) {
+ // List<Object> valList = new ArrayList<Object>();
+ // listOfValList.add(valList);
+ // }
+ //
+ // int index = 0;
+ // for (List<Object> valList : listOfValList) {
+ // if (valList == null)
+ // valList = new ArrayList<Object>();
+ //
+ // if (valList.contains(row[j]) == false)
+ // valList.add(row[j]);
+ //
+ // if (keyAttrName.equals("ID")) {
+ // attr.setListAttribute(keyVal, columnNames[j],
+ // valList);
+ // attr.setAttribute(keyVal, columnNames[j] + "-TOP",
+ // valList.get(0).toString());
+ // } else {
+ // attr.setListAttribute(ids.get(index),
+ // columnNames[j], valList);
+ // attr.setAttribute(ids.get(index), columnNames[j]
+ // + "-TOP", valList.get(0).toString());
+ //
+ // }
+ // hitCount++;
+ // index++;
+ // }
+ // }
+ // }
+ // }
+ //
+ // // System.out.println("Time =====> " +
+ // // (System.currentTimeMillis()-start));
+ //
+ // reader.close();
+ // reader = null;
+ //
+ // report.add("Number of Records (Rows) from BioMart = " +
recordCount
+ // + "\n");
+ // report.add("Number of Terms Mapped = " + hitCount + "\n");
+ // report.add("The following node attributes are created:" +
"\n");
+ // for (String s : columnNames) {
+ // report.add(s + ", " + s + "-TOP");
+ // }
+ // report.add("\nAttributes name ends with \'TOP\' contains
first entry of the list");
+ // return report;
+
+ return newTables;
+ }
+
public Set<CyTable> getCyTables() {
return tables;
}
Deleted:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTaskFactory.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTaskFactory.java
2011-01-20 01:12:20 UTC (rev 23521)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ImportTableTaskFactory.java
2011-01-20 01:12:41 UTC (rev 23522)
@@ -1,32 +0,0 @@
-package org.cytoscape.io.webservice.biomart.task;
-
-import org.cytoscape.io.webservice.biomart.BiomartClient;
-import org.cytoscape.io.webservice.biomart.BiomartQuery;
-import org.cytoscape.io.webservice.client.Query;
-import org.cytoscape.io.webservice.client.WebServiceClientTaskFactory;
-import org.cytoscape.work.TaskIterator;
-
-public class ImportTableTaskFactory implements WebServiceClientTaskFactory {
-
- private final BiomartClient client;
-
- private BiomartQuery query;
-
- public ImportTableTaskFactory(final BiomartClient client) {
- this.client = client;
- }
-
- @Override
- public TaskIterator getTaskIterator() {
- return new TaskIterator(new ImportTableTask(client, query));
- }
-
- @Override
- public void setQuery(Query query) {
- if(query instanceof BiomartQuery == false)
- throw new IllegalArgumentException("Query object is not
compatible.");
-
- this.query = (BiomartQuery) query;
- }
-
-}
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ShowBiomartGUIAction.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ShowBiomartGUIAction.java
2011-01-20 01:12:20 UTC (rev 23521)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/task/ShowBiomartGUIAction.java
2011-01-20 01:12:41 UTC (rev 23522)
@@ -61,7 +61,7 @@
logger.debug("BioMart Dialog initialization process
start.");
initDataSource();
- dialog = new BiomartMainDialog(client, taskManager,
appManager, tblManager, app);
+ dialog = new BiomartMainDialog(client.getRestClient(),
taskManager, appManager, tblManager, app);
logger.info("BioMart Client dialog initialized.");
}
@@ -88,7 +88,7 @@
}
private List<String> initDataSource() {
- final ValuedTask<LoadRepositoryResult> firstTask = new
LoadRepositoryTask(client.getClient());
+ final ValuedTask<LoadRepositoryResult> firstTask = new
LoadRepositoryTask(client.getRestClient());
final ValuedTaskExecutor<LoadRepositoryResult> ex =
new ValuedTaskExecutor<LoadRepositoryResult>(firstTask);
final BioMartTaskFactory tf = new BioMartTaskFactory(ex);
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/ui/BiomartAttrMappingPanel.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/ui/BiomartAttrMappingPanel.java
2011-01-20 01:12:20 UTC (rev 23521)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/ui/BiomartAttrMappingPanel.java
2011-01-20 01:12:41 UTC (rev 23522)
@@ -48,9 +48,9 @@
import javax.swing.Icon;
import javax.swing.ImageIcon;
-import org.cytoscape.io.webservice.biomart.BiomartClient;
import org.cytoscape.io.webservice.biomart.BiomartQuery;
import org.cytoscape.io.webservice.biomart.rest.Attribute;
+import org.cytoscape.io.webservice.biomart.rest.BiomartRestClient;
import org.cytoscape.io.webservice.biomart.rest.Dataset;
import org.cytoscape.io.webservice.biomart.rest.Filter;
import org.cytoscape.io.webservice.biomart.rest.XMLQueryBuilder;
@@ -59,7 +59,6 @@
import org.cytoscape.io.webservice.biomart.task.ImportAttributeListTaskFactory;
import org.cytoscape.io.webservice.biomart.task.ImportFilterTask;
import org.cytoscape.io.webservice.biomart.task.ImportFilterTaskFactory;
-import org.cytoscape.io.webservice.biomart.task.ImportTableTaskFactory;
import org.cytoscape.io.webservice.biomart.task.LoadRepositoryResult;
import org.cytoscape.io.webservice.biomart.task.LoadRepositoryTask;
import org.cytoscape.model.CyNetwork;
@@ -71,7 +70,6 @@
import org.cytoscape.work.TaskManager;
import org.cytoscape.work.ValuedTask;
import org.cytoscape.work.ValuedTaskExecutor;
-import org.cytoscape.work.swing.GUITaskManager;
/**
*
@@ -98,10 +96,6 @@
private boolean cancelFlag = false;
private boolean initialized = false;
- private final BiomartClient client;
-
- private final ImportTableTaskFactory importTaskFactory;
-
// These databases are not compatible with this UI.
private static final List<String> databaseFilter = new
ArrayList<String>();
@@ -110,6 +104,8 @@
private final CyTableManager tblManager;
private final Window parent;
+
+ private final BiomartRestClient restClient;
/**
* Creates a new BiomartNameMappingPanel object.
@@ -120,20 +116,18 @@
* DOCUMENT ME!
* @throws Exception
*/
- public BiomartAttrMappingPanel(final BiomartClient client,
+ public BiomartAttrMappingPanel(final BiomartRestClient client,
final TaskManager taskManager,
final CyApplicationManager appManager,
final CyTableManager tblManager, final Window parent) {
super(LOGO, "Biomart", "Import Settings");
- this.client = client;
+ this.restClient = client;
this.taskManager = taskManager;
this.appManager = appManager;
this.tblManager = tblManager;
this.parent = parent;
- importTaskFactory = new ImportTableTaskFactory(this.client);
-
// Access the MartService and get the available services.
initDataSources();
}
@@ -159,7 +153,7 @@
public void loadMartServiceList() {
final ValuedTask<LoadRepositoryResult> firstTask = new
LoadRepositoryTask(
- client.getClient());
+ restClient);
ValuedTaskExecutor<LoadRepositoryResult> ex = new
ValuedTaskExecutor<LoadRepositoryResult>(
firstTask);
final BioMartTaskFactory tf = new BioMartTaskFactory(ex);
@@ -237,7 +231,7 @@
System.out.println("Calling attribute update task.");
final ImportAttributeListTaskFactory tf = new
ImportAttributeListTaskFactory(
- datasourceName, client.getClient());
+ datasourceName, restClient);
final ImportAttributeListTask firstTask =
(ImportAttributeListTask) tf
.getTaskIterator().next();
taskManager.executeAndWait(tf);
@@ -286,7 +280,7 @@
} else if (type.equals(SourceType.FILTER)) {
final ImportFilterTaskFactory tf = new
ImportFilterTaskFactory(
- datasourceName, client.getClient());
+ datasourceName, restClient);
final ImportFilterTask firstTask = (ImportFilterTask) tf
.getTaskIterator().next();
tf.setTask(firstTask);
@@ -409,16 +403,16 @@
// return mappedKeys;
// }
- private void importAttributesFromService(Dataset dataset,
+ private BiomartQuery importAttributesFromService(Dataset dataset,
Attribute[] attrs, Filter[] filters, String keyInHeader,
String keyAttrName) {
final String query = XMLQueryBuilder.getQueryString(dataset,
attrs,
filters);
- importTaskFactory.setQuery(new BiomartQuery(query,
keyAttrName));
+
+ return new BiomartQuery(query, keyAttrName);
+
- this.taskManager.executeAndWait(importTaskFactory);
-
// AttributeImportQuery qObj = new AttributeImportQuery(query2,
key,
// keyAttrName);
@@ -426,6 +420,11 @@
@Override
protected void importAttributes() {
+
+
+ }
+
+ public BiomartQuery getTableImportQuery() {
final String datasource = datasourceMap.get(databaseComboBox
.getSelectedItem());
final Map<String, String> attrMap =
this.attrNameMap.get(datasource);
@@ -486,10 +485,9 @@
}
}
- // Create Task
- importAttributesFromService(dataset, attrs, filters,
keyInHeader,
+ // Create query
+ return importAttributesFromService(dataset, attrs, filters,
keyInHeader,
keyAttrName);
-
}
}
Modified:
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/ui/BiomartMainDialog.java
===================================================================
---
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/ui/BiomartMainDialog.java
2011-01-20 01:12:20 UTC (rev 23521)
+++
core3/webservice-biomart-client/trunk/src/main/java/org/cytoscape/io/webservice/biomart/ui/BiomartMainDialog.java
2011-01-20 01:12:41 UTC (rev 23522)
@@ -45,6 +45,7 @@
import org.cytoscape.application.swing.CySwingApplication;
import org.cytoscape.io.webservice.biomart.BiomartClient;
+import org.cytoscape.io.webservice.biomart.rest.BiomartRestClient;
import org.cytoscape.model.CyTableManager;
import org.cytoscape.session.CyApplicationManager;
import org.cytoscape.work.TaskManager;
@@ -56,7 +57,7 @@
private static final long serialVersionUID = 2382157952635589843L;
- final BiomartAttrMappingPanel panel;
+ private final BiomartAttrMappingPanel panel;
/**
* Basic GUI to access BioMart services.
@@ -66,7 +67,7 @@
* @param appManager
* @param tblManager
*/
- public BiomartMainDialog(final BiomartClient client, final TaskManager
taskManager,
+ public BiomartMainDialog(final BiomartRestClient client, final
TaskManager taskManager,
final CyApplicationManager appManager,
final CyTableManager tblManager, final
CySwingApplication app) {
super();
@@ -95,8 +96,4 @@
pack();
}
-
- public BiomartAttrMappingPanel getPanel() {
- return this.panel;
- }
}
--
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.