Fixed that output and text became reverted into previous status

Updated status after running paragraph
This commit is contained in:
Jongyoul Lee 2017-03-02 00:43:57 +09:00
parent 47c978f546
commit 2d0d7ca454
2 changed files with 27 additions and 13 deletions

View file

@ -1184,15 +1184,21 @@ public class NotebookServer extends WebSocketServlet
final Note note = notebook.getNote(noteId);
Paragraph p = note.getParagraph(paragraphId);
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
if (note.isPersonalizedMode()) {
p = p.getUserParagraphMap().get(subject.getUser());
}
p.settings.setParams(params);
p.setConfig(config);
p.setTitle((String) fromMessage.get("title"));
p.setText((String) fromMessage.get("paragraph"));
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
if (note.isPersonalizedMode()) {
p = p.getUserParagraph(subject.getUser());
p.settings.setParams(params);
p.setConfig(config);
p.setTitle((String) fromMessage.get("title"));
p.setText((String) fromMessage.get("paragraph"));
}
note.persist(subject);
if (note.isPersonalizedMode()) {
@ -2146,7 +2152,9 @@ public class NotebookServer extends WebSocketServlet
}
}
if (job instanceof Paragraph) {
notebookServer.broadcastParagraph(note, (Paragraph) job);
Paragraph p = (Paragraph) job;
p.setStatusToUserParagraph(job.getStatus());
notebookServer.broadcastParagraph(note, p);
}
try {
notebookServer.broadcastUpdateNoteJobInfo(System.currentTimeMillis() - 5000);

View file

@ -49,6 +49,7 @@ import com.google.common.annotations.VisibleForTesting;
* Paragraph is a representation of an execution unit.
*/
public class Paragraph extends Job implements Serializable, Cloneable {
private static final long serialVersionUID = -6328572073497992016L;
private static Logger logger = LoggerFactory.getLogger(Paragraph.class);
@ -378,6 +379,10 @@ public class Paragraph extends Job implements Serializable, Cloneable {
}
}
for (Paragraph p : userParagraphMap.values()) {
p.setText(getText());
}
String script = getScriptBody();
// inject form
if (repl.getFormType() == FormType.NATIVE) {
@ -409,10 +414,6 @@ public class Paragraph extends Job implements Serializable, Cloneable {
List<InterpreterResultMessage> resultMessages = context.out.toInterpreterResultMessage();
resultMessages.addAll(ret.message());
for (Paragraph p : userParagraphMap.values()) {
p.setText(getText());
}
InterpreterResult res = new InterpreterResult(ret.code(), resultMessages);
Paragraph p = getUserParagraph(getUser());
@ -534,12 +535,12 @@ public class Paragraph extends Job implements Serializable, Cloneable {
Credentials credentials = note.getCredentials();
if (authenticationInfo != null) {
UserCredentials userCredentials =
credentials.getUserCredentials(authenticationInfo.getUser());
credentials.getUserCredentials(authenticationInfo.getUser());
authenticationInfo.setUserCredentials(userCredentials);
}
InterpreterContext interpreterContext =
new InterpreterContext(note.getId(), getId(), getRequiredReplName(), this.getTitle(),
new InterpreterContext(note.getId(), getId(), getRequiredReplName(), this.getTitle(),
this.getText(), this.getAuthenticationInfo(), this.getConfig(), this.settings, registry,
resourcePool, runners, output);
return interpreterContext;
@ -582,7 +583,12 @@ public class Paragraph extends Job implements Serializable, Cloneable {
return new ParagraphRunner(note, note.getId(), getId());
}
public void setStatusToUserParagraph(Status status) {
getUserParagraph(getUser()).setStatus(status);
}
static class ParagraphRunner extends InterpreterContextRunner {
private transient Note note;
public ParagraphRunner(Note note, String noteId, String paragraphId) {
@ -707,7 +713,7 @@ public class Paragraph extends Job implements Serializable, Cloneable {
for (String key : infos.keySet()) {
ParagraphRuntimeInfo info = this.runtimeInfos.get(key);
if (info == null) {
info = new ParagraphRuntimeInfo(key, label, tooltip, group, intpSettingId);
info = new ParagraphRuntimeInfo(key, label, tooltip, group, intpSettingId);
this.runtimeInfos.put(key, info);
}
info.addValue(infos.get(key));