Author: kono
Date: 2012-06-04 18:24:12 -0700 (Mon, 04 Jun 2012)
New Revision: 29451
Removed:
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java
Modified:
core3/impl/trunk/webservice-psicquic-client-impl/pom.xml
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/CyActivator.java
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICRestClient.java
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICWebServiceClient.java
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/RegistryManager.java
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/ui/PSICQUICSearchUI.java
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/ui/SourceStatusPanel.java
core3/impl/trunk/webservice-psicquic-client-impl/src/test/java/org/cytoscape/webservice/psicquic/PSICQUICClientTest.java
Log:
First new version after hackathon.
Modified: core3/impl/trunk/webservice-psicquic-client-impl/pom.xml
===================================================================
--- core3/impl/trunk/webservice-psicquic-client-impl/pom.xml 2012-06-04
23:44:21 UTC (rev 29450)
+++ core3/impl/trunk/webservice-psicquic-client-impl/pom.xml 2012-06-05
01:24:12 UTC (rev 29451)
@@ -16,7 +16,7 @@
<modelVersion>4.0.0</modelVersion>
<artifactId>webservice-psicquic-client-impl</artifactId>
- <name>Cytoscape PSIQUIC Webservice Impl (${project.artifactId})</name>
+ <name>Cytoscape PSIQUIC Web Service Impl (${project.artifactId})</name>
<packaging>bundle</packaging>
@@ -76,7 +76,7 @@
<artifactId>swing-util-api</artifactId>
</dependency>
- <!-- MI Cluster -->
+ <!-- MI Cluster dependency -->
<dependency>
<groupId>cytoscape-temp</groupId>
<artifactId>uk.ac.ebi.enfin.mi.cluster.micluster</artifactId>
@@ -115,11 +115,6 @@
</dependency>
<dependency>
<groupId>org.cytoscape</groupId>
- <artifactId>equations-api</artifactId>
- <scope>test</scope>
- </dependency>
- <dependency>
- <groupId>org.cytoscape</groupId>
<artifactId>webservice-api</artifactId>
<type>test-jar</type>
<scope>test</scope>
Modified:
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/CyActivator.java
===================================================================
---
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/CyActivator.java
2012-06-04 23:44:21 UTC (rev 29450)
+++
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/CyActivator.java
2012-06-05 01:24:12 UTC (rev 29451)
@@ -25,7 +25,7 @@
CreateNetworkViewTaskFactory createViewTaskFactoryServiceRef =
getService(bc, CreateNetworkViewTaskFactory.class);
- PSICQUICWebServiceClient psicquicClient = new
PSICQUICWebServiceClient(
+ final PSICQUICWebServiceClient psicquicClient = new
PSICQUICWebServiceClient(
"http://www.ebi.ac.uk/Tools/webservices/psicquic/registry/registry", "PSICQUIC
Universal Client",
"REST version of PSICQUIC web service client.",
cyNetworkFactoryServiceRef, cyNetworkManagerServiceRef,
tm, createViewTaskFactoryServiceRef,
openBrowser);
Modified:
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICRestClient.java
===================================================================
---
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICRestClient.java
2012-06-04 23:44:21 UTC (rev 29450)
+++
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICRestClient.java
2012-06-05 01:24:12 UTC (rev 29451)
@@ -68,8 +68,10 @@
public static final Long ERROR_TIMEOUT = -2l;
public static final Long ERROR_CANCEL = -3l;
- // Timeout for search
- private static final long SEARCH_TIMEOUT = 5000;
+ // Timeout for search. TODO: Make public as property.
+ private static final long SEARCH_TIMEOUT_MSEC = 7000;
+
+ // Timeout for import. TODO: Make public as property.
private static final long IMPORT_TIMEOUT = 1000;
private final CyNetworkFactory factory;
@@ -288,10 +290,8 @@
List<Future<Long>> futures;
try {
- futures = exe.invokeAll(tasks, SEARCH_TIMEOUT,
TimeUnit.MILLISECONDS);
+ futures = exe.invokeAll(tasks, SEARCH_TIMEOUT_MSEC,
TimeUnit.MILLISECONDS);
- logger.debug("Task submitted!");
-
final Iterator<SearchTask> taskItr = tasks.iterator();
double completed = 0.0d;
@@ -303,7 +303,7 @@
final SearchTask task = taskItr.next();
final String source = task.getURL();
try {
- resultMap.put(source,
future.get(SEARCH_TIMEOUT, TimeUnit.MILLISECONDS));
+ resultMap.put(source,
future.get(SEARCH_TIMEOUT_MSEC, TimeUnit.MILLISECONDS));
logger.debug(source + " : Got response
= " + resultMap.get(source));
} catch (ExecutionException e) {
logger.warn("Error occured in search: "
+ source, e);
Deleted:
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java
===================================================================
---
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java
2012-06-04 23:44:21 UTC (rev 29450)
+++
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICUniversalClient.java
2012-06-05 01:24:12 UTC (rev 29451)
@@ -1,341 +0,0 @@
-package org.cytoscape.webservice.psicquic;
-
-
-
-
-public class PSICQUICUniversalClient {
-//
-// private static final long serialVersionUID = 4485772700287524894L;
-//
-// private static final String[] IMPORT_MODE = { "Detection Method",
"Interaction ID" };
-// private static final String[] IMPORT_DATA_FORMAT = { "MITAB25", "PSI-MI
XML 2.5" };
-// private static final String[] SEARCH_MODE = { "Interactor ID(s)",
"Query", "Interaction ID(s)", "Pipeline" };
-//
-// private enum Mode {
-// SEARCH, IMPORT;
-// }
-//
-// private enum QueryMode {
-// GET_BY_INTERACTOR, GET_BY_QUERY;
-// }
-//
-// private QueryMode qMode = QueryMode.GET_BY_INTERACTOR;
-//
-// private void setProperty() {
-// props = new ModulePropertiesImpl(clientID, "wsc");
-//
-// // General setting
-// props.add(new Tunable("block_size", "Block Size",
Tunable.INTEGER, Integer.valueOf(100)));
-// props.add(new Tunable("timeout", "Timeout (sec.)",
Tunable.INTEGER, new Integer(6000)));
-//
-// final String[] modeArray = {
QueryMode.GET_BY_INTERACTOR.name(), QueryMode.GET_BY_QUERY.toString() };
-// props.add(new Tunable("query_mode", "Query Mode", Tunable.LIST,
Integer.valueOf(0), (Object) modeArray,
-// (Object) null, 0));
-//
-// }
-//
-//
-// // Display name of this client.
-// private static final String DISPLAY_NAME = "PSICQUIC Universal Web
Service Client";
-//
-// // Client ID. This should be unique.
-// private static final String CLIENT_ID = "psicquic";
-//
-// // // Instance of this client. This is a singleton.
-// private PSICQUICRestClient client;
-//
-// // Visual Style name for the networks generated by this client.
-// private static final String DEF_VS_NAME = "PSI-MI 25 Style";
-// private VisualStyle defaultVS = null;
-//
-// private Map<URI, QueryResponse> sResult;
-// private List<DbRef> queryList;
-// private String query;
-//
-// private final ServiceState states;
-//
-// static {
-// try {
-// client = new PSICQUICUniversalClient();
-// } catch (Exception e) {
-// CyLogger.getLogger().error("Could not initialize
PSICQUIC Client.", e);
-// }
-// }
-//
-// private PSICQUICUniversalClient() throws Exception {
-// super(CLIENT_ID, DISPLAY_NAME, new ClientType[] {
ClientType.NETWORK }, null, new PSICQUICServiceRegistory(),
-// null);
-//
-// setDescription();
-// // Set properties for this client.
-// setProperty();
-//
-// this.states = new ServiceState(((PSICQUICServiceRegistory)
clientStub));
-//
-// }
-//
-// public static WebServiceClient<PSICQUICServiceRegistory> getClient() {
-// return client;
-// }
-//
-// public VisualStyle getDefaultVisualStyle() {
-// return PSI25VisualStyleBuilder.getDefVS();
-// }
-//
-// @Override
-// public void executeService(CyWebServiceEvent e) throws
CyWebServiceException {
-//
-// if (e.getSource().equals(CLIENT_ID)) {
-// if
(e.getEventType().equals(WSEventType.IMPORT_NETWORK)) {
-// SearchResultDialog searchResultDialog = new
SearchResultDialog(Cytoscape.getDesktop(), states);
-// searchResultDialog.setVisible(true);
-// Set<String> selected =
searchResultDialog.getSelected();
-//
-// importNetwork(selected, null);
-// } else if
(e.getEventType().equals(WSEventType.EXPAND_NETWORK)) {
-// SearchResultDialog searchResultDialog = new
SearchResultDialog(Cytoscape.getDesktop(), states);
-// searchResultDialog.setVisible(true);
-// Set<String> selected =
searchResultDialog.getSelected();
-// importNetwork(selected,
Cytoscape.getCurrentNetwork());
-// } else if
(e.getEventType().equals(WSEventType.SEARCH_DATABASE)) {
-// search(e.getParameter().toString(), e);
-// }
-// }
-//
-// }
-//
-// private void search(String queryString, CyWebServiceEvent<?> e) throws
CyWebServiceException {
-//
-// final PSICQUICServiceRegistory searchClient =
((PSICQUICServiceRegistory) clientStub);
-// sResult = null;
-// int blockSize = 100;
-// try {
-// blockSize =
Integer.parseInt(props.getValue("block_size"));
-// } catch (Exception exp) {
-// blockSize = 100;
-// }
-//
-// this.query = queryString;
-// final RequestInfo info = new RequestInfo();
-// info.setResultType(PSICQUICReturnType.COUNT.getTypeName());
-// info.setBlockSize(blockSize);
-// try {
-// Tunable mode = props.get("query_mode");
-// System.out.println("QueryMode ====> " +
mode.getValue());
-//
-// if
(mode.getValue().equals(QueryMode.GET_BY_INTERACTOR.ordinal())) {
-// System.out.println("QueryMode ====> " +
mode.getValue());
-// queryList = buildInteractorList(query);
-// sResult = searchClient.getCount(queryList,
info, "OR");
-// } else {
-// // Get by Query (MIQL)
-// sResult = searchClient.getCount(query, info);
-// }
-//
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// throw new
CyWebServiceException(CyWebServiceException.WSErrorCode.REMOTE_EXEC_FAILED);
-// }
-//
-// if (sResult == null)
-// return;
-//
-// WSEventType nextMove = e.getNextMove();
-// if (nextMove == null)
-// nextMove = WSEventType.IMPORT_NETWORK;
-//
-// Integer total = 0;
-// for (URI key : sResult.keySet()) {
-// final Integer count =
sResult.get(key).getResultInfo().getTotalResults();
-//
states.setRecentResultCount(states.getName(key.toString()), count);
-// total = total +
sResult.get(key).getResultInfo().getTotalResults();
-// }
-//
-// Cytoscape.firePropertyChange(SEARCH_FINISHED.toString(),
this.clientID,
-// new DatabaseSearchResult<Map<URI,
QueryResponse>>(total, sResult, nextMove));
-//
-// }
-//
-// private void importNetwork(Set<String> selected, CyNetwork e) throws
CyWebServiceException {
-//
-// if (selected == null || selected.size() == 0)
-// return;
-//
-// PSICQUICServiceRegistory importClient =
((PSICQUICServiceRegistory) clientStub);
-// for (URI uri : importClient.getServiceNames().keySet()) {
-// String name = importClient.getServiceNames().get(uri);
-// if (selected.contains(name) == false)
-// importClient.skip.add(uri);
-// }
-//
-// Map<URI, List<QueryResponse>> importResult = null;
-// final RequestInfo info = new RequestInfo();
-//
-// info.setResultType(PSICQUICReturnType.MITAB25.getTypeName());
-// info.setBlockSize(100);
-// try {
-// if (queryList != null) {
-// // Use OR as operand
-// importResult =
importClient.getByInteractorList(queryList, info, "OR");
-// } else {
-// importResult = importClient.getByQuery(query,
info);
-// }
-// } catch (Exception ex) {
-// ex.printStackTrace();
-// throw new
CyWebServiceException(CyWebServiceException.WSErrorCode.REMOTE_EXEC_FAILED);
-// }
-//
-// if (importResult == null)
-// return;
-//
-// // Ask user to display names
-// final List<String> defNetworkNames = new ArrayList<String>();
-// final Date time = new Date(System.currentTimeMillis());
-// final Map<URI, String> nameMap = importClient.getServiceNames();
-// Map<URI, String> newNameMap = new HashMap<URI, String>();
-// String netName = null;
-// for (URI name : importResult.keySet()) {
-// if (importClient.isEmpty(name))
-// continue;
-// else {
-// netName = nameMap.get(name);
-// defNetworkNames.add(netName);
-// newNameMap.put(name, netName);
-// }
-// }
-//
-// final ResultDialog report = new
ResultDialog(Cytoscape.getDesktop(), true, newNameMap);
-// report.setLocationRelativeTo(Cytoscape.getDesktop());
-// report.setVisible(true);
-// report.setModal(true);
-//
-// final Mitab25Mapper mapper = new Mitab25Mapper();
-// List<CyNetwork> target = new ArrayList<CyNetwork>();
-//
-// // Create parent empty network
-// String parentName = "PSICQUIC Query Results";
-// String postfix = ": " + time.toString();
-// if (query != null)
-// postfix = postfix + " (" + query + ")";
-//
-// parentName = parentName + postfix;
-//
-// newNameMap = report.getNewNames();
-//
-// final CyNetwork parentNetwork =
Cytoscape.createNetwork(parentName, false);
-//
-// for (URI key : importResult.keySet()) {
-//
-// StringBuilder builder = new StringBuilder();
-// List<QueryResponse> res = importResult.get(key);
-// for (QueryResponse qr : res) {
-// builder.append(qr.getResultSet().getMitab());
-// }
-// final CyNetwork net = mapper.map(builder.toString(),
newNameMap.get(key), parentNetwork);
-// if (net != null)
-// target.add(net);
-// }
-// final VisualMappingManager vmm =
Cytoscape.getVisualMappingManager();
-// final VisualStyle defaultVS =
PSI25VisualStyleBuilder.getDefVS();
-// if
(vmm.getCalculatorCatalog().getVisualStyle(defaultVS.getName()) == null)
-// vmm.getCalculatorCatalog().addVisualStyle(defaultVS);
-//
-// // Use nested network feature
-// final CyNode centerNode = Cytoscape.getCyNode(parentName, true);
-// parentNetwork.addNode(centerNode);
-//
-// for (CyNetwork net : target) {
-// vmm.setVisualStyle(defaultVS);
-// final CyNetworkView targetView =
Cytoscape.getNetworkView(net.getIdentifier());
-// targetView.setVisualStyle(defaultVS.getName());
-// targetView.redrawGraph(true, false);
-// CyNode nestedNode = Cytoscape.getCyNode(net.getTitle(),
true);
-// nestedNode.setNestedNetwork(net);
-//
-//
Cytoscape.getNodeAttributes().setAttribute(nestedNode.getIdentifier(),
-// PSI25VisualStyleBuilder.ATTR_PREFIX +
"interactor type", "nested");
-//
-// parentNetwork.addNode(nestedNode);
-// parentNetwork.addEdge(Cytoscape.getCyEdge(nestedNode,
centerNode, "interaction", "query_result", true));
-// }
-// Cytoscape.createNetworkView(parentNetwork);
-//
-// query = null;
-// queryList = null;
-//
-// // Call Advanced Network Merge
-// if (report.isMerge())
-// displayNetworkMerge();
-// }
-//
-// /**
-// * Use reflection to display the AdvancedNetworkMerge app.
-// */
-// private void displayNetworkMerge() {
-// Class<?> advancedNetworkMergeClass;
-// try {
-// advancedNetworkMergeClass =
Class.forName("csapps.network.merge.NetworkMergeApp");
-// } catch (ClassNotFoundException e1) {
-// CyLogger.getLogger().warn("Could not find Advanced
Network Merge App!", e1);
-// e1.printStackTrace();
-// return;
-// }
-//
-// Method actionPerformedMethod;
-// try {
-// actionPerformedMethod =
advancedNetworkMergeClass.getMethod("invokeAction");
-// } catch (SecurityException e2) {
-// e2.printStackTrace();
-// return;
-// } catch (NoSuchMethodException e2) {
-// e2.printStackTrace();
-// return;
-// }
-//
-// try {
-// actionPerformedMethod.invoke(null);
-// } catch (IllegalArgumentException e3) {
-// e3.printStackTrace();
-// return;
-// } catch (IllegalAccessException e3) {
-// e3.printStackTrace();
-// return;
-// } catch (InvocationTargetException e3) {
-// e3.getCause().printStackTrace();
-// return;
-// }
-// }
-//
-// // Build interactor list
-// private List<DbRef> buildInteractorList(String query) {
-// List<DbRef> interactorList = new ArrayList<DbRef>();
-//
-// Pattern pattern2 = Pattern.compile(" +|\n|\t+");
-// String[] interactorNames = pattern2.split(query);
-//
-// for (String name : interactorNames) {
-// System.out.println("==> " + name);
-// final DbRef dbRef = new DbRef();
-// dbRef.setId(name);
-// interactorList.add(dbRef);
-// }
-// return interactorList;
-// }
-//
-//
-// public TaskIterator createTaskIterator() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// public Object getSearchResult() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-//
-// public Set<CyNetwork> getNetworks() {
-// // TODO Auto-generated method stub
-// return null;
-// }
-
-}
Modified:
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICWebServiceClient.java
===================================================================
---
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICWebServiceClient.java
2012-06-04 23:44:21 UTC (rev 29450)
+++
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/PSICQUICWebServiceClient.java
2012-06-05 01:24:12 UTC (rev 29451)
@@ -34,7 +34,7 @@
private static final Logger logger =
LoggerFactory.getLogger(PSICQUICWebServiceClient.class);
// Timeout value for registry manager.
- private static final Long TIMEOUT = 30l;
+ private static final Long TIMEOUT_IN_SECCONDS = 30l;
private PSICQUICRestClient client;
private RegistryManager regManager;
@@ -73,7 +73,7 @@
List<Future<RegistryManager>> futures = null;
try {
- futures = exe.invokeAll(tasks, TIMEOUT,
TimeUnit.SECONDS);
+ futures = exe.invokeAll(tasks, TIMEOUT_IN_SECCONDS,
TimeUnit.SECONDS);
} catch (InterruptedException e) {
logger.error("Initialization interrupted.", e);
return;
@@ -83,22 +83,22 @@
try {
regManager = future.get();
} catch (ExecutionException e) {
- logger.error("Error initialize regManager: ",
e);
- return;
+ throw new IllegalStateException("PSICQUIC Reg
manager could not be initialized.", e);
} catch (CancellationException ce) {
- logger.warn("Initialization operation timeout",
ce);
- return;
- } catch (InterruptedException e) {
- logger.error("Initialization interrupted.", e);
- return;
+ throw new IllegalStateException("Timeout
error.", ce);
+ } catch (InterruptedException ie) {
+ throw new IllegalStateException("PSICQUIC Reg
manager initialization interrupted.", ie);
}
}
+ if(regManager == null)
+ throw new IllegalStateException("PSICQUIC Reg manager
could not be initialized.");
+
client = new PSICQUICRestClient(factory, regManager);
long endTime = System.currentTimeMillis();
double sec = (endTime - startTime) / (1000.0);
- logger.info("RegistryManager initialized in " + sec + " sec.");
+ logger.info("Registry Manager initialized in " + sec + " sec.");
}
public TaskIterator createTaskIterator(Object query) {
Modified:
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/RegistryManager.java
===================================================================
---
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/RegistryManager.java
2012-06-04 23:44:21 UTC (rev 29450)
+++
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/RegistryManager.java
2012-06-05 01:24:12 UTC (rev 29451)
@@ -39,7 +39,9 @@
// Tag definitions
private static final String REST_URL = "restUrl";
private static final String TAG = "tag";
+ private static final String COUNT = "count";
private static final String IS_ACTIVE = "active";
+
private static final String DEF_SERVICE_URL =
"http://www.ebi.ac.uk/Tools/webservices/psicquic/registry/registry";
// Defines action command
@@ -48,48 +50,66 @@
}
private final String serviceURLString;
-
+
private final Map<String, String> activeServiceMap;
private final Map<String, String> inactiveServiceMap;
private final Map<String, String> source2NameMap;
private final SortedSet<String> allServiceNames;
-
+
private final Map<String, Boolean> statusMap;
private final Map<String, String> urlMap;
private final Map<String, List<String>> tagMap;
-
-
+ private final Map<String, Long> countMap;
+
/**
* Constructor to use default registry location.
*/
public RegistryManager() {
- this(null);
+ this(DEF_SERVICE_URL);
}
-
-
+
/**
* Use custom registry location.
*
- * @param regLocaiton URL of the registry
+ * @param regLocaiton
+ * URL of the registry
*/
public RegistryManager(String regLocaiton) {
- if(regLocaiton == null || regLocaiton.trim().length() == 0)
+ if (regLocaiton == null || regLocaiton.trim().length() == 0)
serviceURLString = DEF_SERVICE_URL;
- else
+ else
serviceURLString = regLocaiton;
-
+
activeServiceMap = new HashMap<String, String>();
inactiveServiceMap = new HashMap<String, String>();
source2NameMap = new HashMap<String, String>();
statusMap = new HashMap<String, Boolean>();
urlMap = new HashMap<String, String>();
tagMap = new HashMap<String, List<String>>();
+ countMap = new HashMap<String, Long>();
+
invoke();
-
+
allServiceNames = new
TreeSet<String>(activeServiceMap.keySet());
allServiceNames.addAll(inactiveServiceMap.keySet());
}
+
+ public void refresh() {
+ activeServiceMap.clear();
+ inactiveServiceMap.clear();
+ source2NameMap.clear();
+ statusMap.clear();
+ urlMap.clear();
+ tagMap.clear();
+ countMap.clear();
+ invoke();
+
+ allServiceNames.clear();
+ allServiceNames.addAll(activeServiceMap.keySet());
+ allServiceNames.addAll(inactiveServiceMap.keySet());
+ }
+
public Map<String, String> getActiveServices() {
return activeServiceMap;
}
@@ -97,24 +117,28 @@
public Map<String, String> getInactiveServices() {
return inactiveServiceMap;
}
-
+
public Map<String, List<String>> getTagMap() {
return this.tagMap;
}
-
+
+ public Map<String, Long> getCountMap() {
+ return this.countMap;
+ }
+
public SortedSet<String> getAllServiceNames() {
return this.allServiceNames;
}
-
+
public Map<String, String> getSource2NameMap() {
// Lazy instantiation.
- if(source2NameMap.size() == 0) {
- for(String name: activeServiceMap.keySet())
+ if (source2NameMap.size() == 0) {
+ for (String name : activeServiceMap.keySet())
source2NameMap.put(activeServiceMap.get(name),
name);
- for(String name: inactiveServiceMap.keySet())
+ for (String name : inactiveServiceMap.keySet())
source2NameMap.put(inactiveServiceMap.get(name), name);
}
-
+
return source2NameMap;
}
@@ -126,7 +150,7 @@
logger.error("Could not initialize PSICQUIC registory
manager.");
}
setMap();
-
+
logger.info("Found " + activeServiceMap.size() + " active
PSICQUIC services.");
}
@@ -141,7 +165,7 @@
connection.connect();
BufferedReader reader = new BufferedReader(new
InputStreamReader(connection.getInputStream()));
- StringBuilder builder = new StringBuilder();
+ final StringBuilder builder = new StringBuilder();
String next;
while ((next = reader.readLine()) != null)
@@ -192,50 +216,59 @@
statusMap.put(serviceName,
Boolean.parseBoolean(item.getFirstChild().getNodeValue()));
else if (tag.equals(TAG)) {
List<String> tagList = tagMap.get(serviceName);
- if(tagList == null)
+ if (tagList == null)
tagList = new ArrayList<String>();
tagList.add(item.getFirstChild().getNodeValue());
tagMap.put(serviceName, tagList);
+ } else if (tag.equals(COUNT)) {
+ String entry =
item.getFirstChild().getNodeValue();
+ Long numberOfRecoreds = 0l;
+ try {
+ numberOfRecoreds =
Long.parseLong(entry);
+ } catch (Exception ex) {
+ logger.warn("Could not get count", ex);
+ }
+ countMap.put(serviceName, numberOfRecoreds);
}
-
+
walk(n, serviceName);
}
}
private void setMap() {
- for(final String serviceName : statusMap.keySet()) {
+ for (final String serviceName : statusMap.keySet()) {
if (statusMap.get(serviceName) == true)
activeServiceMap.put(serviceName,
urlMap.get(serviceName));
else
inactiveServiceMap.put(serviceName,
urlMap.get(serviceName));
}
}
-
+
public boolean isActive(final String serviceName) {
- if(serviceName == null)
+ if (serviceName == null)
throw new NullPointerException("Service Name is null.");
-
- if(this.inactiveServiceMap.keySet().contains(serviceName))
+
+ if (this.inactiveServiceMap.keySet().contains(serviceName))
return false;
else
return true;
}
-
+
public String getRestURL(final String serviceName) {
- if(serviceName == null)
+ if (serviceName == null)
throw new NullPointerException("Service Name is null.");
-
- if(allServiceNames.contains(serviceName) == false) {
+
+ if (allServiceNames.contains(serviceName) == false) {
throw new IllegalArgumentException("Could not find the
service in the registry: " + serviceName);
}
-
+
String serviceURLString = activeServiceMap.get(serviceName);
- if(serviceURLString == null)
+ if (serviceURLString == null)
serviceURLString = inactiveServiceMap.get(serviceName);
-
- if(serviceURLString == null)
+
+ if (serviceURLString == null)
throw new IllegalStateException("Could not find REST
service URL for " + serviceName);
-
+
return serviceURLString;
}
}
Modified:
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/ui/PSICQUICSearchUI.java
===================================================================
---
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/ui/PSICQUICSearchUI.java
2012-06-04 23:44:21 UTC (rev 29450)
+++
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/ui/PSICQUICSearchUI.java
2012-06-05 01:24:12 UTC (rev 29451)
@@ -15,11 +15,13 @@
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JComboBox;
+import javax.swing.JEditorPane;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
+import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.ChangeEvent;
@@ -41,7 +43,7 @@
public class PSICQUICSearchUI extends JPanel implements ChangeListener {
private static final long serialVersionUID = 3163269742016489767L;
-
+
private static final String MIQL_REFERENCE_PAGE_URL =
"http://code.google.com/p/psicquic/wiki/MiqlReference";
// Color Scheme
@@ -54,8 +56,11 @@
private static final String MIQL_MODE = "Query Text (MIQL)";
private static final String INTERACTOR_ID_LIST = "List of Interactors
(gene/protein/compound ID)";
- private static final String MIQL_QUERY_AREA_MESSAGE_STRING = "Please
enter search query (MIQL) here. \nIf you need help, please click Syntax Help
button below.";
- private static final String INTERACTOR_LIST_AREA_MESSAGE_STRING =
"Please enter list of genes/proteins/compounds, separated by space.";
+ private static final String MIQL_QUERY_AREA_MESSAGE_STRING = "Please
enter search query (MIQL) here. "
+ + "Currently the result table shows number of all
binary interactions available in the database. "
+ + "\nIf you need help, please click Syntax Help button
below.";
+ private static final String INTERACTOR_LIST_AREA_MESSAGE_STRING =
"Please enter list of genes/proteins/compounds, separated by space. "
+ + "Currently the result table shows number of all
binary interactions available in the database.";
private final RegistryManager regManager;
private final PSICQUICRestClient client;
@@ -63,7 +68,7 @@
private final CyNetworkManager networkManager;
private final CreateNetworkViewTaskFactory createViewTaskFactory;
- private JTextArea queryArea;
+ private JEditorPane queryArea;
private SourceStatusPanel statesPanel;
private JScrollPane scrollPane;
@@ -71,6 +76,7 @@
private JLabel modeLabel;
private JButton helpButton;
private JButton searchButton;
+ private JButton refreshButton;
private JPanel queryBuilderPanel;
@@ -83,9 +89,9 @@
private boolean firstClick = true;
private final OpenBrowser openBrowserUtil;
-
+
public PSICQUICSearchUI(final CyNetworkManager networkManager, final
RegistryManager regManager,
- final PSICQUICRestClient client, final TaskManager<?,?>
tmManager,
+ final PSICQUICRestClient client, final TaskManager<?,
?> tmManager,
final CreateNetworkViewTaskFactory
createViewTaskFactory, final OpenBrowser openBrowserUtil) {
this.regManager = regManager;
this.client = client;
@@ -116,6 +122,15 @@
statesPanel.enableComponents(true);
}
});
+
+ refreshButton = new JButton("Refresh");
+ refreshButton.setPreferredSize(new java.awt.Dimension(70, 28));
+ refreshButton.addActionListener(new
java.awt.event.ActionListener() {
+ public void actionPerformed(java.awt.event.ActionEvent
evt) {
+ refreshButtonActionPerformed();
+ }
+ });
+
modeLabel = new JLabel("Query Type:");
JRadioButton miqlMode = new
JRadioButton(SearchMode.MIQL.toString(), true);
miqlMode.setActionCommand(SearchMode.MIQL.toString());
@@ -138,12 +153,12 @@
searchPanel.add(miqlMode);
searchPanel.add(idListMode);
searchPanel.add(searchButton);
+ searchPanel.add(refreshButton);
// Query Panel
- queryArea = new JTextArea();
+ queryArea = new JEditorPane();
queryArea.setText(MIQL_QUERY_AREA_MESSAGE_STRING);
queryArea.addMouseListener(new MouseAdapter() {
-
@Override
public void mousePressed(MouseEvent ev) {
if (firstClick) {
@@ -153,6 +168,8 @@
}
});
+ queryArea.setPreferredSize(new Dimension(400, 100));
+
this.queryBuilderPanel = new JPanel();
queryBuilderPanel.setBackground(Color.white);
@@ -162,11 +179,11 @@
this.helpButton = new JButton("Syntax Help");
helpButton.setToolTipText("Show MIQL Syntax Reference in Web
Browser...");
helpButton.addActionListener(new ActionListener() {
-
+
@Override
public void actionPerformed(ActionEvent e) {
openBrowserUtil.openURL(MIQL_REFERENCE_PAGE_URL);
-
+
}
});
@@ -195,14 +212,14 @@
scrollPane = new JScrollPane();
scrollPane.setBackground(Color.white);
-
+
final TitledBorder border = new TitledBorder(searchAreaTitle);
border.setTitleColor(MIQL_COLOR);
border.setTitleFont(STRONG_FONT);
scrollPane.setBorder(border);
scrollPane.setBorder(border);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
- scrollPane.setPreferredSize(new Dimension(150, 150));
+ scrollPane.setPreferredSize(new Dimension(500, 150));
scrollPane.setViewportView(queryArea);
this.add(scrollPane, BorderLayout.NORTH);
@@ -211,20 +228,32 @@
createViewTaskFactory);
this.add(statesPanel, BorderLayout.SOUTH);
statesPanel.enableComponents(false);
+
+ queryBuilderPanel.setMaximumSize(new Dimension(950, 60));
}
+ private void refreshButtonActionPerformed() {
+ SwingUtilities.invokeLater(new Runnable() {
+
+ @Override
+ public void run() {
+ regManager.refresh();
+ stateChanged(null);
+ }
+ });
+ }
+
private void addSpeciesQuery() {
-
+
final Object selectedItem = speciesSelector.getSelectedItem();
final Species species = (Species) selectedItem;
String currentQuery = this.queryArea.getText();
- if(currentQuery.contains(MIQL_QUERY_AREA_MESSAGE_STRING)) {
+ if (currentQuery.contains(MIQL_QUERY_AREA_MESSAGE_STRING)) {
currentQuery = "";
queryArea.setText("");
}
-
-
+
final String newQuery;
if (species == Species.ALL) {
newQuery = currentQuery.replaceAll("species:\".+\"",
"");
@@ -267,14 +296,13 @@
statesPanel = new
SourceStatusPanel(queryArea.getText(), client, regManager, networkManager,
result,
taskManager, mode,
createViewTaskFactory);
add(statesPanel, BorderLayout.SOUTH);
-
+
statesPanel.sort();
Window parentWindow = ((Window)
getRootPane().getParent());
parentWindow.pack();
repaint();
-
parentWindow.toFront();
}
}
@@ -305,16 +333,16 @@
border.setTitleColor(borderColor);
border.setTitleFont(STRONG_FONT);
scrollPane.setBorder(border);
-
+
remove(statesPanel);
- statesPanel = new SourceStatusPanel(queryArea.getText(),
client, regManager, networkManager, null,
- taskManager, mode, createViewTaskFactory);
+ statesPanel = new SourceStatusPanel(queryArea.getText(),
client, regManager, networkManager, null, taskManager,
+ mode, createViewTaskFactory);
add(statesPanel, BorderLayout.SOUTH);
Window parentWindow = ((Window) getRootPane().getParent());
parentWindow.pack();
repaint();
-
+
statesPanel.enableComponents(false);
-
+
}
}
Modified:
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/ui/SourceStatusPanel.java
===================================================================
---
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/ui/SourceStatusPanel.java
2012-06-04 23:44:21 UTC (rev 29450)
+++
core3/impl/trunk/webservice-psicquic-client-impl/src/main/java/org/cytoscape/webservice/psicquic/ui/SourceStatusPanel.java
2012-06-05 01:24:12 UTC (rev 29451)
@@ -22,6 +22,7 @@
import javax.swing.RowSorter;
import javax.swing.SortOrder;
import javax.swing.SwingConstants;
+import javax.swing.SwingUtilities;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableModel;
@@ -34,7 +35,6 @@
import org.cytoscape.webservice.psicquic.task.ImportNetworkFromPSICQUICTask;
import org.cytoscape.work.TaskIterator;
import org.cytoscape.work.TaskManager;
-import org.junit.runner.manipulation.Sorter;
public class SourceStatusPanel extends JPanel {
@@ -73,6 +73,11 @@
this.createViewTaskFactory = createViewTaskFactory;
setTableModel(result);
+
+ refreshGUI();
+ }
+
+ private void refreshGUI() {
initComponents();
setCoumnWidth();
@@ -93,6 +98,7 @@
this.selectAllButton.setEnabled(enable);
this.importNetworkButton.setEnabled(enable);
this.clearSelectionButton.setEnabled(enable);
+ this.clusterResultCheckBox.setEnabled(enable);
this.setEnabled(enable);
}
@@ -173,7 +179,7 @@
} else
rowValues[3] = 0;
} else {
- rowValues[3] = 0;
+ rowValues[3] =
manager.getCountMap().get(serviceName).intValue();
}
if (errorID != null) {
Modified:
core3/impl/trunk/webservice-psicquic-client-impl/src/test/java/org/cytoscape/webservice/psicquic/PSICQUICClientTest.java
===================================================================
---
core3/impl/trunk/webservice-psicquic-client-impl/src/test/java/org/cytoscape/webservice/psicquic/PSICQUICClientTest.java
2012-06-04 23:44:21 UTC (rev 29450)
+++
core3/impl/trunk/webservice-psicquic-client-impl/src/test/java/org/cytoscape/webservice/psicquic/PSICQUICClientTest.java
2012-06-05 01:24:12 UTC (rev 29451)
@@ -39,9 +39,4 @@
client = new PSICQUICWebServiceClient(uriString, displayName,
description, cyNetworkFactoryServiceRef,
cyNetworkManagerServiceRef, tm,
createViewTaskFactoryServiceRef, openBrowser);
}
-
- @After
- public void tearDown() throws Exception {
- }
-
}
--
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.