Skip to content

Instantly share code, notes, and snippets.

@doanduyhai
Created March 3, 2016 16:28
Show Gist options
  • Save doanduyhai/350ddf29cedd4ca37f45 to your computer and use it in GitHub Desktop.
Save doanduyhai/350ddf29cedd4ca37f45 to your computer and use it in GitHub Desktop.
diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java
index d9b93f2..00df966 100644
--- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java
+++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/scheduler/Job.java
@@ -103,11 +103,16 @@ public abstract class Job {
this(jobName, listener, JobProgressPoller.DEFAULT_INTERVAL_MSEC);
}
+ public Job(String jobId, String jobName, JobListener listener) {
+ this(jobId, jobName, listener, JobProgressPoller.DEFAULT_INTERVAL_MSEC);
+ }
+
public Job(String jobId, String jobName, JobListener listener, long progressUpdateIntervalMs) {
this.jobName = jobName;
this.listener = listener;
this.progressUpdateIntervalMs = progressUpdateIntervalMs;
+ dateCreated = new Date();
id = jobId;
setStatus(Status.READY);
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
index b0470c8..ae1c7f4 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Note.java
@@ -165,8 +165,13 @@ public class Note implements Serializable, JobListener {
*
* @param srcParagraph
*/
- public void addCloneParagraph(Paragraph srcParagraph) {
- Paragraph newParagraph = new Paragraph(this, this, replLoader);
+ public void addCloneParagraph(boolean keepOriginalId, Paragraph srcParagraph) {
+ final Paragraph newParagraph;
+ if (keepOriginalId) {
+ newParagraph = new Paragraph(srcParagraph.getId(), this, this, replLoader);
+ } else {
+ newParagraph = new Paragraph(this, this, replLoader);
+ }
Map<String, Object> config = new HashMap<>(srcParagraph.getConfig());
Map<String, Object> param = new HashMap<>(srcParagraph.settings.getParams());
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
index 14d2fd8..e541ea3 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Notebook.java
@@ -195,7 +195,7 @@ public class Notebook {
newNote.setName(oldNote.getName());
List<Paragraph> paragraphs = oldNote.getParagraphs();
for (Paragraph p : paragraphs) {
- newNote.addCloneParagraph(p);
+ newNote.addCloneParagraph(true, p);
}
newNote.persist();
@@ -231,7 +231,7 @@ public class Notebook {
List<Paragraph> paragraphs = sourceNote.getParagraphs();
for (Paragraph p : paragraphs) {
- newNote.addCloneParagraph(p);
+ newNote.addCloneParagraph(false, p);
}
notebookIndex.addIndexDoc(newNote);
diff --git a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
index ce7528f..06dcd3d 100644
--- a/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
+++ b/zeppelin-zengine/src/main/java/org/apache/zeppelin/notebook/Paragraph.java
@@ -51,6 +51,19 @@ public class Paragraph extends Job implements Serializable, Cloneable {
private Map<String, Object> config; // paragraph configs like isOpen, colWidth, etc
public final GUI settings; // form and parameter settings
+ public Paragraph(String paragraphId, Note note, JobListener listener,
+ NoteInterpreterLoader replLoader) {
+ super(paragraphId, generateId(), listener);
+ this.note = note;
+ this.replLoader = replLoader;
+ title = null;
+ text = null;
+ authenticationInfo = null;
+ dateUpdated = null;
+ settings = new GUI();
+ config = new HashMap<String, Object>();
+ }
+
public Paragraph(Note note, JobListener listener, NoteInterpreterLoader replLoader) {
super(generateId(), listener);
this.note = note;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment