最近我在修改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的代码显示的更多相关文章

  1. WPF DatePicker只显示年和月 修改:可以只显示年

    最近的项目,查询时只需要年和月,不需要日,因此需要对原有的DatePicker进行修改,查询了网上的内容,最终从一篇帖子里看到了添加附加属性的方法,地址是http://stackoverflow.co ...

  2. 修改woocommerce列表产品显示数量

    WooCommerce列表产品数量默认显示为10,如果是显示3列或4列,则最后一行会有空白留出,为了美观,往往我们要设置显示合适的产品数量.因此,只要把如下代码复制到当前主题的functions.ph ...

  3. 修改LiveChart的提示显示位置

    问题:修改LiveChart的提示显示位置 摘要:相信WPF开发者在用LiveCharts的时候会有遇到这个需求.就是产品要求折线图的提示要显示的正常点. 需求:如下图所示.原本显示是在下方并且没有小 ...

  4. 【HOW】用PowerShell脚本修改用户配置文件属性显示次序

    首先将如下脚本保存为PowerShell文件,如:ReorderUserProfileProperty.ps1. 在执行此脚本时,如果不输入任何参数,将列出所有用户配置文件属性的名称和显示次序:如果只 ...

  5. Bootstrap系列 -- 8. 代码显示

    一. Bootstrap中的代码块 代码块一般在博客中使用的较多,比较博客园中提供的贴代码. 在Bootstrap中提供了三种形式的代码显示 1. 使用<code></code> ...

  6. C# 反编译-Reflector 反混淆-De4Dot 修改dll/exe代码-reflexil

    反编译工具 Reflector 破解版下载地址:http://pan.baidu.com/s/15UwJo 使用方法:略 反混淆工具De4Dot 开源软件 下载地址http://pan.baidu.c ...

  7. 修改一行SQL代码 性能提升了N倍

    在PostgreSQL中修改了一行不明显的代码,把(ANY(ARRAY[...]) 改成 ANY(VALUES(...))),结果查询时间从20s变为0.2s.最初我们学习使用EXPLAN ANALY ...

  8. thinkphp从数据库里的html代码显示页面不解析

    首先,这个问题不应该出现在这里,因为以前在用ThinkPHP3.1.2的时候,利用富文本编辑器保存文本后,直接从数据库里面取出的数据都能正常显示,改用ThinkPHP3.2.3之后,thinkphp从 ...

  9. Android开发技巧——TextView加载HTML的图片及代码显示问题

    前几天在做一个Gradle用户指南的应用程序,使用的是TextView来加载HTML内容(至于为什么不用WebView,我也没有认真使用并比较过,也许以后会换吧),其中遇见了一些纠结的问题,所幸主要的 ...

随机推荐

  1. 基于表单布局:分析过时的table结构与当下的div结构

    一些话在前面 最近做了百度前端学院一个小任务,其中涉及到表单布局的问题, 它要处理的布局问题:左边的标签要右对齐,右边的输入框.单选按钮等要实现左对齐. 从开始入门就被告知table布局已经过时了,当 ...

  2. Linux 学习 二, 安装JDK

    我是利用在window环境下载好JDK,然后传到VMware中linux中 下载JDK http://www.oracle.com/technetwork/java/javase/downloads/ ...

  3. FRM-40654 Record has been updated

    该错误是由于界面上对数据进行了修改后(比如为A),将修改前的数据(B)与数据库中的数据(B)进行配不成功时报错: 首先确认Form界面是否有其他人对数据进行修改: 如果无人修改: 将数据库的数据查询出 ...

  4. URL地址中中文乱码详解(javascript中encodeURI和decodeURI方法、java.net.URLDecoder.encode、java.net.URLDecoder.decode)

    引言: 在Restful类的服务设计中,经常会碰到需要在URL地址中使用中文作为的参数的情况,这种情况下,一般都需要正确的设置和编码中文字符信息.乱码问题就此产生了,该如何解决呢?且听本文详细道来. ...

  5. nginx处理HTTP header问题

    在实际开发中遇到http header 自定义key中包含下划线(_)时服务端header丢失的问题,解决办法详细见以下网页内容,感谢原博主 http://blog.csdn.net/dac55300 ...

  6. LA 5031 图询问

    题目链接:https://vjudge.net/contest/159527#problem/A 题意:(求一个 图 中的连通分量中的 第 k 大) 一张图,n 个点,m 条边, 有一些操作: 删除 ...

  7. 转:spring mvc返回json数据格式

    转:http://www.cnblogs.com/ssslinppp/p/4675495.html <Spring学习笔记-MVC>系列文章,讲解返回json数据的文章共有3篇,分别为: ...

  8. 2018.7.6 js实现点击事件---点击小图出现大图---时间定时器----注册表单验证

    <!DOCTYPE html> <html lang="zh"> <head> <meta charset="UTF-8&quo ...

  9. TeamCity实战(2):NuGet服务器

    如果有在内网架设NuGet服务器的需要,比如说公司要求所有开发人员的开发机与外网隔离,但是项目开发又必须要通过NuGet获取开发包的情况. 打开选项其实很简单,但是打开之后怎么样更新开发包要复杂些了. ...

  10. iOS内存管理部分内容

    Objective-C 高级编程 iOS与OS X多线程和内存管理第一章部分讲述了关于ARC的内容,还讲述了关于修饰符的问题,还讲了好多底层的实现的内容,这些底层实现却往往是在面试的过程中经常被遇到的 ...