use of org.apache.zeppelin.types.InterpreterSettingsList in project zeppelin by apache.
the class NotebookServer method saveInterpreterBindings.
public void saveInterpreterBindings(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
List<InterpreterSettingsList> settingList = new ArrayList<>();
String noteId = (String) fromMessage.data.get("noteId");
// use write lock, because defaultInterpreterGroup is overwritten
getNotebook().processNote(noteId, note -> {
if (note != null) {
List<String> settingIdList = gson.fromJson(String.valueOf(fromMessage.data.get("selectedSettingIds")), new TypeToken<ArrayList<String>>() {
}.getType());
if (!settingIdList.isEmpty()) {
note.setDefaultInterpreterGroup(settingIdList.get(0));
getNotebook().saveNote(note, context.getAutheInfo());
}
List<InterpreterSetting> bindedSettings = note.getBindedInterpreterSettings(new ArrayList<>(context.getUserAndRoles()));
for (InterpreterSetting setting : bindedSettings) {
settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
}
}
return null;
});
conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList)));
}
use of org.apache.zeppelin.types.InterpreterSettingsList in project SSM by Intel-bigdata.
the class InterpreterBindingUtils method getInterpreterBindings.
public static List<InterpreterSettingsList> getInterpreterBindings(Notebook notebook, String noteId) {
List<InterpreterSettingsList> settingList = new LinkedList<>();
List<InterpreterSetting> selectedSettings = notebook.getBindedInterpreterSettings(noteId);
for (InterpreterSetting setting : selectedSettings) {
settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
}
List<InterpreterSetting> availableSettings = notebook.getInterpreterSettingManager().get();
for (InterpreterSetting setting : availableSettings) {
boolean selected = false;
for (InterpreterSetting selectedSetting : selectedSettings) {
if (selectedSetting.getId().equals(setting.getId())) {
selected = true;
break;
}
}
if (!selected) {
settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), false));
}
}
return settingList;
}
use of org.apache.zeppelin.types.InterpreterSettingsList in project zeppelin by apache.
the class InterpreterBindingUtils method getInterpreterBindings.
public static List<InterpreterSettingsList> getInterpreterBindings(Notebook notebook, String noteId) {
List<InterpreterSettingsList> settingList = new LinkedList<>();
List<InterpreterSetting> selectedSettings = notebook.getBindedInterpreterSettings(noteId);
for (InterpreterSetting setting : selectedSettings) {
settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
}
List<InterpreterSetting> availableSettings = notebook.getInterpreterSettingManager().get();
for (InterpreterSetting setting : availableSettings) {
boolean selected = false;
for (InterpreterSetting selectedSetting : selectedSettings) {
if (selectedSetting.getId().equals(setting.getId())) {
selected = true;
break;
}
}
if (!selected) {
settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), false));
}
}
return settingList;
}
use of org.apache.zeppelin.types.InterpreterSettingsList in project zeppelin by apache.
the class NotebookServer method getInterpreterBindings.
public void getInterpreterBindings(NotebookSocket conn, Message fromMessage) throws IOException {
String noteId = (String) fromMessage.data.get("noteId");
List<InterpreterSettingsList> settingList = InterpreterBindingUtils.getInterpreterBindings(notebook(), noteId);
conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList)));
}
use of org.apache.zeppelin.types.InterpreterSettingsList in project zeppelin by apache.
the class NotebookServer method getInterpreterBindings.
public void getInterpreterBindings(NotebookSocket conn, ServiceContext context, Message fromMessage) throws IOException {
List<InterpreterSettingsList> settingList = new ArrayList<>();
String noteId = (String) fromMessage.data.get("noteId");
getNotebook().processNote(noteId, note -> {
if (note != null) {
List<InterpreterSetting> bindedSettings = note.getBindedInterpreterSettings(new ArrayList<>(context.getUserAndRoles()));
for (InterpreterSetting setting : bindedSettings) {
settingList.add(new InterpreterSettingsList(setting.getId(), setting.getName(), setting.getInterpreterInfos(), true));
}
}
conn.send(serializeMessage(new Message(OP.INTERPRETER_BINDINGS).put("interpreterBindings", settingList)));
return null;
});
}
Aggregations