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

Identifying results with unique ID

Returning result ID via CyRest
parent 691ebc9c
No related branches found
No related tags found
No related merge requests found
package de.hhu.ba.yoshikoWrapper.core;
import java.util.HashMap;
import de.hhu.ba.yoshikoWrapper.graphModel.YoshikoResult;
public class ResultList {
private static HashMap<Integer,YoshikoResult> map = new HashMap<Integer,YoshikoResult>();
public static void add(YoshikoResult yoshikoResult) {
int i = 0;
while (true) {
if (!map.containsKey(i)) {
map.put(i, yoshikoResult);
yoshikoResult.setID(i);
return;
}
i++;
}
}
public static void remove(int resultID) {
map.remove(resultID);
}
}
......@@ -144,6 +144,4 @@ public class GraphAnalyzer {
}
return false;
}
}
\ No newline at end of file
......@@ -25,6 +25,7 @@ import java.util.ArrayList;
import org.cytoscape.model.CyNetwork;
import de.hhu.ba.yoshikoWrapper.core.ResultList;
import de.hhu.ba.yoshikoWrapper.swig.SolutionFlags;
......@@ -39,12 +40,20 @@ public class YoshikoResult{
private SolutionFlags flags;
private int id;
public YoshikoResult(CyNetwork net, SolutionFlags flags) {
solutions = new ArrayList<YoshikoSolution>();
this.originalGraph = net;
this.flags = flags;
ResultList.add(this);
}
public void delete() {
for (YoshikoSolution s: solutions) {
s.delete();
}
ResultList.remove(this.id);
}
//___________SETTER GETTER_____________//
......@@ -71,11 +80,12 @@ public class YoshikoResult{
return originalGraph;
}
public void delete() {
for (YoshikoSolution s: solutions) {
s.delete();
}
public void setID(int id) {
this.id = id;
}
public int getID() {
return id;
}
}
......@@ -27,7 +27,7 @@ public final class HelpLinks {
public static final HashMap<String,Object> mainInfo = new HashMap<String,Object>();
static {
mainInfo.put("url", "https://spqrph.github.io/cytoscape-tutorials/presentations/yoshiko/yoshiko.html#/title");
mainInfo.put("url", "https://spqrph.github.io/cytoscape-tutorials/presentations/yoshiko.html#/title");
}
}
......@@ -120,6 +120,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
@Override
public void actionPerformed(ActionEvent e) {
CommandExecutor.executeCommand("cybrowser", "show",HelpLinks.mainInfo , null);
//TODO: Auto select CyBrowser tab
}
});
......
......@@ -287,11 +287,12 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
super.cancel();
}
@SuppressWarnings("unchecked")
@Override
public <R> R getResults(Class<? extends R> type) {
//TODO: Return Result in some format that is suitable for console applications
if (type.equals(YoshikoResult.class)) {
return (R) (result!=null ? result : null);
//We return the id of the result so we can work with the result from CMD
if (type.equals(String.class)) {
return (R) (""+result.getID());
}
return null;
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment