关于修改zeppelin的代码显示
最近我在修改zeppelin(0.7版本)的源码相关的知识,目前做的工作是修改zeppelin的代码,为了让zeppelin可以可以在页面中显示数据集,并且在其数据库中存储式真实的路径1.如果我们要运行paragraph的代码的时候,我们要修改
我们要修改NotebookServer.setParagraphUsingMessage(Note note, Message fromMessage, String paragraphId, String text, String title, Map<String, Object> params, Map<String, Object> config)方法,
目的让你在zeppelin上面写数据集但是存储在zeppelin的代码里面是真实路径
代码:
Paragraph p = note.getParagraph(paragraphId);
//修改text的值
if(text != null){
if(text.contains("#mydata")){
text = text.replaceAll("#mydata","/tmp/xjdx.txt");
}
}
p.setText(text);
p.setTitle(title);
AuthenticationInfo subject =
new AuthenticationInfo(fromMessage.principal, fromMessage.ticket);
p.setAuthenticationInfo(subject);
p.settings.setParams(params);
p.setConfig(config);
return p;
-----------------------------------------------------------
修改页面或者换其他的notebook
private void updateParagraph(NotebookSocket conn, HashSet<String> userAndRoles,
Notebook notebook, Message fromMessage) throws IOException {
LOG.info("----------------------------------updateParagraph-------------------------------");
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);
final Note note = notebook.getNote(noteId);
NotebookAuthorization notebookAuthorization = notebook.getNotebookAuthorization();
AuthenticationInfo subject = new AuthenticationInfo(fromMessage.principal);
if (!notebookAuthorization.isWriter(noteId, userAndRoles)) {
permissionError(conn, "write", fromMessage.principal, userAndRoles,
notebookAuthorization.getWriters(noteId));
return;
}
Paragraph p = note.getParagraph(paragraphId);
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"));
//修改text的值
String myText = (String) fromMessage.get("paragraph");
if(myText != null){
if(myText.contains("#mydata")){
myText = myText.replaceAll("#mydata","/tmp/xjdx.txt");
}
}
p.setText(myText);
note.persist(subject);
if (note.isPersonalizedMode()) {
Map<String, Paragraph> userParagraphMap =
note.getParagraph(paragraphId).getUserParagraphMap();
broadcastParagraphs(userParagraphMap, p);
} else {
broadcastParagraph(note, p);
}
}
------------------------------------------------------------
整体刷新页面或者是换notebook的显示模式
private void sendNote(NotebookSocket conn, HashSet<String> userAndRoles, Notebook notebook,
Message fromMessage) throws IOException {
LOG.info("New operation from {} : {} : {} : {} : {}", conn.getRequest().getRemoteAddr(),
conn.getRequest().getRemotePort(), fromMessage.principal, fromMessage.op,
fromMessage.get("id"));
String noteId = (String) fromMessage.get("id");
if (noteId == null) {
return;
}
String user = fromMessage.principal;
Note note = notebook.getNote(noteId);
NotebookAuthorization notebookAuthorization = notebook.getNotebookAuthorization();
if (note != null) {
if (!notebookAuthorization.isReader(noteId, userAndRoles)) {
permissionError(conn, "read", fromMessage.principal, userAndRoles,
notebookAuthorization.getReaders(noteId));
return;
}
addConnectionToNote(note.getId(), conn);
if (note.isPersonalizedMode()) {
note = note.getUserNote(user);
}
String msg2 = serializeMessage(new Message(OP.NOTE).put("note", note));
Message message2 = deserializeMessage(msg2);
Map note2 = message2.getType("note");
if (note2 != null) {
List<Map> paragraphs2 = (List<Map>)note2.get("paragraphs");
for (Map m : paragraphs2) {
String text2 = (String)m.get("text");
if(text2 != null){
if(text2.contains("/tmp/xjdx.txt")){
text2 = text2.replaceAll("/tmp/xjdx.txt","#mydata");
}
}
m.put("text", text2);
}
}
conn.send(serializeMessage(message2));
sendAllAngularObjects(note, user, conn);
} else {
conn.send(serializeMessage(new Message(OP.NOTE).put("note", null)));
}
}
------------------------------------------------------
旁边的一些辅助功能以及run后面的访问流程,例如copy以及showline的方法
public void broadcastParagraph(Note note, Paragraph p) {
Paragraph p2 = p;
if (p.settings != null) {
//clone()方法
p2 = p.cloneParagraphForUser(p.getId());
String text = p2.getText();
if (text != null) {
if (text.contains("/tmp/xjdx.txt")) {
text = text.replaceAll("/tmp/xjdx.txt", "#mydata");
p2.setText(text);
}
}
}
if (note.isPersonalizedMode()) {
broadcastParagraphs(p.getUserParagraphMap(), p2);
} else {
broadcast(note.getId(), new Message(OP.PARAGRAPH).put("paragraph", p2));
}
}
关于修改zeppelin的代码显示的更多相关文章
- WPF DatePicker只显示年和月 修改:可以只显示年
最近的项目,查询时只需要年和月,不需要日,因此需要对原有的DatePicker进行修改,查询了网上的内容,最终从一篇帖子里看到了添加附加属性的方法,地址是http://stackoverflow.co ...
- 修改woocommerce列表产品显示数量
WooCommerce列表产品数量默认显示为10,如果是显示3列或4列,则最后一行会有空白留出,为了美观,往往我们要设置显示合适的产品数量.因此,只要把如下代码复制到当前主题的functions.ph ...
- 修改LiveChart的提示显示位置
问题:修改LiveChart的提示显示位置 摘要:相信WPF开发者在用LiveCharts的时候会有遇到这个需求.就是产品要求折线图的提示要显示的正常点. 需求:如下图所示.原本显示是在下方并且没有小 ...
- 【HOW】用PowerShell脚本修改用户配置文件属性显示次序
首先将如下脚本保存为PowerShell文件,如:ReorderUserProfileProperty.ps1. 在执行此脚本时,如果不输入任何参数,将列出所有用户配置文件属性的名称和显示次序:如果只 ...
- Bootstrap系列 -- 8. 代码显示
一. Bootstrap中的代码块 代码块一般在博客中使用的较多,比较博客园中提供的贴代码. 在Bootstrap中提供了三种形式的代码显示 1. 使用<code></code> ...
- C# 反编译-Reflector 反混淆-De4Dot 修改dll/exe代码-reflexil
反编译工具 Reflector 破解版下载地址:http://pan.baidu.com/s/15UwJo 使用方法:略 反混淆工具De4Dot 开源软件 下载地址http://pan.baidu.c ...
- 修改一行SQL代码 性能提升了N倍
在PostgreSQL中修改了一行不明显的代码,把(ANY(ARRAY[...]) 改成 ANY(VALUES(...))),结果查询时间从20s变为0.2s.最初我们学习使用EXPLAN ANALY ...
- thinkphp从数据库里的html代码显示页面不解析
首先,这个问题不应该出现在这里,因为以前在用ThinkPHP3.1.2的时候,利用富文本编辑器保存文本后,直接从数据库里面取出的数据都能正常显示,改用ThinkPHP3.2.3之后,thinkphp从 ...
- Android开发技巧——TextView加载HTML的图片及代码显示问题
前几天在做一个Gradle用户指南的应用程序,使用的是TextView来加载HTML内容(至于为什么不用WebView,我也没有认真使用并比较过,也许以后会换吧),其中遇见了一些纠结的问题,所幸主要的 ...
随机推荐
- CSS3的Animation
1.animation-name :动画名 2.animation-duration:时间 3.animation-delay:延时 4.animation-iteration-co ...
- 【菜鸟学Linux】Cron Job定期删除Log(日志)文件
以前一直做Windows开发,近期的项目中要求使用Linux.作为小菜鸟一枚,赶紧买了一本经典书<鸟哥的Linux私房菜>学习.最近刚好有一个小任务 - 由于产品产生的Log很多,而且增长 ...
- C#面向对象几组关键字的详解(this,base,dynamic,var,const,readonly,is,as)
× 目录 [1]this和base的区别 [2]var和dynamic的区别 [3]const和readonly的区别 [4]is和as的区别 这几个关键字,在用法上有许多相似之处.这里主要看看细节之 ...
- Html + JS : 点击对应的按钮,进行选择是隐藏还是显示(用户回复功能)
例如: 当我点击按钮1时,点击第一下进行显示This is comment 01,点击第二下隐藏This is comment 01 当我点击按钮2时,点击第一下进行显示This is comment ...
- POJ-2155 Matrix---二维树状数组+区域更新单点查询
题目链接: https://vjudge.net/problem/POJ-2155 题目大意: 给一个n*n的01矩阵,然后有两种操作(m次)C x1 y1 x2 y2是把这个小矩形内所有数字异或一遍 ...
- Android OpenGL ES 画球体
近期由于兴趣所向.開始学习OpenGL绘图. 本文以"画球体"为点,小结一下近期所学. > 初识OpenGL ES 接触OpenGL是从Android開始的.众所周知,And ...
- Delphi7 企业版安装记录
Borland Delphi Enterprise Version 7.0[Build 4.453] 云盘下载: 链接:http://pan.baidu.com/s/1gff6Fuz 密码:z ...
- shell脚本监控URL并自动发邮件
1.安装sendmail:yum install -y sendmail 2.安装mail:yum install -y mail 3.安装mutt:yum install -y mutt 4.启动s ...
- 1993: C语言实验——最值
1993: C语言实验——最值 Time Limit: 1 Sec Memory Limit: 64 MBSubmit: 1541 Solved: 727[Submit][Status][Web ...
- Visual Studio 2013 ReportViewer Control
最近需要给学生讲报表,.NET的自然就是选择RDLC了. 因为学生比赛是用Visual Studio 2013,所以我在自己的笔记本上安装了Visual Studio 2013(平常是用2010),安 ...