Search in sources :

Example 1 with RipDatabaseWizardPage2

use of org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage2 in project pentaho-kettle by pentaho.

the class SpoonJobDelegate method ripDBWizard.

/**
 * Create a job that extracts tables & data from a database.
 * <p>
 * <p>
 *
 * 0) Select the database to rip
 * <p>
 * 1) Select the tables in the database to rip
 * <p>
 * 2) Select the database to dump to
 * <p>
 * 3) Select the repository directory in which it will end up
 * <p>
 * 4) Select a name for the new job
 * <p>
 * 5) Create an empty job with the selected name.
 * <p>
 * 6) Create 1 transformation for every selected table
 * <p>
 * 7) add every created transformation to the job & evaluate
 * <p>
 */
public void ripDBWizard() {
    final List<DatabaseMeta> databases = spoon.getActiveDatabases();
    if (databases.size() == 0) {
        // Nothing to do here
        return;
    }
    final RipDatabaseWizardPage1 page1 = new RipDatabaseWizardPage1("1", databases);
    final RipDatabaseWizardPage2 page2 = new RipDatabaseWizardPage2("2");
    final RipDatabaseWizardPage3 page3 = new RipDatabaseWizardPage3("3", spoon.getRepository());
    Wizard wizard = new Wizard() {

        public boolean performFinish() {
            try {
                JobMeta jobMeta = ripDB(databases, page3.getJobname(), page3.getRepositoryDirectory(), page3.getDirectory(), page1.getSourceDatabase(), page1.getTargetDatabase(), page2.getSelection());
                if (jobMeta == null) {
                    return false;
                }
                if (page3.getRepositoryDirectory() != null) {
                    spoon.saveToRepository(jobMeta, false);
                } else {
                    spoon.saveToFile(jobMeta);
                }
                addJobGraph(jobMeta);
                return true;
            } catch (Exception e) {
                new ErrorDialog(spoon.getShell(), "Error", "An unexpected error occurred!", e);
                return false;
            }
        }

        /**
         * @see org.eclipse.jface.wizard.Wizard#canFinish()
         */
        public boolean canFinish() {
            return page3.canFinish();
        }
    };
    wizard.addPage(page1);
    wizard.addPage(page2);
    wizard.addPage(page3);
    WizardDialog wd = new WizardDialog(spoon.getShell(), wizard);
    WizardDialog.setDefaultImage(GUIResource.getInstance().getImageWizard());
    wd.setMinimumPageSize(700, 400);
    wd.updateSize();
    wd.open();
}
Also used : RipDatabaseWizardPage3(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage3) JobMeta(org.pentaho.di.job.JobMeta) RipDatabaseWizardPage2(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage2) RipDatabaseWizardPage1(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage1) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Wizard(org.eclipse.jface.wizard.Wizard) WizardDialog(org.eclipse.jface.wizard.WizardDialog) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException)

Aggregations

InvocationTargetException (java.lang.reflect.InvocationTargetException)1 Wizard (org.eclipse.jface.wizard.Wizard)1 WizardDialog (org.eclipse.jface.wizard.WizardDialog)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 KettleException (org.pentaho.di.core.exception.KettleException)1 KettleStepException (org.pentaho.di.core.exception.KettleStepException)1 JobMeta (org.pentaho.di.job.JobMeta)1 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)1 RipDatabaseWizardPage1 (org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage1)1 RipDatabaseWizardPage2 (org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage2)1 RipDatabaseWizardPage3 (org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage3)1