diff --git a/docs/rest-api/rest-notebook.md b/docs/rest-api/rest-notebook.md index 766f38d0e5..1c5ebdeec6 100644 --- a/docs/rest-api/rest-notebook.md +++ b/docs/rest-api/rest-notebook.md @@ -112,15 +112,6 @@ Notebooks REST API supports the following operations: List, Create, Get, Delete, { "title": "paragraph title2", "text": "paragraph text2", - "showTitle": true, - "colWidth": 9.0, - "graph": { - "mode": "pieChart" - } - } - { - "title": "paragraph title3", - "text": "paragraph text3", "config": { "title": true, "colWidth": 6.0, @@ -622,31 +613,18 @@ Notebooks REST API supports the following operations: List, Create, Get, Delete, } - sample JSON input (providing graph,showTitle and colWidth information) + sample JSON input (providing paragraph config)
 {
   "title": "paragraph title2",
   "text": "paragraph text2",
-  "showTitle": true,
-  "colWidth": 9.0,
-  "graph": {
-    "mode": "pieChart"
-  }
- }
- - - sample JSON input (providing paragraph config) -
-{
-  "title": "paragraph title3",
-  "text": "paragraph text3",
   "config": {
     "title": true,
     "colWidth": 6.0,
     "results": [
       {
         "graph": {
-          "mode": "scatterChart",
+          "mode": "pieChart",
           "optionOpen": true
         }
       }
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
index bb2ea07d11..8c1075e986 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/NotebookRestApi.java
@@ -955,38 +955,7 @@ public class NotebookRestApi {
     p.setTitle(request.getTitle());
     p.setText(request.getText());
     Map< String, Object > config = request.getConfig();
-    if ( config != null){
-      Vector< String > ignoredFields = new Vector<>();
-      if ( request.getGraph() != null)
-        ignoredFields.add("graph");
-      if ( request.getColWidth() != null)
-        ignoredFields.add("colWidth");
-      if ( request.getShowTitle() != null)
-        ignoredFields.add("showTitle");
-      if ( ignoredFields.size() > 0 )
-        LOG.warn("As config is provided, the following field(s) are ignored {}",
-                ignoredFields.toString());
-    }
-    else {
-      config = new HashMap<>();
-      Map graph = request.getGraph();
-      if (graph != null) {
-        List results = new ArrayList<>();
-        Map result = new HashMap<>();
-        result.put("graph", graph);
-        results.add(result);
-        config.put("results", results);
-      }
-      Double colWidth = request.getColWidth();
-      if (colWidth != null) {
-        config.put("colWidth", colWidth);
-      }
-      Boolean showTitle = request.getShowTitle();
-      if (showTitle != null) {
-        config.put("title", showTitle);
-      }
-    }
-    if ( !config.isEmpty()) {
+    if ( config != null && !config.isEmpty()) {
       configureParagraph(p, config, user);
     }
   }
diff --git a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java
index 238ec4d4de..5be732f8be 100644
--- a/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java
+++ b/zeppelin-server/src/main/java/org/apache/zeppelin/rest/message/NewParagraphRequest.java
@@ -31,9 +31,6 @@ public class NewParagraphRequest {
   String title;
   String text;
   Double index;
-  HashMap< String, Object > graph;
-  Boolean showTitle;
-  Double colWidth;
   HashMap< String, Object > config;
 
   public NewParagraphRequest() {
@@ -52,11 +49,5 @@ public class NewParagraphRequest {
     return index;
   }
 
-  public HashMap< String, Object > getGraph() { return graph; }
-
-  public Boolean getShowTitle() { return showTitle; }
-
-  public Double getColWidth() { return colWidth; }
-
   public HashMap< String, Object > getConfig() { return config; }
 }
diff --git a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java
index 5ebca2d9a0..d53c3b55a1 100644
--- a/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java
+++ b/zeppelin-server/src/test/java/org/apache/zeppelin/rest/ZeppelinRestApiTest.java
@@ -134,10 +134,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi {
     String jsonRequest = "{\"name\":\"" + noteName + "\", \"paragraphs\": [" +
         "{\"title\": \"title1\", \"text\": \"text1\"}," +
         "{\"title\": \"title2\", \"text\": \"text2\"}," +
-        "{\"title\": \"titleConfig1\", \"text\": \"text3\", " +
-        "\"graph\": {\"mode\": \"pieChart\"}, " +
-        "\"colWidth\": 9.0, \"showTitle\": true}, " +
-        "{\"title\": \"titleConfig2\", \"text\": \"text4\", " +
+        "{\"title\": \"titleConfig\", \"text\": \"text3\", " +
         "\"config\": {\"colWidth\": 9.0, \"title\": true, "+
         "\"results\": [{\"graph\": {\"mode\": \"pieChart\"}}] "+
         "}}]} ";
@@ -160,7 +157,7 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi {
       expectedNoteName = "Note " + newNoteId;
     }
     assertEquals("compare note name", expectedNoteName, newNoteName);
-    assertEquals("initial paragraph check failed", 5, newNote.getParagraphs().size());
+    assertEquals("initial paragraph check failed", 4, newNote.getParagraphs().size());
     for (Paragraph p : newNote.getParagraphs()) {
       if (StringUtils.isEmpty(p.getText())) {
         continue;
@@ -633,12 +630,12 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi {
     assertEquals("title2", paragraphAtIdx0.getTitle());
     assertEquals("text2", paragraphAtIdx0.getText());
 
-    //append paragraph providing config
-    String jsonRequest3 = "{\"title\": \"title3\", \"text\": \"text3\", " +
-                          "\"graph\": {\"mode\": \"pieChart\"}, " +
-                          "\"colWidth\": 9.0, \"showTitle\": true}";
+    //append paragraph providing graph
+    String jsonRequest3 = "{\"title\": \"title3\", \"text\": \"text3\", "+
+                          "\"config\": {\"colWidth\": 9.0, \"title\": true, "+
+                          "\"results\": [{\"graph\": {\"mode\": \"pieChart\"}}]}}";
     PostMethod post3 = httpPost("/notebook/" + note.getId() + "/paragraph", jsonRequest3);
-    LOG.info("testInsertParagraph response3\n" + post3.getResponseBodyAsString());
+    LOG.info("testInsertParagraph response4\n" + post3.getResponseBodyAsString());
     assertThat("Test insert method:", post3, isAllowed());
     post3.releaseConnection();
 
@@ -651,24 +648,6 @@ public class ZeppelinRestApiTest extends AbstractTestRestApi {
     assertEquals(9.0, p.getConfig().get("colWidth"));
     assertTrue(((boolean) p.getConfig().get("title")));
 
-    //append paragraph providing graph
-    String jsonRequest4 = "{\"title\": \"title4\", \"text\": \"text4\", "+
-                          "\"config\": {\"colWidth\": 9.0, \"title\": true, "+
-                          "\"results\": [{\"graph\": {\"mode\": \"pieChart\"}}]}}";
-    PostMethod post4 = httpPost("/notebook/" + note.getId() + "/paragraph", jsonRequest4);
-    LOG.info("testInsertParagraph response4\n" + post4.getResponseBodyAsString());
-    assertThat("Test insert method:", post4, isAllowed());
-    post4.releaseConnection();
-
-    Paragraph p2 = note.getLastParagraph();
-    assertEquals("title4", p2.getTitle());
-    assertEquals("text4", p2.getText());
-    Map result2 = ((List)p.getConfig().get("results")).get(0);
-    String mode2 = ((Map)result.get("graph")).get("mode").toString();
-    assertEquals("pieChart", mode2);
-    assertEquals(9.0, p2.getConfig().get("colWidth"));
-    assertTrue(((boolean) p2.getConfig().get("title")));
-
 
     ZeppelinServer.notebook.removeNote(note.getId(), anonymous);
   }