Package org.apache.sqoop.model

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));
      connection.setCreationDate(new Date((Long) object.get(CREATED)));
      connection.setLastUpdateDate(new Date((Long) object.get(UPDATED)));

      connections.add(connection);
    }

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


    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.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(
      getConnectionConfigurationClass());
    FormUtils.fromForms(connection.getFrameworkPart().getForms(),
      frameworkConnection);

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

    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) {
        RepositoryManager.getInstance().getRepository().updateConnection(connection);
      } else {
        RepositoryManager.getInstance().getRepository().createConnection(connection);
        outputBean.setId(connection.getPersistenceId());
      }
    }

    return outputBean;
  }
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

    }

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

  }

  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

    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

        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);
        connection.setCreationDate(creationDate);
        connection.setLastUpdateDate(lastUpdateDate);

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

   *
   * @param cid Connector id
   * @return
   */
  public MConnection newConnection(long cid) {
    return new MConnection(
      cid,
      getConnector(cid).getConnectionForms(),
      getFramework().getConnectionForms()
    );
  }
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.