Package org.apache.sqoop.connector.spi

Examples of org.apache.sqoop.connector.spi.MetadataUpgrader


      Validator validator = connector.getValidator();

      boolean upgradeSuccessful = true;

      MetadataUpgrader upgrader = connector.getMetadataUpgrader();
      List<MConnection> connections = findConnectionsForConnector(
        connectorID);
      List<MJob> jobs = findJobsForConnector(connectorID);
      // -- BEGIN TXN --
      tx = getTransaction();
      tx.begin();
      deleteConnectionsAndJobs(connections, jobs, tx);
      updateConnector(newConnector, tx);
      for (MConnection connection : connections) {
        long connectionID = connection.getPersistenceId();
        // Make a new copy of the forms from the connector,
        // 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 {
          logInvalidModelObject("connection", newConnection, validation);
          upgradeSuccessful = false;
        }
      }
      for (MJob job : jobs) {
        // Make a new copy of the forms from the connector,
        // else the values will get set in the forms in the connector for
        // each connection.
        List<MForm> forms = newConnector.getJobForms(job.getType()).clone(false).getForms();
        MJobForms newJobForms = new MJobForms(job.getType(), forms);
        upgrader.upgrade(job.getConnectorPart(), newJobForms);
        MJob newJob = new MJob(connectorID, job.getConnectionId(),
          job.getType(), newJobForms, job.getFrameworkPart());
        newJob.setPersistenceId(job.getPersistenceId());

        // Transform form structures to objects for validations
View Full Code Here


  public final void upgradeFramework(MFramework framework) {
    LOG.info("Upgrading framework metadata");
    RepositoryTransaction tx = null;
    try {
      MetadataUpgrader upgrader = FrameworkManager.getInstance()
        .getMetadataUpgrader();
      List<MConnection> connections = findConnections();
      List<MJob> jobs = findJobs();

      Validator validator = FrameworkManager.getInstance().getValidator();

      boolean upgradeSuccessful = true;

      // -- BEGIN TXN --
      tx = getTransaction();
      tx.begin();
      deleteConnectionsAndJobs(connections, jobs, tx);
      updateFramework(framework, tx);
      for (MConnection connection : connections) {
        long connectionID = connection.getPersistenceId();
        // Make a new copy of the forms from the connector,
        // 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 {
          logInvalidModelObject("connection", newConnection, validation);
          upgradeSuccessful = false;
        }
      }
      for (MJob job : jobs) {
        // Make a new copy of the forms from the framework,
        // else the values will get set in the forms in the connector for
        // each connection.
        List<MForm> forms = framework.getJobForms(job.getType()).clone(false).getForms();
        MJobForms newJobForms = new MJobForms(job.getType(), forms);
        upgrader.upgrade(job.getFrameworkPart(), newJobForms);
        MJob newJob = new MJob(job.getConnectorId(), job.getConnectionId(),
          job.getType(), job.getConnectorPart(), newJobForms);
        newJob.setPersistenceId(job.getPersistenceId());

        // Transform form structures to objects for validations
View Full Code Here

TOP

Related Classes of org.apache.sqoop.connector.spi.MetadataUpgrader

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.