Skip to content
Snippets Groups Projects
Commit 8b49e01e authored by Philipp Spohr's avatar Philipp Spohr
Browse files

Support for retrieving clusters via CyRest

parent 5e35c3c0
No related branches found
No related tags found
No related merge requests found
......@@ -127,6 +127,13 @@ public class CyActivator extends AbstractCyActivator {
props_GET_SOLUTIONS.setProperty(COMMAND_DESCRIPTION,"Retrieve solutions associated with a result");
registerService(context, commandTaskFactory_GET_SOLUTIONS, TaskFactory.class, props_GET_SOLUTIONS);
TaskFactory commandTaskFactory_GET_CLUSTERS = new CommandTaskFactory(YoshikoCommand.GET_CLUSTERS);
Properties props_GET_CLUSTERS = new Properties();
props_GET_CLUSTERS.setProperty(COMMAND_NAMESPACE, "yoshiko");
props_GET_CLUSTERS.setProperty(COMMAND, YoshikoCommand.GET_CLUSTERS.toString());
props_GET_CLUSTERS.setProperty(COMMAND_DESCRIPTION,"Retrieve clusters associated with a solution");
registerService(context, commandTaskFactory_GET_CLUSTERS, TaskFactory.class, props_GET_CLUSTERS);
//Initialize and register main panel
MainPanel mainPanel = new MainPanel();
registerService(context,mainPanel,CytoPanelComponent.class, new Properties());
......
......@@ -88,4 +88,8 @@ public class YoshikoResult{
return id;
}
public YoshikoSolution getSolution(long solutionID) {
return solutions.get(solutionID);
}
}
......@@ -22,7 +22,6 @@
package de.hhu.ba.yoshikoWrapper.graphModel;
import java.util.Collection;
import java.util.Comparator;
import java.util.HashMap;
import java.util.List;
......
......@@ -4,9 +4,7 @@ import org.cytoscape.work.TaskFactory;
import org.cytoscape.work.TaskIterator;
import de.hhu.ba.yoshikoWrapper.core.ParameterSet;
import de.hhu.ba.yoshikoWrapper.tasks.AlgorithmTask;
import de.hhu.ba.yoshikoWrapper.tasks.CreateClusterViewsTask;
import de.hhu.ba.yoshikoWrapper.tasks.GetSolutionsTask;
import de.hhu.ba.yoshikoWrapper.tasks.*;
public class CommandTaskFactory implements TaskFactory{
......@@ -39,7 +37,11 @@ public class CommandTaskFactory implements TaskFactory{
new GetSolutionsTask()
);
}
else if (command == YoshikoCommand.GET_CLUSTERS) {
return new TaskIterator(
new GetClustersTask()
);
}
else if (command == YoshikoCommand.PERFORM_ALGORITHM) {
return new TaskIterator(
new AlgorithmTask(
......
......@@ -12,7 +12,8 @@ public enum YoshikoCommand {
CREATE_CLUSTER_VIEW,
CREATE_META_GRAPH,
PERFORM_ALGORITHM,
GET_SOLUTIONS;
GET_SOLUTIONS,
GET_CLUSTERS;
@Override
public String toString() {
......@@ -22,6 +23,9 @@ public enum YoshikoCommand {
else if (this==CREATE_CLUSTER_VIEW) {
return "createcvs";
}
else if (this==GET_CLUSTERS) {
return "clusters"; //TODO: maybe smarter names for the commands
}
else if (this==GET_SOLUTIONS) {
return "solutions";
}
......
package de.hhu.ba.yoshikoWrapper.tasks;
import java.util.ArrayList;
import java.util.Collection;
import org.cytoscape.work.ObservableTask;
import org.cytoscape.work.TaskMonitor;
......@@ -17,9 +17,9 @@ public class GetClustersTask implements ObservableTask {
public int resultID = -1;
@Tunable(description="The solution ID for which the solutions should be displayed", context="nogui")
public int solutionID = -1;
public long solutionID = -1;
private ArrayList<YoshikoCluster> clusters;
private Collection<YoshikoCluster> clusters;
@Override
public void run(TaskMonitor taskMonitor) throws Exception {
......@@ -27,11 +27,14 @@ public class GetClustersTask implements ObservableTask {
if (result == null) {
throw new Exception("No result with ID: "+resultID+" was found!"); //TODO: Localization
}
if (result.getSolution(solutionID)== null) {
throw new Exception("No solution with ID: "+solutionID+" was found!"); //TODO: Localization
}
clusters = result.getSolution(solutionID).getClusters();
}
@Override
public void cancel() {
// TODO Auto-generated method stub
}
......@@ -40,7 +43,9 @@ public class GetClustersTask implements ObservableTask {
public <R> R getResults(Class<? extends R> type) {
if (type.equals(String.class)) {
String ret = "";
for (YoshikoCluster c: clusters) {
ret+="Cluster[ID="+c.getID()+"]: "+c.getSize()+" nodes\n";
}
return (R) ret;
}
return null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment