mirror of
https://github.com/apache/sqoop.git
synced 2025-05-10 02:40:49 +08:00
SQOOP-2608: Sqoop2: MNamedElement should inherit from MValidatedElement
(Abraham Fine via Jarek Jarcec Cecho)
This commit is contained in:
parent
38de9dde8d
commit
3d004facd8
@ -810,7 +810,7 @@ public Token<?>[] addDelegationTokens(String renewer,
|
|||||||
private Status applyLinkValidations(ValidationResultBean bean, MLink link) {
|
private Status applyLinkValidations(ValidationResultBean bean, MLink link) {
|
||||||
ConfigValidationResult linkConfig = bean.getValidationResults()[0];
|
ConfigValidationResult linkConfig = bean.getValidationResults()[0];
|
||||||
// Apply validation results
|
// Apply validation results
|
||||||
ConfigUtils.applyValidation(link.getConnectorLinkConfig().getConfigs(), linkConfig);
|
ConfigUtils.applyValidation(link.getConnectorLinkConfig(), linkConfig);
|
||||||
Long id = bean.getId();
|
Long id = bean.getId();
|
||||||
if (id != null) {
|
if (id != null) {
|
||||||
link.setPersistenceId(id);
|
link.setPersistenceId(id);
|
||||||
@ -825,13 +825,13 @@ private Status applyJobValidations(ValidationResultBean bean, MJob job) {
|
|||||||
ConfigValidationResult driver = bean.getValidationResults()[2];
|
ConfigValidationResult driver = bean.getValidationResults()[2];
|
||||||
|
|
||||||
ConfigUtils.applyValidation(
|
ConfigUtils.applyValidation(
|
||||||
job.getFromJobConfig().getConfigs(),
|
job.getFromJobConfig(),
|
||||||
fromConfig);
|
fromConfig);
|
||||||
ConfigUtils.applyValidation(
|
ConfigUtils.applyValidation(
|
||||||
job.getToJobConfig().getConfigs(),
|
job.getToJobConfig(),
|
||||||
toConfig);
|
toConfig);
|
||||||
ConfigUtils.applyValidation(
|
ConfigUtils.applyValidation(
|
||||||
job.getDriverConfig().getConfigs(),
|
job.getDriverConfig(),
|
||||||
driver
|
driver
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -343,12 +343,13 @@ public static void fromConfigs(List<MConfig> configs, Object configuration) {
|
|||||||
* @param configs
|
* @param configs
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
public static void applyValidation(List<MConfig> configs, ConfigValidationResult result) {
|
public static void applyValidation(MConfigList configList, ConfigValidationResult result) {
|
||||||
for(MConfig config : configs) {
|
applyValidation(configList, "", result);
|
||||||
applyValidation(config, result);
|
for(MConfig config : configList.getConfigs()) {
|
||||||
|
applyValidation(configList, config.getName(), result);
|
||||||
|
|
||||||
for(MInput input : config.getInputs()) {
|
for(MInput input : config.getInputs()) {
|
||||||
applyValidation(input, result);
|
applyValidation(input, input.getName(), result);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -361,8 +362,8 @@ public static void applyValidation(List<MConfig> configs, ConfigValidationResult
|
|||||||
* @param element
|
* @param element
|
||||||
* @param result
|
* @param result
|
||||||
*/
|
*/
|
||||||
public static void applyValidation(MValidatedElement element, ConfigValidationResult result) {
|
public static void applyValidation(MValidatedElement element, String name, ConfigValidationResult result) {
|
||||||
List<Message> messages = result.getMessages().get(element.getName());
|
List<Message> messages = result.getMessages().get(name);
|
||||||
|
|
||||||
if(messages != null) {
|
if(messages != null) {
|
||||||
element.setValidationMessages(messages);
|
element.setValidationMessages(messages);
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
abstract public class MAccountableEntity extends MValidatedElement {
|
abstract public class MAccountableEntity extends MNamedElement {
|
||||||
|
|
||||||
private static final boolean DEFAULT_ENABLED = true;
|
private static final boolean DEFAULT_ENABLED = true;
|
||||||
|
|
||||||
|
@ -33,7 +33,7 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
public final class MConfig extends MValidatedElement implements MClonable {
|
public final class MConfig extends MNamedElement implements MClonable {
|
||||||
|
|
||||||
private final List<MInput<?>> inputs;
|
private final List<MInput<?>> inputs;
|
||||||
private Set<String> inputNames = new HashSet<String>();
|
private Set<String> inputNames = new HashSet<String>();
|
||||||
|
@ -29,7 +29,7 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
public class MConfigList implements MClonable {
|
public class MConfigList extends MValidatedElement implements MClonable {
|
||||||
|
|
||||||
private final List<MConfig> configObjects;
|
private final List<MConfig> configObjects;
|
||||||
private final MConfigType type;
|
private final MConfigType type;
|
||||||
|
@ -28,7 +28,7 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Public
|
@InterfaceAudience.Public
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
public abstract class MInput<T> extends MValidatedElement implements MClonable {
|
public abstract class MInput<T> extends MNamedElement implements MClonable {
|
||||||
private final boolean sensitive;
|
private final boolean sensitive;
|
||||||
|
|
||||||
private final String overrides;
|
private final String overrides;
|
||||||
|
@ -25,7 +25,7 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
public abstract class MNamedElement extends MPersistableEntity {
|
public abstract class MNamedElement extends MValidatedElement {
|
||||||
private static final String LABEL_KEY_SUFFIX = ".label";
|
private static final String LABEL_KEY_SUFFIX = ".label";
|
||||||
private static final String HELP_KEY_SUFFIX = ".help";
|
private static final String HELP_KEY_SUFFIX = ".help";
|
||||||
|
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
*/
|
*/
|
||||||
@InterfaceAudience.Private
|
@InterfaceAudience.Private
|
||||||
@InterfaceStability.Unstable
|
@InterfaceStability.Unstable
|
||||||
public abstract class MValidatedElement extends MNamedElement {
|
public abstract class MValidatedElement extends MPersistableEntity {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Validation messages.
|
* Validation messages.
|
||||||
@ -42,8 +42,7 @@ public abstract class MValidatedElement extends MNamedElement {
|
|||||||
*/
|
*/
|
||||||
private Status validationStatus;
|
private Status validationStatus;
|
||||||
|
|
||||||
public MValidatedElement(String name) {
|
public MValidatedElement() {
|
||||||
super(name);
|
|
||||||
resetValidationMessages();
|
resetValidationMessages();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ public class TestMValidatedElement {
|
|||||||
@Test
|
@Test
|
||||||
public void testInitialization() {
|
public void testInitialization() {
|
||||||
MValidatedElement input = new MIntegerInput("input", false,InputEditable.ANY, StringUtils.EMPTY );
|
MValidatedElement input = new MIntegerInput("input", false,InputEditable.ANY, StringUtils.EMPTY );
|
||||||
assertEquals("input", input.getName());
|
|
||||||
assertEquals(Status.OK, input.getValidationStatus());
|
assertEquals(Status.OK, input.getValidationStatus());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1121,7 +1121,7 @@ static String getName(ConsoleReader reader, String name) throws IOException {
|
|||||||
*
|
*
|
||||||
* @param element Validated element
|
* @param element Validated element
|
||||||
*/
|
*/
|
||||||
static void printValidationMessage(MValidatedElement element, boolean includeInputPrefix) {
|
static void printValidationMessage(MNamedElement element, boolean includeInputPrefix) {
|
||||||
if(element.getValidationStatus() == Status.getDefault()) {
|
if(element.getValidationStatus() == Status.getDefault()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user