From commits-return-4820-archive-asf-public=cust-asf.ponee.io@zeppelin.apache.org Sun Aug 26 06:43:52 2018 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by mx-eu-01.ponee.io (Postfix) with SMTP id 75C1C180679 for ; Sun, 26 Aug 2018 06:43:49 +0200 (CEST) Received: (qmail 53791 invoked by uid 500); 26 Aug 2018 04:43:48 -0000 Mailing-List: contact commits-help@zeppelin.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@zeppelin.apache.org Delivered-To: mailing list commits@zeppelin.apache.org Received: (qmail 51687 invoked by uid 99); 26 Aug 2018 04:43:46 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Sun, 26 Aug 2018 04:43:46 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id D2E36E11B2; Sun, 26 Aug 2018 04:43:44 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jongyoul@apache.org To: commits@zeppelin.apache.org Date: Sun, 26 Aug 2018 04:44:13 -0000 Message-Id: In-Reply-To: <0adeff196a68402393e9e95080c19527@git.apache.org> References: <0adeff196a68402393e9e95080c19527@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [30/49] zeppelin git commit: [ZEPPELIN-3740] Adopt `google-java-format` and `fmt-maven-plugin` http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/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 930ed7c..0bcec1e 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,33 +24,32 @@ 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> 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() { @@ -60,9 +59,8 @@ public class AngularObjectRegistry { /** * Add object into registry * - * 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 @@ -85,14 +83,14 @@ public class AngularObjectRegistry { } } } - + private Map getRegistryForKey(String noteId, String paragraphId) { synchronized (registry) { String key = getRegistryKey(noteId, paragraphId); if (!registry.containsKey(key)) { registry.put(key, new HashMap()); } - + return registry.get(key); } } @@ -100,9 +98,8 @@ public class AngularObjectRegistry { /** * Add object into registry * - * 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 @@ -111,8 +108,7 @@ 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) { @@ -126,8 +122,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); } @@ -170,9 +166,9 @@ public class AngularObjectRegistry { /** * Remove all angular object in the scope. * - * 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 @@ -188,6 +184,7 @@ 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 @@ -202,6 +199,7 @@ 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 @@ -216,11 +214,10 @@ 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/55f6c91c/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 081bb43..c8f2bfa 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,12 +17,11 @@ 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/55f6c91c/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 c5bd5e2..286a372 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,9 +19,7 @@ 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/55f6c91c/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 8bae53f..767a466 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,12 +19,6 @@ 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; @@ -32,23 +26,22 @@ 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 params = new HashMap<>(); // form parameters from client Map forms = new LinkedHashMap<>(); // form configuration - public GUI() { - - } + public GUI() {} public void setParams(Map values) { this.params = values; @@ -109,8 +102,8 @@ public class GUI implements Serializable { return value; } - public List checkbox(String id, Collection defaultChecked, - ParamOption[] options) { + public List checkbox( + String id, Collection defaultChecked, ParamOption[] options) { Collection checked = (Collection) params.get(id); if (checked == null) { checked = defaultChecked; @@ -153,7 +146,6 @@ 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/55f6c91c/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 40878a8..80b1235 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,14 +17,6 @@ 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; @@ -35,6 +27,13 @@ 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. @@ -62,8 +61,7 @@ public class Input implements Serializable { protected boolean hidden; protected String argument; - public Input() { - } + public Input() {} public boolean isHidden() { return hidden; @@ -118,17 +116,17 @@ public class Input 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 @@ -215,7 +213,6 @@ public class Input implements Serializable { valuePart = null; } - String varName; String displayName = null; String type = null; @@ -268,11 +265,9 @@ public class Input implements Serializable { } } - } else { // no option defaultValue = valuePart; } - } Input input = null; @@ -295,8 +290,8 @@ public class Input implements Serializable { return input; } - public static LinkedHashMap extractSimpleQueryForm(String script, - boolean noteForm) { + public static LinkedHashMap extractSimpleQueryForm( + String script, boolean noteForm) { LinkedHashMap forms = new LinkedHashMap<>(); if (script == null) { return forms; @@ -341,16 +336,18 @@ public class Input 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 checked = value instanceof Collection ? (Collection) value - : Arrays.asList((Object[]) value); + Collection checked = + value instanceof Collection + ? (Collection) value + : Arrays.asList((Object[]) value); List 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); @@ -360,7 +357,7 @@ public class Input 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); @@ -370,10 +367,8 @@ public class Input implements Serializable { return replaced; } - public static String[] split(String str) { return str.split(";(?=([^\"']*\"[^\"']*\")*[^\"']*$)"); - } /* @@ -382,28 +377,32 @@ public class Input 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 splits = new ArrayList<>(); @@ -456,8 +455,10 @@ public class Input 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; @@ -465,8 +466,9 @@ public class Input 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) { @@ -513,8 +515,8 @@ public class Input 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; @@ -525,8 +527,7 @@ public class Input 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/55f6c91c/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 7c67dad..45ecba0 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,11 +20,10 @@ 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 { @@ -58,27 +57,21 @@ public class OldInput extends Input { 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/55f6c91c/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 65b4f6b..88d32d1 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,7 +28,6 @@ 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; @@ -53,27 +52,26 @@ public class RuntimeTypeAdapterFactory 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 RuntimeTypeAdapterFactory of(Class baseType, String typeFieldName) { return new RuntimeTypeAdapterFactory(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 RuntimeTypeAdapterFactory of(Class baseType) { return new RuntimeTypeAdapterFactory(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 registerSubtype(Class type, String label) { if (type == null) { @@ -88,11 +86,11 @@ public class RuntimeTypeAdapterFactory 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 registerSubtype(Class type) { return registerSubtype(type, type.getSimpleName()); @@ -113,32 +111,41 @@ public class RuntimeTypeAdapterFactory implements TypeAdapterFactory { } return new TypeAdapter() { - @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 delegate = (TypeAdapter) labelToDelegate.get(label); + TypeAdapter delegate = (TypeAdapter) 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 delegate = (TypeAdapter) subtypeToDelegate.get(srcType); + TypeAdapter delegate = (TypeAdapter) 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")) { @@ -152,4 +159,3 @@ public class RuntimeTypeAdapterFactory implements TypeAdapterFactory { }.nullSafe(); } } - http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/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 02a0ff4..6d3be2a 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,18 +15,14 @@ * limitations under the License. */ - package org.apache.zeppelin.display.ui; import java.util.Collection; -/** - * Html Checkbox - */ +/** Html Checkbox */ public class CheckBox extends OptionInput { - public CheckBox() { - } + public CheckBox() {} public CheckBox(String name, Object[] defaultValue, ParamOption[] options) { this.name = name; @@ -38,5 +34,4 @@ public class CheckBox extends OptionInput { public CheckBox(String name, Collection defaultValue, ParamOption[] options) { this(name, defaultValue.toArray(), options); } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/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 d5a1c0d..95de795 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,7 +15,6 @@ * limitations under the License. */ - package org.apache.zeppelin.display.ui; import org.apache.zeppelin.display.Input; @@ -27,9 +26,7 @@ import org.apache.zeppelin.display.Input; */ public abstract class OptionInput extends Input { - /** - * Parameters option. - */ + /** Parameters option. */ public static class ParamOption { Object value; String displayName; @@ -49,7 +46,6 @@ public abstract class OptionInput extends Input { if (value != null ? !value.equals(that.value) : that.value != null) return false; return displayName != null ? displayName.equals(that.displayName) : that.displayName == null; - } @Override @@ -74,7 +70,6 @@ public abstract class OptionInput extends Input { public void setDisplayName(String displayName) { this.displayName = displayName; } - } protected ParamOption[] options; http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/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 e3fd624..fefa4d8 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,22 +15,17 @@ * limitations under the License. */ - package org.apache.zeppelin.display.ui; import org.apache.zeppelin.display.Input; public class Password extends Input { - 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/55f6c91c/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 212d3d7..54f06aa 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,14 +17,10 @@ package org.apache.zeppelin.display.ui; -/** - * Html Dropdown list - */ +/** Html Dropdown list */ public class Select extends OptionInput { - public Select() { - - } + public Select() {} public Select(String name, Object defaultValue, ParamOption[] options) { this.name = name; @@ -32,5 +28,4 @@ public class Select extends OptionInput { this.defaultValue = defaultValue; this.options = options; } - } http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/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 b9f9946..c06d1bb 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,24 +15,18 @@ * 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 { - 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/55f6c91c/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 d138595..260a9bb 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,15 +16,13 @@ */ 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 { @@ -40,22 +38,19 @@ 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 */ @@ -66,6 +61,7 @@ public abstract class Application { /** * Print string on the notebook with newline + * * @param string * @throws IOException */ @@ -76,6 +72,7 @@ public abstract class Application { /** * Print resource on the notebook + * * @param resourceName * @throws IOException */ @@ -87,14 +84,14 @@ public abstract class Application { /** * Print resource as a javascript * - * Using this method does not require print javascript inside of 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 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. * - * This method inject '$z' into the variable scope for convenience. + *

This method inject '$z' into the variable scope for convenience. * - * $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 @@ -109,14 +106,14 @@ public abstract class Application { /** * Print string as a javascript * - * Using this method does not require print javascript inside of 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 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. * - * This method inject '$z' into the variable scope for convenience. + *

This method inject '$z' into the variable scope for convenience. * - * $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 @@ -136,8 +133,9 @@ 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/55f6c91c/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 8d3f67e..1f8246a 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,9 +18,7 @@ package org.apache.zeppelin.helium; import org.apache.zeppelin.interpreter.InterpreterOutput; -/** - * ApplicationContext - */ +/** ApplicationContext */ public class ApplicationContext { private final String noteId; private final String paragraphId; @@ -28,12 +26,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/55f6c91c/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 ca971f5..b34b715 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,15 +18,19 @@ 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/55f6c91c/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 d3c6488..5fa3553 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,9 +16,7 @@ */ package org.apache.zeppelin.helium; -/** - * Application exception - */ +/** Application exception */ public class ApplicationException extends Exception { public ApplicationException(String s) { super(s); @@ -28,9 +26,7 @@ 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/55f6c91c/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 241273a..967d039 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,14 +16,6 @@ */ 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; @@ -33,10 +25,15 @@ 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); @@ -47,13 +44,10 @@ public class ApplicationLoader { public ApplicationLoader(ResourcePool resourcePool, DependencyResolver depResolver) { this.depResolver = depResolver; this.resourcePool = resourcePool; - cached = Collections.synchronizedMap( - new HashMap>()); + cached = Collections.synchronizedMap(new HashMap>()); } - /** - * Information of loaded application - */ + /** Information of loaded application */ private static class RunningApplication { HeliumPackage packageInfo; String noteId; @@ -90,13 +84,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 @@ -104,8 +98,7 @@ 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"); @@ -116,8 +109,9 @@ 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 appClass = loadClass(packageInfo); @@ -139,7 +133,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(); } @@ -154,10 +148,8 @@ 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; @@ -165,7 +157,7 @@ public class ApplicationLoader { resources = resources.filterByNoteId(noteId).filterByParagraphId(paragraphId); - for (String [] requires : requiredResources) { + for (String[] requires : requiredResources) { args.clear(); for (String require : requires) { @@ -197,7 +189,6 @@ public class ApplicationLoader { return null; } - private Class loadClass(HeliumPackage packageInfo) throws Exception { if (cached.containsKey(packageInfo)) { return cached.get(packageInfo); @@ -219,8 +210,7 @@ public class ApplicationLoader { } URLClassLoader applicationClassLoader = new URLClassLoader( - urlList.toArray(new URL[]{}), - Thread.currentThread().getContextClassLoader()); + urlList.toArray(new URL[] {}), Thread.currentThread().getContextClassLoader()); Class cls = (Class) applicationClassLoader.loadClass(packageInfo.getClassName()); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/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 272a152..96fd261 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,12 +18,11 @@ 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/55f6c91c/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 dedb603..2ff7ee8 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,22 +16,18 @@ */ package org.apache.zeppelin.helium; +import java.util.List; import org.apache.zeppelin.display.AngularObject; import org.apache.zeppelin.display.AngularObjectRegistry; -import java.util.List; - -/** - * Angular Registry for helium app - */ +/** 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/55f6c91c/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 e9995c1..4571883 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,44 +17,42 @@ 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; -import java.util.Map; - -/** - * Helium package definition - */ +/** 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 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; @@ -85,8 +83,7 @@ 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() { @@ -133,7 +130,9 @@ public class HeliumPackage implements JsonSerializable { return spell; } - public Map getConfig() { return config; } + public Map getConfig() { + return config; + } public String toJson() { return gson.toJson(this); http://git-wip-us.apache.org/repos/asf/zeppelin/blob/55f6c91c/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 53360a0..02043d1 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,9 +17,7 @@ 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/55f6c91c/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 519d09d..e55faa7 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,9 +17,7 @@ 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/55f6c91c/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 6a44f12..da03dfa 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,6 +17,11 @@ 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; @@ -31,15 +36,7 @@ import org.apache.zeppelin.resource.ResourceSet; import org.slf4j.Logger; import org.slf4j.LoggerFactory; -import java.io.IOException; -import java.util.ArrayList; -import java.util.LinkedList; -import java.util.List; -import java.util.Map; - -/** - * Base class for ZeppelinContext - */ +/** Base class for ZeppelinContext */ public abstract class BaseZeppelinContext { private static final Logger LOGGER = LoggerFactory.getLogger(BaseZeppelinContext.class); @@ -73,18 +70,14 @@ 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) { @@ -121,8 +114,7 @@ public abstract class BaseZeppelinContext { } @ZeppelinApi - public List checkbox(String name, List defaultChecked, - ParamOption[] options) { + public List checkbox(String name, List defaultChecked, ParamOption[] options) { return checkbox(name, defaultChecked, options, false); } @@ -147,8 +139,8 @@ public abstract class BaseZeppelinContext { } @ZeppelinApi - public List noteCheckbox(String name, List defaultChecked, - ParamOption[] options) { + public List noteCheckbox( + String name, List defaultChecked, ParamOption[] options) { return checkbox(name, defaultChecked, options, true); } @@ -157,9 +149,8 @@ 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 { @@ -175,8 +166,7 @@ public abstract class BaseZeppelinContext { } } - private List checkbox(String name, ParamOption[] options, - boolean noteForm) { + private List checkbox(String name, ParamOption[] options, boolean noteForm) { List defaultValues = new LinkedList<>(); for (ParamOption option : options) { defaultValues.add(option.getValue()); @@ -188,8 +178,8 @@ public abstract class BaseZeppelinContext { } } - private List checkbox(String name, List defaultChecked, - ParamOption[] options, boolean noteForm) { + private List checkbox( + String name, List defaultChecked, ParamOption[] options, boolean noteForm) { if (noteForm) { return noteGui.checkbox(name, defaultChecked, options); } else { @@ -205,7 +195,6 @@ public abstract class BaseZeppelinContext { return gui; } - public GUI getNoteGui() { return noteGui; } @@ -225,10 +214,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 */ @@ -238,10 +227,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 @@ -250,8 +239,10 @@ 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) { @@ -291,8 +282,7 @@ 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); } @@ -314,8 +304,9 @@ 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"); @@ -323,7 +314,8 @@ public abstract class BaseZeppelinContext { List paragraphIds = new ArrayList<>(); paragraphIds.add(paragraphId); List paragraphIndices = new ArrayList<>(); - context.getIntpEventClient() + context + .getIntpEventClient() .runParagraphs(noteId, paragraphIds, paragraphIndices, context.getParagraphId()); } @@ -334,7 +326,8 @@ public abstract class BaseZeppelinContext { public void runNote(String noteId, InterpreterContext context) throws IOException { List paragraphIds = new ArrayList<>(); List paragraphIndices = new ArrayList<>(); - context.getIntpEventClient() + context + .getIntpEventClient() .runParagraphs(noteId, paragraphIds, paragraphIndices, context.getParagraphId()); } @@ -349,10 +342,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(); @@ -363,7 +356,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 { @@ -372,20 +365,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 paragraphIds = new ArrayList<>(); List paragraphIndices = new ArrayList<>(); paragraphIndices.add(idx); - context.getIntpEventClient() + context + .getIntpEventClient() .runParagraphs(noteId, paragraphIds, paragraphIndices, context.getParagraphId()); } @@ -394,9 +387,7 @@ 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()); @@ -418,7 +409,6 @@ public abstract class BaseZeppelinContext { return ao; } - /** * Get angular object. Look up notebook scope first and then global scope * @@ -453,11 +443,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 { @@ -465,11 +455,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 { @@ -477,11 +467,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 @@ -490,11 +480,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 @@ -506,7 +496,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 @@ -517,7 +507,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 @@ -525,7 +515,6 @@ public abstract class BaseZeppelinContext { angularWatch(name, null, watcher); } - /** * Remove watcher from angular variable (local) * @@ -548,7 +537,6 @@ public abstract class BaseZeppelinContext { angularUnwatch(name, null, watcher); } - /** * Remove all watchers for the angular variable (local) * @@ -591,11 +579,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(); @@ -608,12 +596,11 @@ 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) @@ -631,7 +618,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) { @@ -693,8 +680,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 @@ -707,7 +694,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 { @@ -738,7 +725,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 @@ -761,7 +748,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) { @@ -769,12 +756,11 @@ 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 @@ -783,7 +769,6 @@ public abstract class BaseZeppelinContext { hooks.unregister(noteId, className, event); } - /** * Add object into resource pool * @@ -797,8 +782,7 @@ 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 @@ -838,9 +822,7 @@ 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/55f6c91c/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 87748ff..20ddfdd 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,11 +21,7 @@ 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"; @@ -49,5 +45,4 @@ 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/55f6c91c/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 f11cbc3..b50e00d 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,9 +17,7 @@ package org.apache.zeppelin.interpreter; -/** - * Property for registered interpreter - */ +/** Property for registered interpreter */ public class DefaultInterpreterProperty { private String envName; private String propertyName; @@ -27,8 +25,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; @@ -48,9 +46,13 @@ 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()); } @@ -122,7 +124,8 @@ 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); } }