use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method completion.
private void completion(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
String noteId = connectionManager.getAssociatedNoteId(conn);
String paragraphId = (String) fromMessage.get("id");
String buffer = (String) fromMessage.get("buf");
int cursor = (int) Double.parseDouble(fromMessage.get("cursor").toString());
getNotebookService().completion(noteId, paragraphId, buffer, cursor, context, new WebSocketServiceCallback<List<InterpreterCompletion>>(conn) {
@Override
public void onSuccess(List<InterpreterCompletion> completions, ServiceContext context) throws IOException {
super.onSuccess(completions, context);
Message resp = new Message(OP.COMPLETION_LIST).put("id", paragraphId);
resp.put("completions", completions);
conn.send(serializeMessage(resp));
}
@Override
public void onFailure(Exception ex, ServiceContext context) throws IOException {
super.onFailure(ex, context);
Message resp = new Message(OP.COMPLETION_LIST).put("id", paragraphId);
resp.put("completions", new ArrayList<>());
conn.send(serializeMessage(resp));
}
});
}
use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method getEditorSetting.
private void getEditorSetting(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
String paragraphId = (String) fromMessage.get("paragraphId");
String paragraphText = (String) fromMessage.get("paragraphText");
String noteId = connectionManager.getAssociatedNoteId(conn);
getNotebookService().getEditorSetting(noteId, paragraphText, context, new WebSocketServiceCallback<Map<String, Object>>(conn) {
@Override
public void onSuccess(Map<String, Object> settings, ServiceContext context) throws IOException {
super.onSuccess(settings, context);
Message resp = new Message(OP.EDITOR_SETTING);
resp.put("paragraphId", paragraphId);
resp.put("editor", settings);
conn.send(serializeMessage(resp));
}
@Override
public void onFailure(Exception ex, ServiceContext context) {
LOG.warn(ex.getMessage());
}
});
}
use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method onParagraphRemove.
@Override
public void onParagraphRemove(Paragraph p) {
try {
ServiceContext context = new ServiceContext(new AuthenticationInfo(), authorizationService.getOwners(p.getNote().getId()));
getJobManagerService().getNoteJobInfoByUnixTime(System.currentTimeMillis() - 5000, context, new JobManagerServiceCallback());
} catch (IOException e) {
LOG.warn("can not broadcast for job manager: {}", e.getMessage(), e);
}
}
use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method getNoteByRevisionForCompare.
private void getNoteByRevisionForCompare(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.get("noteId");
String revisionId = (String) fromMessage.get("revisionId");
String position = (String) fromMessage.get("position");
getNotebookService().getNoteByRevisionForCompare(noteId, revisionId, context, new WebSocketServiceCallback<Note>(conn) {
@Override
public void onSuccess(Note note, ServiceContext context) throws IOException {
super.onSuccess(note, context);
conn.send(serializeMessage(new Message(OP.NOTE_REVISION_FOR_COMPARE).put("noteId", noteId).put("revisionId", revisionId).put("position", position).put("note", note)));
}
});
}
use of org.apache.zeppelin.service.ServiceContext in project zeppelin by apache.
the class NotebookServer method removeParagraph.
private void removeParagraph(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
final String paragraphId = (String) fromMessage.get("id");
String noteId = connectionManager.getAssociatedNoteId(conn);
getNotebookService().removeParagraph(noteId, paragraphId, context, new WebSocketServiceCallback<Paragraph>(conn) {
@Override
public void onSuccess(Paragraph p, ServiceContext context) throws IOException {
super.onSuccess(p, context);
connectionManager.broadcast(p.getNote().getId(), new Message(OP.PARAGRAPH_REMOVED).put("id", p.getId()));
}
});
}
Aggregations