if (hasParam(req, "action")) {
if ("restart".equals(getParam(req, "action")) && hasParam(req, "id")) {
try {
long id = Long.parseLong(getParam(req, "id"));
final FlowExecutionHolder holder = allFlows.loadExecutableFlow(id);
if (holder == null) {
addMessage(req, String.format("Unknown flow with id[%s]", id));
}
else {
Flows.resetFailedFlows(holder.getFlow());
this.getApplication().getJobExecutorManager().execute(holder);
addMessage(req, String.format("Flow[%s] restarted.", id));
}
}
catch (NumberFormatException e) {
addMessage(req, String.format("Apparently [%s] is not a valid long.", getParam(req, "id")));
}
catch (JobExecutionException e) {
addMessage(req, "Error restarting " + getParam(req, "id") + ". " + e.getMessage());
}
}
}
long currMaxId = allFlows.getCurrMaxId();
String beginParam = req.getParameter("begin");
int begin = beginParam == null? 0 : Integer.parseInt(beginParam);
String sizeParam = req.getParameter("size");
int size = sizeParam == null? 20 : Integer.parseInt(sizeParam);
List<ExecutableFlow> execs = new ArrayList<ExecutableFlow>(size);
for (int i = begin; i < begin + size; i++) {
final FlowExecutionHolder holder = allFlows.loadExecutableFlow(currMaxId - i);
ExecutableFlow flow = null;
if (holder != null)
flow = holder.getFlow();
if (flow != null)
execs.add(flow);
}