Examples of MConnection


Examples of org.apache.sqoop.model.MConnection

    ResourceBundle frameworkBundle = frameworkBean.getResourceBundle();

    MConnector connector = connectorBean.getConnectors().get(0);
    ResourceBundle connectorBundle = connectorBean.getResourceBundles().get(connector.getPersistenceId());

    MConnection connection = new MConnection(connector.getPersistenceId(),
                                             connector.getConnectionForms(),
                                             framework.getConnectionForms());

    Status status = Status.FINE;

    io.out.println(getResource().getString(Constants.RES_PROMPT_FILL_CONN_METADATA));

    do {
      // Print error introduction if needed
      if( !status.canProceed() ) {
        errorIntroduction(io);
      }

      // Fill in data from user
      if(!fillConnection(io, reader, connection,
                         connectorBundle, frameworkBundle)) {
        return;
      }

      // Try to create
      status = createConnectionApplyValidations(connection);
    } while(!status.canProceed());


    io.out.println(MessageFormat.format(getResource()
        .getString(Constants.RES_CREATE_CONN_SUCCESSFUL), status.name(),
        connection.getPersistenceId()));
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

      JSONArray frameworkPart = (JSONArray) object.get(FRAMEWORK_PART);

      List<MForm> connectorForms = restoreForms(connectorPart);
      List<MForm> frameworkForms = restoreForms(frameworkPart);

      MConnection connection = new MConnection(connectorId,
        new MConnectionForms(connectorForms),
        new MConnectionForms(frameworkForms));

      connection.setPersistenceId((Long) object.get(ID));
      connection.setName((String) object.get(NAME));

      connections.add(connection);
    }

    if(jsonObject.containsKey(CONNECTOR_RESOURCES)) {
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

    ConsoleReader reader = new ConsoleReader();

    ConnectionBean connectionBean = readConnection(connectionId);

    // TODO(jarcec): Check that we have expected data
    MConnection connection = connectionBean.getConnections().get(0);
    ResourceBundle frameworkBundle
      = connectionBean.getFrameworkBundle();
    ResourceBundle connectorBundle
      = connectionBean.getConnectorBundle(connection.getConnectorId());

    Status status = Status.FINE;

    io.out.println(getResource().getString(Constants
        .RES_PROMPT_UPDATE_CONN_METADATA));
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

    ConnectorBean connectorBean;

    MFramework framework = frameworkBean.getFramework();
    ResourceBundle frameworkBundle = frameworkBean.getResourceBundle();

    MConnection connection = connectionBean.getConnections().get(0);

    connectorBean = readConnector(String.valueOf(connection.getConnectorId()));
    MConnector connector = connectorBean.getConnectors().get(0);
    ResourceBundle connectorBundle = connectorBean.getResourceBundles().get(connector.getPersistenceId());

    MJob.Type jobType = MJob.Type.valueOf(type.toUpperCase());

    MJob job = new MJob(
      connector.getPersistenceId(),
      connection.getPersistenceId(),
      jobType,
      connector.getJobForms(jobType),
      framework.getJobForms(jobType)
    );
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

  private void cloneConnection(Long connectionId) throws IOException {
    printlnResource(Constants.RES_CLONE_CLONING_CONN, connectionId);

    ConsoleReader reader = new ConsoleReader();

    MConnection connection = client.getConnection(connectionId);
    // Remove persistent id as we're making a clone
    connection.setPersistenceId(MPersistableEntity.PERSISTANCE_ID_DEFAULT);

    Status status = Status.FINE;
    printlnResource(Constants.RES_PROMPT_UPDATE_CONN_METADATA);

    ResourceBundle connectorBundle = client.getResourceBundle(connection.getConnectorId());
    ResourceBundle frameworkBundle = client.getFrameworkResourceBundle();
    do {
      // Print error introduction if needed
      if( !status.canProceed() ) {
        errorIntroduction();
      }

      // Fill in data from user
      if(!fillConnection(reader, connection, connectorBundle, frameworkBundle)) {
        return;
      }

      status = client.createConnection(connection);

    } while(!status.canProceed());

    printlnResource(Constants.RES_CLONE_CONN_SUCCESSFUL, status.name(), connection.getPersistenceId());
  }
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.setCreationDate(created);
    connection.setLastUpdateDate(updated);

    // 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(created, target.getCreationDate());
    assertEquals(updated, target.getLastUpdateDate());

    // 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.setCreationDate(created);
    connection.setLastUpdateDate(updated);

    // 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());
  }

  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

  @Test
  public void testBasicImport() 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

  @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
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.