reimplement run.eachParagraph to run.all method

This commit is contained in:
CloverHearts 2016-08-17 15:58:07 +09:00
parent 1428795f80
commit a672cf38d1
2 changed files with 19 additions and 21 deletions

View file

@ -479,21 +479,12 @@ public class NotebookRestApi {
return new JsonResponse<>(Status.NOT_FOUND, "note not found.").build();
}
for (Paragraph paragraph : note.getParagraphs()) {
note.setLastReplName(paragraph.getId());
try {
note.run(paragraph.getId());
} catch (Exception ex) {
LOG.error("Exception from run", ex);
if (paragraph != null) {
paragraph.setReturn(
new InterpreterResult(InterpreterResult.Code.ERROR, ex.getMessage()),
ex);
paragraph.setStatus(Job.Status.ERROR);
}
return new JsonResponse<>(Status.PRECONDITION_FAILED,
paragraph.getJobName() + " Not selected or Invalid Interpreter bind").build();
}
try {
note.runAll();
} catch (Exception ex) {
LOG.error("Exception from run", ex);
return new JsonResponse<>(Status.PRECONDITION_FAILED,
ex.getMessage() + "- Not selected or Invalid Interpreter bind").build();
}
return new JsonResponse<>(Status.OK).build();

View file

@ -445,11 +445,11 @@ public class Note implements Serializable, ParagraphJobListener {
AuthenticationInfo authenticationInfo = new AuthenticationInfo();
authenticationInfo.setUser(cronExecutingUser);
p.setAuthenticationInfo(authenticationInfo);
p.setListener(jobListenerFactory.getParagraphJobListener(this));
Interpreter intp = factory.getInterpreter(getId(), p.getRequiredReplName());
intp.getScheduler().submit(p);
try {
run(p.getId());
} catch (InterpreterException intpException) {
throw intpException;
}
}
}
}
@ -472,7 +472,14 @@ public class Note implements Serializable, ParagraphJobListener {
logger.debug("New paragraph: {}", pText);
p.setEffectiveText(pText);
} else {
throw new InterpreterException("Interpreter " + requiredReplName + " not found");
InterpreterException intpException;
intpException = new InterpreterException(
"Pargaraph " + p.getJobName() + "'s Interpreter " + requiredReplName + " not found");
p.setReturn(
new InterpreterResult(InterpreterResult.Code.ERROR, intpException.getMessage()),
intpException);
p.setStatus(Job.Status.ERROR);
throw intpException;
}
}
if (p.getConfig().get("enabled") == null || (Boolean) p.getConfig().get("enabled")) {