mirror of
https://github.com/apache/sqoop.git
synced 2025-05-06 16:49:53 +08:00
SQOOP-2092: Support for LONG in MInputType
(Veena Basavaraj via Jarek Jarcec Cecho)
This commit is contained in:
parent
01bae79d2b
commit
88588a8b45
@ -29,6 +29,7 @@
|
|||||||
import org.apache.sqoop.model.MInput;
|
import org.apache.sqoop.model.MInput;
|
||||||
import org.apache.sqoop.model.MInputType;
|
import org.apache.sqoop.model.MInputType;
|
||||||
import org.apache.sqoop.model.MIntegerInput;
|
import org.apache.sqoop.model.MIntegerInput;
|
||||||
|
import org.apache.sqoop.model.MLongInput;
|
||||||
import org.apache.sqoop.model.MMapInput;
|
import org.apache.sqoop.model.MMapInput;
|
||||||
import org.apache.sqoop.model.MStringInput;
|
import org.apache.sqoop.model.MStringInput;
|
||||||
import org.json.simple.JSONArray;
|
import org.json.simple.JSONArray;
|
||||||
@ -166,6 +167,10 @@ static MConfig restoreConfig(JSONObject config) {
|
|||||||
mInput = new MIntegerInput(name, sensitive.booleanValue(), editable, overrides);
|
mInput = new MIntegerInput(name, sensitive.booleanValue(), editable, overrides);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case LONG: {
|
||||||
|
mInput = new MLongInput(name, sensitive.booleanValue(), editable, overrides);
|
||||||
|
break;
|
||||||
|
}
|
||||||
case BOOLEAN: {
|
case BOOLEAN: {
|
||||||
mInput = new MBooleanInput(name, sensitive.booleanValue(), editable, overrides);
|
mInput = new MBooleanInput(name, sensitive.booleanValue(), editable, overrides);
|
||||||
break;
|
break;
|
||||||
|
@ -158,6 +158,8 @@ private static MConfig toConfig(String configName, Class klass, Object object) {
|
|||||||
input = new MMapInput(inputName, sensitive, editable, overrides);
|
input = new MMapInput(inputName, sensitive, editable, overrides);
|
||||||
} else if (type == Integer.class) {
|
} else if (type == Integer.class) {
|
||||||
input = new MIntegerInput(inputName, sensitive, editable, overrides);
|
input = new MIntegerInput(inputName, sensitive, editable, overrides);
|
||||||
|
} else if (type == Long.class) {
|
||||||
|
input = new MLongInput(inputName, sensitive, editable, overrides);
|
||||||
} else if (type == Boolean.class) {
|
} else if (type == Boolean.class) {
|
||||||
input = new MBooleanInput(inputName, sensitive, editable, overrides);
|
input = new MBooleanInput(inputName, sensitive, editable, overrides);
|
||||||
} else if (type.isEnum()) {
|
} else if (type.isEnum()) {
|
||||||
@ -439,7 +441,7 @@ public static String toJson(Object configuration) {
|
|||||||
map.put(key, ((Map) value).get(key));
|
map.put(key, ((Map) value).get(key));
|
||||||
}
|
}
|
||||||
jsonConfig.put(inputName, map);
|
jsonConfig.put(inputName, map);
|
||||||
} else if(type == Integer.class) {
|
} else if(type == Integer.class || type == Long.class) {
|
||||||
jsonConfig.put(inputName, value);
|
jsonConfig.put(inputName, value);
|
||||||
} else if(type.isEnum()) {
|
} else if(type.isEnum()) {
|
||||||
jsonConfig.put(inputName, value.toString());
|
jsonConfig.put(inputName, value.toString());
|
||||||
@ -532,6 +534,8 @@ public static void fillValues(String json, Object configuration) {
|
|||||||
inputField.set(configValue, map);
|
inputField.set(configValue, map);
|
||||||
} else if(type == Integer.class) {
|
} else if(type == Integer.class) {
|
||||||
inputField.set(configValue, ((Long)jsonInputs.get(inputName)).intValue());
|
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()) {
|
} else if(type.isEnum()) {
|
||||||
inputField.set(configValue, Enum.valueOf((Class<? extends Enum>) inputField.getType(), (String) jsonInputs.get(inputName)));
|
inputField.set(configValue, Enum.valueOf((Class<? extends Enum>) inputField.getType(), (String) jsonInputs.get(inputName)));
|
||||||
} else if(type == Boolean.class) {
|
} else if(type == Boolean.class) {
|
||||||
|
@ -86,6 +86,10 @@ public MIntegerInput getIntegerInput(String inputName) {
|
|||||||
return (MIntegerInput)getInput(inputName);
|
return (MIntegerInput)getInput(inputName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MLongInput getLongInput(String inputName) {
|
||||||
|
return (MLongInput)getInput(inputName);
|
||||||
|
}
|
||||||
|
|
||||||
public MBooleanInput getBooleanInput(String inputName) {
|
public MBooleanInput getBooleanInput(String inputName) {
|
||||||
return (MBooleanInput)getInput(inputName);
|
return (MBooleanInput)getInput(inputName);
|
||||||
}
|
}
|
||||||
|
@ -77,6 +77,10 @@ public MIntegerInput getIntegerInput(String name) {
|
|||||||
return (MIntegerInput) getInput(name);
|
return (MIntegerInput) getInput(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public MLongInput getLongInput(String name) {
|
||||||
|
return (MLongInput) getInput(name);
|
||||||
|
}
|
||||||
|
|
||||||
public MMapInput getMapInput(String name) {
|
public MMapInput getMapInput(String name) {
|
||||||
return (MMapInput) getInput(name);
|
return (MMapInput) getInput(name);
|
||||||
}
|
}
|
||||||
|
@ -45,5 +45,8 @@ public enum MInputType {
|
|||||||
/** String based input that can contain only predefined values **/
|
/** String based input that can contain only predefined values **/
|
||||||
ENUM,
|
ENUM,
|
||||||
|
|
||||||
|
/** Long input type */
|
||||||
|
LONG,
|
||||||
|
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
96
common/src/main/java/org/apache/sqoop/model/MLongInput.java
Normal file
96
common/src/main/java/org/apache/sqoop/model/MLongInput.java
Normal file
@ -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;
|
||||||
|
}
|
||||||
|
}
|
@ -35,6 +35,7 @@
|
|||||||
import org.apache.sqoop.model.MEnumInput;
|
import org.apache.sqoop.model.MEnumInput;
|
||||||
import org.apache.sqoop.model.MInput;
|
import org.apache.sqoop.model.MInput;
|
||||||
import org.apache.sqoop.model.MIntegerInput;
|
import org.apache.sqoop.model.MIntegerInput;
|
||||||
|
import org.apache.sqoop.model.MLongInput;
|
||||||
import org.apache.sqoop.model.MMapInput;
|
import org.apache.sqoop.model.MMapInput;
|
||||||
import org.apache.sqoop.model.MStringInput;
|
import org.apache.sqoop.model.MStringInput;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
@ -136,7 +137,7 @@ protected MConfig getMapConfig() {
|
|||||||
*/
|
*/
|
||||||
protected MConfig getConfig() {
|
protected MConfig getConfig() {
|
||||||
List<MInput<?>> inputs;
|
List<MInput<?>> inputs;
|
||||||
MInput input;
|
MInput<?> input;
|
||||||
|
|
||||||
inputs = new LinkedList<MInput<?>>();
|
inputs = new LinkedList<MInput<?>>();
|
||||||
|
|
||||||
@ -149,6 +150,9 @@ protected MConfig getConfig() {
|
|||||||
input = new MIntegerInput("Integer", false, InputEditable.ANY, StringUtils.EMPTY);
|
input = new MIntegerInput("Integer", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||||
inputs.add(input);
|
inputs.add(input);
|
||||||
|
|
||||||
|
input = new MLongInput("Long", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||||
|
inputs.add(input);
|
||||||
|
|
||||||
input = new MBooleanInput("Boolean", false, InputEditable.ANY, StringUtils.EMPTY);
|
input = new MBooleanInput("Boolean", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||||
inputs.add(input);
|
inputs.add(input);
|
||||||
|
|
||||||
|
@ -175,7 +175,7 @@ public void testJson() {
|
|||||||
TestConfiguration config = new TestConfiguration();
|
TestConfiguration config = new TestConfiguration();
|
||||||
config.aConfig.a1 = "A";
|
config.aConfig.a1 = "A";
|
||||||
config.bConfig.b2 = "B";
|
config.bConfig.b2 = "B";
|
||||||
config.cConfig.intValue = 4;
|
config.cConfig.longValue = 4L;
|
||||||
config.cConfig.map.put("C", "D");
|
config.cConfig.map.put("C", "D");
|
||||||
config.cConfig.enumeration = Enumeration.X;
|
config.cConfig.enumeration = Enumeration.X;
|
||||||
|
|
||||||
@ -197,7 +197,7 @@ public void testJson() {
|
|||||||
assertNull(targetConfig.bConfig.b1);
|
assertNull(targetConfig.bConfig.b1);
|
||||||
AssertJUnit.assertEquals("B", targetConfig.bConfig.b2);
|
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.assertEquals(1, targetConfig.cConfig.map.size());
|
||||||
AssertJUnit.assertTrue(targetConfig.cConfig.map.containsKey("C"));
|
AssertJUnit.assertTrue(targetConfig.cConfig.map.containsKey("C"));
|
||||||
AssertJUnit.assertEquals("D", targetConfig.cConfig.map.get("C"));
|
AssertJUnit.assertEquals("D", targetConfig.cConfig.map.get("C"));
|
||||||
@ -231,7 +231,7 @@ protected List<MConfig> getConfigs() {
|
|||||||
|
|
||||||
// Config C
|
// Config C
|
||||||
inputs = new LinkedList<MInput<?>>();
|
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 MMapInput("cConfig.map", false, InputEditable.ANY, StringUtils.EMPTY));
|
||||||
inputs.add(new MEnumInput("cConfig.enumeration", false, InputEditable.ANY, StringUtils.EMPTY,
|
inputs.add(new MEnumInput("cConfig.enumeration", false, InputEditable.ANY, StringUtils.EMPTY,
|
||||||
new String[] { "X", "Y" }));
|
new String[] { "X", "Y" }));
|
||||||
@ -411,7 +411,7 @@ public static class BConfig {
|
|||||||
@ConfigClass
|
@ConfigClass
|
||||||
public static class CConfig {
|
public static class CConfig {
|
||||||
@Input
|
@Input
|
||||||
Integer intValue;
|
Long longValue;
|
||||||
@Input
|
@Input
|
||||||
Map<String, String> map;
|
Map<String, String> map;
|
||||||
@Input
|
@Input
|
||||||
|
@ -37,9 +37,12 @@ public class TestMAccountableEntity {
|
|||||||
@Test
|
@Test
|
||||||
public void testInitialization() {
|
public void testInitialization() {
|
||||||
List<MConfig> configs = new ArrayList<MConfig>();
|
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<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||||
list.add(input);
|
list.add(intInput);
|
||||||
|
list.add(longInput);
|
||||||
|
|
||||||
MConfig config = new MConfig("CONFIGNAME", list);
|
MConfig config = new MConfig("CONFIGNAME", list);
|
||||||
configs.add(config);
|
configs.add(config);
|
||||||
MAccountableEntity link = new MLink(123l, new MLinkConfig(configs));
|
MAccountableEntity link = new MLink(123l, new MLinkConfig(configs));
|
||||||
@ -57,5 +60,8 @@ public void testInitialization() {
|
|||||||
assertEquals(testLastUpdateDate, link.getLastUpdateDate());
|
assertEquals(testLastUpdateDate, link.getLastUpdateDate());
|
||||||
assertEquals(false, link.getEnabled());
|
assertEquals(false, link.getEnabled());
|
||||||
assertEquals("user", link.getLastUpdateUser());
|
assertEquals("user", link.getLastUpdateUser());
|
||||||
|
assertEquals(1, ((MLink) link).getConnectorLinkConfig().getConfigs().size());
|
||||||
|
assertEquals(2, ((MLink) link).getConnectorLinkConfig().getConfigs().get(0).getInputs().size());
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -54,20 +54,21 @@ public void testEquals() {
|
|||||||
List<MInput<?>> list1 = new ArrayList<MInput<?>>();
|
List<MInput<?>> list1 = new ArrayList<MInput<?>>();
|
||||||
list1.add(input1);
|
list1.add(input1);
|
||||||
list1.add(input2);
|
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> input3 = new MIntegerInput("sqoopsqoop1", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||||
MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY, StringUtils.EMPTY );
|
MInput<Integer> input4 = new MIntegerInput("sqoopsqoop2", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||||
List<MInput<?>> list2 = new ArrayList<MInput<?>>();
|
List<MInput<?>> list2 = new ArrayList<MInput<?>>();
|
||||||
list2.add(input3);
|
list2.add(input3);
|
||||||
list2.add(input4);
|
list2.add(input4);
|
||||||
MConfig mform2 = new MConfig("config", list2);
|
MConfig mConfig2 = new MConfig("config", list2);
|
||||||
assertEquals(mform2, mform1);
|
assertEquals(mConfig2, mConfig1);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testGetInputs() {
|
public void testGetInputs() {
|
||||||
MIntegerInput intInput = new MIntegerInput("Config.A", false, InputEditable.ANY, StringUtils.EMPTY );
|
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 );
|
MMapInput mapInput = new MMapInput("Config.B", false, InputEditable.ANY, StringUtils.EMPTY );
|
||||||
MStringInput stringInput = new MStringInput("Config.C", false, InputEditable.ANY,
|
MStringInput stringInput = new MStringInput("Config.C", false, InputEditable.ANY,
|
||||||
StringUtils.EMPTY, (short) 3);
|
StringUtils.EMPTY, (short) 3);
|
||||||
@ -76,12 +77,14 @@ public void testGetInputs() {
|
|||||||
|
|
||||||
List<MInput<?>> inputs = new ArrayList<MInput<?>>();
|
List<MInput<?>> inputs = new ArrayList<MInput<?>>();
|
||||||
inputs.add(intInput);
|
inputs.add(intInput);
|
||||||
|
inputs.add(longInput);
|
||||||
inputs.add(mapInput);
|
inputs.add(mapInput);
|
||||||
inputs.add(stringInput);
|
inputs.add(stringInput);
|
||||||
inputs.add(enumInput);
|
inputs.add(enumInput);
|
||||||
|
|
||||||
MConfig config = new MConfig("Config", inputs);
|
MConfig config = new MConfig("Config", inputs);
|
||||||
assertEquals(intInput, config.getIntegerInput("Config.A"));
|
assertEquals(intInput, config.getIntegerInput("Config.A"));
|
||||||
|
assertEquals(longInput, config.getLongInput("Config.A1"));
|
||||||
assertEquals(mapInput, config.getMapInput("Config.B"));
|
assertEquals(mapInput, config.getMapInput("Config.B"));
|
||||||
assertEquals(stringInput, config.getStringInput("Config.C"));
|
assertEquals(stringInput, config.getStringInput("Config.C"));
|
||||||
assertEquals(enumInput, config.getEnumInput("Config.D"));
|
assertEquals(enumInput, config.getEnumInput("Config.D"));
|
||||||
|
@ -107,6 +107,8 @@ private MFromConfig fromConfig() {
|
|||||||
List<MConfig> configs = new ArrayList<MConfig>();
|
List<MConfig> configs = new ArrayList<MConfig>();
|
||||||
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
|
MIntegerInput input = new MIntegerInput("INTEGER-INPUT", false, InputEditable.ANY, StringUtils.EMPTY);
|
||||||
input.setValue(100);
|
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);
|
MStringInput strInput = new MStringInput("STRING-INPUT",false, InputEditable.ANY, StringUtils.EMPTY, (short)20);
|
||||||
strInput.setValue("TEST-VALUE");
|
strInput.setValue("TEST-VALUE");
|
||||||
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
List<MInput<?>> list = new ArrayList<MInput<?>>();
|
||||||
|
@ -26,6 +26,7 @@
|
|||||||
import org.apache.sqoop.driver.Driver;
|
import org.apache.sqoop.driver.Driver;
|
||||||
import org.apache.sqoop.error.code.CommonRepositoryError;
|
import org.apache.sqoop.error.code.CommonRepositoryError;
|
||||||
import org.apache.sqoop.model.InputEditable;
|
import org.apache.sqoop.model.InputEditable;
|
||||||
|
import org.apache.sqoop.model.MLongInput;
|
||||||
import org.apache.sqoop.model.SubmissionError;
|
import org.apache.sqoop.model.SubmissionError;
|
||||||
import org.apache.sqoop.model.MBooleanInput;
|
import org.apache.sqoop.model.MBooleanInput;
|
||||||
import org.apache.sqoop.model.MConfig;
|
import org.apache.sqoop.model.MConfig;
|
||||||
@ -2010,6 +2011,9 @@ private void loadDriverConfigs(List<MConfig> driverConfig,
|
|||||||
case INTEGER:
|
case INTEGER:
|
||||||
input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides);
|
input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||||
break;
|
break;
|
||||||
|
case LONG:
|
||||||
|
input = new MLongInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||||
|
break;
|
||||||
case ENUM:
|
case ENUM:
|
||||||
input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides, inputEnumValues.split(","));
|
input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides, inputEnumValues.split(","));
|
||||||
break;
|
break;
|
||||||
@ -2158,6 +2162,9 @@ public void loadConnectorConfigs(List<MConfig> linkConfig, List<MConfig> fromCon
|
|||||||
case INTEGER:
|
case INTEGER:
|
||||||
input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides);
|
input = new MIntegerInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||||
break;
|
break;
|
||||||
|
case LONG:
|
||||||
|
input = new MLongInput(inputName, inputSensitivity, editableEnum, overrides);
|
||||||
|
break;
|
||||||
case ENUM:
|
case ENUM:
|
||||||
input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides,
|
input = new MEnumInput(inputName, inputSensitivity, editableEnum, overrides,
|
||||||
inputEnumValues.split(","));
|
inputEnumValues.split(","));
|
||||||
|
@ -40,6 +40,7 @@
|
|||||||
import org.apache.sqoop.model.MIntegerInput;
|
import org.apache.sqoop.model.MIntegerInput;
|
||||||
import org.apache.sqoop.model.MJob;
|
import org.apache.sqoop.model.MJob;
|
||||||
import org.apache.sqoop.model.MLink;
|
import org.apache.sqoop.model.MLink;
|
||||||
|
import org.apache.sqoop.model.MLongInput;
|
||||||
import org.apache.sqoop.model.MMapInput;
|
import org.apache.sqoop.model.MMapInput;
|
||||||
import org.apache.sqoop.model.MStringInput;
|
import org.apache.sqoop.model.MStringInput;
|
||||||
import org.apache.sqoop.shell.core.Constants;
|
import org.apache.sqoop.shell.core.Constants;
|
||||||
@ -186,6 +187,9 @@ private static void displayConfig(MConfig config, ResourceBundle bundle) {
|
|||||||
case INTEGER:
|
case INTEGER:
|
||||||
displayInputInteger((MIntegerInput) input);
|
displayInputInteger((MIntegerInput) input);
|
||||||
break;
|
break;
|
||||||
|
case LONG:
|
||||||
|
displayLongInteger((MLongInput) input);
|
||||||
|
break;
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
displayInputBoolean((MBooleanInput) input);
|
displayInputBoolean((MBooleanInput) input);
|
||||||
break;
|
break;
|
||||||
@ -223,6 +227,15 @@ private static void displayInputInteger(MIntegerInput input) {
|
|||||||
print(input.getValue());
|
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.
|
* Display content of Boolean input.
|
||||||
*
|
*
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
import org.apache.sqoop.model.MConfig;
|
import org.apache.sqoop.model.MConfig;
|
||||||
import org.apache.sqoop.model.MInput;
|
import org.apache.sqoop.model.MInput;
|
||||||
import org.apache.sqoop.model.MIntegerInput;
|
import org.apache.sqoop.model.MIntegerInput;
|
||||||
|
import org.apache.sqoop.model.MLongInput;
|
||||||
import org.apache.sqoop.model.MMapInput;
|
import org.apache.sqoop.model.MMapInput;
|
||||||
import org.apache.sqoop.model.MJob;
|
import org.apache.sqoop.model.MJob;
|
||||||
import org.apache.sqoop.model.MNamedElement;
|
import org.apache.sqoop.model.MNamedElement;
|
||||||
@ -182,6 +183,8 @@ public static boolean fillInput(String prefix, MInput input, CommandLine line) t
|
|||||||
return fillInputString(prefix, (MStringInput) input, line);
|
return fillInputString(prefix, (MStringInput) input, line);
|
||||||
case INTEGER:
|
case INTEGER:
|
||||||
return fillInputInteger(prefix, (MIntegerInput) input, line);
|
return fillInputInteger(prefix, (MIntegerInput) input, line);
|
||||||
|
case LONG:
|
||||||
|
return fillInputLong(prefix, (MLongInput) input, line);
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return fillInputBoolean(prefix, (MBooleanInput) input, line);
|
return fillInputBoolean(prefix, (MBooleanInput) input, line);
|
||||||
case MAP:
|
case MAP:
|
||||||
@ -289,6 +292,33 @@ private static boolean fillInputInteger(String prefix,
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 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.
|
* Load string input from CLI option.
|
||||||
*
|
*
|
||||||
@ -459,6 +489,8 @@ static boolean fillInputWithBundle(MInput input, ConsoleReader reader, ResourceB
|
|||||||
return fillInputStringWithBundle((MStringInput) input, reader, bundle);
|
return fillInputStringWithBundle((MStringInput) input, reader, bundle);
|
||||||
case INTEGER:
|
case INTEGER:
|
||||||
return fillInputInteger((MIntegerInput) input, reader, bundle);
|
return fillInputInteger((MIntegerInput) input, reader, bundle);
|
||||||
|
case LONG:
|
||||||
|
return fillInputLong((MLongInput) input, reader, bundle);
|
||||||
case BOOLEAN:
|
case BOOLEAN:
|
||||||
return fillInputBooleanWithBundle((MBooleanInput) input, reader, bundle);
|
return fillInputBooleanWithBundle((MBooleanInput) input, reader, bundle);
|
||||||
case MAP:
|
case MAP:
|
||||||
@ -708,6 +740,41 @@ private static boolean fillInputInteger(MIntegerInput input,
|
|||||||
return true;
|
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.
|
* Load string input from the user.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user