Package org.apache.sqoop.model

Examples of org.apache.sqoop.model.MConnection


      "3,'Czech Republic','Brno'",
      "4,'USA','Palo Alto'"
    );

    // 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(provider.escapeTableName(getTableName()));
    fillInputForm(job);
View Full Code Here


    // Inserted values
    Map<String, String> map = new HashMap<String, String>();
    map.put("A", "B");

    // Connection object with all various values
    MConnection connection = new MConnection(connector.getPersistenceId(), connector.getConnectionForms(), framework.getConnectionForms());
    MConnectionForms forms = connection.getConnectorPart();
    forms.getStringInput("f.String").setValue("A");
    forms.getMapInput("f.Map").setValue(map);
    forms.getIntegerInput("f.Integer").setValue(1);
    forms.getBooleanInput("f.Boolean").setValue(true);
    forms.getEnumInput("f.Enum").setValue("YES");

    // Create the connection in repository
    handler.createConnection(connection, getDerbyConnection());
    assertNotSame(connection.getPersistenceId(), MPersistableEntity.PERSISTANCE_ID_DEFAULT);

    // Retrieve created connection
    MConnection retrieved = handler.findConnection(connection.getPersistenceId(), getDerbyConnection());
    forms = retrieved.getConnectorPart();
    assertEquals("A", forms.getStringInput("f.String").getValue());
    assertEquals(map, forms.getMapInput("f.Map").getValue());
    assertEquals(1, (int)forms.getIntegerInput("f.Integer").getValue());
    assertEquals(true, (boolean)forms.getBooleanInput("f.Boolean").getValue());
    assertEquals("YES", forms.getEnumInput("f.Enum").getValue());
