Examples of MConnection


Examples of org.apache.sqoop.model.MConnection

  private void updateConnection(Long connectionId) throws IOException {
    printlnResource(Constants.RES_UPDATE_UPDATING_CONN, connectionId);

    ConsoleReader reader = new ConsoleReader();

    MConnection connection = client.getConnection(connectionId);

    ResourceBundle connectorBundle = client.getResourceBundle(connection.getConnectorId());
    ResourceBundle frameworkBundle = client.getFrameworkResourceBundle();

    Status status = Status.FINE;

    printlnResource(Constants.RES_PROMPT_UPDATE_CONN_METADATA);
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

    if(connections.size() != 1) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Expected one connection metadata but got " + connections.size());
    }

    MConnection connection = connections.get(0);

    // Verify that user is not trying to spoof us
    MConnectionForms connectorForms =
      ConnectorManager.getInstance().getConnectorMetadata(connection.getConnectorId())
      .getConnectionForms();
    MConnectionForms frameworkForms = FrameworkManager.getInstance().getFramework()
      .getConnectionForms();

    if(!connectorForms.equals(connection.getConnectorPart())
      || !frameworkForms.equals(connection.getFrameworkPart())) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Detected incorrect form structure");
    }

    // Responsible connector for this session
    SqoopConnector connector =
      ConnectorManager.getInstance().getConnector(connection.getConnectorId());

    // Get validator objects
    Validator connectorValidator = connector.getValidator();
    Validator frameworkValidator = FrameworkManager.getInstance().getValidator();

    // We need translate forms to configuration objects
    Object connectorConfig = ClassUtils.instantiate(
      connector.getConnectionConfigurationClass());
    Object frameworkConfig = ClassUtils.instantiate(
      FrameworkManager.getInstance().getConnectionConfigurationClass());

    FormUtils.fromForms(
      connection.getConnectorPart().getForms(), connectorConfig);
    FormUtils.fromForms(
      connection.getFrameworkPart().getForms(), frameworkConfig);

    // Validate both parts
    Validation connectorValidation =
      connectorValidator.validateConnection(connectorConfig);
    Validation frameworkValidation =
      frameworkValidator.validateConnection(frameworkConfig);

    Status finalStatus = Status.getWorstStatus(connectorValidation.getStatus(),
      frameworkValidation.getStatus());

    // Return back validations in all cases
    ValidationBean outputBean =
      new ValidationBean(connectorValidation, frameworkValidation);

    // If we're good enough let's perform the action
    if(finalStatus.canProceed()) {
      if(update) {
        AuditLoggerManager.getInstance()
            .logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
            "update", "connection", String.valueOf(connection.getPersistenceId()));

        connection.setLastUpdateUser(username);
        RepositoryManager.getInstance().getRepository().updateConnection(connection);
      } else {
        connection.setCreationUser(username);
        connection.setLastUpdateUser(username);
        RepositoryManager.getInstance().getRepository().createConnection(connection);
        outputBean.setId(connection.getPersistenceId());

        AuditLoggerManager.getInstance()
            .logAuditEvent(ctx.getUserName(), ctx.getRequest().getRemoteAddr(),
            "create", "connection", String.valueOf(connection.getPersistenceId()));
      }
    }

    return outputBean;
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

  @Test
  public void testBasicImport() throws Exception {
    createAndLoadTableCities();

    // Connection creation
    MConnection connection = getClient().newConnection("generic-jdbc-connector");
    fillConnectionForm(connection);
    createConnection(connection);

    // Job creation
    MJob job = getClient().newJob(connection.getPersistenceId(), MJob.Type.IMPORT);

    // Connector values
    MFormList forms = job.getConnectorPart();
    forms.getStringInput("table.tableName").setValue(provider.escapeTableName(getTableName()));
    forms.getStringInput("table.partitionColumn").setValue(provider.escapeColumnName("id"));
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

  @Test
  public void testColumns() throws Exception {
    createAndLoadTableCities();

    // Connection creation
    MConnection connection = getClient().newConnection(1L);
    fillConnectionForm(connection);

    createConnection(connection);

    // Job creation
    MJob job = getClient().newJob(connection.getPersistenceId(), MJob.Type.IMPORT);

    // Connector values
    MFormList forms = job.getConnectorPart();
    forms.getStringInput("table.tableName").setValue(provider.escapeTableName(getTableName()));
    forms.getStringInput("table.partitionColumn").setValue(provider.escapeColumnName("id"));
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

      "3,'Czech Republic','Brno'",
      "4,'USA','Palo Alto'"
    );
    new Cities(provider, stageTableName).createTables();
    // Connection creation
    MConnection connection = getClient().newConnection("generic-jdbc-connector");
    fillConnectionForm(connection);
    createConnection(connection);

    // Job creation
    MJob job = getClient().newJob(connection.getPersistenceId(),
      MJob.Type.EXPORT);

    // Connector values
    MFormList forms = job.getConnectorPart();
    forms.getStringInput("table.tableName").setValue(
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

  @Test
  public void testSplitter() throws Exception {
    createAndLoadTableUbuntuReleases();

    // Connection creation
    MConnection connection = getClient().newConnection("generic-jdbc-connector");
    fillConnectionForm(connection);
    createConnection(connection);

    // Job creation
    MJob job = getClient().newJob(connection.getPersistenceId(), MJob.Type.IMPORT);

    // Connector values
    MFormList forms = job.getConnectorPart();
    forms.getStringInput("table.tableName").setValue(provider.escapeTableName(getTableName()));
    forms.getStringInput("table.partitionColumn").setValue(provider.escapeColumnName(partitionColumn));
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

public class TestConnectionBean {
  @Test
  public void testSerialization() {
    Date created = new Date();
    Date updated = new Date();
    MConnection connection = getConnection("ahoj");
    connection.setName("Connection");
    connection.setPersistenceId(666);
    connection.setCreationUser("admin");
    connection.setCreationDate(created);
    connection.setLastUpdateUser("user");
    connection.setLastUpdateDate(updated);
    connection.setEnabled(false);

    // Fill some data at the beginning
    MStringInput input = (MStringInput) connection.getConnectorPart().getForms()
      .get(0).getInputs().get(0);
    input.setValue("Hi there!");

    // Serialize it to JSON object
    ConnectionBean bean = new ConnectionBean(connection);
    JSONObject json = bean.extract(false);

    // Check for sensitivity
    JSONArray all = (JSONArray)json.get("all");
    JSONObject allItem = (JSONObject)all.get(0);
    JSONArray connectors = (JSONArray)allItem.get("connector");
    JSONObject connector = (JSONObject)connectors.get(0);
    JSONArray inputs = (JSONArray)connector.get("inputs");
    for (Object input1 : inputs) {
      assertTrue(((JSONObject)input1).containsKey("sensitive"));
    }

    // "Move" it across network in text form
    String string = json.toJSONString();

    // Retrieved transferred object
    JSONObject retrievedJson = (JSONObject) JSONValue.parse(string);
    ConnectionBean retrievedBean = new ConnectionBean();
    retrievedBean.restore(retrievedJson);
    MConnection target = retrievedBean.getConnections().get(0);

    // Check id and name
    assertEquals(666, target.getPersistenceId());
    assertEquals("Connection", target.getName());
    assertEquals("admin", target.getCreationUser());
    assertEquals(created, target.getCreationDate());
    assertEquals("user", target.getLastUpdateUser());
    assertEquals(updated, target.getLastUpdateDate());
    assertEquals(false, target.getEnabled());

    // Test that value was correctly moved
    MStringInput targetInput = (MStringInput) target.getConnectorPart()
      .getForms().get(0).getInputs().get(0);
    assertEquals("Hi there!", targetInput.getValue());
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

  @Test
  public void testSensitivityFilter() {
    Date created = new Date();
    Date updated = new Date();
    MConnection connection = getConnection("ahoj");
    connection.setName("Connection");
    connection.setPersistenceId(666);
    connection.setCreationUser("admin");
    connection.setCreationDate(created);
    connection.setLastUpdateUser("user");
    connection.setLastUpdateDate(updated);
    connection.setEnabled(true);

    // Fill some data at the beginning
    MStringInput input = (MStringInput) connection.getConnectorPart().getForms()
      .get(0).getInputs().get(0);
    input.setValue("Hi there!");

    // Serialize it to JSON object
    ConnectionBean bean = new ConnectionBean(connection);
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

  public static MFramework getFramework() {
    return new MFramework(getConnectionForms(), getAllJobForms(), "1");
  }

  public static MConnection getConnection(String name) {
    return new MConnection(1,
                           getConnector(name).getConnectionForms(),
                           getFramework().getConnectionForms()
    );
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

    if(connections.size() != 1) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Expected one connection metadata but got " + connections.size());
    }

    MConnection connection = connections.get(0);

    // Verify that user is not trying to spoof us
    MConnectionForms connectorForms =
      ConnectorManager.getConnectorMetadata(connection.getConnectorId())
      .getConnectionForms();
    MConnectionForms frameworkForms = FrameworkManager.getFramework()
      .getConnectionForms();

    if(!connectorForms.equals(connection.getConnectorPart())
      || !frameworkForms.equals(connection.getFrameworkPart())) {
      throw new SqoopException(ServerError.SERVER_0003,
        "Detected incorrect form structure");
    }

    // Responsible connector for this session
    SqoopConnector connector =
      ConnectorManager.getConnector(connection.getConnectorId());

    // Get validator objects
    Validator connectorValidator = connector.getValidator();
    Validator frameworkValidator = FrameworkManager.getValidator();

    // We need translate forms to configuration objects
    Object connectorConfig = ClassUtils.instantiate(
      connector.getConnectionConfigurationClass());
    Object frameworkConfig = ClassUtils.instantiate(
      FrameworkManager.getConnectionConfigurationClass());

    FormUtils.fromForms(
      connection.getConnectorPart().getForms(), connectorConfig);
    FormUtils.fromForms(
      connection.getFrameworkPart().getForms(), frameworkConfig);

    // Validate both parts
    Validation connectorValidation =
      connectorValidator.validateConnection(connectorConfig);
    Validation frameworkValidation =
      frameworkValidator.validateConnection(frameworkConfig);

    Status finalStatus = Status.getWorstStatus(connectorValidation.getStatus(),
      frameworkValidation.getStatus());

    // Return back validations in all cases
    ValidationBean outputBean =
      new ValidationBean(connectorValidation, frameworkValidation);

    // If we're good enough let's perform the action
    if(finalStatus.canProceed()) {
      if(update) {
        RepositoryManager.getRepository().updateConnection(connection);
      } else {
        RepositoryManager.getRepository().createConnection(connection);
        outputBean.setId(connection.getPersistenceId());
      }
    }

    return outputBean;
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.