use of org.apache.zeppelin.notebook.Paragraph in project zeppelin by apache.
the class NotebookServer method updateParagraph.
private void updateParagraph(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
String paragraphId = (String) fromMessage.get("id");
if (paragraphId == null) {
return;
}
Map<String, Object> params = (Map<String, Object>) fromMessage.get("params");
Map<String, Object> config = (Map<String, Object>) fromMessage.get("config");
String noteId = getOpenNoteId(conn);
if (!hasParagraphWriterPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "write")) {
return;
}
final Note note = notebook.getNote(noteId);
Paragraph p = note.getParagraph(paragraphId);
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()) {
Map<String, Paragraph> userParagraphMap = note.getParagraph(paragraphId).getUserParagraphMap();
broadcastParagraphs(userParagraphMap, p);
} else {
broadcastParagraph(note, p);
}
}
use of org.apache.zeppelin.notebook.Paragraph in project zeppelin by apache.
the class NotebookServer method setParagraphUsingMessage.
private Paragraph setParagraphUsingMessage(Note note, Message fromMessage, String paragraphId, String text, String title, Map<String, Object> params, Map<String, Object> config) {
Paragraph p = note.getParagraph(paragraphId);
p.setText(text);
p.setTitle(title);
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal, fromMessage.ticket);
p.setAuthenticationInfo(subject);
p.settings.setParams(params);
p.setConfig(config);
if (note.isPersonalizedMode()) {
p = note.getParagraph(paragraphId);
p.setText(text);
p.setTitle(title);
p.setAuthenticationInfo(subject);
p.settings.setParams(params);
p.setConfig(config);
}
return p;
}
use of org.apache.zeppelin.notebook.Paragraph in project zeppelin by apache.
the class NotebookServer method clearParagraphOutput.
private void clearParagraphOutput(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook, Message fromMessage) throws IOException {
final String paragraphId = (String) fromMessage.get("id");
if (paragraphId == null) {
return;
}
String noteId = getOpenNoteId(conn);
if (!hasParagraphWriterPermission(conn, notebook, noteId, userAndRoles, fromMessage.principal, "write")) {
return;
}
final Note note = notebook.getNote(noteId);
note.clearParagraphOutput(paragraphId);
Paragraph paragraph = note.getParagraph(paragraphId);
broadcastParagraph(note, paragraph);
}
use of org.apache.zeppelin.notebook.Paragraph in project zeppelin by apache.
the class NotebookServer method onOutputClear.
/**
* This callback is for the paragraph that runs on ZeppelinServer
*/
@Override
public void onOutputClear(String noteId, String paragraphId) {
Notebook notebook = notebook();
final Note note = notebook.getNote(noteId);
note.clearParagraphOutput(paragraphId);
Paragraph paragraph = note.getParagraph(paragraphId);
broadcastParagraph(note, paragraph);
}
use of org.apache.zeppelin.notebook.Paragraph in project zeppelin by apache.
the class NotebookServer method clearParagraphRuntimeInfo.
public void clearParagraphRuntimeInfo(InterpreterSetting setting) {
Map<String, Set<String>> noteIdAndParaMap = setting.getNoteIdAndParaMap();
if (noteIdAndParaMap != null && !noteIdAndParaMap.isEmpty()) {
for (String noteId : noteIdAndParaMap.keySet()) {
Set<String> paraIdSet = noteIdAndParaMap.get(noteId);
if (paraIdSet != null && !paraIdSet.isEmpty()) {
for (String paraId : paraIdSet) {
Note note = notebook().getNote(noteId);
if (note != null) {
Paragraph paragraph = note.getParagraph(paraId);
if (paragraph != null) {
paragraph.clearRuntimeInfo(setting.getId());
broadcast(noteId, new Message(OP.PARAGRAPH).put("paragraph", paragraph));
}
}
}
}
}
}
setting.clearNoteIdAndParaMap();
}
Aggregations