View Full Code Here

        // else the values will get set in the forms in the connector for
        // each connection.
        List<MForm> forms = newConnector.getConnectionForms().clone(false).getForms();
        MConnectionForms newConnectionForms = new MConnectionForms(forms);
        upgrader.upgrade(connection.getConnectorPart(), newConnectionForms);
        MConnection newConnection = new MConnection(connectorID,
          newConnectionForms, connection.getFrameworkPart());
        newConnection.setPersistenceId(connectionID);

        // Transform form structures to objects for validations
        Object newConfigurationObject = ClassUtils.instantiate(connector.getConnectionConfigurationClass());
        FormUtils.fromForms(newConnection.getConnectorPart().getForms(), newConfigurationObject);

        Validation validation = validator.validateConnection(newConfigurationObject);
        if (validation.getStatus().canProceed()) {
          updateConnection(newConnection, tx);
        } else {
View Full Code Here

        // else the values will get set in the forms in the connector for
        // each connection.
        List<MForm> forms = framework.getConnectionForms().clone(false).getForms();
        MConnectionForms newConnectionForms = new MConnectionForms(forms);
        upgrader.upgrade(connection.getFrameworkPart(), newConnectionForms);
        MConnection newConnection = new MConnection(connection.getConnectorId(),
          connection.getConnectorPart(), newConnectionForms);
        newConnection.setPersistenceId(connectionID);

        // Transform form structures to objects for validations
        Object newConfigurationObject = ClassUtils.instantiate(FrameworkManager.getInstance().getConnectionConfigurationClass());
        FormUtils.fromForms(newConnection.getFrameworkPart().getForms(), newConfigurationObject);

        Validation validation = validator.validateConnection(newConfigurationObject);
        if (validation.getStatus().canProceed()) {
          updateConnection(newConnection, tx);
        } else {
View Full Code Here

        }
      }
    } else {
      long xid = Long.valueOf(sxid);

      MConnection connection = repository.findConnection(xid);
      long connectorId = connection.getConnectorId();

      bean = new ConnectionBean(connection);

      bean.addConnectorBundle(connectorId,
        ConnectorManager.getInstance().getResourceBundle(connectorId, locale));
View Full Code Here

  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

   */
  public static void displayFormWarning(MAccountableEntity entity) {
    List<MForm> formList = new ArrayList<MForm>();
    boolean showMessage = true;
    if (entity instanceof MConnection) {
      MConnection connection = (MConnection) entity;
      formList.addAll(connection.getConnectorPart().getForms());
      formList.addAll(connection.getFrameworkPart().getForms());
    } else if(entity instanceof MJob) {
      MJob job = (MJob) entity;
      formList.addAll(job.getConnectorPart().getForms());
      formList.addAll(job.getFrameworkPart().getForms());
    }
View Full Code Here

    if (!job.getEnabled()) {
      throw new SqoopException(FrameworkError.FRAMEWORK_0009,
        "Job id: " + job.getPersistenceId());
    }

    MConnection connection = repository.findConnection(job.getConnectionId());

    if (!connection.getEnabled()) {
      throw new SqoopException(FrameworkError.FRAMEWORK_0010,
        "Connection id: " + connection.getPersistenceId());
    }

    SqoopConnector connector =
      ConnectorManager.getInstance().getConnector(job.getConnectorId());

    // Transform forms to connector specific classes
    Object connectorConnection = ClassUtils.instantiate(
      connector.getConnectionConfigurationClass());
    FormUtils.fromForms(connection.getConnectorPart().getForms(),
      connectorConnection);

    Object connectorJob = ClassUtils.instantiate(
      connector.getJobConfigurationClass(job.getType()));
    FormUtils.fromForms(job.getConnectorPart().getForms(), connectorJob);

    // Transform framework specific forms
    Object frameworkConnection = ClassUtils.instantiate(
      FrameworkManager.getInstance().getConnectionConfigurationClass());
    FormUtils.fromForms(connection.getFrameworkPart().getForms(),
      frameworkConnection);

    Object frameworkJob = ClassUtils.instantiate(
      FrameworkManager.getInstance().getJobConfigurationClass(job.getType()));
    FormUtils.fromForms(job.getFrameworkPart().getForms(), frameworkJob);
View Full Code Here

    }

    // Load prepared connections into database
    loadConnections();

    MConnection connA = handler.findConnection(1, getDerbyConnection());
    assertNotNull(connA);
    assertEquals(1, connA.getPersistenceId());
    assertEquals("CA", connA.getName());

    List<MForm> forms;

    // Check connector part
    forms = connA.getConnectorPart().getForms();
    assertEquals("Value1", forms.get(0).getInputs().get(0).getValue());
    assertNull(forms.get(0).getInputs().get(1).getValue());
    assertEquals("Value3", forms.get(1).getInputs().get(0).getValue());
    assertNull(forms.get(1).getInputs().get(1).getValue());

    // Check framework part
    forms = connA.getFrameworkPart().getForms();
    assertEquals("Value13", forms.get(0).getInputs().get(0).getValue());
    assertNull(forms.get(0).getInputs().get(1).getValue());
    assertEquals("Value15", forms.get(1).getInputs().get(0).getValue());
    assertNull(forms.get(1).getInputs().get(1).getValue());
  }
View Full Code Here

    assertTrue(handler.existsConnection(2, getDerbyConnection()));
    assertFalse(handler.existsConnection(3, getDerbyConnection()));
  }

  public void testCreateConnection() throws Exception {
    MConnection connection = getConnection();

    // Load some data
    fillConnection(connection);

    handler.createConnection(connection, getDerbyConnection());

    assertEquals(1, connection.getPersistenceId());
    assertCountForTable("SQOOP.SQ_CONNECTION", 1);
    assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 4);

    MConnection retrieved = handler.findConnection(1, getDerbyConnection());
    assertEquals(1, retrieved.getPersistenceId());

    List<MForm> forms;
    forms = connection.getConnectorPart().getForms();
    assertEquals("Value1", forms.get(0).getInputs().get(0).getValue());
    assertNull(forms.get(0).getInputs().get(1).getValue());
View Full Code Here

TOP

Related Classes of org.apache.sqoop.model.MConnection

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.