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