// Disable all proper values
ExecutableFlow executableFlow = holder.getFlow();
traverseFlow(disabledJobs, executableFlow);
PrintWriter writer = resp.getWriter();
JSONUtils jsonUtils = new JSONUtils();
HashMap<String,Object> results = new HashMap<String,Object>();
try {
this.getApplication().getJobExecutorManager().execute(holder);
results.put("id", holder.getFlow().getId());
results.put("success", true);
results.put("message", String.format("Executing Flow[%s].", id));
} catch(Exception e) {
results.put("id", holder.getFlow().getId());
results.put("error", true);
results.put("message", String.format("Error running Flow[%s]. " + e.getMessage(), id));
}
writer.print(jsonUtils.toJSONString(results));
writer.flush();
}
else if (action.equals("run")) {
String name = getParam(req, "name");
String value = req.getParameter("disabled");
String[] disabledValues = value.split(",");
HashSet<String> disabledJobs = new HashSet<String>();
for (String disabled : disabledValues) {
if (!disabled.isEmpty()) {
disabledJobs.add(disabled);
}
}
ExecutableFlow flow = allFlows.createNewExecutableFlow(name);
if (flow == null) {
addError(req, "Job " + name + " not found.");
}
traverseFlow(disabledJobs, flow);
PrintWriter writer = resp.getWriter();
JSONUtils jsonUtils = new JSONUtils();
HashMap<String,Object> results = new HashMap<String,Object>();
try {
this.getApplication().getJobExecutorManager().execute(flow);
results.put("success", true);
results.put("message", String.format("Executing Flow[%s].", name));
results.put("id", flow.getId());
} catch(Exception e) {
results.put("error", true);
results.put("message", String.format("Error running Flow[%s]. " + e.getMessage(), name));
}
writer.print(jsonUtils.toJSONString(results));
writer.flush();
}
}