JSONObject input = (JSONObject) inputs.get(i);
MInputType type =
MInputType.valueOf((String) input.get(FORM_INPUT_TYPE));
String name = (String) input.get(FORM_INPUT_NAME);
Boolean sensitive = (Boolean) input.get(FORM_INPUT_SENSITIVE);
MInput mInput = null;
switch (type) {
case STRING: {
long size = (Long) input.get(FORM_INPUT_SIZE);
mInput = new MStringInput(name, sensitive.booleanValue(), (short) size);
break;
}
case MAP: {
mInput = new MMapInput(name, sensitive.booleanValue());
break;
}
case INTEGER: {
mInput = new MIntegerInput(name, sensitive.booleanValue());
break;
}
case BOOLEAN: {
mInput = new MBooleanInput(name, sensitive.booleanValue());
break;
}
case ENUM: {
String values = (String) input.get(FORM_INPUT_VALUES);
mInput = new MEnumInput(name, sensitive.booleanValue(), values.split(","));
break;
}
}
// Propagate form ID
mInput.setPersistenceId((Long)input.get(ID));
// Propagate form optional value
if(input.containsKey(FORM_INPUT_VALUE)) {
switch (type) {
case MAP:
try {
mInput.setValue((Map<String, String>)input.get(FORM_INPUT_VALUE));
} catch (ClassCastException e) {
throw new SqoopException(SerializationError.SERIALIZATION_001, name + " requires a 'map' value.");
}
break;
default:
mInput.restoreFromUrlSafeValueString(
(String) input.get(FORM_INPUT_VALUE));
break;
}
}
mInputs.add(mInput);