Author: Srinivasarao
Date: 2009-07-09 11:55:48 -0700 (Thu, 09 Jul 2009)
New Revision: 17290
Removed:
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/IndexAndSearchTaskImpl.java
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/ReindexTaskImpl.java
Modified:
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/EnhancedSearchQueryImpl.java
Log:
Modified:
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/EnhancedSearchQueryImpl.java
===================================================================
---
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/EnhancedSearchQueryImpl.java
2009-07-09 18:48:15 UTC (rev 17289)
+++
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/EnhancedSearchQueryImpl.java
2009-07-09 18:55:48 UTC (rev 17290)
@@ -37,7 +37,7 @@
import java.io.IOException;
import java.util.ArrayList;
-
+import java.util.Iterator;
import org.apache.lucene.analysis.standard.StandardAnalyzer;
import org.apache.lucene.queryParser.ParseException;
import org.apache.lucene.search.HitCollector;
@@ -48,7 +48,9 @@
import org.apache.lucene.document.Document;
import org.cytoscape.search.EnhancedSearchQuery;
+import org.cytoscape.model.CyEdge;
import org.cytoscape.model.CyNetwork;
+import org.cytoscape.model.CyNode;
import org.cytoscape.search.util.EnhancedSearchUtils;
import org.cytoscape.search.util.CustomMultiFieldQueryParser;
import org.cytoscape.search.util.AttributeFields;
@@ -56,7 +58,9 @@
public class EnhancedSearchQueryImpl extends EnhancedSearchQuery {
private IdentifiersCollector hitCollector = null;
-
+ private ArrayList<CyNode> nodelist = null;
+ private ArrayList<CyEdge> edgelist = null;
+
public EnhancedSearchQueryImpl(RAMDirectory index, CyNetwork net) {
super(index,net);
}
@@ -135,7 +139,51 @@
return null;
}
}
-
+ private void parseHits(){
+ ArrayList<String> al = hitCollector.getHits();
+ Iterator<String> it = al.iterator();
+ nodelist = new ArrayList<CyNode>();
+ edgelist = new ArrayList<CyEdge>();
+ while(it.hasNext()){
+ String currid = (String) it.next();
+ CyNode currNode = network.getNode((new
Integer(currid)).intValue());
+ if(currNode!=null){
+ nodelist.add(currNode);
+ }
+ else{
+ CyEdge currEdge = network.getEdge((new
Integer(currid)).intValue());
+ if (currEdge != null) {
+ edgelist.add(currEdge);
+ } else{
+ System.out.println("Unknown Identifier
"+ currid);
+ }
+ }
+ }
+ }
+ public ArrayList<CyNode> getNodeHits(){
+ if(hitCollector!=null)
+ {
+ if(nodelist==null)
+ {
+ parseHits();
+ }
+ return nodelist;
+ }
+ else{
+ return null;
+ }
+ }
+ public ArrayList<CyEdge> getEdgeHits(){
+ if(hitCollector!=null)
+ {
+ if(edgelist==null)
+ parseHits();
+ return edgelist;
+ }
+ else{
+ return null;
+ }
+ }
}
Deleted:
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/IndexAndSearchTaskImpl.java
===================================================================
---
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/IndexAndSearchTaskImpl.java
2009-07-09 18:48:15 UTC (rev 17289)
+++
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/IndexAndSearchTaskImpl.java
2009-07-09 18:55:48 UTC (rev 17290)
@@ -1,181 +0,0 @@
-/*
- Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.cytoscape.search.internal;
-
-import java.util.ArrayList;
-import java.util.List;
-import java.util.Iterator;
-
-import org.apache.lucene.store.RAMDirectory;
-//import org.apache.lucene.search.*;
-
-import org.cytoscape.search.*;
-import org.cytoscape.model.CyEdge;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.model.CyNode;
-//import cytoscape.Cytoscape;
-import org.cytoscape.work.TaskMonitor;
-
-public class IndexAndSearchTaskImpl extends IndexAndSearchTask {
-
-
- /**
- * Constructor.
- *
- * @param network
- * Network to execute query on.
- * @param query
- * Query string.
- */
- public IndexAndSearchTaskImpl(CyNetwork network, String query) {
- super(network,query);
- }
-
- /**
- * Executes Task: IndexAndSearch
- */
- public void run(TaskMonitor tm) {
- this.taskMonitor = tm;
-
- EnhancedSearchFactoryImpl esf = new EnhancedSearchFactoryImpl();
- final EnhancedSearch enhancedSearch =
esf.getGlobalEnhancedSearchInstance();
-
- // Index the given network or use existing index
- RAMDirectory idx = null;
-
- String status = enhancedSearch.getNetworkIndexStatus(network);
- if (status == EnhancedSearch.INDEX_SET) {
- idx = enhancedSearch.getNetworkIndex(network);
- } else {
- taskMonitor.setStatusMessage("Indexing network");
- EnhancedSearchIndex indexHandler = new
EnhancedSearchIndexImpl(network);
- idx = indexHandler.getIndex();
- enhancedSearch.setNetworkIndex(network, idx);
-
- if (interrupted) {
- return;
- }
- }
-
-
- // Execute query
- taskMonitor.setStatusMessage("Executing query");
- EnhancedSearchQuery queryHandler = new
EnhancedSearchQueryImpl(idx,network);
- queryHandler.executeQuery(query);
-
- if (interrupted) {
- return;
- }
-/*
- // Display results
- Cytoscape.getCurrentNetwork().unselectAllNodes();
- Cytoscape.getCurrentNetwork().unselectAllEdges();
- Cytoscape.getCurrentNetworkView().updateView();
-*/
- int hitCount = queryHandler.getHitCount();
- if (hitCount == 0) {
- System.out.println("No hits. ");
- return;
- }
- System.out.println("There are " + hitCount + " hits.");
- taskMonitor.setStatusMessage("Displaying " + hitCount + "
hits");
- ArrayList<String> hits = queryHandler.getHits();
-
- List<CyNode> nodeList = new ArrayList<CyNode>();
- List<CyEdge> edgeList = new ArrayList<CyEdge>();
-
- Iterator<String> it = hits.iterator();
- int numCompleted = 0;
- while (it.hasNext() && !interrupted) {
- String currID = (String) it.next();
- CyNode currNode = network.getNode((new
Integer(currID)).intValue());
- if (currNode != null) {
- nodeList.add(currNode);
- } else {
- CyEdge currEdge = network.getEdge((new
Integer(currID)).intValue());
- if (currEdge != null) {
- edgeList.add(currEdge);
- } else {
- System.out.println("Unknown identifier
" + (currID));
- }
- }
-
- int percentCompleted = (numCompleted * 100 / hitCount);
- taskMonitor.setProgress(percentCompleted);
-
- numCompleted++;
- }
-/*
- // Refresh view to show selected nodes and edges
- network.setSelectedNodeState(nodeList, true);
- network.setSelectedEdgeState(edgeList, true);
- Cytoscape.getCurrentNetworkView().updateView();
-*/
- }
-
- /**
- * DOCUMENT ME!
- */
- public void halt() {
- this.interrupted = true;
- }
-
- public void cancel() {
- this.interrupted = true;
- }
- /**
- * Sets the TaskMonitor.
- *
- * @param taskMonitor
- * TaskMonitor Object.
- * @throws IllegalThreadStateException
- * Illegal Thread State.
- */
- public void setTaskMonitor(TaskMonitor taskMonitor)
- throws IllegalThreadStateException {
- this.taskMonitor = taskMonitor;
- }
-
- /**
- * Gets Title of Task.
- *
- * @return Title of Task.
- */
- public String getTitle() {
- return "Searching the network";
- }
-
-}
\ No newline at end of file
Deleted:
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/ReindexTaskImpl.java
===================================================================
---
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/ReindexTaskImpl.java
2009-07-09 18:48:15 UTC (rev 17289)
+++
csplugins/trunk/soc/srinivasarao/search-impl/src/main/java/org/cytoscape/search/internal/ReindexTaskImpl.java
2009-07-09 18:55:48 UTC (rev 17290)
@@ -1,126 +0,0 @@
-/*
- Copyright (c) 2006, 2007, The Cytoscape Consortium (www.cytoscape.org)
-
- The Cytoscape Consortium is:
- - Institute for Systems Biology
- - University of California San Diego
- - Memorial Sloan-Kettering Cancer Center
- - Institut Pasteur
- - Agilent Technologies
-
- This library is free software; you can redistribute it and/or modify it
- under the terms of the GNU Lesser General Public License as published
- by the Free Software Foundation; either version 2.1 of the License, or
- any later version.
-
- This library is distributed in the hope that it will be useful, but
- WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
- MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. The software and
- documentation provided hereunder is on an "as is" basis, and the
- Institute for Systems Biology and the Whitehead Institute
- have no obligations to provide maintenance, support,
- updates, enhancements or modifications. In no event shall the
- Institute for Systems Biology and the Whitehead Institute
- be liable to any party for direct, indirect, special,
- incidental or consequential damages, including lost profits, arising
- out of the use of this software and its documentation, even if the
- Institute for Systems Biology and the Whitehead Institute
- have been advised of the possibility of such damage. See
- the GNU Lesser General Public License for more details.
-
- You should have received a copy of the GNU Lesser General Public License
- along with this library; if not, write to the Free Software Foundation,
- Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA.
- */
-
-package org.cytoscape.search.internal;
-
-import org.apache.lucene.store.RAMDirectory;
-import org.cytoscape.search.*;
-import org.cytoscape.model.CyNetwork;
-import org.cytoscape.work.Task;
-import org.cytoscape.work.TaskMonitor;
-import org.cytoscape.search.ReindexTask;
-
-public class ReindexTaskImpl extends ReindexTask implements Task {
-
- //private CyNetwork network;
-
- //private TaskMonitor taskMonitor;
-
- //private boolean interrupted = false;
-
- /**
- * Constructor.
- *
- * @param network
- * Network to execute query on.
- */
- public ReindexTaskImpl(CyNetwork network) {
- super(network);
- }
-
- /**
- * Executes Task: Reindex
- */
- public void run(TaskMonitor tm) {
-
- this.taskMonitor = tm;
- EnhancedSearchFactoryImpl esf = new EnhancedSearchFactoryImpl();
- final EnhancedSearch enhancedSearch =
esf.getGlobalEnhancedSearchInstance();
-
- // Index the given network or use existing index
- RAMDirectory idx = null;
-
- taskMonitor.setStatusMessage("Re-indexing network");
- EnhancedSearchIndex indexHandler = new
EnhancedSearchIndexImpl(network);
- idx = indexHandler.getIndex();
- enhancedSearch.setNetworkIndex(network, idx);
-
- if (interrupted) {
- return;
- }
-
- taskMonitor.setProgress(100);
- taskMonitor.setStatusMessage("Network re-indexed successfuly");
-
- }
-
- /**
- * DOCUMENT ME!
- */
-
- public void halt() {
- this.interrupted = true;
- }
-
- /**
- * DOCUMENT ME!
- */
-
- public void cancel() {
- this.interrupted = true;
- }
- /**
- * Sets the TaskMonitor.
- *
- * @param taskMonitor
- * TaskMonitor Object.
- * @throws IllegalThreadStateException
- * Illegal Thread State.
- */
- public void setTaskMonitor(TaskMonitor taskMonitor)
- throws IllegalThreadStateException {
- this.taskMonitor = taskMonitor;
- }
-
- /**
- * Gets Title of Task.
- *
- * @return Title of Task.
- */
- public String getTitle() {
- return "Re-indexing network";
- }
-
-}
\ 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
-~----------~----~----~----~------~----~------~--~---