http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java index 0bcec1e..930ed7c 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistry.java @@ -24,32 +24,33 @@ import java.util.Map; /** * AngularObjectRegistry keeps all the object that binded to Angular Display System. - * AngularObjectRegistry is created per interpreter group. It provides three different scope of - * AngularObjects : - Paragraphscope : AngularObject is valid in specific paragraph - Notebook - * scope: AngularObject is valid in a single notebook - Global scope : Shared to all notebook that - * uses the same interpreter group + * AngularObjectRegistry is created per interpreter group. + * It provides three different scope of AngularObjects : + * - Paragraphscope : AngularObject is valid in specific paragraph + * - Notebook scope: AngularObject is valid in a single notebook + * - Global scope : Shared to all notebook that uses the same interpreter group */ public class AngularObjectRegistry { Map<String, Map<String, AngularObject>> registry = new HashMap<>(); private final String GLOBAL_KEY = "_GLOBAL_"; private AngularObjectRegistryListener listener; private String interpreterId; + AngularObjectListener angularObjectListener; - public AngularObjectRegistry( - final String interpreterId, final AngularObjectRegistryListener listener) { + public AngularObjectRegistry(final String interpreterId, + final AngularObjectRegistryListener listener) { this.interpreterId = interpreterId; this.listener = listener; - angularObjectListener = - new AngularObjectListener() { - @Override - public void updated(AngularObject updatedObject) { - if (listener != null) { - listener.onUpdate(interpreterId, updatedObject); - } - } - }; + angularObjectListener = new AngularObjectListener() { + @Override + public void updated(AngularObject updatedObject) { + if (listener != null) { + listener.onUpdate(interpreterId, updatedObject); + } + } + }; } public AngularObjectRegistryListener getListener() { @@ -59,8 +60,9 @@ public class AngularObjectRegistry { /** * Add object into registry * - * <p>Paragraph scope when noteId and paragraphId both not null Notebook scope when paragraphId is - * null Global scope when noteId and paragraphId both null + * Paragraph scope when noteId and paragraphId both not null + * Notebook scope when paragraphId is null + * Global scope when noteId and paragraphId both null * * @param name Name of object * @param o Reference to the object @@ -83,14 +85,14 @@ public class AngularObjectRegistry { } } } - + private Map<String, AngularObject> getRegistryForKey(String noteId, String paragraphId) { synchronized (registry) { String key = getRegistryKey(noteId, paragraphId); if (!registry.containsKey(key)) { registry.put(key, new HashMap<String, AngularObject>()); } - + return registry.get(key); } } @@ -98,8 +100,9 @@ public class AngularObjectRegistry { /** * Add object into registry * - * <p>Paragraph scope when noteId and paragraphId both not null Notebook scope when paragraphId is - * null Global scope when noteId and paragraphId both null + * Paragraph scope when noteId and paragraphId both not null + * Notebook scope when paragraphId is null + * Global scope when noteId and paragraphId both null * * @param name Name of object * @param o Reference to the object @@ -108,7 +111,8 @@ public class AngularObjectRegistry { * @param emit skip firing onAdd event on false * @return AngularObject that added */ - public AngularObject add(String name, Object o, String noteId, String paragraphId, boolean emit) { + public AngularObject add(String name, Object o, String noteId, String paragraphId, + boolean emit) { AngularObject ao = createNewAngularObject(name, o, noteId, paragraphId); synchronized (registry) { @@ -122,8 +126,8 @@ public class AngularObjectRegistry { return ao; } - protected AngularObject createNewAngularObject( - String name, Object o, String noteId, String paragraphId) { + protected AngularObject createNewAngularObject(String name, Object o, String noteId, + String paragraphId) { return new AngularObject(name, o, noteId, paragraphId, angularObjectListener); } @@ -166,9 +170,9 @@ public class AngularObjectRegistry { /** * Remove all angular object in the scope. * - * <p>Remove all paragraph scope angular object when noteId and paragraphId both not null Remove - * all notebook scope angular object when paragraphId is null Remove all global scope angular - * objects when noteId and paragraphId both null + * Remove all paragraph scope angular object when noteId and paragraphId both not null + * Remove all notebook scope angular object when paragraphId is null + * Remove all global scope angular objects when noteId and paragraphId both null * * @param noteId noteId * @param paragraphId paragraphId @@ -184,7 +188,6 @@ public class AngularObjectRegistry { /** * Get a object from registry - * * @param name name of object * @param noteId noteId that belongs to * @param paragraphId paragraphId that belongs to @@ -199,7 +202,6 @@ public class AngularObjectRegistry { /** * Get all object in the scope - * * @param noteId noteId that belongs to * @param paragraphId paragraphId that belongs to * @return all angularobject in the scope @@ -214,10 +216,11 @@ public class AngularObjectRegistry { } return all; } - + /** - * Get all angular object related to specific note. That includes all global scope objects, - * notebook scope objects and paragraph scope objects belongs to the noteId. + * Get all angular object related to specific note. + * That includes all global scope objects, notebook scope objects and paragraph scope objects + * belongs to the noteId. * * @param noteId * @return
http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java index c8f2bfa..081bb43 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectRegistryListener.java @@ -17,11 +17,12 @@ package org.apache.zeppelin.display; -/** */ +/** + * + * + */ public interface AngularObjectRegistryListener { void onAdd(String interpreterGroupId, AngularObject object); - void onUpdate(String interpreterGroupId, AngularObject object); - void onRemove(String interpreterGroupId, String name, String noteId, String paragraphId); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectWatcher.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectWatcher.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectWatcher.java index 286a372..c5bd5e2 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectWatcher.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/AngularObjectWatcher.java @@ -19,7 +19,9 @@ package org.apache.zeppelin.display; import org.apache.zeppelin.interpreter.InterpreterContext; -/** */ +/** + * + */ public abstract class AngularObjectWatcher { private InterpreterContext context; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java index 767a466..8bae53f 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/GUI.java @@ -19,6 +19,12 @@ package org.apache.zeppelin.display; import com.google.gson.Gson; import com.google.gson.GsonBuilder; +import org.apache.zeppelin.display.ui.CheckBox; +import org.apache.zeppelin.display.ui.OptionInput.ParamOption; +import org.apache.zeppelin.display.ui.Password; +import org.apache.zeppelin.display.ui.Select; +import org.apache.zeppelin.display.ui.TextBox; + import java.io.Serializable; import java.util.Collection; import java.util.HashMap; @@ -26,22 +32,23 @@ import java.util.LinkedHashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.apache.zeppelin.display.ui.CheckBox; -import org.apache.zeppelin.display.ui.OptionInput.ParamOption; -import org.apache.zeppelin.display.ui.Password; -import org.apache.zeppelin.display.ui.Select; -import org.apache.zeppelin.display.ui.TextBox; -/** Settings of a form. */ + +/** + * Settings of a form. + */ public class GUI implements Serializable { - private static Gson gson = - new GsonBuilder().registerTypeAdapterFactory(Input.TypeAdapterFactory).create(); + private static Gson gson = new GsonBuilder() + .registerTypeAdapterFactory(Input.TypeAdapterFactory) + .create(); Map<String, Object> params = new HashMap<>(); // form parameters from client Map<String, Input> forms = new LinkedHashMap<>(); // form configuration - public GUI() {} + public GUI() { + + } public void setParams(Map<String, Object> values) { this.params = values; @@ -102,8 +109,8 @@ public class GUI implements Serializable { return value; } - public List<Object> checkbox( - String id, Collection<Object> defaultChecked, ParamOption[] options) { + public List<Object> checkbox(String id, Collection<Object> defaultChecked, + ParamOption[] options) { Collection<Object> checked = (Collection<Object>) params.get(id); if (checked == null) { checked = defaultChecked; @@ -146,6 +153,7 @@ public class GUI implements Serializable { return false; } return forms != null ? forms.equals(gui.forms) : gui.forms == null; + } @Override http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java index 80b1235..40878a8 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/Input.java @@ -17,6 +17,14 @@ package org.apache.zeppelin.display; +import org.apache.commons.lang.StringUtils; +import org.apache.zeppelin.display.ui.CheckBox; +import org.apache.zeppelin.display.ui.OptionInput; +import org.apache.zeppelin.display.ui.OptionInput.ParamOption; +import org.apache.zeppelin.display.ui.Password; +import org.apache.zeppelin.display.ui.Select; +import org.apache.zeppelin.display.ui.TextBox; + import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; @@ -27,13 +35,6 @@ import java.util.List; import java.util.Map; import java.util.regex.Matcher; import java.util.regex.Pattern; -import org.apache.commons.lang.StringUtils; -import org.apache.zeppelin.display.ui.CheckBox; -import org.apache.zeppelin.display.ui.OptionInput; -import org.apache.zeppelin.display.ui.OptionInput.ParamOption; -import org.apache.zeppelin.display.ui.Password; -import org.apache.zeppelin.display.ui.Select; -import org.apache.zeppelin.display.ui.TextBox; /** * Base class for dynamic forms. Also used as factory class of dynamic forms. @@ -61,7 +62,8 @@ public class Input<T> implements Serializable { protected boolean hidden; protected String argument; - public Input() {} + public Input() { + } public boolean isHidden() { return hidden; @@ -116,17 +118,17 @@ public class Input<T> implements Serializable { return false; } if (defaultValue instanceof Object[]) { - if (defaultValue != null - ? !Arrays.equals((Object[]) defaultValue, (Object[]) input.defaultValue) + if (defaultValue != null ? + !Arrays.equals((Object[]) defaultValue, (Object[]) input.defaultValue) : input.defaultValue != null) { return false; } - } else if (defaultValue != null - ? !defaultValue.equals(input.defaultValue) - : input.defaultValue != null) { + } else if (defaultValue != null ? + !defaultValue.equals(input.defaultValue) : input.defaultValue != null) { return false; } return argument != null ? argument.equals(input.argument) : input.argument == null; + } @Override @@ -213,6 +215,7 @@ public class Input<T> implements Serializable { valuePart = null; } + String varName; String displayName = null; String type = null; @@ -265,9 +268,11 @@ public class Input<T> implements Serializable { } } + } else { // no option defaultValue = valuePart; } + } Input input = null; @@ -290,8 +295,8 @@ public class Input<T> implements Serializable { return input; } - public static LinkedHashMap<String, Input> extractSimpleQueryForm( - String script, boolean noteForm) { + public static LinkedHashMap<String, Input> extractSimpleQueryForm(String script, + boolean noteForm) { LinkedHashMap<String, Input> forms = new LinkedHashMap<>(); if (script == null) { return forms; @@ -336,18 +341,16 @@ public class Input<T> implements Serializable { } String expanded; - if (value instanceof Object[] || value instanceof Collection) { // multi-selection + if (value instanceof Object[] || value instanceof Collection) { // multi-selection OptionInput optionInput = (OptionInput) input; String delimiter = input.argument; if (delimiter == null) { delimiter = DEFAULT_DELIMITER; } - Collection<Object> checked = - value instanceof Collection - ? (Collection<Object>) value - : Arrays.asList((Object[]) value); + Collection<Object> checked = value instanceof Collection ? (Collection<Object>) value + : Arrays.asList((Object[]) value); List<Object> validChecked = new LinkedList<>(); - for (Object o : checked) { // filter out obsolete checked values + for (Object o : checked) { // filter out obsolete checked values for (ParamOption option : optionInput.getOptions()) { if (option.getValue().equals(o)) { validChecked.add(o); @@ -357,7 +360,7 @@ public class Input<T> implements Serializable { } params.put(input.name, validChecked); expanded = StringUtils.join(validChecked, delimiter); - } else { // single-selection + } else { // single-selection expanded = value.toString(); } replaced = match.replaceFirst(expanded); @@ -367,8 +370,10 @@ public class Input<T> implements Serializable { return replaced; } + public static String[] split(String str) { return str.split(";(?=([^\"']*\"[^\"']*\")*[^\"']*$)"); + } /* @@ -377,32 +382,28 @@ public class Input<T> implements Serializable { * str.split("\\|(?=([^\"']*\"[^\"']*\")*[^\"']*$)"); } */ + public static String[] splitPipe(String str) { return split(str, '|'); } public static String[] split(String str, char split) { - return split(str, new String[] {String.valueOf(split)}, false); + return split(str, new String[]{String.valueOf(split)}, false); } public static String[] split(String str, String[] splitters, boolean includeSplitter) { String escapeSeq = "\"',;${}"; char escapeChar = '\\'; - String[] blockStart = new String[] {"\"", "'", "${", "N_(", "N_<"}; - String[] blockEnd = new String[] {"\"", "'", "}", "N_)", "N_>"}; + String[] blockStart = new String[]{"\"", "'", "${", "N_(", "N_<"}; + String[] blockEnd = new String[]{"\"", "'", "}", "N_)", "N_>"}; return split(str, escapeSeq, escapeChar, blockStart, blockEnd, splitters, includeSplitter); + } - public static String[] split( - String str, - String escapeSeq, - char escapeChar, - String[] blockStart, - String[] blockEnd, - String[] splitters, - boolean includeSplitter) { + public static String[] split(String str, String escapeSeq, char escapeChar, String[] blockStart, + String[] blockEnd, String[] splitters, boolean includeSplitter) { List<String> splits = new ArrayList<>(); @@ -455,10 +456,8 @@ public class Input<T> implements Serializable { if (isNestedBlock(blockStart[blockStack.get(0)]) == true) { // try to find nested block start - if (curString - .substring(lastEscapeOffset + 1) - .endsWith(getBlockStr(blockStart[blockStack.get(0)])) - == true) { + if (curString.substring(lastEscapeOffset + 1).endsWith( + getBlockStr(blockStart[blockStack.get(0)])) == true) { blockStack.add(0, blockStack.get(0)); // block is started blockStartPos = i; continue; @@ -466,9 +465,8 @@ public class Input<T> implements Serializable { } // check if block is finishing - if (curString - .substring(lastEscapeOffset + 1) - .endsWith(getBlockStr(blockEnd[blockStack.get(0)]))) { + if (curString.substring(lastEscapeOffset + 1).endsWith( + getBlockStr(blockEnd[blockStack.get(0)]))) { // the block closer is one of the splitters (and not nested block) if (isNestedBlock(blockEnd[blockStack.get(0)]) == false) { for (String splitter : splitters) { @@ -515,8 +513,8 @@ public class Input<T> implements Serializable { // check if block is started for (int b = 0; b < blockStart.length; b++) { - if (curString.substring(lastEscapeOffset + 1).endsWith(getBlockStr(blockStart[b])) - == true) { + if (curString.substring(lastEscapeOffset + 1) + .endsWith(getBlockStr(blockStart[b])) == true) { blockStack.add(0, b); // block is started blockStartPos = i; break; @@ -527,7 +525,8 @@ public class Input<T> implements Serializable { if (curString.length() > 0) { splits.add(curString.toString().trim()); } - return splits.toArray(new String[] {}); + return splits.toArray(new String[]{}); + } private static String getBlockStr(String blockDef) { http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/OldInput.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/OldInput.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/OldInput.java index 45ecba0..7c67dad 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/OldInput.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/OldInput.java @@ -20,10 +20,11 @@ package org.apache.zeppelin.display; import org.apache.zeppelin.display.ui.OptionInput.ParamOption; /** - * Old Input type. The reason I still keep Old Input is for compatibility. There's one bug in the - * old input forms. There's 2 ways to create input forms: frontend & backend. The bug is in - * frontend. The type would not be set correctly when input form is created in frontend - * (Input.getInputForm). + * Old Input type. + * The reason I still keep Old Input is for compatibility. There's one bug in the old input forms. + * There's 2 ways to create input forms: frontend & backend. + * The bug is in frontend. The type would not be set correctly when input form + * is created in frontend (Input.getInputForm). */ public class OldInput extends Input<Object> { @@ -57,21 +58,27 @@ public class OldInput extends Input<Object> { this.options = options; } - /** */ + /** + * + */ public static class OldTextBox extends OldInput { public OldTextBox(String name, Object defaultValue) { super(name, defaultValue); } } - /** */ + /** + * + */ public static class OldSelect extends OldInput { public OldSelect(String name, Object defaultValue, ParamOption[] options) { super(name, defaultValue, options); } } - /** */ + /** + * + */ public static class OldCheckBox extends OldInput { public OldCheckBox(String name, Object defaultValue, ParamOption[] options) { super(name, defaultValue, options); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java index 88d32d1..65b4f6b 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/RuntimeTypeAdapterFactory.java @@ -28,6 +28,7 @@ import com.google.gson.internal.Streams; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import com.google.gson.stream.JsonWriter; + import java.io.IOException; import java.util.LinkedHashMap; import java.util.Map; @@ -52,26 +53,27 @@ public class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory { } /** - * Creates a new runtime type adapter using for {@code baseType} using {@code typeFieldName} as - * the type field name. Type field names are case sensitive. + * Creates a new runtime type adapter using for {@code baseType} using {@code + * typeFieldName} as the type field name. Type field names are case sensitive. */ public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType, String typeFieldName) { return new RuntimeTypeAdapterFactory<T>(baseType, typeFieldName); } /** - * Creates a new runtime type adapter for {@code baseType} using {@code "type"} as the type field - * name. + * Creates a new runtime type adapter for {@code baseType} using {@code "type"} as + * the type field name. */ public static <T> RuntimeTypeAdapterFactory<T> of(Class<T> baseType) { return new RuntimeTypeAdapterFactory<T>(baseType, "type"); } /** - * Registers {@code type} identified by {@code label}. Labels are case sensitive. + * Registers {@code type} identified by {@code label}. Labels are case + * sensitive. * - * @throws IllegalArgumentException if either {@code type} or {@code label} have already been - * registered on this type adapter. + * @throws IllegalArgumentException if either {@code type} or {@code label} + * have already been registered on this type adapter. */ public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type, String label) { if (type == null) { @@ -86,11 +88,11 @@ public class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory { } /** - * Registers {@code type} identified by its {@link Class#getSimpleName simple name}. Labels are - * case sensitive. + * Registers {@code type} identified by its {@link Class#getSimpleName simple + * name}. Labels are case sensitive. * - * @throws IllegalArgumentException if either {@code type} or its simple name have already been - * registered on this type adapter. + * @throws IllegalArgumentException if either {@code type} or its simple name + * have already been registered on this type adapter. */ public RuntimeTypeAdapterFactory<T> registerSubtype(Class<? extends T> type) { return registerSubtype(type, type.getSimpleName()); @@ -111,41 +113,32 @@ public class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory { } return new TypeAdapter<R>() { - @Override - public R read(JsonReader in) throws IOException { + @Override public R read(JsonReader in) throws IOException { JsonElement jsonElement = Streams.parse(in); JsonElement labelJsonElement = jsonElement.getAsJsonObject().remove(typeFieldName); String label = (labelJsonElement == null ? null : labelJsonElement.getAsString()); @SuppressWarnings("unchecked") // registration requires that subtype extends T - TypeAdapter<R> delegate = (TypeAdapter<R>) labelToDelegate.get(label); + TypeAdapter<R> delegate = (TypeAdapter<R>) labelToDelegate.get(label); if (delegate == null) { - throw new JsonParseException( - "cannot deserialize " - + baseType - + " subtype named " - + label - + "; did you forget to register a subtype?"); + throw new JsonParseException("cannot deserialize " + baseType + " subtype named " + + label + "; did you forget to register a subtype?"); } return delegate.fromJsonTree(jsonElement); } - @Override - public void write(JsonWriter out, R value) throws IOException { + @Override public void write(JsonWriter out, R value) throws IOException { Class<?> srcType = value.getClass(); String label = subtypeToLabel.get(srcType); @SuppressWarnings("unchecked") // registration requires that subtype extends T - TypeAdapter<R> delegate = (TypeAdapter<R>) subtypeToDelegate.get(srcType); + TypeAdapter<R> delegate = (TypeAdapter<R>) subtypeToDelegate.get(srcType); if (delegate == null) { - throw new JsonParseException( - "cannot serialize " + srcType.getName() + "; did you forget to register a subtype?"); + throw new JsonParseException("cannot serialize " + srcType.getName() + + "; did you forget to register a subtype?"); } JsonObject jsonObject = delegate.toJsonTree(value).getAsJsonObject(); if (jsonObject.has(typeFieldName) && !srcType.getSimpleName().equals("OldInput")) { - throw new JsonParseException( - "cannot serialize " - + srcType.getName() - + " because it already defines a field named " - + typeFieldName); + throw new JsonParseException("cannot serialize " + srcType.getName() + + " because it already defines a field named " + typeFieldName); } JsonObject clone = new JsonObject(); if (!srcType.getSimpleName().equals("OldInput")) { @@ -159,3 +152,4 @@ public class RuntimeTypeAdapterFactory<T> implements TypeAdapterFactory { }.nullSafe(); } } + http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java index 6d3be2a..02a0ff4 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/CheckBox.java @@ -15,14 +15,18 @@ * limitations under the License. */ + package org.apache.zeppelin.display.ui; import java.util.Collection; -/** Html Checkbox */ +/** + * Html Checkbox + */ public class CheckBox extends OptionInput<Object[]> { - public CheckBox() {} + public CheckBox() { + } public CheckBox(String name, Object[] defaultValue, ParamOption[] options) { this.name = name; @@ -34,4 +38,5 @@ public class CheckBox extends OptionInput<Object[]> { public CheckBox(String name, Collection<Object> defaultValue, ParamOption[] options) { this(name, defaultValue.toArray(), options); } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/OptionInput.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/OptionInput.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/OptionInput.java index 95de795..d5a1c0d 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/OptionInput.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/OptionInput.java @@ -15,6 +15,7 @@ * limitations under the License. */ + package org.apache.zeppelin.display.ui; import org.apache.zeppelin.display.Input; @@ -26,7 +27,9 @@ import org.apache.zeppelin.display.Input; */ public abstract class OptionInput<T> extends Input<T> { - /** Parameters option. */ + /** + * Parameters option. + */ public static class ParamOption { Object value; String displayName; @@ -46,6 +49,7 @@ public abstract class OptionInput<T> extends Input<T> { if (value != null ? !value.equals(that.value) : that.value != null) return false; return displayName != null ? displayName.equals(that.displayName) : that.displayName == null; + } @Override @@ -70,6 +74,7 @@ public abstract class OptionInput<T> extends Input<T> { public void setDisplayName(String displayName) { this.displayName = displayName; } + } protected ParamOption[] options; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Password.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Password.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Password.java index fefa4d8..e3fd624 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Password.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Password.java @@ -15,17 +15,22 @@ * limitations under the License. */ + package org.apache.zeppelin.display.ui; import org.apache.zeppelin.display.Input; public class Password extends Input<String> { - public Password() {} + public Password() { + + } public Password(String name) { this.name = name; this.displayName = name; this.defaultValue = ""; } + } + http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Select.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Select.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Select.java index 54f06aa..212d3d7 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Select.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/Select.java @@ -17,10 +17,14 @@ package org.apache.zeppelin.display.ui; -/** Html Dropdown list */ +/** + * Html Dropdown list + */ public class Select extends OptionInput<Object> { - public Select() {} + public Select() { + + } public Select(String name, Object defaultValue, ParamOption[] options) { this.name = name; @@ -28,4 +32,5 @@ public class Select extends OptionInput<Object> { this.defaultValue = defaultValue; this.options = options; } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/TextBox.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/TextBox.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/TextBox.java index c06d1bb..b9f9946 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/TextBox.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/display/ui/TextBox.java @@ -15,18 +15,24 @@ * limitations under the License. */ + package org.apache.zeppelin.display.ui; import org.apache.zeppelin.display.Input; -/** Html TextBox control */ +/** + * Html TextBox control + */ public class TextBox extends Input<String> { - public TextBox() {} + public TextBox() { + + } public TextBox(String name, String defaultValue) { this.name = name; this.displayName = name; this.defaultValue = defaultValue; } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java index 260a9bb..d138595 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/Application.java @@ -16,13 +16,15 @@ */ package org.apache.zeppelin.helium; -import java.io.IOException; import org.apache.zeppelin.annotation.Experimental; import org.apache.zeppelin.resource.ResourceSet; +import java.io.IOException; + /** - * Base class for pluggable application (e.g. visualization) Application can access resources from - * ResourcePool and interact with front-end using AngularDisplay system + * Base class for pluggable application (e.g. visualization) + * Application can access resources from ResourcePool and interact with front-end using + * AngularDisplay system */ @Experimental public abstract class Application { @@ -38,19 +40,22 @@ public abstract class Application { } /** - * This method can be invoked multiple times before unload(), Either just after application - * selected or when paragraph re-run after application load + * This method can be invoked multiple times before unload(), + * Either just after application selected or when paragraph re-run after application load */ @Experimental - public abstract void run(ResourceSet args) throws ApplicationException, IOException; + public abstract void run(ResourceSet args) + throws ApplicationException, IOException; - /** this method is invoked just before application is removed */ + + /** + * this method is invoked just before application is removed + */ @Experimental public abstract void unload() throws ApplicationException; /** * Print string on the notebook - * * @param string * @throws IOException */ @@ -61,7 +66,6 @@ public abstract class Application { /** * Print string on the notebook with newline - * * @param string * @throws IOException */ @@ -72,7 +76,6 @@ public abstract class Application { /** * Print resource on the notebook - * * @param resourceName * @throws IOException */ @@ -84,14 +87,14 @@ public abstract class Application { /** * Print resource as a javascript * - * <p>Using this method does not require print javascript inside of <script></script> tag. - * Javascript printed using this method will be run in the un-named function. i.e. each method - * call will creates different variable scope for the javascript code. + * Using this method does not require print javascript inside of <script></script> tag. + * Javascript printed using this method will be run in the un-named function. + * i.e. each method call will creates different variable scope for the javascript code. * - * <p>This method inject '$z' into the variable scope for convenience. + * This method inject '$z' into the variable scope for convenience. * - * <p>$z.scope : angularjs scope object for this application $z.id : unique id for this - * application instance + * $z.scope : angularjs scope object for this application + * $z.id : unique id for this application instance * * @param resourceName * @throws IOException @@ -106,14 +109,14 @@ public abstract class Application { /** * Print string as a javascript * - * <p>Using this method does not require print javascript inside of <script></script> tag. - * Javascript printed using this method will be run in the un-named function. i.e. each method - * call will creates different variable scope for the javascript code. + * Using this method does not require print javascript inside of <script></script> tag. + * Javascript printed using this method will be run in the un-named function. + * i.e. each method call will creates different variable scope for the javascript code. * - * <p>This method inject '$z' into the variable scope for convenience. + * This method inject '$z' into the variable scope for convenience. * - * <p>$z.scope : angularjs scope object for this application $z.id : unique id for this - * application instance + * $z.scope : angularjs scope object for this application + * $z.id : unique id for this application instance * * @param js * @throws IOException @@ -133,9 +136,8 @@ public abstract class Application { js.append("id : \"" + context.getApplicationInstanceId() + "\",\n"); js.append("scope : angular.element(\"#app_js_" + js.hashCode() + "\").scope()\n"); js.append("};\n"); - js.append( - "$z.result = ($z.scope._devmodeResult) ? " - + "$z.scope._devmodeResult : $z.scope.$parent.paragraph.result;\n"); + js.append("$z.result = ($z.scope._devmodeResult) ? " + + "$z.scope._devmodeResult : $z.scope.$parent.paragraph.result;\n"); context.out.write(js.toString()); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java index 1f8246a..8d3f67e 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationContext.java @@ -18,7 +18,9 @@ package org.apache.zeppelin.helium; import org.apache.zeppelin.interpreter.InterpreterOutput; -/** ApplicationContext */ +/** + * ApplicationContext + */ public class ApplicationContext { private final String noteId; private final String paragraphId; @@ -26,12 +28,12 @@ public class ApplicationContext { private final HeliumAppAngularObjectRegistry angularObjectRegistry; public final InterpreterOutput out; - public ApplicationContext( - String noteId, - String paragraphId, - String applicationInstanceId, - HeliumAppAngularObjectRegistry angularObjectRegistry, - InterpreterOutput out) { + + public ApplicationContext(String noteId, + String paragraphId, + String applicationInstanceId, + HeliumAppAngularObjectRegistry angularObjectRegistry, + InterpreterOutput out) { this.noteId = noteId; this.paragraphId = paragraphId; this.applicationInstanceId = applicationInstanceId; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java index b34b715..ca971f5 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationEventListener.java @@ -18,19 +18,15 @@ package org.apache.zeppelin.helium; import org.apache.zeppelin.interpreter.InterpreterResult; -/** Event from HeliumApplication running on remote interpreter process */ +/** + * Event from HeliumApplication running on remote interpreter process + */ public interface ApplicationEventListener { - void onOutputAppend(String noteId, String paragraphId, int index, String appId, String output); - + void onOutputAppend( + String noteId, String paragraphId, int index, String appId, String output); void onOutputUpdated( - String noteId, - String paragraphId, - int index, - String appId, - InterpreterResult.Type type, - String output); - + String noteId, String paragraphId, int index, String appId, + InterpreterResult.Type type, String output); void onLoad(String noteId, String paragraphId, String appId, HeliumPackage pkg); - void onStatusChange(String noteId, String paragraphId, String appId, String status); } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationException.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationException.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationException.java index 5fa3553..d3c6488 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationException.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationException.java @@ -16,7 +16,9 @@ */ package org.apache.zeppelin.helium; -/** Application exception */ +/** + * Application exception + */ public class ApplicationException extends Exception { public ApplicationException(String s) { super(s); @@ -26,7 +28,9 @@ public class ApplicationException extends Exception { super(e); } - public ApplicationException() {} + public ApplicationException() { + + } public ApplicationException(String message, Throwable cause) { super(message, cause); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java index 967d039..241273a 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ApplicationLoader.java @@ -16,6 +16,14 @@ */ package org.apache.zeppelin.helium; +import org.apache.zeppelin.dep.DependencyResolver; +import org.apache.zeppelin.resource.DistributedResourcePool; +import org.apache.zeppelin.resource.Resource; +import org.apache.zeppelin.resource.ResourcePool; +import org.apache.zeppelin.resource.ResourceSet; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; + import java.io.File; import java.lang.reflect.Constructor; import java.net.URL; @@ -25,15 +33,10 @@ import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; -import org.apache.zeppelin.dep.DependencyResolver; -import org.apache.zeppelin.resource.DistributedResourcePool; -import org.apache.zeppelin.resource.Resource; -import org.apache.zeppelin.resource.ResourcePool; -import org.apache.zeppelin.resource.ResourceSet; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -/** Load application */ +/** + * Load application + */ public class ApplicationLoader { Logger logger = LoggerFactory.getLogger(ApplicationLoader.class); @@ -44,10 +47,13 @@ public class ApplicationLoader { public ApplicationLoader(ResourcePool resourcePool, DependencyResolver depResolver) { this.depResolver = depResolver; this.resourcePool = resourcePool; - cached = Collections.synchronizedMap(new HashMap<HeliumPackage, Class<Application>>()); + cached = Collections.synchronizedMap( + new HashMap<HeliumPackage, Class<Application>>()); } - /** Information of loaded application */ + /** + * Information of loaded application + */ private static class RunningApplication { HeliumPackage packageInfo; String noteId; @@ -84,13 +90,13 @@ public class ApplicationLoader { } RunningApplication r = (RunningApplication) o; - return packageInfo.equals(r.getPackageInfo()) - && paragraphId.equals(r.getParagraphId()) - && noteId.equals(r.getNoteId()); + return packageInfo.equals(r.getPackageInfo()) && paragraphId.equals(r.getParagraphId()) && + noteId.equals(r.getNoteId()); } } /** + * * Instantiate application * * @param packageInfo @@ -98,7 +104,8 @@ public class ApplicationLoader { * @return * @throws Exception */ - public Application load(HeliumPackage packageInfo, ApplicationContext context) throws Exception { + public Application load(HeliumPackage packageInfo, ApplicationContext context) + throws Exception { if (packageInfo.getType() != HeliumType.APPLICATION) { throw new ApplicationException( "Can't instantiate " + packageInfo.getType() + " package using ApplicationLoader"); @@ -109,9 +116,8 @@ public class ApplicationLoader { new RunningApplication(packageInfo, context.getNoteId(), context.getParagraphId()); // get resource required by this package - ResourceSet resources = - findRequiredResourceSet( - packageInfo.getResources(), context.getNoteId(), context.getParagraphId()); + ResourceSet resources = findRequiredResourceSet(packageInfo.getResources(), + context.getNoteId(), context.getParagraphId()); // load class Class<Application> appClass = loadClass(packageInfo); @@ -133,7 +139,7 @@ public class ApplicationLoader { } public ResourceSet findRequiredResourceSet( - String[][] requiredResources, String noteId, String paragraphId) { + String [][] requiredResources, String noteId, String paragraphId) { if (requiredResources == null || requiredResources.length == 0) { return new ResourceSet(); } @@ -148,8 +154,10 @@ public class ApplicationLoader { return findRequiredResourceSet(requiredResources, noteId, paragraphId, allResources); } - static ResourceSet findRequiredResourceSet( - String[][] requiredResources, String noteId, String paragraphId, ResourceSet resources) { + static ResourceSet findRequiredResourceSet(String [][] requiredResources, + String noteId, + String paragraphId, + ResourceSet resources) { ResourceSet args = new ResourceSet(); if (requiredResources == null || requiredResources.length == 0) { return args; @@ -157,7 +165,7 @@ public class ApplicationLoader { resources = resources.filterByNoteId(noteId).filterByParagraphId(paragraphId); - for (String[] requires : requiredResources) { + for (String [] requires : requiredResources) { args.clear(); for (String require : requires) { @@ -189,6 +197,7 @@ public class ApplicationLoader { return null; } + private Class<Application> loadClass(HeliumPackage packageInfo) throws Exception { if (cached.containsKey(packageInfo)) { return cached.get(packageInfo); @@ -210,7 +219,8 @@ public class ApplicationLoader { } URLClassLoader applicationClassLoader = new URLClassLoader( - urlList.toArray(new URL[] {}), Thread.currentThread().getContextClassLoader()); + urlList.toArray(new URL[]{}), + Thread.currentThread().getContextClassLoader()); Class<Application> cls = (Class<Application>) applicationClassLoader.loadClass(packageInfo.getClassName()); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ClassLoaderApplication.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ClassLoaderApplication.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ClassLoaderApplication.java index 96fd261..272a152 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ClassLoaderApplication.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/ClassLoaderApplication.java @@ -18,11 +18,12 @@ package org.apache.zeppelin.helium; import org.apache.zeppelin.resource.ResourceSet; -/** Application wrapper */ +/** + * Application wrapper + */ public class ClassLoaderApplication extends Application { Application app; ClassLoader cl; - public ClassLoaderApplication(Application app, ClassLoader cl) throws ApplicationException { super(app.context()); this.app = app; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumAppAngularObjectRegistry.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumAppAngularObjectRegistry.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumAppAngularObjectRegistry.java index 2ff7ee8..dedb603 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumAppAngularObjectRegistry.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumAppAngularObjectRegistry.java @@ -16,18 +16,22 @@ */ package org.apache.zeppelin.helium; -import java.util.List; import org.apache.zeppelin.display.AngularObject; import org.apache.zeppelin.display.AngularObjectRegistry; -/** Angular Registry for helium app */ +import java.util.List; + +/** + * Angular Registry for helium app + */ public class HeliumAppAngularObjectRegistry { private final String noteId; private final String appId; private final AngularObjectRegistry angularObjectRegistry; - public HeliumAppAngularObjectRegistry( - AngularObjectRegistry angularObjectRegistry, String noteId, String appId) { + public HeliumAppAngularObjectRegistry(AngularObjectRegistry angularObjectRegistry, + String noteId, + String appId) { this.angularObjectRegistry = angularObjectRegistry; this.noteId = noteId; this.appId = appId; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java index 4571883..e9995c1 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumPackage.java @@ -17,42 +17,44 @@ package org.apache.zeppelin.helium; import com.google.gson.Gson; -import java.util.Map; import org.apache.zeppelin.annotation.Experimental; import org.apache.zeppelin.common.JsonSerializable; -/** Helium package definition */ +import java.util.Map; + +/** + * Helium package definition + */ @Experimental public class HeliumPackage implements JsonSerializable { private static final Gson gson = new Gson(); private HeliumType type; - private String name; // user friendly name of this application - private String description; // description - private String artifact; // artifact name e.g) groupId:artifactId:versionId - private String className; // entry point + private String name; // user friendly name of this application + private String description; // description + private String artifact; // artifact name e.g) groupId:artifactId:versionId + private String className; // entry point // resource classnames that requires [[ .. and .. and .. ] or [ .. and .. and ..] ..] - private String[][] resources; + private String [][] resources; private String license; private String icon; private String published; - private String groupId; // get groupId of INTERPRETER type package - private String artifactId; // get artifactId of INTERPRETER type package + private String groupId; // get groupId of INTERPRETER type package + private String artifactId; // get artifactId of INTERPRETER type package private SpellPackageInfo spell; private Map<String, Object> config; - public HeliumPackage( - HeliumType type, - String name, - String description, - String artifact, - String className, - String[][] resources, - String license, - String icon) { + public HeliumPackage(HeliumType type, + String name, + String description, + String artifact, + String className, + String[][] resources, + String license, + String icon) { this.type = type; this.name = name; this.description = description; @@ -83,7 +85,8 @@ public class HeliumPackage implements JsonSerializable { } public static boolean isBundleType(HeliumType type) { - return (type == HeliumType.VISUALIZATION || type == HeliumType.SPELL); + return (type == HeliumType.VISUALIZATION || + type == HeliumType.SPELL); } public String getName() { @@ -130,9 +133,7 @@ public class HeliumPackage implements JsonSerializable { return spell; } - public Map<String, Object> getConfig() { - return config; - } + public Map<String, Object> getConfig() { return config; } public String toJson() { return gson.toJson(this); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumType.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumType.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumType.java index 02043d1..53360a0 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumType.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/HeliumType.java @@ -17,7 +17,9 @@ package org.apache.zeppelin.helium; -/** Type of Helium Package */ +/** + * Type of Helium Package + */ public enum HeliumType { INTERPRETER, NOTEBOOK_REPO, http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/SpellPackageInfo.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/SpellPackageInfo.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/SpellPackageInfo.java index e55faa7..519d09d 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/SpellPackageInfo.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/helium/SpellPackageInfo.java @@ -17,7 +17,9 @@ package org.apache.zeppelin.helium; -/** Info for Helium Spell Package. */ +/** + * Info for Helium Spell Package. + */ public class SpellPackageInfo { private String magic; private String usage; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/BaseZeppelinContext.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/BaseZeppelinContext.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/BaseZeppelinContext.java index da03dfa..6a44f12 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/BaseZeppelinContext.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/BaseZeppelinContext.java @@ -17,11 +17,6 @@ package org.apache.zeppelin.interpreter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; import org.apache.thrift.TException; import org.apache.zeppelin.annotation.Experimental; import org.apache.zeppelin.annotation.ZeppelinApi; @@ -36,7 +31,15 @@ import org.apache.zeppelin.resource.ResourceSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -/** Base class for ZeppelinContext */ +import java.io.IOException; +import java.util.ArrayList; +import java.util.LinkedList; +import java.util.List; +import java.util.Map; + +/** + * Base class for ZeppelinContext + */ public abstract class BaseZeppelinContext { private static final Logger LOGGER = LoggerFactory.getLogger(BaseZeppelinContext.class); @@ -70,14 +73,18 @@ public abstract class BaseZeppelinContext { */ protected abstract String showData(Object obj); - /** @deprecated use z.textbox instead */ + /** + * @deprecated use z.textbox instead + */ @Deprecated @ZeppelinApi public Object input(String name) { return textbox(name); } - /** @deprecated use z.textbox instead */ + /** + * @deprecated use z.textbox instead + */ @Deprecated @ZeppelinApi public Object input(String name, Object defaultValue) { @@ -114,7 +121,8 @@ public abstract class BaseZeppelinContext { } @ZeppelinApi - public List<Object> checkbox(String name, List<Object> defaultChecked, ParamOption[] options) { + public List<Object> checkbox(String name, List<Object> defaultChecked, + ParamOption[] options) { return checkbox(name, defaultChecked, options, false); } @@ -139,8 +147,8 @@ public abstract class BaseZeppelinContext { } @ZeppelinApi - public List<Object> noteCheckbox( - String name, List<Object> defaultChecked, ParamOption[] options) { + public List<Object> noteCheckbox(String name, List<Object> defaultChecked, + ParamOption[] options) { return checkbox(name, defaultChecked, options, true); } @@ -149,8 +157,9 @@ public abstract class BaseZeppelinContext { return select(name, defaultValue, paramOptions, true); } - private Object select( - String name, Object defaultValue, ParamOption[] paramOptions, boolean noteForm) { + + private Object select(String name, Object defaultValue, ParamOption[] paramOptions, + boolean noteForm) { if (noteForm) { return noteGui.select(name, defaultValue, paramOptions); } else { @@ -166,7 +175,8 @@ public abstract class BaseZeppelinContext { } } - private List<Object> checkbox(String name, ParamOption[] options, boolean noteForm) { + private List<Object> checkbox(String name, ParamOption[] options, + boolean noteForm) { List<Object> defaultValues = new LinkedList<>(); for (ParamOption option : options) { defaultValues.add(option.getValue()); @@ -178,8 +188,8 @@ public abstract class BaseZeppelinContext { } } - private List<Object> checkbox( - String name, List<Object> defaultChecked, ParamOption[] options, boolean noteForm) { + private List<Object> checkbox(String name, List<Object> defaultChecked, + ParamOption[] options, boolean noteForm) { if (noteForm) { return noteGui.checkbox(name, defaultChecked, options); } else { @@ -195,6 +205,7 @@ public abstract class BaseZeppelinContext { return gui; } + public GUI getNoteGui() { return noteGui; } @@ -214,10 +225,10 @@ public abstract class BaseZeppelinContext { public void setMaxResult(int maxResult) { this.maxResult = maxResult; } - + /** - * display special types of objects for interpreter. Each interpreter can has its own supported - * classes. + * display special types of objects for interpreter. + * Each interpreter can has its own supported classes. * * @param o object */ @@ -227,10 +238,10 @@ public abstract class BaseZeppelinContext { } /** - * display special types of objects for interpreter. Each interpreter can has its own supported - * classes. + * display special types of objects for interpreter. + * Each interpreter can has its own supported classes. * - * @param o object + * @param o object * @param maxResult maximum number of rows to display */ @ZeppelinApi @@ -239,10 +250,8 @@ public abstract class BaseZeppelinContext { if (isSupportedObject(o)) { interpreterContext.out.write(showData(o)); } else { - interpreterContext.out.write( - "ZeppelinContext doesn't support to show type: " - + o.getClass().getCanonicalName() - + "\n"); + interpreterContext.out.write("ZeppelinContext doesn't support to show type: " + + o.getClass().getCanonicalName() + "\n"); interpreterContext.out.write(o.toString()); } } catch (IOException e) { @@ -282,7 +291,8 @@ public abstract class BaseZeppelinContext { } @ZeppelinApi - public void run(String noteId, String paragraphId) throws IOException { + public void run(String noteId, String paragraphId) + throws IOException { run(noteId, paragraphId, InterpreterContext.get(), true); } @@ -304,9 +314,8 @@ public abstract class BaseZeppelinContext { * @param context */ @ZeppelinApi - public void run( - String noteId, String paragraphId, InterpreterContext context, boolean checkCurrentParagraph) - throws IOException { + public void run(String noteId, String paragraphId, InterpreterContext context, + boolean checkCurrentParagraph) throws IOException { if (paragraphId.equals(context.getParagraphId()) && checkCurrentParagraph) { throw new RuntimeException("Can not run current Paragraph"); @@ -314,8 +323,7 @@ public abstract class BaseZeppelinContext { List<String> paragraphIds = new ArrayList<>(); paragraphIds.add(paragraphId); List<Integer> paragraphIndices = new ArrayList<>(); - context - .getIntpEventClient() + context.getIntpEventClient() .runParagraphs(noteId, paragraphIds, paragraphIndices, context.getParagraphId()); } @@ -326,8 +334,7 @@ public abstract class BaseZeppelinContext { public void runNote(String noteId, InterpreterContext context) throws IOException { List<String> paragraphIds = new ArrayList<>(); List<Integer> paragraphIndices = new ArrayList<>(); - context - .getIntpEventClient() + context.getIntpEventClient() .runParagraphs(noteId, paragraphIds, paragraphIndices, context.getParagraphId()); } @@ -342,10 +349,10 @@ public abstract class BaseZeppelinContext { } /** - * @param idx paragraph index + * @param idx paragraph index * @param checkCurrentParagraph check whether you call this run method in the current paragraph. - * Set it to false only when you are sure you are not invoking this method to run current - * paragraph. Otherwise you would run current paragraph in infinite loop. + * Set it to false only when you are sure you are not invoking this method to run current + * paragraph. Otherwise you would run current paragraph in infinite loop. */ public void run(int idx, boolean checkCurrentParagraph) throws IOException { String noteId = interpreterContext.getNoteId(); @@ -356,7 +363,7 @@ public abstract class BaseZeppelinContext { * Run paragraph at index * * @param noteId - * @param idx index starting from 0 + * @param idx index starting from 0 * @param context interpreter context */ public void run(String noteId, int idx, InterpreterContext context) throws IOException { @@ -365,20 +372,20 @@ public abstract class BaseZeppelinContext { /** * @param noteId - * @param idx paragraph index - * @param context interpreter context - * @param checkCurrentParagraph check whether you call this run method in the current paragraph. - * Set it to false only when you are sure you are not invoking this method to run current - * paragraph. Otherwise you would run current paragraph in infinite loop. + * @param idx paragraph index + * @param context interpreter context + * @param checkCurrentParagraph + * check whether you call this run method in the current paragraph. + * Set it to false only when you are sure you are not invoking this method to run current + * paragraph. Otherwise you would run current paragraph in infinite loop. */ - public void run(String noteId, int idx, InterpreterContext context, boolean checkCurrentParagraph) - throws IOException { + public void run(String noteId, int idx, InterpreterContext context, + boolean checkCurrentParagraph) throws IOException { List<String> paragraphIds = new ArrayList<>(); List<Integer> paragraphIndices = new ArrayList<>(); paragraphIndices.add(idx); - context - .getIntpEventClient() + context.getIntpEventClient() .runParagraphs(noteId, paragraphIds, paragraphIndices, context.getParagraphId()); } @@ -387,7 +394,9 @@ public abstract class BaseZeppelinContext { runAll(interpreterContext); } - /** Run all paragraphs. except this. */ + /** + * Run all paragraphs. except this. + */ @ZeppelinApi public void runAll(InterpreterContext context) throws IOException { runNote(context.getNoteId()); @@ -409,6 +418,7 @@ public abstract class BaseZeppelinContext { return ao; } + /** * Get angular object. Look up notebook scope first and then global scope * @@ -443,11 +453,11 @@ public abstract class BaseZeppelinContext { } /** - * Create angular variable in notebook scope and bind with front end Angular display system. If - * variable exists, it'll be overwritten. + * Create angular variable in notebook scope and bind with front end Angular display system. + * If variable exists, it'll be overwritten. * * @param name name of the variable - * @param o value + * @param o value */ @ZeppelinApi public void angularBind(String name, Object o) throws TException { @@ -455,11 +465,11 @@ public abstract class BaseZeppelinContext { } /** - * Create angular variable in global scope and bind with front end Angular display system. If - * variable exists, it'll be overwritten. + * Create angular variable in global scope and bind with front end Angular display system. + * If variable exists, it'll be overwritten. * * @param name name of the variable - * @param o value + * @param o value */ @Deprecated public void angularBindGlobal(String name, Object o) throws TException { @@ -467,11 +477,11 @@ public abstract class BaseZeppelinContext { } /** - * Create angular variable in local scope and bind with front end Angular display system. If - * variable exists, value will be overwritten and watcher will be added. + * Create angular variable in local scope and bind with front end Angular display system. + * If variable exists, value will be overwritten and watcher will be added. * - * @param name name of variable - * @param o value + * @param name name of variable + * @param o value * @param watcher watcher of the variable */ @ZeppelinApi @@ -480,11 +490,11 @@ public abstract class BaseZeppelinContext { } /** - * Create angular variable in global scope and bind with front end Angular display system. If - * variable exists, value will be overwritten and watcher will be added. + * Create angular variable in global scope and bind with front end Angular display system. + * If variable exists, value will be overwritten and watcher will be added. * - * @param name name of variable - * @param o value + * @param name name of variable + * @param o value * @param watcher watcher of the variable */ @Deprecated @@ -496,7 +506,7 @@ public abstract class BaseZeppelinContext { /** * Add watcher into angular variable (local scope) * - * @param name name of the variable + * @param name name of the variable * @param watcher watcher */ @ZeppelinApi @@ -507,7 +517,7 @@ public abstract class BaseZeppelinContext { /** * Add watcher into angular variable (global scope) * - * @param name name of the variable + * @param name name of the variable * @param watcher watcher */ @Deprecated @@ -515,6 +525,7 @@ public abstract class BaseZeppelinContext { angularWatch(name, null, watcher); } + /** * Remove watcher from angular variable (local) * @@ -537,6 +548,7 @@ public abstract class BaseZeppelinContext { angularUnwatch(name, null, watcher); } + /** * Remove all watchers for the angular variable (local) * @@ -579,11 +591,11 @@ public abstract class BaseZeppelinContext { } /** - * Create angular variable in notebook scope and bind with front end Angular display system. If - * variable exists, it'll be overwritten. + * Create angular variable in notebook scope and bind with front end Angular display system. + * If variable exists, it'll be overwritten. * * @param name name of the variable - * @param o value + * @param o value */ public void angularBind(String name, Object o, String noteId) throws TException { AngularObjectRegistry registry = interpreterContext.getAngularObjectRegistry(); @@ -596,11 +608,12 @@ public abstract class BaseZeppelinContext { } /** - * Create angular variable in notebook scope and bind with front end Angular display system. If - * variable exists, value will be overwritten and watcher will be added. + * Create angular variable in notebook scope and bind with front end Angular display + * system. + * If variable exists, value will be overwritten and watcher will be added. * - * @param name name of variable - * @param o value + * @param name name of variable + * @param o value * @param watcher watcher of the variable */ private void angularBind(String name, Object o, String noteId, AngularObjectWatcher watcher) @@ -618,7 +631,7 @@ public abstract class BaseZeppelinContext { /** * Add watcher into angular binding variable * - * @param name name of the variable + * @param name name of the variable * @param watcher watcher */ public void angularWatch(String name, String noteId, AngularObjectWatcher watcher) { @@ -680,8 +693,8 @@ public abstract class BaseZeppelinContext { /** * General function to register hook event * - * @param event The type of event to hook to (pre_exec, post_exec) - * @param cmd The code to be executed by the interpreter on given event + * @param event The type of event to hook to (pre_exec, post_exec) + * @param cmd The code to be executed by the interpreter on given event * @param replName Name of the interpreter */ @Experimental @@ -694,7 +707,7 @@ public abstract class BaseZeppelinContext { * registerHook() wrapper for current repl * * @param event The type of event to hook to (pre_exec, post_exec) - * @param cmd The code to be executed by the interpreter on given event + * @param cmd The code to be executed by the interpreter on given event */ @Experimental public void registerHook(String event, String cmd) throws InvalidHookException { @@ -725,7 +738,7 @@ public abstract class BaseZeppelinContext { /** * Unbind code from given hook event and given repl * - * @param event The type of event to hook to (pre_exec, post_exec) + * @param event The type of event to hook to (pre_exec, post_exec) * @param replName Name of the interpreter */ @Experimental @@ -748,7 +761,7 @@ public abstract class BaseZeppelinContext { * Unbind code from given hook event and given note * * @param noteId The id of note - * @param event The type of event to hook to (pre_exec, post_exec) + * @param event The type of event to hook to (pre_exec, post_exec) */ @Experimental public void unregisterNoteHook(String noteId, String event) { @@ -756,11 +769,12 @@ public abstract class BaseZeppelinContext { hooks.unregister(noteId, className, event); } + /** * Unbind code from given hook event, given note and given repl * - * @param noteId The id of note - * @param event The type of event to hook to (pre_exec, post_exec) + * @param noteId The id of note + * @param event The type of event to hook to (pre_exec, post_exec) * @param replName Name of the interpreter */ @Experimental @@ -769,6 +783,7 @@ public abstract class BaseZeppelinContext { hooks.unregister(noteId, className, event); } + /** * Add object into resource pool * @@ -782,7 +797,8 @@ public abstract class BaseZeppelinContext { } /** - * Get object from resource pool Search local process first and then the other processes + * Get object from resource pool + * Search local process first and then the other processes * * @param name * @return null if resource not found @@ -822,7 +838,9 @@ public abstract class BaseZeppelinContext { return resource != null; } - /** Get all resources */ + /** + * Get all resources + */ @ZeppelinApi public ResourceSet getAll() { ResourcePool resourcePool = interpreterContext.getResourcePool(); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java index 20ddfdd..87748ff 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/Constants.java @@ -21,7 +21,11 @@ import java.util.HashMap; import java.util.Map; import java.util.concurrent.TimeUnit; -/** Interpreter related constants */ +/** + * Interpreter related constants + * + * + */ public class Constants { public static final String ZEPPELIN_INTERPRETER_PORT = "zeppelin.interpreter.port"; @@ -45,4 +49,5 @@ public class Constants { TIME_SUFFIXES.put("h", TimeUnit.HOURS); TIME_SUFFIXES.put("d", TimeUnit.DAYS); } + } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/0d746fa2/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java ---------------------------------------------------------------------- diff --git a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java index b50e00d..f11cbc3 100644 --- a/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java +++ b/zeppelin-interpreter/src/main/java/org/apache/zeppelin/interpreter/DefaultInterpreterProperty.java @@ -17,7 +17,9 @@ package org.apache.zeppelin.interpreter; -/** Property for registered interpreter */ +/** + * Property for registered interpreter + */ public class DefaultInterpreterProperty { private String envName; private String propertyName; @@ -25,8 +27,8 @@ public class DefaultInterpreterProperty { private String description; private String type; - public DefaultInterpreterProperty( - String envName, String propertyName, Object defaultValue, String description, String type) { + public DefaultInterpreterProperty(String envName, String propertyName, Object defaultValue, + String description, String type) { this.envName = envName; this.propertyName = propertyName; this.defaultValue = defaultValue; @@ -46,13 +48,9 @@ public class DefaultInterpreterProperty { this(envName, propertyName, defaultValue, null, InterpreterPropertyType.TEXTAREA.getValue()); } - public DefaultInterpreterProperty( - String envName, String propertyName, String defaultValue, String description) { - this( - envName, - propertyName, - defaultValue, - description, + public DefaultInterpreterProperty(String envName, String propertyName, String defaultValue, + String description) { + this(envName, propertyName, defaultValue, description, InterpreterPropertyType.TEXTAREA.getValue()); } @@ -124,8 +122,7 @@ public class DefaultInterpreterProperty { @Override public String toString() { - return String.format( - "{envName=%s, propertyName=%s, defaultValue=%s, description=%20s, " + "type=%s}", - envName, propertyName, defaultValue, description, type); + return String.format("{envName=%s, propertyName=%s, defaultValue=%s, description=%20s, " + + "type=%s}", envName, propertyName, defaultValue, description, type); } }
