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 { ...@@ -144,6 +144,4 @@ public class GraphAnalyzer {
} }
return false; return false;
} }
} }
\ No newline at end of file
...@@ -25,6 +25,7 @@ import java.util.ArrayList; ...@@ -25,6 +25,7 @@ import java.util.ArrayList;
import org.cytoscape.model.CyNetwork; import org.cytoscape.model.CyNetwork;
import de.hhu.ba.yoshikoWrapper.core.ResultList;
import de.hhu.ba.yoshikoWrapper.swig.SolutionFlags; import de.hhu.ba.yoshikoWrapper.swig.SolutionFlags;
...@@ -39,12 +40,20 @@ public class YoshikoResult{ ...@@ -39,12 +40,20 @@ public class YoshikoResult{
private SolutionFlags flags; private SolutionFlags flags;
private int id;
public YoshikoResult(CyNetwork net, SolutionFlags flags) { public YoshikoResult(CyNetwork net, SolutionFlags flags) {
solutions = new ArrayList<YoshikoSolution>(); solutions = new ArrayList<YoshikoSolution>();
this.originalGraph = net; this.originalGraph = net;
this.flags = flags; this.flags = flags;
ResultList.add(this);
}
public void delete() {
for (YoshikoSolution s: solutions) {
s.delete();
}
ResultList.remove(this.id);
} }
//___________SETTER GETTER_____________// //___________SETTER GETTER_____________//
...@@ -71,11 +80,12 @@ public class YoshikoResult{ ...@@ -71,11 +80,12 @@ public class YoshikoResult{
return originalGraph; return originalGraph;
} }
public void delete() { public void setID(int id) {
for (YoshikoSolution s: solutions) { this.id = id;
s.delete();
}
} }
public int getID() {
return id;
}
} }
...@@ -27,7 +27,7 @@ public final class HelpLinks { ...@@ -27,7 +27,7 @@ public final class HelpLinks {
public static final HashMap<String,Object> mainInfo = new HashMap<String,Object>(); public static final HashMap<String,Object> mainInfo = new HashMap<String,Object>();
static { 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 { ...@@ -120,6 +120,7 @@ public class MainPanel extends JPanel implements CytoPanelComponent {
@Override @Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
CommandExecutor.executeCommand("cybrowser", "show",HelpLinks.mainInfo , null); CommandExecutor.executeCommand("cybrowser", "show",HelpLinks.mainInfo , null);
//TODO: Auto select CyBrowser tab
} }
}); });
......
...@@ -287,11 +287,12 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask { ...@@ -287,11 +287,12 @@ public class AlgorithmTask extends AbstractTask implements ObservableTask {
super.cancel(); super.cancel();
} }
@SuppressWarnings("unchecked")
@Override @Override
public <R> R getResults(Class<? extends R> type) { public <R> R getResults(Class<? extends R> type) {
//TODO: Return Result in some format that is suitable for console applications //We return the id of the result so we can work with the result from CMD
if (type.equals(YoshikoResult.class)) { if (type.equals(String.class)) {
return (R) (result!=null ? result : null); return (R) (""+result.getID());
} }
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