mirror of
https://github.com/apache/sqoop.git
synced 2025-05-10 07:31:32 +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) {
|
||||
ConfigValidationResult linkConfig = bean.getValidationResults()[0];
|
||||
// Apply validation results
|
||||
ConfigUtils.applyValidation(link.getConnectorLinkConfig().getConfigs(), linkConfig);
|
||||
ConfigUtils.applyValidation(link.getConnectorLinkConfig(), linkConfig);
|
||||
Long id = bean.getId();
|
||||
if (id != null) {
|
||||
link.setPersistenceId(id);
|
||||
@ -825,13 +825,13 @@ private Status applyJobValidations(ValidationResultBean bean, MJob job) {
|
||||
ConfigValidationResult driver = bean.getValidationResults()[2];
|
||||
|
||||
ConfigUtils.applyValidation(
|
||||
job.getFromJobConfig().getConfigs(),
|
||||
job.getFromJobConfig(),
|
||||
fromConfig);
|
||||
ConfigUtils.applyValidation(
|
||||
job.getToJobConfig().getConfigs(),
|
||||
job.getToJobConfig(),
|
||||
toConfig);
|
||||
ConfigUtils.applyValidation(
|
||||
job.getDriverConfig().getConfigs(),
|
||||
job.getDriverConfig(),
|
||||
driver
|
||||
);
|
||||
|
||||
|
@ -343,12 +343,13 @@ public static void fromConfigs(List<MConfig> configs, Object configuration) {
|
||||
* @param configs
|
||||
* @param result
|
||||
*/
|
||||
public static void applyValidation(List<MConfig> configs, ConfigValidationResult result) {
|
||||
for(MConfig config : configs) {
|
||||
applyValidation(config, result);
|
||||
public static void applyValidation(MConfigList configList, ConfigValidationResult result) {
|
||||
applyValidation(configList, "", result);
|
||||
for(MConfig config : configList.getConfigs()) {
|
||||
applyValidation(configList, config.getName(), result);
|
||||
|
||||
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 result
|
||||
*/
|
||||
public static void applyValidation(MValidatedElement element, ConfigValidationResult result) {
|
||||
List<Message> messages = result.getMessages().get(element.getName());
|
||||
public static void applyValidation(MValidatedElement element, String name, ConfigValidationResult result) {
|
||||
List<Message> messages = result.getMessages().get(name);
|
||||
|
||||
if(messages != null) {
|
||||
element.setValidationMessages(messages);
|
||||
|
@ -28,7 +28,7 @@
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
@InterfaceStability.Unstable
|
||||
abstract public class MAccountableEntity extends MValidatedElement {
|
||||
abstract public class MAccountableEntity extends MNamedElement {
|
||||
|
||||
private static final boolean DEFAULT_ENABLED = true;
|
||||
|
||||
|
@ -33,7 +33,7 @@
|
||||
*/
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Unstable
|
||||
public final class MConfig extends MValidatedElement implements MClonable {
|
||||
public final class MConfig extends MNamedElement implements MClonable {
|
||||
|
||||
private final List<MInput<?>> inputs;
|
||||
private Set<String> inputNames = new HashSet<String>();
|
||||
|
@ -29,7 +29,7 @@
|
||||
*/
|
||||
@InterfaceAudience.Public
|
||||
@InterfaceStability.Unstable
|
||||
public class MConfigList implements MClonable {
|
||||
public class MConfigList extends MValidatedElement implements MClonable {
|
||||
|
||||
private final List<MConfig> configObjects;
|
||||
private final MConfigType type;
|
||||
|
@ -28,7 +28,7 @@
|
||||
*/
|
||||
@InterfaceAudience.Public
|
||||
@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 String overrides;
|
||||
|
@ -25,7 +25,7 @@
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
@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 HELP_KEY_SUFFIX = ".help";
|
||||
|
||||
|
@ -30,7 +30,7 @@
|
||||
*/
|
||||
@InterfaceAudience.Private
|
||||
@InterfaceStability.Unstable
|
||||
public abstract class MValidatedElement extends MNamedElement {
|
||||
public abstract class MValidatedElement extends MPersistableEntity {
|
||||
|
||||
/**
|
||||
* Validation messages.
|
||||
@ -42,8 +42,7 @@ public abstract class MValidatedElement extends MNamedElement {
|
||||
*/
|
||||
private Status validationStatus;
|
||||
|
||||
public MValidatedElement(String name) {
|
||||
super(name);
|
||||
public MValidatedElement() {
|
||||
resetValidationMessages();
|
||||
}
|
||||
|
||||
|
@ -35,7 +35,6 @@ public class TestMValidatedElement {
|
||||
@Test
|
||||
public void testInitialization() {
|
||||
MValidatedElement input = new MIntegerInput("input", false,InputEditable.ANY, StringUtils.EMPTY );
|
||||
assertEquals("input", input.getName());
|
||||
assertEquals(Status.OK, input.getValidationStatus());
|
||||
}
|
||||
|
||||
|
@ -1121,7 +1121,7 @@ static String getName(ConsoleReader reader, String name) throws IOException {
|
||||
*
|
||||
* @param element Validated element
|
||||
*/
|
||||
static void printValidationMessage(MValidatedElement element, boolean includeInputPrefix) {
|
||||
static void printValidationMessage(MNamedElement element, boolean includeInputPrefix) {
|
||||
if(element.getValidationStatus() == Status.getDefault()) {
|
||||
return;
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user