Examples of MConnection


Examples of org.apache.sqoop.model.MConnection

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

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

      bean = new ConnectionBean(connection);

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

Examples of org.apache.sqoop.model.MConnection

        loadForms(connectorConnForms, connectorJobForms,
          formConnectorFetchStmt, inputFetchStmt, 2);
        loadForms(frameworkConnForms, frameworkJobForms,
          formFrameworkFetchStmt, inputFetchStmt, 2);

        MConnection connection = new MConnection(connectorId,
          new MConnectionForms(connectorConnForms),
          new MConnectionForms(frameworkConnForms));

        connection.setPersistenceId(id);
        connection.setName(name);

        connections.add(connection);
      }
    } finally {
      closeResultSets(rsConnection);
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

    }

    // 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

Examples of org.apache.sqoop.model.MConnection

    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

Examples of org.apache.sqoop.model.MConnection

  }

  public void testUpdateConnection() throws Exception {
    loadConnections();

    MConnection connection = handler.findConnection(1, getDerbyConnection());

    List<MForm> forms;

    forms = connection.getConnectorPart().getForms();
    ((MStringInput)forms.get(0).getInputs().get(1)).setValue("Injected");

    forms = connection.getFrameworkPart().getForms();
    ((MStringInput)forms.get(1).getInputs().get(1)).setValue("Injected");

    connection.setName("name");

    handler.updateConnection(connection, getDerbyConnection());

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

    MConnection retrieved = handler.findConnection(1, getDerbyConnection());
    assertEquals("name", connection.getName());

    forms = retrieved.getConnectorPart().getForms();
    assertEquals("Injected", forms.get(0).getInputs().get(1).getValue());

    forms = retrieved.getFrameworkPart().getForms();
    assertEquals("Injected", forms.get(1).getInputs().get(1).getValue());
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

    assertCountForTable("SQOOP.SQ_CONNECTION", 0);
    assertCountForTable("SQOOP.SQ_CONNECTION_INPUT", 0);
  }

  public MConnection getConnection() {
    return new MConnection(1,
      handler.findConnector("A", getDerbyConnection()).getConnectionForms(),
      handler.findFramework(getDerbyConnection()).getConnectionForms()
    );
  }
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

*
*/
public class TestConnectionBean {
  @Test
  public void testSerialization() {
    MConnection connection = getConnection("ahoj");
    connection.setName("Connection");
    connection.setPersistenceId(666);

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

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

    // 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

    MJob job = repository.findJob(jobId);
    if(job == null) {
      throw new SqoopException(FrameworkError.FRAMEWORK_0004,
        "Unknown job id " + jobId);
    }
    MConnection connection = repository.findConnection(job.getConnectionId());
    SqoopConnector connector =
      ConnectorManager.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(
      getConnectionConfigurationClass());
    FormUtils.fromForms(connection.getFrameworkPart().getForms(),
      frameworkConnection);

    Object frameworkJob = ClassUtils.instantiate(
      getJobConfigurationClass(job.getType()));
    FormUtils.fromForms(job.getFrameworkPart().getForms(), frameworkJob);
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());

    // Remove persistent id as we're making a clone
    connection.setPersistenceId(MPersistableEntity.PERSISTANCE_ID_DEFAULT);

    Status status = Status.FINE;

    io.out.println(getResource().getString(Constants
       .RES_PROMPT_UPDATE_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;
      }

      status = createConnectionApplyValidations(connection);

    } while(!status.canProceed());

    io.out.println(MessageFormat.format(getResource()
        .getString(Constants.RES_CLONE_CONN_SUCCESSFUL),
        status.name(), connection.getPersistenceId()));
  }
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.