Package org.apache.sqoop.validation

Examples of org.apache.sqoop.validation.Validation$Message


  }

  public static Status updateJobApplyValidations(MJob job) {
    ValidationBean bean = updateJob(job);

    Validation connector = bean.getConnectorValidation();
    Validation framework = bean.getFrameworkValidation();

    FormUtils.applyValidation(job.getConnectorPart().getForms(),
      connector);
    FormUtils.applyValidation(job.getFrameworkPart().getForms(),
      connector);

    Long id = bean.getId();
    if(id != null) {
      job.setPersistenceId(id);
    }

    return Status.getWorstStatus(connector.getStatus(), framework.getStatus());
  }
View Full Code Here


      messages.put(new Validation.FormInput((String)key), message);
    }

    Status status = Status.valueOf((String) jsonObject.get(STATUS));

    return new Validation(status, messages);
  }
View Full Code Here

    assertNull(config.bForm.b2);
    assertNull(config.bForm.b2);
  }

  public void testApplyValidation() {
    Validation validation = getValidation();
    List<MForm> forms = getForms();

    FormUtils.applyValidation(forms, validation);

    assertEquals(Status.ACCEPTABLE,
View Full Code Here

      new Validation.Message(Status.ACCEPTABLE, "e1"));
    messages.put(
      new Validation.FormInput("aForm", "a2"),
      new Validation.Message(Status.UNACCEPTABLE, "e2"));

    return new Validation(Status.UNACCEPTABLE, messages);
  }
View Full Code Here

    assertNull(retrievedBean.getId());

    Validation.FormInput fa = new Validation.FormInput("f", "i");
    Validation.FormInput fb = new Validation.FormInput("f2", "i2");

    Validation connector = retrievedBean.getConnectorValidation();
    assertEquals(Status.FINE, connector.getStatus());
    assertEquals(2, connector.getMessages().size());
    assertTrue(connector.getMessages().containsKey(fa));
    assertEquals(new Validation.Message(Status.FINE, "d"),
      connector.getMessages().get(fa));

    Validation framework = retrievedBean.getFrameworkValidation();
    assertEquals(Status.UNACCEPTABLE, framework.getStatus());
    assertEquals(2, framework.getMessages().size());
    assertTrue(framework.getMessages().containsKey(fb));
    assertEquals(new Validation.Message(Status.UNACCEPTABLE, "c"),
      framework.getMessages().get(fb));
  }
View Full Code Here

      new Validation.Message(status, "d"));
    messages.put(
      new Validation.FormInput("f2", "i2"),
      new Validation.Message(status, "c"));

    return new Validation(status, messages);
  }
View Full Code Here

*/
public class GenericJdbcValidator extends Validator {

  @Override
  public Validation validateConnection(Object configuration) {
    Validation validation = new Validation(ConnectionConfiguration.class);
    ConnectionConfiguration config = (ConnectionConfiguration)configuration;

    if(config.connection.jdbcDriver == null) {
      validation.addMessage(Status.UNACCEPTABLE, "connection", "jdbcDriver", "Driver can't be empty");
    } else {
      try {
        Class.forName(config.connection.jdbcDriver);
      } catch (ClassNotFoundException e) {
        validation.addMessage(Status.UNACCEPTABLE, "connection", "jdbcDriver", "Can't load specified driver");
      }
    }

    if(config.connection.connectionString == null) {
      validation.addMessage(Status.UNACCEPTABLE, "connection", "connectionString", "JDBC URL can't be empty");
    } else if(!config.connection.connectionString.startsWith("jdbc:")) {
      validation.addMessage(Status.UNACCEPTABLE, "connection", "connectionString", "This do not seem as a valid JDBC URL");
    }

    // See if we can connect to the database
    try {
      DriverManager.getConnection(config.connection.connectionString,
        config.connection.username, config.connection.password);
    } catch (SQLException e) {
      validation.addMessage(Status.ACCEPTABLE, "connection", "Can't connect to the database with given credentials: " + e.getMessage());
    }

    // Return final validation object
    return validation;
  }
View Full Code Here

        return super.validateJob(type, jobConfiguration);
    }
  }

  private Validation validateExportJob(Object jobConfiguration) {
    Validation validation = new Validation(ExportJobConfiguration.class);
    ExportJobConfiguration configuration = (ExportJobConfiguration)jobConfiguration;

    if(configuration.table.tableName == null && configuration.table.sql == null) {
      validation.addMessage(Status.UNACCEPTABLE, "table", "Either table name or SQL must be specified");
    }
    if(configuration.table.tableName != null && configuration.table.sql != null) {
      validation.addMessage(Status.UNACCEPTABLE, "table", "Both table name and SQL cannot be specified");
    }

    return validation;
  }
View Full Code Here

    return validation;
  }

  private Validation validateImportJob(Object jobConfiguration) {
    Validation validation = new Validation(ImportJobConfiguration.class);
    ImportJobConfiguration configuration = (ImportJobConfiguration)jobConfiguration;

    if(configuration.table.tableName == null && configuration.table.sql == null) {
      validation.addMessage(Status.UNACCEPTABLE, "table", "Either table name or SQL must be specified");
    }
    if(configuration.table.tableName != null && configuration.table.sql != null) {
      validation.addMessage(Status.UNACCEPTABLE, "table", "Both table name and SQL cannot be specified");
    }
    if(configuration.table.schemaName != null && configuration.table.sql != null) {
      validation.addMessage(Status.UNACCEPTABLE, "table", "Both schema name and SQL cannot be specified");
    }

    if(configuration.table.sql != null && !configuration.table.sql.contains(GenericJdbcConnectorConstants.SQL_CONDITIONS_TOKEN)) {
      validation.addMessage(Status.UNACCEPTABLE, "table", "sql", "SQL statement must contain placeholder for auto generated "
        + "conditions - " + GenericJdbcConnectorConstants.SQL_CONDITIONS_TOKEN);
    }

    return validation;
  }
View Full Code Here

*/
public class FrameworkValidator extends Validator {

  @Override
  public Validation validateConnection(Object connectionConfiguration) {
    Validation validation = new Validation(ConnectionConfiguration.class);
    // No validation on connection object
    return validation;
  }
View Full Code Here

TOP

Related Classes of org.apache.sqoop.validation.Validation$Message

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.