mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
[ZEPPELIN-2106]: keeping only the API providing the whole config
This commit is contained in:
parent
76af44ab6c
commit
0994ac0ec0
4 changed files with 10 additions and 93 deletions
|
|
@ -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,
|
|||
}</pre></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> sample JSON input (providing graph,showTitle and colWidth information) </td>
|
||||
<td> sample JSON input (providing paragraph config) </td>
|
||||
<td><pre>
|
||||
{
|
||||
"title": "paragraph title2",
|
||||
"text": "paragraph text2",
|
||||
"showTitle": true,
|
||||
"colWidth": 9.0,
|
||||
"graph": {
|
||||
"mode": "pieChart"
|
||||
}
|
||||
}</pre></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td> sample JSON input (providing paragraph config) </td>
|
||||
<td><pre>
|
||||
{
|
||||
"title": "paragraph title3",
|
||||
"text": "paragraph text3",
|
||||
"config": {
|
||||
"title": true,
|
||||
"colWidth": 6.0,
|
||||
"results": [
|
||||
{
|
||||
"graph": {
|
||||
"mode": "scatterChart",
|
||||
"mode": "pieChart",
|
||||
"optionOpen": true
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Object> results = new ArrayList<>();
|
||||
Map<String, Object> 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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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; }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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<Map>)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);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue