sqoop-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jar...@apache.org
Subject sqoop git commit: SQOOP-2092: Support for LONG in MInputType
Date Mon, 16 Feb 2015 15:15:27 GMT
Repository: sqoop
Updated Branches:
  refs/heads/sqoop2 01bae79d2 -> 88588a8b4


SQOOP-2092: Support for LONG in MInputType

(Veena Basavaraj via Jarek Jarcec Cecho)


Project: http://git-wip-us.apache.org/repos/asf/sqoop/repo
Commit: http://git-wip-us.apache.org/repos/asf/sqoop/commit/88588a8b
Tree: http://git-wip-us.apache.org/repos/asf/sqoop/tree/88588a8b
Diff: http://git-wip-us.apache.org/repos/asf/sqoop/diff/88588a8b

Branch: refs/heads/sqoop2
Commit: 88588a8b45d3904acf23de0f7bfdbb2b58d8c3bf
Parents: 01bae79
Author: Jarek Jarcec Cecho <jarcec@apache.org>
Authored: Mon Feb 16 07:15:09 2015 -0800
Committer: Jarek Jarcec Cecho <jarcec@apache.org>
Committed: Mon Feb 16 07:15:09 2015 -0800

----------------------------------------------------------------------
 .../json/util/ConfigInputSerialization.java     |  5 +
 .../org/apache/sqoop/model/ConfigUtils.java     |  6 +-
 .../java/org/apache/sqoop/model/MConfig.java    |  4 +
 .../org/apache/sqoop/model/MConfigList.java     |  4 +
 .../java/org/apache/sqoop/model/MInputType.java |  3 +
 .../java/org/apache/sqoop/model/MLongInput.java | 96 ++++++++++++++++++++
 .../json/util/TestConfigSerialization.java      |  6 +-
 .../org/apache/sqoop/model/TestConfigUtils.java |  8 +-
 .../sqoop/model/TestMAccountableEntity.java     | 10 +-
 .../org/apache/sqoop/model/TestMConfig.java     |  9 +-
 .../java/org/apache/sqoop/model/TestMJob.java   |  2 +
 .../common/CommonRepositoryHandler.java         |  7 ++
 .../sqoop/shell/utils/ConfigDisplayer.java      | 13 +++
 .../apache/sqoop/shell/utils/ConfigFiller.java  | 67 ++++++++++++++
 14 files changed, 229 insertions(+), 11 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
b/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
index f671447..ffaf041 100644
--- a/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
+++ b/common/src/main/java/org/apache/sqoop/json/util/ConfigInputSerialization.java
@@ -29,6 +29,7 @@ import org.apache.sqoop.model.MConfigType;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MInputType;
 import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MLongInput;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONArray;
@@ -166,6 +167,10 @@ public final class ConfigInputSerialization {
         mInput = new MIntegerInput(name, sensitive.booleanValue(), editable, overrides);
         break;
       }
