Skip to content
Snippets Groups Projects
Commit e3b3246b authored by Jan Kožusznik's avatar Jan Kožusznik
Browse files

fix: add unknown state, allow Start Canceled

parent ad496cff
No related branches found
No related tags found
No related merge requests found
......@@ -7,20 +7,23 @@ import java.util.Map;
import cz.it4i.fiji.haas_java_client.JobState;
public class JobStateComparator implements Comparator<JobState>{
public class JobStateComparator implements Comparator<JobState> {
private static Map<JobState,Integer> priorities = new HashMap<>();
private static void add(JobState state) {
private static Map<JobState, Integer> priorities = new HashMap<>();
private static void add(JobState state) {
priorities.put(state, priorities.size());
}
static {
Arrays.asList(JobState.Finished,JobState.Queued, JobState.Running, JobState.Canceled, JobState.Failed).forEach(state->add(state));
Arrays.asList(JobState.Finished, JobState.Queued, JobState.Running, JobState.Canceled, JobState.Failed, JobState.Unknown)
.forEach(state -> add(state));
}
@Override
public int compare(JobState o1, JobState o2) {
if(!priorities.keySet().containsAll(Arrays.asList(o1, o2))) {
throw new IllegalArgumentException();
if (!priorities.keySet().containsAll(Arrays.asList(o1, o2))) {
throw new IllegalArgumentException("compare: " + o1 + ", " + o2);
}
return priorities.get(o1) - priorities.get(o2);
}
......
......@@ -107,7 +107,7 @@ public class BenchmarkSPIMController extends BorderPane implements CloseableCont
job.getValue().startJob(p);
job.getValue().update();
}), job -> JavaFXRoutines.notNullValue(job, j -> j.getState() == JobState.Configuring
|| j.getState() == JobState.Finished || j.getState() == JobState.Failed));
|| j.getState() == JobState.Finished || j.getState() == JobState.Failed || j.getState() == JobState.Canceled));
menu.addItem("Cancel job", job -> executeWSCallAsync("Canceling job", p -> {
job.getValue().cancelJob();
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment