mirror of
https://github.com/apache/zeppelin
synced 2026-05-24 09:38:26 +00:00
fix compile errors
This commit is contained in:
parent
0156ffc89c
commit
1d6fd3ec65
34 changed files with 782 additions and 609 deletions
|
|
@ -122,7 +122,7 @@ public class AlluxioInterpreterTest {
|
|||
"\ncat /testDir", null);
|
||||
|
||||
Assert.assertEquals(Code.ERROR, output.code());
|
||||
Assert.assertEquals(expected, output.message());
|
||||
Assert.assertEquals(expected, output.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -141,7 +141,7 @@ public class AlluxioInterpreterTest {
|
|||
|
||||
Assert.assertEquals(Code.SUCCESS, output.code());
|
||||
Assert.assertArrayEquals(expected,
|
||||
output.message().substring(0, output.message().length() - 1).getBytes());
|
||||
output.message().get(0).getData().substring(0, output.message().get(0).getData().length() - 1).getBytes());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -157,7 +157,7 @@ public class AlluxioInterpreterTest {
|
|||
testFile.getAbsolutePath() + " /testFile", null);
|
||||
Assert.assertEquals(
|
||||
"Copied " + testFile.getAbsolutePath() + " to /testFile\n\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
|
||||
long fileLength = fs.getStatus(new AlluxioURI("/testFile")).getLength();
|
||||
Assert.assertEquals(SIZE_BYTES, fileLength);
|
||||
|
|
@ -215,7 +215,7 @@ public class AlluxioInterpreterTest {
|
|||
testFile.getParent() + " /testDir", null);
|
||||
Assert.assertEquals(
|
||||
"Copied " + testFile.getParent() + " to /testDir\n\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
|
||||
long fileLength1 = fs.getStatus(new AlluxioURI("/testDir/testFile")).getLength();
|
||||
long fileLength2 = fs.getStatus(new AlluxioURI("/testDir/testDirInner/testFile2")).getLength();
|
||||
|
|
@ -242,7 +242,7 @@ public class AlluxioInterpreterTest {
|
|||
testFile.getPath() + " " + uri, null);
|
||||
Assert.assertEquals(
|
||||
"Copied " + testFile.getPath() + " to " + uri + "\n\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
|
||||
long fileLength = fs.getStatus(new AlluxioURI("/destFileURI")).getLength();
|
||||
Assert.assertEquals(10L, fileLength);
|
||||
|
|
@ -290,7 +290,7 @@ public class AlluxioInterpreterTest {
|
|||
|
||||
Assert.assertEquals(
|
||||
"Copied /testFile to " + mLocalAlluxioCluster.getAlluxioHome() + "/testFile\n\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
fileReadTest("/testFile", 10);
|
||||
}
|
||||
|
||||
|
|
@ -299,7 +299,7 @@ public class AlluxioInterpreterTest {
|
|||
InterpreterResult output = alluxioInterpreter.interpret("count /NotExistFile", null);
|
||||
Assert.assertEquals(Code.ERROR, output.code());
|
||||
Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -318,14 +318,14 @@ public class AlluxioInterpreterTest {
|
|||
expected += String.format(format, "File Count", "Folder Count", "Total Bytes");
|
||||
expected += String.format(format, 3, 2, 60);
|
||||
expected += "\n";
|
||||
Assert.assertEquals(expected, output.message());
|
||||
Assert.assertEquals(expected, output.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void fileinfoNotExistTest() throws IOException {
|
||||
InterpreterResult output = alluxioInterpreter.interpret("fileInfo /NotExistFile", null);
|
||||
Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
Assert.assertEquals(Code.ERROR, output.code());
|
||||
}
|
||||
|
||||
|
|
@ -333,7 +333,7 @@ public class AlluxioInterpreterTest {
|
|||
public void locationNotExistTest() throws IOException {
|
||||
InterpreterResult output = alluxioInterpreter.interpret("location /NotExistFile", null);
|
||||
Assert.assertEquals(ExceptionMessage.PATH_DOES_NOT_EXIST.getMessage("/NotExistFile") + "\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
Assert.assertEquals(Code.ERROR, output.code());
|
||||
}
|
||||
|
||||
|
|
@ -366,7 +366,7 @@ public class AlluxioInterpreterTest {
|
|||
expected += "\n";
|
||||
|
||||
Assert.assertEquals(Code.SUCCESS, output.code());
|
||||
Assert.assertEquals(expected, output.message());
|
||||
Assert.assertEquals(expected, output.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -406,7 +406,7 @@ public class AlluxioInterpreterTest {
|
|||
"/testRoot/testFileC");
|
||||
expected += "\n";
|
||||
|
||||
Assert.assertEquals(expected, output.message());
|
||||
Assert.assertEquals(expected, output.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -417,7 +417,7 @@ public class AlluxioInterpreterTest {
|
|||
boolean existsDir = fs.exists(new AlluxioURI("/Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File"));
|
||||
Assert.assertEquals(
|
||||
"Successfully created directory /Complex!@#$%^&*()-_=+[]{};\"'<>,.?/File\n\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
Assert.assertTrue(existsDir);
|
||||
}
|
||||
|
||||
|
|
@ -441,7 +441,7 @@ public class AlluxioInterpreterTest {
|
|||
boolean existsDir = fs.exists(new AlluxioURI("/root/testFile1"));
|
||||
Assert.assertEquals(
|
||||
"Successfully created directory /root/testFile1\n\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
Assert.assertTrue(existsDir);
|
||||
}
|
||||
|
||||
|
|
@ -454,7 +454,7 @@ public class AlluxioInterpreterTest {
|
|||
boolean existsDir = fs.exists(new AlluxioURI("/root/testFile1"));
|
||||
Assert.assertEquals(
|
||||
"Successfully created directory " + qualifiedPath + "\n\n",
|
||||
output.message());
|
||||
output.message().get(0).getData());
|
||||
Assert.assertTrue(existsDir);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class CassandraInterpreterTest {
|
|||
//Then
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo("name\tborn\tcountry\tdied\tgender\tstyles\ttype\n" +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("name\tborn\tcountry\tdied\tgender\tstyles\ttype\n" +
|
||||
"Bogdan Raczynski\t1977-01-01\tPoland\tnull\tMale\t[Dance, Electro]\tPerson\n" +
|
||||
"Krishna Das\t1947-05-31\tUSA\tnull\tMale\t[Unknown]\tPerson\n" +
|
||||
"Sheryl Crow\t1962-02-11\tUSA\tnull\tFemale\t[Classic, Rock, Country, Blues, Pop, Folk]\tPerson\n" +
|
||||
|
|
@ -166,7 +166,7 @@ public class CassandraInterpreterTest {
|
|||
//Then
|
||||
assertThat(actual).isNotNull();
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo("name\tborn\tcountry\tdied\tgender\tstyles\ttype\n" +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("name\tborn\tcountry\tdied\tgender\tstyles\ttype\n" +
|
||||
"Bogdan Raczynski\t1977-01-01\tPoland\tnull\tMale\t[Dance, Electro]\tPerson\n" +
|
||||
"Krishna Das\t1947-05-31\tUSA\tnull\tMale\t[Unknown]\tPerson\n");
|
||||
|
||||
|
|
@ -191,7 +191,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo("title\tartist\tyear\n" +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("title\tartist\tyear\n" +
|
||||
"The Impossible Dream EP\tCarter the Unstoppable Sex Machine\t1992\n" +
|
||||
"The Way You Are\tTears for Fears\t1983\n" +
|
||||
"Primitive\tSoulfly\t2003\n");
|
||||
|
|
@ -207,7 +207,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.ERROR);
|
||||
assertThat(actual.message())
|
||||
assertThat(actual.message().get(0).getData())
|
||||
.contains("Error parsing input:\n" +
|
||||
"\t'SELECT * zeppelin.albums'\n" +
|
||||
"Did you forget to add ; (semi-colon) at the end of each CQL statement ?");
|
||||
|
|
@ -223,7 +223,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.ERROR);
|
||||
assertThat(actual.message()).contains("line 1:9 missing K_FROM at 'zeppelin' (SELECT * [zeppelin]....)");
|
||||
assertThat(actual.message().get(0).getData()).contains("line 1:9 missing K_FROM at 'zeppelin' (SELECT * [zeppelin]....)");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -237,7 +237,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.ERROR);
|
||||
assertThat(actual.message())
|
||||
assertThat(actual.message().get(0).getData())
|
||||
.contains("Not enough replicas available for query at consistency THREE (3 required but only 1 alive)");
|
||||
}
|
||||
|
||||
|
|
@ -315,7 +315,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo("key\tval\n" +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("key\tval\n" +
|
||||
"myKey\tmyValue\n");
|
||||
}
|
||||
|
||||
|
|
@ -336,7 +336,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo(
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo(
|
||||
"login\taddresses\tage\tdeceased\tfirstname\tlast_update\tlastname\tlocation\n" +
|
||||
"jdoe\t" +
|
||||
"{street_number:3,street_name:'Beverly Hills Bld',zip_code:90209," +
|
||||
|
|
@ -359,7 +359,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.ERROR);
|
||||
assertThat(actual.message())
|
||||
assertThat(actual.message().get(0).getData())
|
||||
.isEqualTo("The statement 'select_users' can not be bound to values. " +
|
||||
"Are you sure you did prepare it with @prepare[select_users] ?");
|
||||
}
|
||||
|
|
@ -381,7 +381,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo("firstname\tlastname\tage\n" +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("firstname\tlastname\tage\n" +
|
||||
"Helen\tSUE\t27\n");
|
||||
|
||||
}
|
||||
|
|
@ -398,7 +398,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -412,7 +412,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo("name\tcountry\tstyles\n" +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("name\tcountry\tstyles\n" +
|
||||
"Bogdan Raczynski\tPoland\t[Dance, Electro]\n" +
|
||||
"Krishna Das\tUSA\t[Unknown]\n" +
|
||||
"Sheryl Crow\tUSA\t[Classic, Rock, Country, Blues, Pop, Folk]\n");
|
||||
|
|
@ -430,7 +430,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).contains("last_update\n" +
|
||||
assertThat(actual.message().get(0).getData()).contains("last_update\n" +
|
||||
"Thu Jul 30 12:00:01");
|
||||
}
|
||||
|
||||
|
|
@ -445,7 +445,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo("firstname\tlastname\n" +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("firstname\tlastname\n" +
|
||||
"null\tNULL\n");
|
||||
}
|
||||
|
||||
|
|
@ -460,7 +460,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(actual.message()).isEqualTo("login\tdeceased\n" +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("login\tdeceased\n" +
|
||||
"bind_bool\tfalse\n");
|
||||
}
|
||||
|
||||
|
|
@ -477,7 +477,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.ERROR);
|
||||
assertThat(actual.message()).isEqualTo("The statement 'to_be_removed' can not be bound to values. " +
|
||||
assertThat(actual.message().get(0).getData()).isEqualTo("The statement 'to_be_removed' can not be bound to values. " +
|
||||
"Are you sure you did prepare it with @prepare[to_be_removed] ?");
|
||||
}
|
||||
|
||||
|
|
@ -500,7 +500,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -513,7 +513,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.ERROR);
|
||||
assertThat(actual.message()).contains("All host(s) tried for query failed");
|
||||
assertThat(actual.message().get(0).getData()).contains("All host(s) tried for query failed");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -530,7 +530,7 @@ public class CassandraInterpreterTest {
|
|||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -546,7 +546,7 @@ public class CassandraInterpreterTest {
|
|||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -562,7 +562,7 @@ public class CassandraInterpreterTest {
|
|||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -648,7 +648,7 @@ public class CassandraInterpreterTest {
|
|||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -664,7 +664,7 @@ public class CassandraInterpreterTest {
|
|||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -681,7 +681,7 @@ public class CassandraInterpreterTest {
|
|||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -695,7 +695,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.ERROR);
|
||||
assertThat(actual.message()).contains("Cannot find table system.complex_table");
|
||||
assertThat(actual.message().get(0).getData()).contains("Cannot find table system.complex_table");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -709,7 +709,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.ERROR);
|
||||
assertThat(actual.message()).contains("Cannot find type system.address");
|
||||
assertThat(actual.message().get(0).getData()).contains("Cannot find type system.address");
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -723,7 +723,7 @@ public class CassandraInterpreterTest {
|
|||
|
||||
//Then
|
||||
assertThat(actual.code()).isEqualTo(Code.SUCCESS);
|
||||
assertThat(reformatHtml(actual.message())).isEqualTo(expected);
|
||||
assertThat(reformatHtml(actual.message().get(0).getData())).isEqualTo(expected);
|
||||
}
|
||||
|
||||
private static String reformatHtml(String rawHtml) {
|
||||
|
|
|
|||
|
|
@ -128,7 +128,7 @@ public class ElasticsearchInterpreterTest {
|
|||
assertEquals(Code.ERROR, res.code());
|
||||
|
||||
res = interpreter.interpret("count /logs", null);
|
||||
assertEquals("50", res.message());
|
||||
assertEquals("50", res.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -207,7 +207,7 @@ public class ElasticsearchInterpreterTest {
|
|||
assertEquals(Code.ERROR, res.code());
|
||||
|
||||
res = interpreter.interpret("delete /logs/http/11", null);
|
||||
assertEquals("11", res.message());
|
||||
assertEquals("11", res.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -53,56 +53,56 @@ public class HDFSFileInterpreterTest extends TestCase {
|
|||
// 3. flags and arguments to commands are correctly handled
|
||||
|
||||
InterpreterResult result1 = t.interpret("ls -l /", null);
|
||||
assertEquals(result1.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result1.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
|
||||
InterpreterResult result2 = t.interpret("ls -l /./user/..", null);
|
||||
assertEquals(result2.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result2.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
|
||||
assertEquals(result1.message(), result2.message());
|
||||
assertEquals(result1.message().get(0).getData(), result2.message().get(0).getData());
|
||||
|
||||
// Ensure you can do cd and after that the ls uses current directory correctly
|
||||
|
||||
InterpreterResult result3 = t.interpret("cd user", null);
|
||||
assertEquals(result3.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result3.message(), "OK");
|
||||
assertEquals(result3.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result3.message().get(0).getData(), "OK");
|
||||
|
||||
InterpreterResult result4 = t.interpret("ls", null);
|
||||
assertEquals(result4.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result4.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
|
||||
InterpreterResult result5 = t.interpret("ls /user", null);
|
||||
assertEquals(result5.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result5.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
|
||||
assertEquals(result4.message(), result5.message());
|
||||
assertEquals(result4.message().get(0).getData(), result5.message().get(0).getData());
|
||||
|
||||
// Ensure pwd works correctly
|
||||
|
||||
InterpreterResult result6 = t.interpret("pwd", null);
|
||||
assertEquals(result6.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result6.message(), "/user");
|
||||
assertEquals(result6.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result6.message().get(0).getData(), "/user");
|
||||
|
||||
// Move a couple of levels and check we're in the right place
|
||||
|
||||
InterpreterResult result7 = t.interpret("cd ../mr-history/done", null);
|
||||
assertEquals(result7.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result7.message(), "OK");
|
||||
assertEquals(result7.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result7.message().get(0).getData(), "OK");
|
||||
|
||||
InterpreterResult result8 = t.interpret("ls -l ", null);
|
||||
assertEquals(result8.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result8.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
|
||||
InterpreterResult result9 = t.interpret("ls -l /mr-history/done", null);
|
||||
assertEquals(result9.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result9.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
|
||||
assertEquals(result8.message(), result9.message());
|
||||
assertEquals(result8.message().get(0).getData(), result9.message().get(0).getData());
|
||||
|
||||
InterpreterResult result10 = t.interpret("cd ../..", null);
|
||||
assertEquals(result10.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result7.message(), "OK");
|
||||
assertEquals(result10.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result7.message().get(0).getData(), "OK");
|
||||
|
||||
InterpreterResult result11 = t.interpret("ls -l ", null);
|
||||
assertEquals(result11.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result11.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
|
||||
// we should be back to first result after all this navigation
|
||||
assertEquals(result1.message(), result11.message());
|
||||
assertEquals(result1.message().get(0).getData(), result11.message().get(0).getData());
|
||||
|
||||
// auto completion test
|
||||
List expectedResultOne = Arrays.asList(
|
||||
|
|
|
|||
|
|
@ -69,14 +69,14 @@ public class FlinkInterpreterTest {
|
|||
public void testSimpleStatement() {
|
||||
InterpreterResult result = flink.interpret("val a=1", context);
|
||||
result = flink.interpret("print(a)", context);
|
||||
assertEquals("1", result.message());
|
||||
assertEquals("1", result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSimpleStatementWithSystemOutput() {
|
||||
InterpreterResult result = flink.interpret("val a=1", context);
|
||||
result = flink.interpret("System.out.print(a)", context);
|
||||
assertEquals("1", result.message());
|
||||
assertEquals("1", result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -89,7 +89,7 @@ public class FlinkInterpreterTest {
|
|||
String[] expectedCounts = {"(to,2)", "(be,2)", "(or,1)", "(not,1)"};
|
||||
Arrays.sort(expectedCounts);
|
||||
|
||||
String[] counts = result.message().split("\n");
|
||||
String[] counts = result.message().get(0).getData().split("\n");
|
||||
Arrays.sort(counts);
|
||||
|
||||
assertArrayEquals(expectedCounts, counts);
|
||||
|
|
|
|||
|
|
@ -143,7 +143,7 @@ public class GeodeOqlInterpreterTest {
|
|||
InterpreterResult interpreterResult = spyGeodeOqlInterpreter.interpret(OQL_QUERY, null);
|
||||
|
||||
assertEquals(Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(expectedOutput, interpreterResult.message());
|
||||
assertEquals(expectedOutput, interpreterResult.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -157,7 +157,7 @@ public class GeodeOqlInterpreterTest {
|
|||
InterpreterResult interpreterResult = spyGeodeOqlInterpreter.interpret(OQL_QUERY, null);
|
||||
|
||||
assertEquals(Code.ERROR, interpreterResult.code());
|
||||
assertEquals("Test Exception On Connect", interpreterResult.message());
|
||||
assertEquals("Test Exception On Connect", interpreterResult.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -171,7 +171,7 @@ public class GeodeOqlInterpreterTest {
|
|||
InterpreterResult interpreterResult = spyGeodeOqlInterpreter.interpret(OQL_QUERY, null);
|
||||
|
||||
assertEquals(Code.ERROR, interpreterResult.code());
|
||||
assertEquals("Expected Test Exception!", interpreterResult.message());
|
||||
assertEquals("Expected Test Exception!", interpreterResult.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -55,21 +55,21 @@ public class HbaseInterpreterTest {
|
|||
public void putsTest() {
|
||||
InterpreterResult result = hbaseInterpreter.interpret("puts \"Hello World\"", null);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(result.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals("Hello World\n", result.message());
|
||||
assertEquals(result.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
assertEquals("Hello World\n", result.message().get(0).getData());
|
||||
}
|
||||
|
||||
public void putsLoadPath() {
|
||||
InterpreterResult result = hbaseInterpreter.interpret("require 'two_power'; puts twoToThePowerOf(4)", null);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(result.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals("16\n", result.message());
|
||||
assertEquals(result.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
assertEquals("16\n", result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testException() {
|
||||
InterpreterResult result = hbaseInterpreter.interpret("plot practical joke", null);
|
||||
assertEquals(InterpreterResult.Code.ERROR, result.code());
|
||||
assertEquals("(NameError) undefined local variable or method `joke' for main:Object", result.message());
|
||||
assertEquals("(NameError) undefined local variable or method `joke' for main:Object", result.message().get(0).getData());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -83,7 +83,7 @@ public class IgniteInterpreterTest {
|
|||
"val " + sizeVal + " = ignite.cluster().nodes().size()", INTP_CONTEXT);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertTrue(result.message().contains(sizeVal + ": Int = " + ignite.cluster().nodes().size()));
|
||||
assertTrue(result.message().get(0).getData().contains(sizeVal + ": Int = " + ignite.cluster().nodes().size()));
|
||||
|
||||
result = intp.interpret("\"123\"\n .toInt", INTP_CONTEXT);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
|
|
|
|||
|
|
@ -93,8 +93,8 @@ public class IgniteSqlInterpreterTest {
|
|||
InterpreterResult result = intp.interpret("select name, age from person where age > 10", INTP_CONTEXT);
|
||||
|
||||
assertEquals(Code.SUCCESS, result.code());
|
||||
assertEquals(Type.TABLE, result.type());
|
||||
assertEquals("NAME\tAGE\nsun\t100\nmoon\t50\n", result.message());
|
||||
assertEquals(Type.TABLE, result.message().get(0).getType());
|
||||
assertEquals("NAME\tAGE\nsun\t100\nmoon\t50\n", result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ public class JDBCInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
|
||||
// if prefix not found return ERROR and Prefix not found.
|
||||
assertEquals(InterpreterResult.Code.ERROR, interpreterResult.code());
|
||||
assertEquals("Prefix not found.", interpreterResult.message());
|
||||
assertEquals("Prefix not found.", interpreterResult.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ public class KylinInterpreterTest {
|
|||
InterpreterResult result = t.interpret(
|
||||
"select a.date,sum(b.measure) as measure from kylin_fact_table a " +
|
||||
"inner join kylin_lookup_table b on a.date=b.date group by a.date", null);
|
||||
assertEquals(InterpreterResult.Type.TABLE,result.type());
|
||||
assertEquals(InterpreterResult.Type.TABLE,result.message().get(0).getType());
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ public class LensInterpreterTest {
|
|||
t.open();
|
||||
//simple help test
|
||||
InterpreterResult result = t.interpret("help", null);
|
||||
assertEquals(result.type(), InterpreterResult.Type.TEXT);
|
||||
assertEquals(result.message().get(0).getType(), InterpreterResult.Type.TEXT);
|
||||
//assertEquals("unable to find 'query execute' in help message",
|
||||
// result.message().contains("query execute"), result.message());
|
||||
t.close();
|
||||
|
|
|
|||
|
|
@ -82,14 +82,14 @@ public class LivySparkInterpreter extends Interpreter {
|
|||
if (displayAppInfo) {
|
||||
String appId = extractStatementResult(
|
||||
livyHelper.interpret("sc.applicationId", interpreterContext, userSessionMap)
|
||||
.message());
|
||||
.message().get(0).getData());
|
||||
livyHelper.interpret(
|
||||
"val webui=sc.getClass.getMethod(\"ui\").invoke(sc).asInstanceOf[Some[_]].get",
|
||||
interpreterContext, userSessionMap);
|
||||
String webUI = extractStatementResult(
|
||||
livyHelper.interpret(
|
||||
"webui.getClass.getMethod(\"appUIAddress\").invoke(webui)",
|
||||
interpreterContext, userSessionMap).message());
|
||||
interpreterContext, userSessionMap).message().get(0).getData());
|
||||
sessionId2AppIdMap.put(sessionId, appId);
|
||||
sessionId2WebUIMap.put(sessionId, webUI);
|
||||
LOGGER.info("Create livy session with sessionId: {}, appId: {}, webUI: {}",
|
||||
|
|
|
|||
|
|
@ -85,7 +85,7 @@ public class LivySparkSQLInterpreter extends Interpreter {
|
|||
if (res.code() == InterpreterResult.Code.SUCCESS) {
|
||||
StringBuilder resMsg = new StringBuilder();
|
||||
resMsg.append("%table ");
|
||||
String[] rows = res.message().split("\n");
|
||||
String[] rows = res.message().get(0).getData().split("\n");
|
||||
|
||||
String[] headers = rows[1].split("\\|");
|
||||
for (int head = 1; head < headers.length; head++) {
|
||||
|
|
|
|||
|
|
@ -20,15 +20,13 @@ package org.apache.zeppelin.livy;
|
|||
|
||||
import com.cloudera.livy.test.framework.Cluster;
|
||||
import com.cloudera.livy.test.framework.Cluster$;
|
||||
import org.apache.zeppelin.interpreter.InterpreterContext;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOutput;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOutputListener;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResult;
|
||||
import org.apache.zeppelin.interpreter.*;
|
||||
import org.apache.zeppelin.user.AuthenticationInfo;
|
||||
import org.junit.*;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.Properties;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
|
|
@ -88,13 +86,13 @@ public class LivyIntegrationTest {
|
|||
sparkInterpreter.open();
|
||||
InterpreterResult result = sparkInterpreter.interpret("sc.version", context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
|
||||
// test RDD api
|
||||
outputListener.reset();
|
||||
result = sparkInterpreter.interpret("sc.parallelize(1 to 10).sum()", context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertTrue(outputListener.getOutputAppended().contains("Double = 55.0"));
|
||||
|
||||
// test DataFrame api
|
||||
|
|
@ -104,7 +102,7 @@ public class LivyIntegrationTest {
|
|||
result = sparkInterpreter.interpret("val df=sqlContext.createDataFrame(Seq((\"hello\",20)))\n"
|
||||
+ "df.collect()" , context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertTrue(outputListener.getOutputAppended()
|
||||
.contains("Array[org.apache.spark.sql.Row] = Array([hello,20])"));
|
||||
sparkInterpreter.interpret("df.registerTempTable(\"df\")", context);
|
||||
|
|
@ -115,25 +113,25 @@ public class LivyIntegrationTest {
|
|||
sqlInterpreter.open();
|
||||
result = sqlInterpreter.interpret("select * from df", context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, result.type());
|
||||
assertEquals(InterpreterResult.Type.TABLE, result.message().get(0).getType());
|
||||
// TODO (zjffdu), \t at the end of each line is not necessary, it is a bug of LivySparkSQLInterpreter
|
||||
assertEquals("_1\t_2\t\nhello\t20\t\n", result.message());
|
||||
assertEquals("_1\t_2\t\nhello\t20\t\n", result.message().get(0).getData());
|
||||
|
||||
// single line comment
|
||||
outputListener.reset();
|
||||
String singleLineComment = "// my comment";
|
||||
result = sparkInterpreter.interpret(singleLineComment, context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertNull(result.message());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertNull(result.message().get(0).getData());
|
||||
|
||||
// multiple line comment
|
||||
outputListener.reset();
|
||||
String multipleLineComment = "/* multiple \n" + "line \n" + "comment */";
|
||||
result = sparkInterpreter.interpret(multipleLineComment, context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertNull(result.message());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertNull(result.message().get(0).getData());
|
||||
|
||||
// multi-line string
|
||||
outputListener.reset();
|
||||
|
|
@ -142,8 +140,8 @@ public class LivyIntegrationTest {
|
|||
"println(str)";
|
||||
result = sparkInterpreter.interpret(multiLineString, context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertNull(result.message());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertNull(result.message().get(0).getData());
|
||||
assertTrue(outputListener.getOutputAppended().contains("multiple\nline"));
|
||||
|
||||
// case class
|
||||
|
|
@ -153,8 +151,8 @@ public class LivyIntegrationTest {
|
|||
"val p=Person(1, \"name_a\")";
|
||||
result = sparkInterpreter.interpret(caseClassCode, context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertNull(result.message());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertNull(result.message().get(0).getData());
|
||||
assertTrue(outputListener.getOutputAppended().contains("defined class Person"));
|
||||
|
||||
// object class
|
||||
|
|
@ -162,8 +160,8 @@ public class LivyIntegrationTest {
|
|||
String objectClassCode = "object Person {}";
|
||||
result = sparkInterpreter.interpret(objectClassCode, context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertNull(result.message());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertNull(result.message().get(0).getData());
|
||||
assertTrue(outputListener.getOutputAppended().contains("defined module Person"));
|
||||
}
|
||||
|
||||
|
|
@ -182,14 +180,14 @@ public class LivyIntegrationTest {
|
|||
pysparkInterpreter.open();
|
||||
InterpreterResult result = pysparkInterpreter.interpret("sc.version", context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
|
||||
// test RDD api
|
||||
outputListener.reset();
|
||||
result = pysparkInterpreter.interpret("sc.range(1, 10).sum()", context);
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertEquals("45", result.message());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals("45", result.message().get(0).getData());
|
||||
|
||||
// test DataFrame api
|
||||
outputListener.reset();
|
||||
|
|
@ -198,7 +196,7 @@ public class LivyIntegrationTest {
|
|||
result = pysparkInterpreter.interpret("df=sqlContext.createDataFrame([(\"hello\",20)])\n"
|
||||
+ "df.collect()" , context);
|
||||
assertTrue(result.message().contains("[Row(_1=u'hello', _2=20)]"));
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.type());
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
}
|
||||
|
||||
|
|
@ -215,15 +213,19 @@ public class LivyIntegrationTest {
|
|||
private StringBuilder outputUpdated = new StringBuilder();
|
||||
|
||||
@Override
|
||||
public void onAppend(InterpreterOutput out, byte[] line) {
|
||||
public void onAppend(int index, InterpreterResultMessageOutput out, byte[] line) {
|
||||
LOGGER.info("onAppend:" + new String(line));
|
||||
outputAppended.append(new String(line));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdate(InterpreterOutput out, byte[] output) {
|
||||
LOGGER.info("onUpdate:" + new String(output));
|
||||
outputUpdated.append(new String(output));
|
||||
public void onUpdate(int index, InterpreterResultMessageOutput out) {
|
||||
try {
|
||||
LOGGER.info("onUpdate:" + new String(out.toByteArray()));
|
||||
outputUpdated.append(new String(out.toByteArray()));
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
public String getOutputAppended() {
|
||||
|
|
@ -238,5 +240,15 @@ public class LivyIntegrationTest {
|
|||
outputAppended = new StringBuilder();
|
||||
outputUpdated = new StringBuilder();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onUpdateAll(InterpreterOutput out) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onClose(InterpreterOutput out) {
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -46,6 +46,6 @@ public class Markdown4jParserTest {
|
|||
@Test
|
||||
public void testStrikethrough() {
|
||||
InterpreterResult result = md.interpret("This is ~~deleted~~ text", null);
|
||||
assertEquals("<p>This is <s>deleted</s> text</p>\n", result.message());
|
||||
assertEquals("<p>This is <s>deleted</s> text</p>\n", result.message().get(0).getData());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,42 +52,42 @@ public class PegdownParserTest {
|
|||
@Test
|
||||
public void testHeader() {
|
||||
InterpreterResult r1 = md.interpret("# H1", null);
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h1>H1</h1>"), r1.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h1>H1</h1>"), r1.message().get(0).getData());
|
||||
|
||||
InterpreterResult r2 = md.interpret("## H2", null);
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h2>H2</h2>"), r2.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h2>H2</h2>"), r2.message().get(0).getData());
|
||||
|
||||
InterpreterResult r3 = md.interpret("### H3", null);
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h3>H3</h3>"), r3.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h3>H3</h3>"), r3.message().get(0).getData());
|
||||
|
||||
InterpreterResult r4 = md.interpret("#### H4", null);
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h4>H4</h4>"), r4.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h4>H4</h4>"), r4.message().get(0).getData());
|
||||
|
||||
InterpreterResult r5 = md.interpret("##### H5", null);
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h5>H5</h5>"), r5.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h5>H5</h5>"), r5.message().get(0).getData());
|
||||
|
||||
InterpreterResult r6 = md.interpret("###### H6", null);
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h6>H6</h6>"), r6.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h6>H6</h6>"), r6.message().get(0).getData());
|
||||
|
||||
InterpreterResult r7 = md.interpret("Alt-H1\n" + "======", null);
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h1>Alt-H1</h1>"), r7.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h1>Alt-H1</h1>"), r7.message().get(0).getData());
|
||||
|
||||
InterpreterResult r8 = md.interpret("Alt-H2\n" + "------", null);
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h2>Alt-H2</h2>"), r8.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv("<h2>Alt-H2</h2>"), r8.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testStrikethrough() {
|
||||
InterpreterResult result = md.interpret("This is ~~deleted~~ text", null);
|
||||
assertEquals(
|
||||
wrapWithMarkdownClassDiv("<p>This is <del>deleted</del> text</p>"), result.message());
|
||||
wrapWithMarkdownClassDiv("<p>This is <del>deleted</del> text</p>"), result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testItalics() {
|
||||
InterpreterResult result = md.interpret("This is *italics* text", null);
|
||||
assertEquals(
|
||||
wrapWithMarkdownClassDiv("<p>This is <em>italics</em> text</p>"), result.message());
|
||||
wrapWithMarkdownClassDiv("<p>This is <em>italics</em> text</p>"), result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -95,7 +95,7 @@ public class PegdownParserTest {
|
|||
InterpreterResult result = md.interpret("This is **strong emphasis** text", null);
|
||||
assertEquals(
|
||||
wrapWithMarkdownClassDiv("<p>This is <strong>strong emphasis</strong> text</p>"),
|
||||
result.message());
|
||||
result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -115,7 +115,7 @@ public class PegdownParserTest {
|
|||
.toString();
|
||||
|
||||
InterpreterResult result = md.interpret(input, null);
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -137,7 +137,7 @@ public class PegdownParserTest {
|
|||
.toString();
|
||||
|
||||
InterpreterResult result = md.interpret(input, null);
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -188,7 +188,7 @@ public class PegdownParserTest {
|
|||
.toString();
|
||||
|
||||
InterpreterResult result = md.interpret(input, null);
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -197,7 +197,7 @@ public class PegdownParserTest {
|
|||
assertEquals(
|
||||
wrapWithMarkdownClassDiv(
|
||||
"<p>Inline <code>code</code> has <code>back-ticks around</code> it.</p>"),
|
||||
result.message());
|
||||
result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -212,7 +212,7 @@ public class PegdownParserTest {
|
|||
"<blockquote>\n"
|
||||
+ " <p>Blockquotes are very handy in email to emulate reply text.<br/>This line is part of the same quote.</p>\n"
|
||||
+ "</blockquote>"),
|
||||
r1.message());
|
||||
r1.message().get(0).getData());
|
||||
|
||||
InterpreterResult r2 =
|
||||
md.interpret(
|
||||
|
|
@ -223,7 +223,7 @@ public class PegdownParserTest {
|
|||
"<blockquote>\n"
|
||||
+ " <p>This is a very long line that will still be quoted properly when it wraps. Oh boy let’s keep writing to make sure this is long enough to actually wrap for everyone. Oh, you can <em>put</em> <strong>MarkdownInterpreter</strong> into a blockquote. </p>\n"
|
||||
+ "</blockquote>"),
|
||||
r2.message());
|
||||
r2.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -262,7 +262,7 @@ public class PegdownParserTest {
|
|||
.toString();
|
||||
|
||||
InterpreterResult result = md.interpret(input, null);
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -301,7 +301,7 @@ public class PegdownParserTest {
|
|||
.toString();
|
||||
|
||||
InterpreterResult result = md.interpret(input, null);
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message());
|
||||
assertEquals(wrapWithMarkdownClassDiv(expected), result.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -317,7 +317,7 @@ public class PegdownParserTest {
|
|||
.toString();
|
||||
|
||||
InterpreterResult result = md.interpret(input, null);
|
||||
assertThat(result.message(), CoreMatchers.containsString("<img src=\"http://www.websequencediagrams.com/?png="));
|
||||
assertThat(result.message().get(0).getData(), CoreMatchers.containsString("<img src=\"http://www.websequencediagrams.com/?png="));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -331,6 +331,6 @@ public class PegdownParserTest {
|
|||
.toString();
|
||||
|
||||
InterpreterResult result = md.interpret(input, null);
|
||||
assertThat(result.message(), CoreMatchers.containsString("<img src=\"http://yuml.me/diagram/"));
|
||||
assertThat(result.message().get(0).getData(), CoreMatchers.containsString("<img src=\"http://yuml.me/diagram/"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,27 +4,36 @@
|
|||
"text": "%md\n## Welcome to Zeppelin.\n##### This is a live tutorial, you can run the code yourself. (Shift-Enter to Run)",
|
||||
"config": {
|
||||
"colWidth": 12.0,
|
||||
"graph": {
|
||||
"mode": "table",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [],
|
||||
"values": [],
|
||||
"groups": [],
|
||||
"scatter": {}
|
||||
},
|
||||
"editorHide": true
|
||||
"editorHide": true,
|
||||
"result": [
|
||||
{
|
||||
"graph": {
|
||||
"mode": "table",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [],
|
||||
"values": [],
|
||||
"groups": [],
|
||||
"scatter": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"params": {},
|
||||
"forms": {}
|
||||
},
|
||||
"apps": [],
|
||||
"jobName": "paragraph_1423836981412_-1007008116",
|
||||
"id": "20150213-231621_168813393",
|
||||
"result": {
|
||||
"code": "SUCCESS",
|
||||
"type": "HTML",
|
||||
"msg": "\u003ch2\u003eWelcome to Zeppelin.\u003c/h2\u003e\n\u003ch5\u003eThis is a live tutorial, you can run the code yourself. (Shift-Enter to Run)\u003c/h5\u003e\n"
|
||||
"msg": [
|
||||
{
|
||||
"type": "HTML",
|
||||
"data": "\u003ch2\u003eWelcome to Zeppelin.\u003c/h2\u003e\n\u003ch5\u003eThis is a live tutorial, you can run the code yourself. (Shift-Enter to Run)\u003c/h5\u003e\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dateCreated": "Feb 13, 2015 11:16:21 PM",
|
||||
"dateStarted": "Apr 1, 2015 9:11:09 PM",
|
||||
|
|
@ -35,86 +44,109 @@
|
|||
{
|
||||
"title": "Load data into table",
|
||||
"text": "import org.apache.commons.io.IOUtils\nimport java.net.URL\nimport java.nio.charset.Charset\n\n// Zeppelin creates and injects sc (SparkContext) and sqlContext (HiveContext or SqlContext)\n// So you don\u0027t need create them manually\n\n// load bank data\nval bankText \u003d sc.parallelize(\n IOUtils.toString(\n new URL(\"https://s3.amazonaws.com/apache-zeppelin/tutorial/bank/bank.csv\"),\n Charset.forName(\"utf8\")).split(\"\\n\"))\n\ncase class Bank(age: Integer, job: String, marital: String, education: String, balance: Integer)\n\nval bank \u003d bankText.map(s \u003d\u003e s.split(\";\")).filter(s \u003d\u003e s(0) !\u003d \"\\\"age\\\"\").map(\n s \u003d\u003e Bank(s(0).toInt, \n s(1).replaceAll(\"\\\"\", \"\"),\n s(2).replaceAll(\"\\\"\", \"\"),\n s(3).replaceAll(\"\\\"\", \"\"),\n s(5).replaceAll(\"\\\"\", \"\").toInt\n )\n).toDF()\nbank.registerTempTable(\"bank\")",
|
||||
"dateUpdated": "Jan 14, 2016 7:58:56 PM",
|
||||
"user": "anonymous",
|
||||
"dateUpdated": "Nov 19, 2016 12:42:20 PM",
|
||||
"config": {
|
||||
"colWidth": 12.0,
|
||||
"graph": {
|
||||
"mode": "table",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [],
|
||||
"values": [],
|
||||
"groups": [],
|
||||
"scatter": {}
|
||||
},
|
||||
"title": true,
|
||||
"enabled": true,
|
||||
"editorMode": "ace/mode/scala"
|
||||
"editorMode": "ace/mode/scala",
|
||||
"result": [
|
||||
{
|
||||
"graph": {
|
||||
"mode": "table",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [],
|
||||
"values": [],
|
||||
"groups": [],
|
||||
"scatter": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"params": {},
|
||||
"forms": {}
|
||||
},
|
||||
"apps": [],
|
||||
"jobName": "paragraph_1423500779206_-1502780787",
|
||||
"id": "20150210-015259_1403135953",
|
||||
"result": {
|
||||
"code": "SUCCESS",
|
||||
"type": "TEXT",
|
||||
"msg": "import org.apache.commons.io.IOUtils\nimport java.net.URL\nimport java.nio.charset.Charset\nbankText: org.apache.spark.rdd.RDD[String] \u003d ParallelCollectionRDD[32] at parallelize at \u003cconsole\u003e:65\ndefined class Bank\nbank: org.apache.spark.sql.DataFrame \u003d [age: int, job: string, marital: string, education: string, balance: int]\n"
|
||||
"msg": [
|
||||
{
|
||||
"type": "TEXT",
|
||||
"data": "\nimport org.apache.commons.io.IOUtils\n\nimport java.net.URL\n\nimport java.nio.charset.Charset\n\nbankText: org.apache.spark.rdd.RDD[String] \u003d ParallelCollectionRDD[0] at parallelize at \u003cconsole\u003e:32\n\ndefined class Bank\n\nbank: org.apache.spark.sql.DataFrame \u003d [age: int, job: string, marital: string, education: string, balance: int]\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dateCreated": "Feb 10, 2015 1:52:59 AM",
|
||||
"dateStarted": "Jul 3, 2015 1:43:40 PM",
|
||||
"dateFinished": "Jul 3, 2015 1:43:45 PM",
|
||||
"dateStarted": "Nov 19, 2016 12:42:20 PM",
|
||||
"dateFinished": "Nov 19, 2016 12:42:31 PM",
|
||||
"status": "FINISHED",
|
||||
"progressUpdateIntervalMs": 500
|
||||
},
|
||||
{
|
||||
"text": "%sql \nselect age, count(1) value\nfrom bank \nwhere age \u003c 30 \ngroup by age \norder by age",
|
||||
"dateUpdated": "Nov 19, 2016 12:42:14 PM",
|
||||
"config": {
|
||||
"colWidth": 4.0,
|
||||
"graph": {
|
||||
"mode": "multiBarChart",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [
|
||||
{
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"values": [
|
||||
{
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"groups": [],
|
||||
"scatter": {
|
||||
"xAxis": {
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
"result": [
|
||||
{
|
||||
"graph": {
|
||||
"mode": "multiBarChart",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [
|
||||
{
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"values": [
|
||||
{
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"groups": [],
|
||||
"scatter": {
|
||||
"xAxis": {
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
},
|
||||
"yAxis": {
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
}
|
||||
},
|
||||
"yAxis": {
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
"helium": {}
|
||||
}
|
||||
}
|
||||
],
|
||||
"enabled": true,
|
||||
"editorMode": "ace/mode/sql"
|
||||
},
|
||||
"settings": {
|
||||
"params": {},
|
||||
"forms": {}
|
||||
},
|
||||
"apps": [],
|
||||
"jobName": "paragraph_1423500782552_-1439281894",
|
||||
"id": "20150210-015302_1492795503",
|
||||
"result": {
|
||||
"code": "SUCCESS",
|
||||
"type": "TABLE",
|
||||
"msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t20\n24\t24\n25\t44\n26\t77\n27\t94\n28\t103\n29\t97\n"
|
||||
"msg": [
|
||||
{
|
||||
"type": "TABLE",
|
||||
"data": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t20\n24\t24\n25\t44\n26\t77\n27\t94\n28\t103\n29\t97\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dateCreated": "Feb 10, 2015 1:53:02 AM",
|
||||
"dateStarted": "Jul 3, 2015 1:43:17 PM",
|
||||
|
|
@ -124,44 +156,51 @@
|
|||
},
|
||||
{
|
||||
"text": "%sql \nselect age, count(1) value \nfrom bank \nwhere age \u003c ${maxAge\u003d30} \ngroup by age \norder by age",
|
||||
"user": "anonymous",
|
||||
"dateUpdated": "Nov 19, 2016 12:42:52 PM",
|
||||
"config": {
|
||||
"colWidth": 4.0,
|
||||
"graph": {
|
||||
"mode": "multiBarChart",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [
|
||||
{
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"values": [
|
||||
{
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"groups": [],
|
||||
"scatter": {
|
||||
"xAxis": {
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
},
|
||||
"yAxis": {
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
"result": [
|
||||
{
|
||||
"graph": {
|
||||
"mode": "multiBarChart",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [
|
||||
{
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"values": [
|
||||
{
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"groups": [],
|
||||
"scatter": {
|
||||
"xAxis": {
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
},
|
||||
"yAxis": {
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
],
|
||||
"enabled": true
|
||||
},
|
||||
"settings": {
|
||||
"params": {
|
||||
"maxAge": "35"
|
||||
"maxAge": "20"
|
||||
},
|
||||
"forms": {
|
||||
"maxAge": {
|
||||
|
|
@ -171,16 +210,21 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"apps": [],
|
||||
"jobName": "paragraph_1423720444030_-1424110477",
|
||||
"id": "20150212-145404_867439529",
|
||||
"result": {
|
||||
"code": "SUCCESS",
|
||||
"type": "TABLE",
|
||||
"msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t20\n24\t24\n25\t44\n26\t77\n27\t94\n28\t103\n29\t97\n30\t150\n31\t199\n32\t224\n33\t186\n34\t231\n"
|
||||
"msg": [
|
||||
{
|
||||
"type": "TABLE",
|
||||
"data": "age\tvalue\n19\t4\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dateCreated": "Feb 12, 2015 2:54:04 PM",
|
||||
"dateStarted": "Jul 3, 2015 1:43:28 PM",
|
||||
"dateFinished": "Jul 3, 2015 1:43:29 PM",
|
||||
"dateStarted": "Nov 19, 2016 12:42:52 PM",
|
||||
"dateFinished": "Nov 19, 2016 12:42:54 PM",
|
||||
"status": "FINISHED",
|
||||
"progressUpdateIntervalMs": 500
|
||||
},
|
||||
|
|
@ -188,38 +232,42 @@
|
|||
"text": "%sql \nselect age, count(1) value \nfrom bank \nwhere marital\u003d\"${marital\u003dsingle,single|divorced|married}\" \ngroup by age \norder by age",
|
||||
"config": {
|
||||
"colWidth": 4.0,
|
||||
"graph": {
|
||||
"mode": "multiBarChart",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [
|
||||
{
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"values": [
|
||||
{
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"groups": [],
|
||||
"scatter": {
|
||||
"xAxis": {
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
},
|
||||
"yAxis": {
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
"result": [
|
||||
{
|
||||
"graph": {
|
||||
"mode": "multiBarChart",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [
|
||||
{
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"values": [
|
||||
{
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
],
|
||||
"groups": [],
|
||||
"scatter": {
|
||||
"xAxis": {
|
||||
"name": "age",
|
||||
"index": 0.0,
|
||||
"aggr": "sum"
|
||||
},
|
||||
"yAxis": {
|
||||
"name": "value",
|
||||
"index": 1.0,
|
||||
"aggr": "sum"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"params": {
|
||||
|
|
@ -244,12 +292,17 @@
|
|||
}
|
||||
}
|
||||
},
|
||||
"apps": [],
|
||||
"jobName": "paragraph_1423836262027_-210588283",
|
||||
"id": "20150213-230422_1600658137",
|
||||
"result": {
|
||||
"code": "SUCCESS",
|
||||
"type": "TABLE",
|
||||
"msg": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t17\n24\t13\n25\t33\n26\t56\n27\t64\n28\t78\n29\t56\n30\t92\n31\t86\n32\t105\n33\t61\n34\t75\n35\t46\n36\t50\n37\t43\n38\t44\n39\t30\n40\t25\n41\t19\n42\t23\n43\t21\n44\t20\n45\t15\n46\t14\n47\t12\n48\t12\n49\t11\n50\t8\n51\t6\n52\t9\n53\t4\n55\t3\n56\t3\n57\t2\n58\t7\n59\t2\n60\t5\n66\t2\n69\t1\n"
|
||||
"msg": [
|
||||
{
|
||||
"type": "TABLE",
|
||||
"data": "age\tvalue\n19\t4\n20\t3\n21\t7\n22\t9\n23\t17\n24\t13\n25\t33\n26\t56\n27\t64\n28\t78\n29\t56\n30\t92\n31\t86\n32\t105\n33\t61\n34\t75\n35\t46\n36\t50\n37\t43\n38\t44\n39\t30\n40\t25\n41\t19\n42\t23\n43\t21\n44\t20\n45\t15\n46\t14\n47\t12\n48\t12\n49\t11\n50\t8\n51\t6\n52\t9\n53\t4\n55\t3\n56\t3\n57\t2\n58\t7\n59\t2\n60\t5\n66\t2\n69\t1\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dateCreated": "Feb 13, 2015 11:04:22 PM",
|
||||
"dateStarted": "Jul 3, 2015 1:43:33 PM",
|
||||
|
|
@ -261,27 +314,36 @@
|
|||
"text": "%md\n## Congratulations, it\u0027s done.\n##### You can create your own notebook in \u0027Notebook\u0027 menu. Good luck!",
|
||||
"config": {
|
||||
"colWidth": 12.0,
|
||||
"graph": {
|
||||
"mode": "table",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [],
|
||||
"values": [],
|
||||
"groups": [],
|
||||
"scatter": {}
|
||||
},
|
||||
"editorHide": true
|
||||
"editorHide": true,
|
||||
"result": [
|
||||
{
|
||||
"graph": {
|
||||
"mode": "table",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [],
|
||||
"values": [],
|
||||
"groups": [],
|
||||
"scatter": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"params": {},
|
||||
"forms": {}
|
||||
},
|
||||
"apps": [],
|
||||
"jobName": "paragraph_1423836268492_216498320",
|
||||
"id": "20150213-230428_1231780373",
|
||||
"result": {
|
||||
"code": "SUCCESS",
|
||||
"type": "HTML",
|
||||
"msg": "\u003ch2\u003eCongratulations, it\u0027s done.\u003c/h2\u003e\n\u003ch5\u003eYou can create your own notebook in \u0027Notebook\u0027 menu. Good luck!\u003c/h5\u003e\n"
|
||||
"msg": [
|
||||
{
|
||||
"type": "HTML",
|
||||
"data": "\u003ch2\u003eCongratulations, it\u0027s done.\u003c/h2\u003e\n\u003ch5\u003eYou can create your own notebook in \u0027Notebook\u0027 menu. Good luck!\u003c/h5\u003e\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dateCreated": "Feb 13, 2015 11:04:28 PM",
|
||||
"dateStarted": "Apr 1, 2015 9:12:18 PM",
|
||||
|
|
@ -291,6 +353,48 @@
|
|||
},
|
||||
{
|
||||
"text": "%md\n\nAbout bank data\n\n```\nCitation Request:\n This dataset is public available for research. The details are described in [Moro et al., 2011]. \n Please include this citation if you plan to use this database:\n\n [Moro et al., 2011] S. Moro, R. Laureano and P. Cortez. Using Data Mining for Bank Direct Marketing: An Application of the CRISP-DM Methodology. \n In P. Novais et al. (Eds.), Proceedings of the European Simulation and Modelling Conference - ESM\u00272011, pp. 117-121, Guimarães, Portugal, October, 2011. EUROSIS.\n\n Available at: [pdf] http://hdl.handle.net/1822/14838\n [bib] http://www3.dsi.uminho.pt/pcortez/bib/2011-esm-1.txt\n```",
|
||||
"config": {
|
||||
"colWidth": 12.0,
|
||||
"editorHide": true,
|
||||
"result": [
|
||||
{
|
||||
"graph": {
|
||||
"mode": "table",
|
||||
"height": 300.0,
|
||||
"optionOpen": false,
|
||||
"keys": [],
|
||||
"values": [],
|
||||
"groups": [],
|
||||
"scatter": {}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
"settings": {
|
||||
"params": {},
|
||||
"forms": {}
|
||||
},
|
||||
"apps": [],
|
||||
"jobName": "paragraph_1427420818407_872443482",
|
||||
"id": "20150326-214658_12335843",
|
||||
"result": {
|
||||
"code": "SUCCESS",
|
||||
"msg": [
|
||||
{
|
||||
"type": "HTML",
|
||||
"data": "\u003cp\u003eAbout bank data\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eCitation Request:\n This dataset is public available for research. The details are described in [Moro et al., 2011]. \n Please include this citation if you plan to use this database:\n\n [Moro et al., 2011] S. Moro, R. Laureano and P. Cortez. Using Data Mining for Bank Direct Marketing: An Application of the CRISP-DM Methodology. \n In P. Novais et al. (Eds.), Proceedings of the European Simulation and Modelling Conference - ESM\u00272011, pp. 117-121, Guimarães, Portugal, October, 2011. EUROSIS.\n\n Available at: [pdf] http://hdl.handle.net/1822/14838\n [bib] http://www3.dsi.uminho.pt/pcortez/bib/2011-esm-1.txt\n\u003c/code\u003e\u003c/pre\u003e\n"
|
||||
}
|
||||
]
|
||||
},
|
||||
"dateCreated": "Mar 26, 2015 9:46:58 PM",
|
||||
"dateStarted": "Jul 3, 2015 1:44:56 PM",
|
||||
"dateFinished": "Jul 3, 2015 1:44:56 PM",
|
||||
"status": "FINISHED",
|
||||
"progressUpdateIntervalMs": 500
|
||||
},
|
||||
{
|
||||
"text": "",
|
||||
"dateUpdated": "Nov 18, 2016 10:38:40 AM",
|
||||
"config": {
|
||||
"colWidth": 12.0,
|
||||
"graph": {
|
||||
|
|
@ -302,31 +406,13 @@
|
|||
"groups": [],
|
||||
"scatter": {}
|
||||
},
|
||||
"editorHide": true
|
||||
"enabled": true
|
||||
},
|
||||
"settings": {
|
||||
"params": {},
|
||||
"forms": {}
|
||||
},
|
||||
"jobName": "paragraph_1427420818407_872443482",
|
||||
"id": "20150326-214658_12335843",
|
||||
"result": {
|
||||
"code": "SUCCESS",
|
||||
"type": "HTML",
|
||||
"msg": "\u003cp\u003eAbout bank data\u003c/p\u003e\n\u003cpre\u003e\u003ccode\u003eCitation Request:\n This dataset is public available for research. The details are described in [Moro et al., 2011]. \n Please include this citation if you plan to use this database:\n\n [Moro et al., 2011] S. Moro, R. Laureano and P. Cortez. Using Data Mining for Bank Direct Marketing: An Application of the CRISP-DM Methodology. \n In P. Novais et al. (Eds.), Proceedings of the European Simulation and Modelling Conference - ESM\u00272011, pp. 117-121, Guimarães, Portugal, October, 2011. EUROSIS.\n\n Available at: [pdf] http://hdl.handle.net/1822/14838\n [bib] http://www3.dsi.uminho.pt/pcortez/bib/2011-esm-1.txt\n\u003c/code\u003e\u003c/pre\u003e\n"
|
||||
},
|
||||
"dateCreated": "Mar 26, 2015 9:46:58 PM",
|
||||
"dateStarted": "Jul 3, 2015 1:44:56 PM",
|
||||
"dateFinished": "Jul 3, 2015 1:44:56 PM",
|
||||
"status": "FINISHED",
|
||||
"progressUpdateIntervalMs": 500
|
||||
},
|
||||
{
|
||||
"config": {},
|
||||
"settings": {
|
||||
"params": {},
|
||||
"forms": {}
|
||||
},
|
||||
"apps": [],
|
||||
"jobName": "paragraph_1435955447812_-158639899",
|
||||
"id": "20150703-133047_853701097",
|
||||
"dateCreated": "Jul 3, 2015 1:30:47 PM",
|
||||
|
|
@ -337,8 +423,13 @@
|
|||
"name": "Zeppelin Tutorial",
|
||||
"id": "2A94M5J1Z",
|
||||
"angularObjects": {
|
||||
"2B6FF8NNU": [],
|
||||
"2B67PH63Z": []
|
||||
"2C2HP46V7:shared_process": [],
|
||||
"2BZZJUTXD:shared_process": [],
|
||||
"2C4BVUQWR:shared_process": [],
|
||||
"2C1NK2MA7:shared_process": [],
|
||||
"2C4JD4YJF:shared_process": [],
|
||||
"2C2WKHN8Y:shared_process": [],
|
||||
"2C33QX1Z6:shared_process": []
|
||||
},
|
||||
"config": {
|
||||
"looknfeel": "default"
|
||||
|
|
|
|||
|
|
@ -69,33 +69,33 @@ public class PigInterpreterTest {
|
|||
String pigscript = "a = load '" + tmpFile.getAbsolutePath() + "';"
|
||||
+ "dump a;";
|
||||
InterpreterResult result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(Type.TEXT, result.type());
|
||||
assertEquals(Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(Code.SUCCESS, result.code());
|
||||
assertTrue(result.message().contains("(1,andy)\n(2,peter)"));
|
||||
assertTrue(result.message().get(0).getData().contains("(1,andy)\n(2,peter)"));
|
||||
|
||||
// describe
|
||||
pigscript = "a = load '" + tmpFile.getAbsolutePath() + "' as (id: int, name: bytearray);"
|
||||
+ "describe a;";
|
||||
result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(Type.TEXT, result.type());
|
||||
assertEquals(Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(Code.SUCCESS, result.code());
|
||||
assertTrue(result.message().contains("a: {id: int,name: bytearray}"));
|
||||
assertTrue(result.message().get(0).getData().contains("a: {id: int,name: bytearray}"));
|
||||
|
||||
// syntax error (compilation error)
|
||||
pigscript = "a = loa '" + tmpFile.getAbsolutePath() + "';"
|
||||
+ "describe a;";
|
||||
result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(Type.TEXT, result.type());
|
||||
assertEquals(Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(Code.ERROR, result.code());
|
||||
assertTrue(result.message().contains("Syntax error, unexpected symbol at or near 'a'"));
|
||||
assertTrue(result.message().get(0).getData().contains("Syntax error, unexpected symbol at or near 'a'"));
|
||||
|
||||
// execution error
|
||||
pigscript = "a = load 'invalid_path';"
|
||||
+ "dump a;";
|
||||
result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(Type.TEXT, result.type());
|
||||
assertEquals(Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(Code.ERROR, result.code());
|
||||
assertTrue(result.message().contains("Input path does not exist"));
|
||||
assertTrue(result.message().get(0).getData().contains("Input path does not exist"));
|
||||
}
|
||||
|
||||
|
||||
|
|
@ -118,38 +118,38 @@ public class PigInterpreterTest {
|
|||
String pigscript = "a = load '" + tmpFile.getAbsolutePath() + "';"
|
||||
+ "dump a;";
|
||||
InterpreterResult result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(Type.TEXT, result.type());
|
||||
assertEquals(Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(Code.SUCCESS, result.code());
|
||||
assertTrue(result.message().contains("Counters:"));
|
||||
assertTrue(result.message().contains("(1,andy)\n(2,peter)"));
|
||||
assertTrue(result.message().get(0).getData().contains("Counters:"));
|
||||
assertTrue(result.message().get(0).getData().contains("(1,andy)\n(2,peter)"));
|
||||
|
||||
// describe
|
||||
pigscript = "a = load '" + tmpFile.getAbsolutePath() + "' as (id: int, name: bytearray);"
|
||||
+ "describe a;";
|
||||
result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(Type.TEXT, result.type());
|
||||
assertEquals(Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(Code.SUCCESS, result.code());
|
||||
// no job is launched, so no jobStats
|
||||
assertTrue(!result.message().contains("Counters:"));
|
||||
assertTrue(result.message().contains("a: {id: int,name: bytearray}"));
|
||||
assertTrue(!result.message().get(0).getData().contains("Counters:"));
|
||||
assertTrue(result.message().get(0).getData().contains("a: {id: int,name: bytearray}"));
|
||||
|
||||
// syntax error (compilation error)
|
||||
pigscript = "a = loa '" + tmpFile.getAbsolutePath() + "';"
|
||||
+ "describe a;";
|
||||
result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(Type.TEXT, result.type());
|
||||
assertEquals(Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(Code.ERROR, result.code());
|
||||
// no job is launched, so no jobStats
|
||||
assertTrue(!result.message().contains("Counters:"));
|
||||
assertTrue(result.message().contains("Syntax error, unexpected symbol at or near 'a'"));
|
||||
assertTrue(!result.message().get(0).getData().contains("Counters:"));
|
||||
assertTrue(result.message().get(0).getData().contains("Syntax error, unexpected symbol at or near 'a'"));
|
||||
|
||||
// execution error
|
||||
pigscript = "a = load 'invalid_path';"
|
||||
+ "dump a;";
|
||||
result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(Type.TEXT, result.type());
|
||||
assertEquals(Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(Code.ERROR, result.code());
|
||||
assertTrue(result.message().contains("Counters:"));
|
||||
assertTrue(result.message().contains("Input path does not exist"));
|
||||
assertTrue(result.message().get(0).getData().contains("Counters:"));
|
||||
assertTrue(result.message().get(0).getData().contains("Input path does not exist"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -137,10 +137,8 @@ public class PigQueryInterpreterTest {
|
|||
// run script in PigInterpreter
|
||||
String pigscript = "a = load '" + tmpFile.getAbsolutePath() + "' as (id, name);";
|
||||
InterpreterResult result = pigInterpreter.interpret(pigscript, context);
|
||||
assertEquals(InterpreterResult.Type.TEXT, result.message().get(0).getType());
|
||||
assertEquals(0, result.message().size());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, result.code());
|
||||
// empty output
|
||||
assertTrue(result.message().isEmpty());
|
||||
|
||||
// run single line query in PigQueryInterpreter
|
||||
String query = "foreach a generate id;";
|
||||
|
|
|
|||
|
|
@ -140,8 +140,8 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
|
||||
assertEquals("col1\tcol2\nval11\t\n\tval22\n", interpreterResult.message());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.message().get(0).getType());
|
||||
assertEquals("col1\tcol2\nval11\t\n\tval22\n", interpreterResult.message().get(0).getData());
|
||||
|
||||
verifySQLStatementExecuted(sqlQuery);
|
||||
verifyAllResultSetsClosed();
|
||||
|
|
@ -161,8 +161,8 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
|
||||
assertEquals("col1\tcol2\nval11\tval21\nval12\tval22\n", interpreterResult.message());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.message().get(0).getType());
|
||||
assertEquals("col1\tcol2\nval11\tval21\nval12\tval22\n", interpreterResult.message().get(0).getData());
|
||||
|
||||
verifySQLStatementExecuted(sqlQuery);
|
||||
verifyAllResultSetsClosed();
|
||||
|
|
@ -182,8 +182,8 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
|
||||
assertEquals("col1\tcol2\nval11\tval21\n", interpreterResult.message());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.message().get(0).getType());
|
||||
assertEquals("col1\tcol2\nval11\tval21\n", interpreterResult.message().get(0).getData());
|
||||
|
||||
verifySQLStatementExecuted(sqlQuery);
|
||||
verifyAllResultSetsClosed();
|
||||
|
|
@ -203,8 +203,8 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.type());
|
||||
assertEquals("co l1\tco l2\nval11\tv al21\nva l1 2\tval 22\n", interpreterResult.message());
|
||||
assertEquals(InterpreterResult.Type.TABLE, interpreterResult.message().get(0).getType());
|
||||
assertEquals("co l1\tco l2\nval11\tv al21\nva l1 2\tval 22\n", interpreterResult.message().get(0).getData());
|
||||
|
||||
verifySQLStatementExecuted(sqlQuery);
|
||||
verifyAllResultSetsClosed();
|
||||
|
|
@ -223,8 +223,8 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, interpreterResult.type());
|
||||
assertEquals("col1\nval11\nval12\n", interpreterResult.message());
|
||||
assertEquals(InterpreterResult.Type.TEXT, interpreterResult.message().get(0).getType());
|
||||
assertEquals("col1\nval11\nval12\n", interpreterResult.message().get(0).getData());
|
||||
|
||||
verifySQLStatementExecuted(sqlQuery);
|
||||
verifyAllResultSetsClosed();
|
||||
|
|
@ -243,8 +243,8 @@ public class PostgreSqlInterpreterTest extends BasicJDBCTestCaseAdapter {
|
|||
InterpreterResult interpreterResult = psqlInterpreter.interpret(sqlQuery, null);
|
||||
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, interpreterResult.code());
|
||||
assertEquals(InterpreterResult.Type.TEXT, interpreterResult.type());
|
||||
assertEquals("co\tl\n1\nva\nl11\nva\tl\n12\n", interpreterResult.message());
|
||||
assertEquals(InterpreterResult.Type.TEXT, interpreterResult.message().get(0).getType());
|
||||
assertEquals("co\tl\n1\nva\nl11\nva\tl\n12\n", interpreterResult.message().get(0).getData());
|
||||
|
||||
verifySQLStatementExecuted(sqlQuery);
|
||||
verifyAllResultSetsClosed();
|
||||
|
|
|
|||
|
|
@ -153,13 +153,13 @@ public class PythonInterpreterMatplotlibTest {
|
|||
ret = python.interpret("plt.show()", context);
|
||||
assertEquals(ret.message().get(0).getData(), InterpreterResult.Code.SUCCESS, ret.code());
|
||||
assertEquals(ret.message().get(0).getData(), Type.HTML, ret.message().get(0).getType());
|
||||
assertTrue(ret.message().equals(""));
|
||||
assertTrue(ret.message().get(0).getData().equals(""));
|
||||
|
||||
// Now test that plot can be reshown if it is updated. It should be
|
||||
// different from the previous one because it will plot the same line
|
||||
// again but in a different color.
|
||||
ret = python.interpret("plt.plot([1, 2, 3])", context);
|
||||
ret2 = python.interpret("plt.show()", context);
|
||||
assertTrue(!ret1.message().equals(ret2.message()));
|
||||
assertTrue(!ret1.message().get(0).getData().equals(ret2.message().get(0).getData()));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -92,7 +92,7 @@ public class PythonInterpreterWithPythonInstalledTest {
|
|||
//then
|
||||
//System.out.println("\nInterpreter response: \n" + ret.message());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, ret1.code());
|
||||
assertEquals("...\n", ret1.message());
|
||||
assertEquals("...\n", ret1.message().get(0).getData());
|
||||
|
||||
|
||||
InterpreterResult ret2 = realPython.interpret("for i in range(5):", null);
|
||||
|
|
@ -102,7 +102,7 @@ public class PythonInterpreterWithPythonInstalledTest {
|
|||
assertEquals(" File \"<stdin>\", line 2\n" +
|
||||
" \n" +
|
||||
" ^\n" +
|
||||
"IndentationError: expected an indented block\n", ret2.message());
|
||||
"IndentationError: expected an indented block\n", ret2.message().get(0).getData());
|
||||
|
||||
realPython.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ public class ScaldingInterpreterTest {
|
|||
// when interpret incomplete expression
|
||||
InterpreterResult incomplete = repl.interpret("val a = \"\"\"", context);
|
||||
assertEquals(InterpreterResult.Code.INCOMPLETE, incomplete.code());
|
||||
assertTrue(incomplete.message().length() > 0); // expecting some error
|
||||
assertTrue(incomplete.message().get(0).getData().length() > 0); // expecting some error
|
||||
// message
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -47,12 +47,7 @@ public class ScioInterpreterTest {
|
|||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
new LocalResourcePool("id"),
|
||||
new LinkedList<InterpreterContextRunner>(),
|
||||
new InterpreterOutput(new InterpreterOutputListener() {
|
||||
@Override
|
||||
public void onAppend(InterpreterOutput out, byte[] line) {}
|
||||
@Override
|
||||
public void onUpdate(InterpreterOutput out, byte[] output) {}
|
||||
}));
|
||||
new InterpreterOutput(null));
|
||||
}
|
||||
|
||||
@Before
|
||||
|
|
@ -79,14 +74,14 @@ public class ScioInterpreterTest {
|
|||
public void testBasicSyntaxError() {
|
||||
InterpreterResult error = repl.interpret("val a:Int = 'ds'", context);
|
||||
assertEquals(InterpreterResult.Code.ERROR, error.code());
|
||||
assertEquals("Interpreter error", error.message());
|
||||
assertEquals("Interpreter error", error.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testBasicIncomplete() {
|
||||
InterpreterResult incomplete = repl.interpret("val a = \"\"\"", context);
|
||||
assertEquals(InterpreterResult.Code.INCOMPLETE, incomplete.code());
|
||||
assertEquals("Incomplete expression", incomplete.message());
|
||||
assertEquals("Incomplete expression", incomplete.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -112,7 +107,7 @@ public class ScioInterpreterTest {
|
|||
InterpreterResult exception = repl.interpret("val (sc, _) = ContextAndArgs(argz)" + newline
|
||||
+ "throw new Exception(\"test\")", context);
|
||||
assertEquals(InterpreterResult.Code.ERROR, exception.code());
|
||||
assertTrue(exception.message().length() > 0);
|
||||
assertTrue(exception.message().get(0).getData().length() > 0);
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -72,7 +72,7 @@ public class ShellInterpreterTest {
|
|||
result = shell.interpret("invalid_command\nls",context);
|
||||
}
|
||||
assertEquals(InterpreterResult.Code.SUCCESS,result.code());
|
||||
assertTrue(result.message().contains("invalid_command"));
|
||||
assertTrue(result.message().get(0).getData().contains("invalid_command"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ import org.apache.zeppelin.interpreter.InterpreterException;
|
|||
import org.apache.zeppelin.interpreter.InterpreterOutput;
|
||||
import org.apache.zeppelin.interpreter.InterpreterOutputListener;
|
||||
import org.apache.zeppelin.interpreter.InterpreterResultMessageOutput;
|
||||
import org.apache.zeppelin.interpreter.util.InterpreterOutputStream;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
|
|
|
|||
|
|
@ -100,13 +100,14 @@ public class InterpreterOutputTest implements InterpreterOutputListener {
|
|||
assertEquals(InterpreterResult.Type.HTML, out.getOutputAt(1).getType());
|
||||
assertEquals(1, numAppendEvent);
|
||||
assertEquals(2, numUpdateEvent);
|
||||
out.flush();
|
||||
assertEquals("<div>html</div>\n", new String(out.getOutputAt(1).toByteArray()));
|
||||
|
||||
// change type to text again
|
||||
out.write("%text hello\n");
|
||||
assertEquals(InterpreterResult.Type.TEXT, out.getOutputAt(2).getType());
|
||||
assertEquals(2, numAppendEvent);
|
||||
assertEquals(3, numUpdateEvent);
|
||||
assertEquals(4, numUpdateEvent);
|
||||
assertEquals("hello\n", new String(out.getOutputAt(2).toByteArray()));
|
||||
}
|
||||
|
||||
|
|
@ -130,15 +131,18 @@ public class InterpreterOutputTest implements InterpreterOutputListener {
|
|||
assertEquals(InterpreterResult.Type.TABLE, out.getOutputAt(0).getType());
|
||||
assertEquals(InterpreterResult.Type.HTML, out.getOutputAt(1).getType());
|
||||
assertEquals("col1\tcol2\n", new String(out.getOutputAt(0).toByteArray()));
|
||||
out.flush();
|
||||
assertEquals("<h3> This is a hack </h3>\t234\n", new String(out.getOutputAt(1).toByteArray()));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void testTableCellFormatting() throws IOException {
|
||||
out.write("%table col1\tcol2\n%html val1\tval2\n".getBytes());
|
||||
out.write("%table col1\tcol2\n\n%html val1\tval2\n".getBytes());
|
||||
assertEquals(InterpreterResult.Type.TABLE, out.getOutputAt(0).getType());
|
||||
assertEquals("col1\tcol2\n%html val1\tval2\n", new String(out.getOutputAt(0).toByteArray()));
|
||||
assertEquals("col1\tcol2\n", new String(out.getOutputAt(0).toByteArray()));
|
||||
out.flush();
|
||||
assertEquals("val1\tval2\n", new String(out.getOutputAt(1).toByteArray()));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -100,15 +100,15 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce
|
|||
RemoteInterpreter intp = createMockInterpreter();
|
||||
InterpreterResult ret = intp.interpret("SUCCESS::staticresult", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
|
||||
assertEquals("staticresult", ret.message());
|
||||
assertEquals("staticresult", ret.message().get(0).getData());
|
||||
|
||||
ret = intp.interpret("SUCCESS::staticresult2", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
|
||||
assertEquals("staticresult2", ret.message());
|
||||
assertEquals("staticresult2", ret.message().get(0).getData());
|
||||
|
||||
ret = intp.interpret("ERROR::staticresult3", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Code.ERROR, ret.code());
|
||||
assertEquals("staticresult3", ret.message());
|
||||
assertEquals("staticresult3", ret.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -116,11 +116,11 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce
|
|||
RemoteInterpreter intp = createMockInterpreter();
|
||||
InterpreterResult ret = intp.interpret("SUCCESS:streamresult:", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
|
||||
assertEquals("streamresult", ret.message());
|
||||
assertEquals("streamresult", ret.message().get(0).getData());
|
||||
|
||||
ret = intp.interpret("ERROR:streamresult2:", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Code.ERROR, ret.code());
|
||||
assertEquals("streamresult2", ret.message());
|
||||
assertEquals("streamresult2", ret.message().get(0).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -128,7 +128,8 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce
|
|||
RemoteInterpreter intp = createMockInterpreter();
|
||||
InterpreterResult ret = intp.interpret("SUCCESS:stream:static", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Code.SUCCESS, ret.code());
|
||||
assertEquals("streamstatic", ret.message());
|
||||
assertEquals("stream", ret.message().get(0).getData());
|
||||
assertEquals("static", ret.message().get(1).getData());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
|
@ -137,15 +138,17 @@ public class RemoteInterpreterOutputTestStream implements RemoteInterpreterProce
|
|||
|
||||
InterpreterResult ret = intp.interpret("SUCCESS:%html hello:", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Type.HTML, ret.message().get(0).getType());
|
||||
assertEquals("hello", ret.message());
|
||||
assertEquals("hello", ret.message().get(0).getData());
|
||||
|
||||
ret = intp.interpret("SUCCESS:%html\nhello:", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Type.HTML, ret.message().get(0).getType());
|
||||
assertEquals("hello", ret.message());
|
||||
assertEquals("hello", ret.message().get(0).getData());
|
||||
|
||||
ret = intp.interpret("SUCCESS:%html hello:%angular world", createInterpreterContext());
|
||||
assertEquals(InterpreterResult.Type.ANGULAR, ret.message().get(0).getType());
|
||||
assertEquals("helloworld", ret.message());
|
||||
assertEquals(InterpreterResult.Type.HTML, ret.message().get(0).getType());
|
||||
assertEquals("hello", ret.message().get(0).getData());
|
||||
assertEquals(InterpreterResult.Type.ANGULAR, ret.message().get(1).getType());
|
||||
assertEquals("world", ret.message().get(1).getData());
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -253,7 +253,7 @@ public class RemoteInterpreterTest {
|
|||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
new LocalResourcePool("pool1"),
|
||||
new LinkedList<InterpreterContextRunner>(), null));
|
||||
assertEquals("500", ret.message());
|
||||
assertEquals("500", ret.message().get(0).getData());
|
||||
|
||||
ret = intpB.interpret("500",
|
||||
new InterpreterContext(
|
||||
|
|
@ -267,7 +267,7 @@ public class RemoteInterpreterTest {
|
|||
new AngularObjectRegistry(intpGroup.getId(), null),
|
||||
new LocalResourcePool("pool1"),
|
||||
new LinkedList<InterpreterContextRunner>(), null));
|
||||
assertEquals("1000", ret.message());
|
||||
assertEquals("1000", ret.message().get(0).getData());
|
||||
long end = System.currentTimeMillis();
|
||||
assertTrue(end - start >= 1000);
|
||||
|
||||
|
|
@ -374,7 +374,7 @@ public class RemoteInterpreterTest {
|
|||
long end = System.currentTimeMillis();
|
||||
assertTrue(end - start >= 1000);
|
||||
|
||||
assertEquals("1000", ((InterpreterResult) jobB.getReturn()).message());
|
||||
assertEquals("1000", ((InterpreterResult) jobB.getReturn()).message().get(0).getData());
|
||||
|
||||
intpA.close();
|
||||
intpB.close();
|
||||
|
|
@ -766,10 +766,10 @@ public class RemoteInterpreterTest {
|
|||
new LinkedList<InterpreterContextRunner>(), null);
|
||||
|
||||
|
||||
assertEquals("env value 1", intp.interpret("getEnv MY_ENV1", context).message());
|
||||
assertEquals("", intp.interpret("getProperty MY_ENV1", context).message());
|
||||
assertEquals("", intp.interpret("getEnv my.property.1", context).message());
|
||||
assertEquals("property value 1", intp.interpret("getProperty my.property.1", context).message());
|
||||
assertEquals("env value 1", intp.interpret("getEnv MY_ENV1", context).message().get(0).getData());
|
||||
assertEquals(0, intp.interpret("getProperty MY_ENV1", context).message().size());
|
||||
assertEquals(0, intp.interpret("getEnv my.property.1", context).message().size());
|
||||
assertEquals("property value 1", intp.interpret("getProperty my.property.1", context).message().get(0).getData());
|
||||
|
||||
intp.close();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -100,7 +100,6 @@
|
|||
|
||||
var angularObjectRegistry = {};
|
||||
|
||||
|
||||
// Controller init
|
||||
$scope.init = function(newParagraph, note) {
|
||||
$scope.paragraph = newParagraph;
|
||||
|
|
@ -121,14 +120,13 @@
|
|||
|
||||
initializeDefault();
|
||||
|
||||
getApplicationStates();
|
||||
getSuggestions();
|
||||
|
||||
/*
|
||||
var activeApp = _.get($scope.paragraph.config, 'helium.activeApp');
|
||||
if (activeApp) {
|
||||
var app = _.find($scope.apps, {id: activeApp});
|
||||
renderApp(app);
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
var initializeDefault = function() {
|
||||
|
|
@ -138,10 +136,13 @@
|
|||
config.colWidth = 12;
|
||||
}
|
||||
|
||||
|
||||
if (config.enabled === undefined) {
|
||||
config.enabled = true;
|
||||
}
|
||||
|
||||
if (!config.result) {
|
||||
config.result = [];
|
||||
}
|
||||
};
|
||||
|
||||
$scope.$on('updateParagraphOutput', function(event, data) {
|
||||
|
|
@ -151,10 +152,10 @@
|
|||
}
|
||||
|
||||
var update = ($scope.paragraph.result.msg[data.index]) ? true : false;
|
||||
|
||||
|
||||
$scope.paragraph.result.msg[data.index] = {
|
||||
data : data.data,
|
||||
type : data.type
|
||||
data: data.data,
|
||||
type: data.type
|
||||
};
|
||||
|
||||
if (update) {
|
||||
|
|
@ -815,7 +816,6 @@
|
|||
websocketMsgSrv.commitParagraph($scope.paragraph.id, title, text, config, params);
|
||||
};
|
||||
|
||||
|
||||
/** Utility function */
|
||||
if (typeof String.prototype.startsWith !== 'function') {
|
||||
String.prototype.startsWith = function(str) {
|
||||
|
|
@ -858,193 +858,6 @@
|
|||
$scope.keepScrollDown = false;
|
||||
};
|
||||
|
||||
|
||||
// Helium ---------------------------------------------
|
||||
|
||||
// app states
|
||||
$scope.apps = [];
|
||||
|
||||
// suggested apps
|
||||
$scope.suggestion = {};
|
||||
|
||||
$scope.switchApp = function(appId) {
|
||||
var config = $scope.paragraph.config;
|
||||
var settings = $scope.paragraph.settings;
|
||||
|
||||
var newConfig = angular.copy(config);
|
||||
var newParams = angular.copy(settings.params);
|
||||
|
||||
// 'helium.activeApp' can be cleared by setGraphMode()
|
||||
_.set(newConfig, 'helium.activeApp', appId);
|
||||
|
||||
commitConfig(newConfig, newParams);
|
||||
};
|
||||
|
||||
$scope.loadApp = function(heliumPackage) {
|
||||
var noteId = $route.current.pathParams.noteId;
|
||||
$http.post(baseUrlSrv.getRestApiBase() + '/helium/load/' + noteId + '/' + $scope.paragraph.id,
|
||||
heliumPackage)
|
||||
.success(function(data, status, headers, config) {
|
||||
console.log('Load app %o', data);
|
||||
})
|
||||
.error(function(err, status, headers, config) {
|
||||
console.log('Error %o', err);
|
||||
});
|
||||
};
|
||||
|
||||
var commitConfig = function(config, params) {
|
||||
var paragraph = $scope.paragraph;
|
||||
commitParagraph(paragraph.title, paragraph.text, config, params);
|
||||
};
|
||||
|
||||
var getApplicationStates = function() {
|
||||
var appStates = [];
|
||||
var paragraph = $scope.paragraph;
|
||||
|
||||
// Display ApplicationState
|
||||
if (paragraph.apps) {
|
||||
_.forEach(paragraph.apps, function(app) {
|
||||
appStates.push({
|
||||
id: app.id,
|
||||
pkg: app.pkg,
|
||||
status: app.status,
|
||||
output: app.output
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// update or remove app states no longer exists
|
||||
_.forEach($scope.apps, function(currentAppState, idx) {
|
||||
var newAppState = _.find(appStates, {id: currentAppState.id});
|
||||
if (newAppState) {
|
||||
angular.extend($scope.apps[idx], newAppState);
|
||||
} else {
|
||||
$scope.apps.splice(idx, 1);
|
||||
}
|
||||
});
|
||||
|
||||
// add new app states
|
||||
_.forEach(appStates, function(app, idx) {
|
||||
if ($scope.apps.length <= idx || $scope.apps[idx].id !== app.id) {
|
||||
$scope.apps.splice(idx, 0, app);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var getSuggestions = function() {
|
||||
// Get suggested apps
|
||||
var noteId = $route.current.pathParams.noteId;
|
||||
$http.get(baseUrlSrv.getRestApiBase() + '/helium/suggest/' + noteId + '/' + $scope.paragraph.id)
|
||||
.success(function(data, status, headers, config) {
|
||||
$scope.suggestion = data.body;
|
||||
})
|
||||
.error(function(err, status, headers, config) {
|
||||
console.log('Error %o', err);
|
||||
});
|
||||
};
|
||||
|
||||
var getAppScope = function(appState) {
|
||||
if (!appState.scope) {
|
||||
appState.scope = $rootScope.$new(true, $rootScope);
|
||||
}
|
||||
|
||||
return appState.scope;
|
||||
};
|
||||
|
||||
var getAppRegistry = function(appState) {
|
||||
if (!appState.registry) {
|
||||
appState.registry = {};
|
||||
}
|
||||
|
||||
return appState.registry;
|
||||
};
|
||||
|
||||
var renderApp = function(appState) {
|
||||
var retryRenderer = function() {
|
||||
var targetEl = angular.element(document.getElementById('p' + appState.id));
|
||||
console.log('retry renderApp %o', targetEl);
|
||||
if (targetEl.length) {
|
||||
try {
|
||||
console.log('renderApp %o', appState);
|
||||
targetEl.html(appState.output);
|
||||
$compile(targetEl.contents())(getAppScope(appState));
|
||||
} catch (err) {
|
||||
console.log('App rendering error %o', err);
|
||||
}
|
||||
} else {
|
||||
$timeout(retryRenderer, 1000);
|
||||
}
|
||||
};
|
||||
$timeout(retryRenderer);
|
||||
};
|
||||
|
||||
/*
|
||||
** $scope.$on functions below
|
||||
*/
|
||||
|
||||
$scope.$on('appendAppOutput', function(event, data) {
|
||||
if ($scope.paragraph.id === data.paragraphId) {
|
||||
var app = _.find($scope.apps, {id: data.appId});
|
||||
if (app) {
|
||||
app.output += data.data;
|
||||
|
||||
var paragraphAppState = _.find($scope.paragraph.apps, {id: data.appId});
|
||||
paragraphAppState.output = app.output;
|
||||
|
||||
var targetEl = angular.element(document.getElementById('p' + app.id));
|
||||
targetEl.html(app.output);
|
||||
$compile(targetEl.contents())(getAppScope(app));
|
||||
console.log('append app output %o', $scope.apps);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('updateAppOutput', function(event, data) {
|
||||
if ($scope.paragraph.id === data.paragraphId) {
|
||||
var app = _.find($scope.apps, {id: data.appId});
|
||||
if (app) {
|
||||
app.output = data.data;
|
||||
|
||||
var paragraphAppState = _.find($scope.paragraph.apps, {id: data.appId});
|
||||
paragraphAppState.output = app.output;
|
||||
|
||||
var targetEl = angular.element(document.getElementById('p' + app.id));
|
||||
targetEl.html(app.output);
|
||||
$compile(targetEl.contents())(getAppScope(app));
|
||||
console.log('append app output');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('appLoad', function(event, data) {
|
||||
if ($scope.paragraph.id === data.paragraphId) {
|
||||
var app = _.find($scope.apps, {id: data.appId});
|
||||
if (!app) {
|
||||
app = {
|
||||
id: data.appId,
|
||||
pkg: data.pkg,
|
||||
status: 'UNLOADED',
|
||||
output: ''
|
||||
};
|
||||
|
||||
$scope.apps.push(app);
|
||||
$scope.paragraph.apps.push(app);
|
||||
$scope.switchApp(app.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('appStatusChange', function(event, data) {
|
||||
if ($scope.paragraph.id === data.paragraphId) {
|
||||
var app = _.find($scope.apps, {id: data.appId});
|
||||
if (app) {
|
||||
app.status = data.status;
|
||||
var paragraphAppState = _.find($scope.paragraph.apps, {id: data.appId});
|
||||
paragraphAppState.status = app.status;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('angularObjectUpdate', function(event, data) {
|
||||
var noteId = $route.current.pathParams.noteId;
|
||||
if (!data.noteId || data.noteId === noteId) {
|
||||
|
|
@ -1055,14 +868,7 @@
|
|||
scope = paragraphScope;
|
||||
registry = angularObjectRegistry;
|
||||
} else {
|
||||
var app = _.find($scope.apps, {id: data.paragraphId});
|
||||
if (app) {
|
||||
scope = getAppScope(app);
|
||||
registry = getAppRegistry(app);
|
||||
} else {
|
||||
// no matching app in this paragraph
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
var varName = data.angularObject.name;
|
||||
|
||||
|
|
@ -1125,14 +931,7 @@
|
|||
scope = paragraphScope;
|
||||
registry = angularObjectRegistry;
|
||||
} else {
|
||||
var app = _.find($scope.apps, {id: data.paragraphId});
|
||||
if (app) {
|
||||
scope = getAppScope(app);
|
||||
registry = getAppRegistry(app);
|
||||
} else {
|
||||
// no matching app in this paragraph
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
|
||||
var varName = data.name;
|
||||
|
|
@ -1244,10 +1043,8 @@
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
});
|
||||
|
||||
|
||||
$scope.$on('updateProgress', function(event, data) {
|
||||
if (data.id === $scope.paragraph.id) {
|
||||
$scope.currentProgress = data.progress;
|
||||
|
|
@ -1377,7 +1174,5 @@
|
|||
$scope.$on('closeTable', function(event) {
|
||||
$scope.closeTable();
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@ limitations under the License.
|
|||
<button type="button" class="btn btn-default btn-sm"
|
||||
ng-if="type == 'TABLE'"
|
||||
ng-repeat="viz in builtInTableDataVisualizationList track by $index"
|
||||
ng-class="{'active' : viz.id == graphMode}"
|
||||
ng-class="{'active' : viz.id == graphMode && !config.helium.activeApp}"
|
||||
ng-click="switchViz(viz.id)"><i ng-class="viz.icon"></i>
|
||||
</button>
|
||||
|
||||
|
|
@ -90,7 +90,7 @@ limitations under the License.
|
|||
</div>
|
||||
|
||||
<span
|
||||
ng-if="type=='TABLE' && !paragraph.config.helium.activeApp && graphMode!='table' && !asIframe && !viewOnly"
|
||||
ng-if="type=='TABLE' && !config.helium.activeApp && graphMode!='table' && !asIframe && !viewOnly"
|
||||
style="margin-left:10px; cursor:pointer; display: inline-block; vertical-align:top; position: relative; line-height:30px;">
|
||||
<a class="btnText" ng-click="toggleGraphSetting()">
|
||||
settings <span ng-class="config.graph.optionOpen ? 'fa fa-caret-up' : 'fa fa-caret-down'"></span>
|
||||
|
|
|
|||
|
|
@ -114,7 +114,7 @@
|
|||
|
||||
// Data of the result
|
||||
var data;
|
||||
|
||||
|
||||
// config
|
||||
$scope.config;
|
||||
|
||||
|
|
@ -125,7 +125,7 @@
|
|||
var paragraph;
|
||||
|
||||
// index of the result
|
||||
var resultIndex
|
||||
var resultIndex;
|
||||
|
||||
// TableData instance
|
||||
var tableData;
|
||||
|
|
@ -135,7 +135,7 @@
|
|||
|
||||
// graphMode
|
||||
$scope.graphMode;
|
||||
|
||||
|
||||
$scope.init = function(result, config, paragraph, index) {
|
||||
console.log('result controller init %o %o %o', result, config, index);
|
||||
updateData(result, config, paragraph, index);
|
||||
|
|
@ -147,12 +147,8 @@
|
|||
return;
|
||||
}
|
||||
console.log('updateResult %o %o %o %o', result, newConfig, paragraphRef, index);
|
||||
|
||||
|
||||
/*
|
||||
var oldType = $scope.getResultType();
|
||||
var newType = $scope.getResultType(data.paragraph);
|
||||
var oldGraphMode = $scope.getGraphMode();
|
||||
var newGraphMode = $scope.getGraphMode(data.paragraph);
|
||||
var oldActiveApp = _.get($scope.paragraph.config, 'helium.activeApp');
|
||||
var newActiveApp = _.get(data.paragraph.config, 'helium.activeApp');
|
||||
*/
|
||||
|
|
@ -226,7 +222,7 @@
|
|||
if (!config.graph.scatter) {
|
||||
config.graph.scatter = {};
|
||||
}
|
||||
|
||||
|
||||
$scope.graphMode = config.graph.mode;
|
||||
$scope.config = angular.copy(config);
|
||||
|
||||
|
|
@ -242,25 +238,24 @@
|
|||
};
|
||||
|
||||
var renderResult = function(type, refresh) {
|
||||
if (type === 'TABLE') {
|
||||
$scope.renderGraph($scope.graphMode, refresh);
|
||||
} else if (type === 'HTML') {
|
||||
renderHtml();
|
||||
} else if (type === 'ANGULAR') {
|
||||
renderAngular();
|
||||
} else if (type === 'TEXT') {
|
||||
renderText();
|
||||
}
|
||||
|
||||
/*
|
||||
getApplicationStates();
|
||||
getSuggestions();
|
||||
getApplicationStates();
|
||||
var activeApp = _.get($scope.config, 'helium.activeApp');
|
||||
|
||||
if (newActiveApp && newActiveApp !== oldActiveApp) {
|
||||
var app = _.find($scope.apps, {id: newActiveApp});
|
||||
if (activeApp) {
|
||||
var app = _.find($scope.apps, {id: activeApp});
|
||||
renderApp(app);
|
||||
} else {
|
||||
if (type === 'TABLE') {
|
||||
$scope.renderGraph($scope.graphMode, refresh);
|
||||
} else if (type === 'HTML') {
|
||||
renderHtml();
|
||||
} else if (type === 'ANGULAR') {
|
||||
renderAngular();
|
||||
} else if (type === 'TEXT') {
|
||||
renderText();
|
||||
}
|
||||
}
|
||||
*/
|
||||
};
|
||||
|
||||
var renderHtml = function() {
|
||||
|
|
@ -311,7 +306,7 @@
|
|||
// clear all lines before render
|
||||
clearTextOutput();
|
||||
textRendererInitialized = true;
|
||||
|
||||
|
||||
if (data) {
|
||||
appendTextOutput(data);
|
||||
} else {
|
||||
|
|
@ -320,7 +315,7 @@
|
|||
|
||||
angular.element('#p' + $scope.id + '_text').bind('mousewheel', function(e) {
|
||||
$scope.keepScrollDown = false;
|
||||
});
|
||||
});
|
||||
} else {
|
||||
$timeout(retryRenderer, 10);
|
||||
}
|
||||
|
|
@ -342,7 +337,7 @@
|
|||
appendTextOutput(textAppendQueueBeforeInitialize.pop());
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
var appendTextOutput = function(msg) {
|
||||
if (!textRendererInitialized) {
|
||||
textAppendQueueBeforeInitialize.push(msg);
|
||||
|
|
@ -663,9 +658,288 @@
|
|||
}
|
||||
saveAsService.saveAs(dsv, 'data', extension);
|
||||
};
|
||||
|
||||
|
||||
$scope.getBase64ImageSrc = function(base64Data) {
|
||||
return 'data:image/png;base64,' + base64Data;
|
||||
};
|
||||
|
||||
// Helium ----------------
|
||||
var ANGULAR_FUNCTION_OBJECT_NAME_PREFIX = '_Z_ANGULAR_FUNC_';
|
||||
|
||||
// app states
|
||||
$scope.apps = [];
|
||||
|
||||
// suggested apps
|
||||
$scope.suggestion = {};
|
||||
|
||||
$scope.switchApp = function(appId) {
|
||||
var newConfig = angular.copy($scope.config);
|
||||
var newParams = angular.copy(paragraph.settings.params);
|
||||
|
||||
// 'helium.activeApp' can be cleared by switchViz()
|
||||
_.set(newConfig, 'helium.activeApp', appId);
|
||||
|
||||
commitConfig(newConfig, newParams);
|
||||
};
|
||||
|
||||
$scope.loadApp = function(heliumPackage) {
|
||||
var noteId = $route.current.pathParams.noteId;
|
||||
$http.post(baseUrlSrv.getRestApiBase() + '/helium/load/' + noteId + '/' + paragraph.id, heliumPackage)
|
||||
.success(function(data, status, headers, config) {
|
||||
console.log('Load app %o', data);
|
||||
})
|
||||
.error(function(err, status, headers, config) {
|
||||
console.log('Error %o', err);
|
||||
});
|
||||
};
|
||||
|
||||
var commitConfig = function(config, params) {
|
||||
commitParagraphResult(paragraph.title, paragraph.text, config, params);
|
||||
};
|
||||
|
||||
var getApplicationStates = function() {
|
||||
var appStates = [];
|
||||
|
||||
// Display ApplicationState
|
||||
if (paragraph.apps) {
|
||||
_.forEach(paragraph.apps, function(app) {
|
||||
appStates.push({
|
||||
id: app.id,
|
||||
pkg: app.pkg,
|
||||
status: app.status,
|
||||
output: app.output
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
// update or remove app states no longer exists
|
||||
_.forEach($scope.apps, function(currentAppState, idx) {
|
||||
var newAppState = _.find(appStates, {id: currentAppState.id});
|
||||
if (newAppState) {
|
||||
angular.extend($scope.apps[idx], newAppState);
|
||||
} else {
|
||||
$scope.apps.splice(idx, 1);
|
||||
}
|
||||
});
|
||||
|
||||
// add new app states
|
||||
_.forEach(appStates, function(app, idx) {
|
||||
if ($scope.apps.length <= idx || $scope.apps[idx].id !== app.id) {
|
||||
$scope.apps.splice(idx, 0, app);
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
var getSuggestions = function() {
|
||||
// Get suggested apps
|
||||
var noteId = $route.current.pathParams.noteId;
|
||||
$http.get(baseUrlSrv.getRestApiBase() + '/helium/suggest/' + noteId + '/' + paragraph.id)
|
||||
.success(function(data, status, headers, config) {
|
||||
$scope.suggestion = data.body;
|
||||
})
|
||||
.error(function(err, status, headers, config) {
|
||||
console.log('Error %o', err);
|
||||
});
|
||||
};
|
||||
|
||||
var renderApp = function(appState) {
|
||||
var retryRenderer = function() {
|
||||
var targetEl = angular.element(document.getElementById('p' + appState.id));
|
||||
console.log('retry renderApp %o', targetEl);
|
||||
if (targetEl.length) {
|
||||
try {
|
||||
console.log('renderApp %o', appState);
|
||||
targetEl.html(appState.output);
|
||||
$compile(targetEl.contents())(getAppScope(appState));
|
||||
} catch (err) {
|
||||
console.log('App rendering error %o', err);
|
||||
}
|
||||
} else {
|
||||
$timeout(retryRenderer, 1000);
|
||||
}
|
||||
};
|
||||
$timeout(retryRenderer);
|
||||
};
|
||||
|
||||
/*
|
||||
** $scope.$on functions below
|
||||
*/
|
||||
$scope.$on('appendAppOutput', function(event, data) {
|
||||
if (paragraph.id === data.paragraphId) {
|
||||
var app = _.find($scope.apps, {id: data.appId});
|
||||
if (app) {
|
||||
app.output += data.data;
|
||||
|
||||
var paragraphAppState = _.find(paragraph.apps, {id: data.appId});
|
||||
paragraphAppState.output = app.output;
|
||||
|
||||
var targetEl = angular.element(document.getElementById('p' + app.id));
|
||||
targetEl.html(app.output);
|
||||
$compile(targetEl.contents())(getAppScope(app));
|
||||
console.log('append app output %o', $scope.apps);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('updateAppOutput', function(event, data) {
|
||||
if (paragraph.id === data.paragraphId) {
|
||||
var app = _.find($scope.apps, {id: data.appId});
|
||||
if (app) {
|
||||
app.output = data.data;
|
||||
|
||||
var paragraphAppState = _.find(paragraph.apps, {id: data.appId});
|
||||
paragraphAppState.output = app.output;
|
||||
|
||||
var targetEl = angular.element(document.getElementById('p' + app.id));
|
||||
targetEl.html(app.output);
|
||||
$compile(targetEl.contents())(getAppScope(app));
|
||||
console.log('append app output');
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('appLoad', function(event, data) {
|
||||
if (paragraph.id === data.paragraphId) {
|
||||
var app = _.find($scope.apps, {id: data.appId});
|
||||
if (!app) {
|
||||
app = {
|
||||
id: data.appId,
|
||||
pkg: data.pkg,
|
||||
status: 'UNLOADED',
|
||||
output: ''
|
||||
};
|
||||
|
||||
$scope.apps.push(app);
|
||||
paragraph.apps.push(app);
|
||||
$scope.switchApp(app.id);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('appStatusChange', function(event, data) {
|
||||
if (paragraph.id === data.paragraphId) {
|
||||
var app = _.find($scope.apps, {id: data.appId});
|
||||
if (app) {
|
||||
app.status = data.status;
|
||||
var paragraphAppState = _.find(paragraph.apps, {id: data.appId});
|
||||
paragraphAppState.status = app.status;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var getAppRegistry = function(appState) {
|
||||
if (!appState.registry) {
|
||||
appState.registry = {};
|
||||
}
|
||||
|
||||
return appState.registry;
|
||||
};
|
||||
|
||||
var getAppScope = function(appState) {
|
||||
if (!appState.scope) {
|
||||
appState.scope = $rootScope.$new(true, $rootScope);
|
||||
}
|
||||
return appState.scope;
|
||||
};
|
||||
|
||||
$scope.$on('angularObjectUpdate', function(event, data) {
|
||||
var noteId = $route.current.pathParams.noteId;
|
||||
if (!data.noteId || data.noteId === noteId) {
|
||||
var scope;
|
||||
var registry;
|
||||
|
||||
var app = _.find($scope.apps, {id: data.paragraphId});
|
||||
if (app) {
|
||||
scope = getAppScope(app);
|
||||
registry = getAppRegistry(app);
|
||||
} else {
|
||||
// no matching app in this paragraph
|
||||
return;
|
||||
}
|
||||
|
||||
var varName = data.angularObject.name;
|
||||
|
||||
if (angular.equals(data.angularObject.object, scope[varName])) {
|
||||
// return when update has no change
|
||||
return;
|
||||
}
|
||||
|
||||
if (!registry[varName]) {
|
||||
registry[varName] = {
|
||||
interpreterGroupId: data.interpreterGroupId,
|
||||
noteId: data.noteId,
|
||||
paragraphId: data.paragraphId
|
||||
};
|
||||
} else {
|
||||
registry[varName].noteId = registry[varName].noteId || data.noteId;
|
||||
registry[varName].paragraphId = registry[varName].paragraphId || data.paragraphId;
|
||||
}
|
||||
|
||||
registry[varName].skipEmit = true;
|
||||
|
||||
if (!registry[varName].clearWatcher) {
|
||||
registry[varName].clearWatcher = scope.$watch(varName, function(newValue, oldValue) {
|
||||
console.log('angular object (paragraph) updated %o %o', varName, registry[varName]);
|
||||
if (registry[varName].skipEmit) {
|
||||
registry[varName].skipEmit = false;
|
||||
return;
|
||||
}
|
||||
websocketMsgSrv.updateAngularObject(
|
||||
registry[varName].noteId,
|
||||
registry[varName].paragraphId,
|
||||
varName,
|
||||
newValue,
|
||||
registry[varName].interpreterGroupId);
|
||||
});
|
||||
}
|
||||
console.log('angular object (paragraph) created %o', varName);
|
||||
scope[varName] = data.angularObject.object;
|
||||
|
||||
// create proxy for AngularFunction
|
||||
if (varName.startsWith(ANGULAR_FUNCTION_OBJECT_NAME_PREFIX)) {
|
||||
var funcName = varName.substring((ANGULAR_FUNCTION_OBJECT_NAME_PREFIX).length);
|
||||
scope[funcName] = function() {
|
||||
scope[varName] = arguments;
|
||||
console.log('angular function (paragraph) invoked %o', arguments);
|
||||
};
|
||||
|
||||
console.log('angular function (paragraph) created %o', scope[funcName]);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
$scope.$on('angularObjectRemove', function(event, data) {
|
||||
var noteId = $route.current.pathParams.noteId;
|
||||
if (!data.noteId || data.noteId === noteId) {
|
||||
var scope;
|
||||
var registry;
|
||||
|
||||
var app = _.find($scope.apps, {id: data.paragraphId});
|
||||
if (app) {
|
||||
scope = getAppScope(app);
|
||||
registry = getAppRegistry(app);
|
||||
} else {
|
||||
// no matching app in this paragraph
|
||||
return;
|
||||
}
|
||||
|
||||
var varName = data.name;
|
||||
|
||||
// clear watcher
|
||||
if (registry[varName]) {
|
||||
registry[varName].clearWatcher();
|
||||
registry[varName] = undefined;
|
||||
}
|
||||
|
||||
// remove scope variable
|
||||
scope[varName] = undefined;
|
||||
|
||||
// remove proxy for AngularFunction
|
||||
if (varName.startsWith(ANGULAR_FUNCTION_OBJECT_NAME_PREFIX)) {
|
||||
var funcName = varName.substring((ANGULAR_FUNCTION_OBJECT_NAME_PREFIX).length);
|
||||
scope[funcName] = undefined;
|
||||
}
|
||||
}
|
||||
});
|
||||
};
|
||||
})();
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
|
||||
function noteVarShareService() {
|
||||
var store = {};
|
||||
|
||||
|
||||
this.clear = function() {
|
||||
store = {};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in a new issue