+      case LONG: {
+        mInput = new MLongInput(name, sensitive.booleanValue(), editable, overrides);
+        break;
+      }
       case BOOLEAN: {
         mInput = new MBooleanInput(name, sensitive.booleanValue(), editable, overrides);
         break;

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
index 1ec763b..dd6e9ce 100644
--- a/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
+++ b/common/src/main/java/org/apache/sqoop/model/ConfigUtils.java
@@ -158,6 +158,8 @@ public class  ConfigUtils {
           input = new MMapInput(inputName, sensitive, editable, overrides);
         } else if (type == Integer.class) {
           input = new MIntegerInput(inputName, sensitive, editable, overrides);
+        } else if (type == Long.class) {
+          input = new MLongInput(inputName, sensitive, editable, overrides);
         } else if (type == Boolean.class) {
           input = new MBooleanInput(inputName, sensitive, editable, overrides);
         } else if (type.isEnum()) {
@@ -439,7 +441,7 @@ public class  ConfigUtils {
               map.put(key, ((Map) value).get(key));
             }
             jsonConfig.put(inputName, map);
-          } else if(type == Integer.class) {
+          } else if(type == Integer.class || type == Long.class) {
             jsonConfig.put(inputName, value);
           } else if(type.isEnum()) {
             jsonConfig.put(inputName, value.toString());
@@ -532,6 +534,8 @@ public class  ConfigUtils {
             inputField.set(configValue, map);
           } else if(type == Integer.class) {
             inputField.set(configValue, ((Long)jsonInputs.get(inputName)).intValue());
+          } else if(type == Long.class) {
+            inputField.set(configValue, ((Long)jsonInputs.get(inputName)).longValue());
           } else if(type.isEnum()) {
             inputField.set(configValue, Enum.valueOf((Class<? extends Enum>) inputField.getType(),
(String) jsonInputs.get(inputName)));
           } else if(type == Boolean.class) {

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/main/java/org/apache/sqoop/model/MConfig.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConfig.java b/common/src/main/java/org/apache/sqoop/model/MConfig.java
index 1bae6d4..9e12979 100644
--- a/common/src/main/java/org/apache/sqoop/model/MConfig.java
+++ b/common/src/main/java/org/apache/sqoop/model/MConfig.java
@@ -86,6 +86,10 @@ public final class MConfig extends MValidatedElement implements MClonable
{
     return (MIntegerInput)getInput(inputName);
   }
 
+  public MLongInput getLongInput(String inputName) {
+    return (MLongInput)getInput(inputName);
+  }
+
   public MBooleanInput getBooleanInput(String inputName) {
     return (MBooleanInput)getInput(inputName);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/main/java/org/apache/sqoop/model/MConfigList.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MConfigList.java b/common/src/main/java/org/apache/sqoop/model/MConfigList.java
index add80d8..d09434a 100644
--- a/common/src/main/java/org/apache/sqoop/model/MConfigList.java
+++ b/common/src/main/java/org/apache/sqoop/model/MConfigList.java
@@ -77,6 +77,10 @@ public class MConfigList implements MClonable {
     return (MIntegerInput) getInput(name);
   }
 
+  public MLongInput getLongInput(String name) {
+    return (MLongInput) getInput(name);
+  }
+
   public MMapInput getMapInput(String name) {
     return (MMapInput) getInput(name);
   }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/main/java/org/apache/sqoop/model/MInputType.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MInputType.java b/common/src/main/java/org/apache/sqoop/model/MInputType.java
index bdc3424..7e6b90a 100644
--- a/common/src/main/java/org/apache/sqoop/model/MInputType.java
+++ b/common/src/main/java/org/apache/sqoop/model/MInputType.java
@@ -45,5 +45,8 @@ public enum MInputType {
   /** String based input that can contain only predefined values **/
   ENUM,
 
+  /** Long input type */
+  LONG,
+
   ;
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/main/java/org/apache/sqoop/model/MLongInput.java
----------------------------------------------------------------------
diff --git a/common/src/main/java/org/apache/sqoop/model/MLongInput.java b/common/src/main/java/org/apache/sqoop/model/MLongInput.java
new file mode 100644
index 0000000..eb2c277
--- /dev/null
+++ b/common/src/main/java/org/apache/sqoop/model/MLongInput.java
@@ -0,0 +1,96 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.sqoop.model;
+
+import org.apache.sqoop.classification.InterfaceAudience;
+import org.apache.sqoop.classification.InterfaceStability;
+
+/**
+ * Long user input.
+ *
+ */
+@InterfaceAudience.Public
+@InterfaceStability.Unstable
+public class MLongInput extends MInput<Long> {
+
+  public MLongInput(String name, boolean sensitive, InputEditable editable, String overrides)
{
+    super(name, sensitive, editable, overrides);
+  }
+
+  @Override
+  public String getUrlSafeValueString() {
+    if(isEmpty()) {
+      return "";
+    }
+
+    return getValue().toString();
+  }
+
+  @Override
+  public void restoreFromUrlSafeValueString(String valueString) {
+    if(valueString.isEmpty()) {
+      setEmpty();
+    }
+
+    setValue(Long.valueOf(valueString));
+  }
+
+  @Override
+  public MInputType getType() {
+    return MInputType.LONG;
+  }
+
+  @Override
+  public boolean equals(Object other) {
+    if (other == this) {
+      return true;
+    }
+
+    if (!(other instanceof MLongInput)) {
+      return false;
+    }
+
+    MLongInput i = (MLongInput) other;
+    return getName().equals(i.getName());
+  }
+
+  @Override
+  public int hashCode() {
+    return 23 + 31 * getName().hashCode();
+  }
+
+  @Override
+  public boolean isEmpty() {
+    return getValue() == null;
+  }
+
+  @Override
+  public void setEmpty() {
+    setValue(null);
+  }
+
+  @Override
+  public MLongInput clone(boolean cloneWithValue) {
+    MLongInput copy = new MLongInput(getName(), isSensitive(), getEditable(), getOverrides());
+    copy.setPersistenceId(getPersistenceId());
+    if(cloneWithValue) {
+      copy.setValue(this.getValue());
+    }
+    return copy;
+  }
+}

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
index 18a1d4f..f7f45f9 100644
--- a/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
+++ b/common/src/test/java/org/apache/sqoop/json/util/TestConfigSerialization.java
@@ -35,6 +35,7 @@ import org.apache.sqoop.model.MConfigType;
 import org.apache.sqoop.model.MEnumInput;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MLongInput;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.json.simple.JSONObject;
@@ -136,7 +137,7 @@ public class TestConfigSerialization {
    */
   protected MConfig getConfig() {
     List<MInput<?>> inputs;
-    MInput input;
+    MInput<?> input;
 
     inputs = new LinkedList<MInput<?>>();
 
@@ -149,6 +150,9 @@ public class TestConfigSerialization {
     input = new MIntegerInput("Integer", false, InputEditable.ANY, StringUtils.EMPTY);
     inputs.add(input);
 
+    input = new MLongInput("Long", false, InputEditable.ANY, StringUtils.EMPTY);
+    inputs.add(input);
+
     input = new MBooleanInput("Boolean", false, InputEditable.ANY, StringUtils.EMPTY);
     inputs.add(input);
 

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
index 7eafdf4..2cc4965 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestConfigUtils.java
@@ -175,7 +175,7 @@ public class TestConfigUtils {
     TestConfiguration config = new TestConfiguration();
     config.aConfig.a1 = "A";
     config.bConfig.b2 = "B";
-    config.cConfig.intValue = 4;
+    config.cConfig.longValue = 4L;
     config.cConfig.map.put("C", "D");
     config.cConfig.enumeration = Enumeration.X;
 
@@ -197,7 +197,7 @@ public class TestConfigUtils {
     assertNull(targetConfig.bConfig.b1);
     AssertJUnit.assertEquals("B", targetConfig.bConfig.b2);
 
-    AssertJUnit.assertEquals((Integer) 4, targetConfig.cConfig.intValue);
+    AssertJUnit.assertEquals((Long) 4L, targetConfig.cConfig.longValue);
     AssertJUnit.assertEquals(1, targetConfig.cConfig.map.size());
     AssertJUnit.assertTrue(targetConfig.cConfig.map.containsKey("C"));
     AssertJUnit.assertEquals("D", targetConfig.cConfig.map.get("C"));
@@ -231,7 +231,7 @@ public class TestConfigUtils {
 
     // Config C
     inputs = new LinkedList<MInput<?>>();
-    inputs.add(new MIntegerInput("cConfig.intValue", false, InputEditable.ANY, StringUtils.EMPTY));
+    inputs.add(new MLongInput("cConfig.longValue", false, InputEditable.ANY, StringUtils.EMPTY));
     inputs.add(new MMapInput("cConfig.map", false, InputEditable.ANY, StringUtils.EMPTY));
     inputs.add(new MEnumInput("cConfig.enumeration", false, InputEditable.ANY, StringUtils.EMPTY,
         new String[] { "X", "Y" }));
@@ -411,7 +411,7 @@ public class TestConfigUtils {
   @ConfigClass
   public static class CConfig {
     @Input
-    Integer intValue;
+    Long longValue;
     @Input
     Map<String, String> map;
     @Input

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
index 0e66400..b05e778 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMAccountableEntity.java
@@ -37,9 +37,12 @@ public class TestMAccountableEntity {
   @Test
   public void testInitialization() {
     List<MConfig> configs = new ArrayList<MConfig>();
-    MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
+    MIntegerInput intInput = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY,
StringUtils.EMPTY);
+    MLongInput longInput = new MLongInput("LONG-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
     List<MInput<?>> list = new ArrayList<MInput<?>>();
-    list.add(input);
+    list.add(intInput);
+    list.add(longInput);
+
     MConfig config = new MConfig("CONFIGNAME", list);
     configs.add(config);
     MAccountableEntity link = new MLink(123l, new MLinkConfig(configs));
@@ -57,5 +60,8 @@ public class TestMAccountableEntity {
     assertEquals(testLastUpdateDate, link.getLastUpdateDate());
     assertEquals(false, link.getEnabled());
     assertEquals("user", link.getLastUpdateUser());
+    assertEquals(1, ((MLink) link).getConnectorLinkConfig().getConfigs().size());
+    assertEquals(2, ((MLink) link).getConnectorLinkConfig().getConfigs().get(0).getInputs().size());
+
   }
 }

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMConfig.java b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
index 665b64a..2b47c13 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMConfig.java
@@ -54,20 +54,21 @@ public class TestMConfig {
     List<MInput<?>> list1 = new ArrayList<MInput<?>>();
     list1.add(input1);
     list1.add(input2);
-    MConfig mform1 = new MConfig("config", list1);
+    MConfig mConfig1 = new MConfig("config", list1);
 
     MInput<Integer> input3 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY,
StringUtils.EMPTY );
     MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY,
StringUtils.EMPTY );
     List<MInput<?>> list2 = new ArrayList<MInput<?>>();
     list2.add(input3);
     list2.add(input4);
-    MConfig mform2 = new MConfig("config", list2);
-    assertEquals(mform2, mform1);
+    MConfig mConfig2 = new MConfig("config", list2);
+    assertEquals(mConfig2, mConfig1);
   }
 
   @Test
   public void testGetInputs() {
     MIntegerInput intInput = new MIntegerInput("Config.A", false, InputEditable.ANY, StringUtils.EMPTY
);
+    MLongInput longInput = new MLongInput("Config.A1", false, InputEditable.ANY, StringUtils.EMPTY
);
     MMapInput mapInput = new MMapInput("Config.B", false, InputEditable.ANY, StringUtils.EMPTY
);
     MStringInput stringInput = new MStringInput("Config.C", false, InputEditable.ANY,
         StringUtils.EMPTY, (short) 3);
@@ -76,12 +77,14 @@ public class TestMConfig {
 
     List<MInput<?>> inputs = new ArrayList<MInput<?>>();
     inputs.add(intInput);
+    inputs.add(longInput);
     inputs.add(mapInput);
     inputs.add(stringInput);
     inputs.add(enumInput);
 
     MConfig config = new MConfig("Config", inputs);
     assertEquals(intInput, config.getIntegerInput("Config.A"));
+    assertEquals(longInput, config.getLongInput("Config.A1"));
     assertEquals(mapInput, config.getMapInput("Config.B"));
     assertEquals(stringInput, config.getStringInput("Config.C"));
     assertEquals(enumInput, config.getEnumInput("Config.D"));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
----------------------------------------------------------------------
diff --git a/common/src/test/java/org/apache/sqoop/model/TestMJob.java b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
index ee8f45f..336dfb5 100644
--- a/common/src/test/java/org/apache/sqoop/model/TestMJob.java
+++ b/common/src/test/java/org/apache/sqoop/model/TestMJob.java
@@ -107,6 +107,8 @@ public class TestMJob {
     List<MConfig> configs = new ArrayList<MConfig>();
     MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
     input.setValue(100);
+    MLongInput lInput = new MLongInput("LONG-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
+    lInput.setValue(100L);
     MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY,
(short)20);
     strInput.setValue("TEST-VALUE");
     List<MInput<?>> list = new ArrayList<MInput<?>>();

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
----------------------------------------------------------------------
diff --git a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
index b029ab2..6a23fc2 100644
--- a/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
+++ b/repository/repository-common/src/main/java/org/apache/sqoop/repository/common/CommonRepositoryHandler.java
@@ -26,6 +26,7 @@ import org.apache.sqoop.common.SupportedDirections;
 import org.apache.sqoop.driver.Driver;
 import org.apache.sqoop.error.code.CommonRepositoryError;
 import org.apache.sqoop.model.InputEditable;
+import org.apache.sqoop.model.MLongInput;
 import org.apache.sqoop.model.SubmissionError;
 import org.apache.sqoop.model.MBooleanInput;
 import org.apache.sqoop.model.MConfig;
@@ -2010,6 +2011,9 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler
{
           case INTEGER:
             input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides);
             break;
+          case LONG:
+            input = new MLongInput(inputName, inputSensitivity, editableEnum, overrides);
+            break;
           case ENUM:
             input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides,
inputEnumValues.split(","));
             break;
@@ -2158,6 +2162,9 @@ public abstract class CommonRepositoryHandler extends JdbcRepositoryHandler
{
         case INTEGER:
           input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides);
           break;
+        case LONG:
+          input = new MLongInput(inputName, inputSensitivity, editableEnum, overrides);
+          break;
         case ENUM:
           input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides,
               inputEnumValues.split(","));

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java
index aeb6d41..9438441 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigDisplayer.java
@@ -40,6 +40,7 @@ import org.apache.sqoop.model.MInputType;
 import org.apache.sqoop.model.MIntegerInput;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MLink;
+import org.apache.sqoop.model.MLongInput;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MStringInput;
 import org.apache.sqoop.shell.core.Constants;
@@ -186,6 +187,9 @@ public final class ConfigDisplayer {
             case INTEGER:
               displayInputInteger((MIntegerInput) input);
               break;
+            case LONG:
+              displayLongInteger((MLongInput) input);
+              break;
             case BOOLEAN:
               displayInputBoolean((MBooleanInput) input);
               break;
@@ -223,6 +227,15 @@ public final class ConfigDisplayer {
     print(input.getValue());
   }
 
+
+  /**
+   * Display content of Long input.
+   *
+   * @param input Long input
+   */
+  private static void displayLongInteger(MLongInput input) {
+    print(input.getValue());
+  }
   /**
    * Display content of Boolean input.
    *

http://git-wip-us.apache.org/repos/asf/sqoop/blob/88588a8b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
----------------------------------------------------------------------
diff --git a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
index 02278f5..a1f512b 100644
--- a/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
+++ b/shell/src/main/java/org/apache/sqoop/shell/utils/ConfigFiller.java
@@ -29,6 +29,7 @@ import org.apache.sqoop.model.MEnumInput;
 import org.apache.sqoop.model.MConfig;
 import org.apache.sqoop.model.MInput;
 import org.apache.sqoop.model.MIntegerInput;
+import org.apache.sqoop.model.MLongInput;
 import org.apache.sqoop.model.MMapInput;
 import org.apache.sqoop.model.MJob;
 import org.apache.sqoop.model.MNamedElement;
@@ -182,6 +183,8 @@ public final class ConfigFiller {
       return fillInputString(prefix, (MStringInput) input, line);
     case INTEGER:
       return fillInputInteger(prefix, (MIntegerInput) input, line);
+    case LONG:
+      return fillInputLong(prefix, (MLongInput) input, line);
     case BOOLEAN:
       return fillInputBoolean(prefix, (MBooleanInput) input, line);
     case MAP:
@@ -290,6 +293,33 @@ public final class ConfigFiller {
   }
 
   /**
+   * Load long input from CLI option.
+   *
+   * @param prefix
+   *          placed at the beginning of the CLI option key
+   * @param input
+   *          Input that we should read or edit
+   * @param line
+   *          CLI options container
+   * @return
+   * @throws IOException
+   */
+  private static boolean fillInputLong(String prefix, MLongInput input, CommandLine line)
throws IOException {
+    String opt = ConfigOptions.getOptionKey(prefix, input);
+    if (line.hasOption(opt)) {
+      try {
+        input.setValue(Long.valueOf(line.getOptionValue(ConfigOptions.getOptionKey(prefix,
input))));
+      } catch (NumberFormatException ex) {
+        errorMessage(input, "Input is not a valid long ");
+        return false;
+      }
+    } else {
+      input.setEmpty();
+    }
+    return true;
+  }
+
+  /**
    * Load string input from CLI option.
    *
    * @param prefix placed at the beginning of the CLI option key
@@ -459,6 +489,8 @@ public final class ConfigFiller {
         return fillInputStringWithBundle((MStringInput) input, reader, bundle);
       case INTEGER:
         return fillInputInteger((MIntegerInput) input, reader, bundle);
+      case LONG:
+        return fillInputLong((MLongInput) input, reader, bundle);
       case BOOLEAN:
         return fillInputBooleanWithBundle((MBooleanInput) input, reader, bundle);
       case MAP:
@@ -708,6 +740,41 @@ public final class ConfigFiller {
     return true;
   }
 
+  private static boolean fillInputLong(MLongInput input, ConsoleReader reader, ResourceBundle
bundle) throws IOException {
+    generatePrompt(reader, bundle, input);
+
+    if (!input.isEmpty() && !input.isSensitive()) {
+      reader.putString(input.getValue().toString());
+    }
+
+    // Get the data
+    String userTyped;
+    if (input.isSensitive()) {
+      userTyped = reader.readLine('*');
+    } else {
+      userTyped = reader.readLine();
+    }
+
+    if (userTyped == null) {
+      return false;
+    } else if (userTyped.isEmpty()) {
+      input.setEmpty();
+    } else {
+      Long value;
+      try {
+        value = Long.valueOf(userTyped);
+        input.setValue(value);
+      } catch (NumberFormatException ex) {
+        errorMessage("Input is not a valid long");
+        return fillInputLong(input, reader, bundle);
+      }
+
+      input.setValue(Long.valueOf(userTyped));
+    }
+
+    return true;
+  }
+
   /**
    * Load string input from the user.
    *


Mime
View raw message