Examples of MConnection


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(0)).setValue("Updated");
    ((MMapInput)forms.get(0).getInputs().get(1)).setValue(null);
    ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Updated");
    ((MMapInput)forms.get(1).getInputs().get(1)).setValue(null);

    forms = connection.getFrameworkPart().getForms();
    ((MStringInput)forms.get(0).getInputs().get(0)).setValue("Updated");
    ((MMapInput)forms.get(0).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value
    ((MStringInput)forms.get(1).getInputs().get(0)).setValue("Updated");
    ((MMapInput)forms.get(1).getInputs().get(1)).setValue(new HashMap<String, String>()); // inject new map value

    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("Updated", forms.get(0).getInputs().get(0).getValue());
    assertNull(forms.get(0).getInputs().get(1).getValue());
    assertEquals("Updated", forms.get(1).getInputs().get(0).getValue());
    assertNull(forms.get(1).getInputs().get(1).getValue());

    forms = retrieved.getFrameworkPart().getForms();
    assertEquals("Updated", forms.get(0).getInputs().get(0).getValue());
    assertNotNull(forms.get(0).getInputs().get(1).getValue());
    assertEquals(((Map)forms.get(0).getInputs().get(1).getValue()).size(), 0);
    assertEquals("Updated", forms.get(1).getInputs().get(0).getValue());
    assertNotNull(forms.get(1).getInputs().get(1).getValue());
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

    loadConnections();

    // disable connection 1
    handler.enableConnection(1, false, getDerbyConnection());

    MConnection retrieved = handler.findConnection(1, getDerbyConnection());
    assertNotNull(retrieved);
    assertEquals(false, retrieved.getEnabled());

    // enable connection 1
    handler.enableConnection(1, true, getDerbyConnection());

    retrieved = handler.findConnection(1, getDerbyConnection());
    assertNotNull(retrieved);
    assertEquals(true, retrieved.getEnabled());
  }
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

    framework.setPersistenceId(1);
    return framework;
  }

  private MConnection connection(long id, long cid) {
    MConnection connection = new MConnection(cid, new MConnectionForms(new LinkedList<MForm>()),
        new MConnectionForms(new LinkedList<MForm>()));
    connection.setPersistenceId(id);
    return connection;
  }
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);
        connection.setCreationUser(creationUser);
        connection.setCreationDate(creationDate);
        connection.setLastUpdateUser(updateUser);
        connection.setLastUpdateDate(lastUpdateDate);
        connection.setEnabled(enabled);

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

Examples of org.apache.sqoop.model.MConnection

  private void createConnection(long connectorId) throws IOException {
    printlnResource(Constants.RES_CREATE_CREATING_CONN, connectorId);

    ConsoleReader reader = new ConsoleReader();

    MConnection connection = client.newConnection(connectorId);

    ResourceBundle connectorBundle = client.getResourceBundle(connectorId);
    ResourceBundle frameworkBundle = client.getFrameworkResourceBundle();

    Status status = Status.FINE;
    printlnResource(Constants.RES_PROMPT_FILL_CONN_METADATA);
    do {
      // Print error introduction if needed
      if( !status.canProceed() ) {
        errorIntroduction();
      }

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

      // Try to create
      status = client.createConnection(connection);
    } while(!status.canProceed());
    FormDisplayer.displayFormWarning(connection);
    printlnResource(Constants.RES_CREATE_CONN_SUCCESSFUL, status.name(), connection.getPersistenceId());
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

   *
   * @param cid Connector id
   * @return
   */
  public MConnection newConnection(long cid) {
    return new MConnection(
      cid,
      getConnector(cid).getConnectionForms(),
      getFramework().getConnectionForms()
    );
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

   * @param xid Connection id
   * @param type Job type
   * @return
   */
  public MJob newJob(long xid, MJob.Type type) {
    MConnection connection = getConnection(xid);

    return new MJob(
      connection.getConnectorId(),
      connection.getPersistenceId(),
      type,
      getConnector(connection.getConnectorId()).getJobForms(type),
      getFramework().getJobForms(type)
    );
  }
View Full Code Here

Examples of org.apache.sqoop.model.MConnection

      displayConnection(connection);
    }
  }

  private void showConnection(Long xid) {
    MConnection connection = client.getConnection(xid);

    printlnResource(Constants.RES_SHOW_PROMPT_CONNS_TO_SHOW, 1);

    displayConnection(connection);
  }
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));
      connection.setEnabled((Boolean) object.get(ENABLED));
      connection.setCreationUser((String) object.get(CREATION_USER));
      connection.setCreationDate(new Date((Long) object.get(CREATION_DATE)));
      connection.setLastUpdateUser((String) object.get(UPDATE_USER));
      connection.setLastUpdateDate(new Date((Long) object.get(UPDATE_DATE)));

      connections.add(connection);
    }

    if(jsonObject.containsKey(CONNECTOR_RESOURCES)) {
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.