Search in sources :

Example 26 with JobMeta

use of org.pentaho.di.job.JobMeta 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)

Example 27 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class SpoonJobDelegate method ripDB.

public JobMeta ripDB(final List<DatabaseMeta> databases, final String jobname, final RepositoryDirectoryInterface repdir, final String directory, final DatabaseMeta sourceDbInfo, final DatabaseMeta targetDbInfo, final String[] tables) {
    // 
    // Create a new job...
    // 
    final JobMeta jobMeta = new JobMeta();
    jobMeta.setDatabases(databases);
    jobMeta.setFilename(null);
    jobMeta.setName(jobname);
    if (spoon.getRepository() != null) {
        jobMeta.setRepositoryDirectory(repdir);
    } else {
        jobMeta.setFilename(Const.createFilename(directory, jobname, "." + Const.STRING_JOB_DEFAULT_EXT));
    }
    spoon.refreshTree();
    spoon.refreshGraph();
    final Point location = new Point(50, 50);
    // The start entry...
    final JobEntryCopy start = JobMeta.createStartEntry();
    start.setLocation(new Point(location.x, location.y));
    start.setDrawn();
    jobMeta.addJobEntry(start);
    // final Thread parentThread = Thread.currentThread();
    // Create a dialog with a progress indicator!
    IRunnableWithProgress op = monitor -> {
        try {
            // This is running in a new process: copy some KettleVariables
            // info
            // LocalVariables.getInstance().createKettleVariables(Thread.currentThread().getName(),
            // parentThread.getName(), true);
            monitor.beginTask(BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.BuildingNewJob"), tables.length);
            monitor.worked(0);
            JobEntryCopy previous = start;
            // Loop over the table-names...
            for (int i = 0; i < tables.length && !monitor.isCanceled(); i++) {
                monitor.setTaskName(BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.ProcessingTable") + tables[i] + "]...");
                // 
                // Create the new transformation...
                // 
                String transname = BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Transname1") + sourceDbInfo + "].[" + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Transname2") + targetDbInfo + "]";
                TransMeta transMeta = new TransMeta();
                if (repdir != null) {
                    transMeta.setRepositoryDirectory(repdir);
                } else {
                    transMeta.setFilename(Const.createFilename(directory, transname, "." + Const.STRING_TRANS_DEFAULT_EXT));
                }
                // Add the source & target db
                transMeta.addDatabase(sourceDbInfo);
                transMeta.addDatabase(targetDbInfo);
                // 
                // Add a note
                // 
                String note = BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Note1") + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Note2") + sourceDbInfo + "]" + Const.CR;
                note += BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Note3") + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.Note4") + targetDbInfo + "]";
                NotePadMeta ni = new NotePadMeta(note, 150, 10, -1, -1);
                transMeta.addNote(ni);
                // 
                // Add the TableInputMeta step...
                // 
                String fromstepname = BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.FromStep.Name") + tables[i] + "]";
                TableInputMeta tii = new TableInputMeta();
                tii.setDefault();
                tii.setDatabaseMeta(sourceDbInfo);
                // It's already quoted!
                tii.setSQL("SELECT * FROM " + tables[i]);
                String fromstepid = PluginRegistry.getInstance().getPluginId(StepPluginType.class, tii);
                StepMeta fromstep = new StepMeta(fromstepid, fromstepname, tii);
                fromstep.setLocation(150, 100);
                fromstep.setDraw(true);
                fromstep.setDescription(BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.FromStep.Description") + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.FromStep.Description2") + sourceDbInfo + "]");
                transMeta.addStep(fromstep);
                // 
                // Add the TableOutputMeta step...
                // 
                String tostepname = BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.ToStep.Name") + tables[i] + "]";
                TableOutputMeta toi = new TableOutputMeta();
                toi.setDatabaseMeta(targetDbInfo);
                toi.setTableName(tables[i]);
                toi.setCommitSize(100);
                toi.setTruncateTable(true);
                String tostepid = PluginRegistry.getInstance().getPluginId(StepPluginType.class, toi);
                StepMeta tostep = new StepMeta(tostepid, tostepname, toi);
                tostep.setLocation(500, 100);
                tostep.setDraw(true);
                tostep.setDescription(BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.ToStep.Description1") + tables[i] + BaseMessages.getString(PKG, "Spoon.RipDB.Monitor.ToStep.Description2") + targetDbInfo + "]");
                transMeta.addStep(tostep);
                // 
                // Add a hop between the two steps...
                // 
                TransHopMeta hi = new TransHopMeta(fromstep, tostep);
                transMeta.addTransHop(hi);
                // 
                // Now we generate the SQL needed to run for this
                // transformation.
                // 
                // First set the limit to 1 to speed things up!
                String tmpSql = tii.getSQL();
                tii.setSQL(tii.getSQL() + sourceDbInfo.getLimitClause(1));
                String sql;
                try {
                    sql = transMeta.getSQLStatementsString();
                } catch (KettleStepException kse) {
                    throw new InvocationTargetException(kse, BaseMessages.getString(PKG, "Spoon.RipDB.Exception.ErrorGettingSQLFromTransformation") + transMeta + "] : " + kse.getMessage());
                }
                // remove the limit
                tii.setSQL(tmpSql);
                // 
                // Now, save the transformation...
                // 
                boolean ok;
                if (spoon.getRepository() != null) {
                    ok = spoon.saveToRepository(transMeta, false);
                } else {
                    ok = spoon.saveToFile(transMeta);
                }
                if (!ok) {
                    throw new InvocationTargetException(new Exception(BaseMessages.getString(PKG, "Spoon.RipDB.Exception.UnableToSaveTransformationToRepository")), BaseMessages.getString(PKG, "Spoon.RipDB.Exception.UnableToSaveTransformationToRepository"));
                }
                // We can now continue with the population of the job...
                // //////////////////////////////////////////////////////////////////////
                location.x = 250;
                if (i > 0) {
                    location.y += 100;
                }
                // 
                if (!Utils.isEmpty(sql)) {
                    String jesqlname = BaseMessages.getString(PKG, "Spoon.RipDB.JobEntrySQL.Name") + tables[i] + "]";
                    JobEntrySQL jesql = new JobEntrySQL(jesqlname);
                    jesql.setDatabase(targetDbInfo);
                    jesql.setSQL(sql);
                    jesql.setDescription(BaseMessages.getString(PKG, "Spoon.RipDB.JobEntrySQL.Description") + targetDbInfo + "].[" + tables[i] + "]");
                    JobEntryCopy jecsql = new JobEntryCopy();
                    jecsql.setEntry(jesql);
                    jecsql.setLocation(new Point(location.x, location.y));
                    jecsql.setDrawn();
                    jobMeta.addJobEntry(jecsql);
                    // Add the hop too...
                    JobHopMeta jhi = new JobHopMeta(previous, jecsql);
                    jobMeta.addJobHop(jhi);
                    previous = jecsql;
                }
                // 
                // Add the jobentry for the transformation too...
                // 
                String jetransname = BaseMessages.getString(PKG, "Spoon.RipDB.JobEntryTrans.Name") + tables[i] + "]";
                JobEntryTrans jetrans = new JobEntryTrans(jetransname);
                jetrans.setTransname(transMeta.getName());
                if (spoon.getRepository() != null) {
                    jetrans.setSpecificationMethod(ObjectLocationSpecificationMethod.REPOSITORY_BY_NAME);
                    jetrans.setDirectory(transMeta.getRepositoryDirectory().getPath());
                } else {
                    jetrans.setSpecificationMethod(ObjectLocationSpecificationMethod.FILENAME);
                    jetrans.setFileName(Const.createFilename("${" + Const.INTERNAL_VARIABLE_JOB_FILENAME_DIRECTORY + "}", transMeta.getName(), "." + Const.STRING_TRANS_DEFAULT_EXT));
                }
                JobEntryCopy jectrans = new JobEntryCopy(jetrans);
                jectrans.setDescription(BaseMessages.getString(PKG, "Spoon.RipDB.JobEntryTrans.Description1") + Const.CR + BaseMessages.getString(PKG, "Spoon.RipDB.JobEntryTrans.Description2") + sourceDbInfo + "].[" + tables[i] + "]" + Const.CR + BaseMessages.getString(PKG, "Spoon.RipDB.JobEntryTrans.Description3") + targetDbInfo + "].[" + tables[i] + "]");
                jectrans.setDrawn();
                location.x += 400;
                jectrans.setLocation(new Point(location.x, location.y));
                jobMeta.addJobEntry(jectrans);
                // Add a hop between the last 2 job entries.
                JobHopMeta jhi2 = new JobHopMeta(previous, jectrans);
                jobMeta.addJobHop(jhi2);
                previous = jectrans;
                monitor.worked(1);
            }
            monitor.worked(100);
            monitor.done();
        } catch (Exception e) {
            new ErrorDialog(spoon.getShell(), "Error", "An unexpected error occurred!", e);
        }
    };
    try {
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(spoon.getShell());
        pmd.run(false, true, op);
    } catch (InvocationTargetException | InterruptedException e) {
        new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.RipDB.ErrorRippingTheDatabase.Message"), e);
        return null;
    } finally {
        spoon.refreshGraph();
        spoon.refreshTree();
    }
    return jobMeta;
}
Also used : DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) ObjectType(org.pentaho.di.ui.spoon.TabMapEntry.ObjectType) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) TableOutputMeta(org.pentaho.di.trans.steps.tableoutput.TableOutputMeta) Point(org.pentaho.di.core.gui.Point) Date(java.util.Date) JobEntrySQL(org.pentaho.di.job.entries.sql.JobEntrySQL) GUIResource(org.pentaho.di.ui.core.gui.GUIResource) TransMeta(org.pentaho.di.trans.TransMeta) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) Document(org.w3c.dom.Document) Job(org.pentaho.di.job.Job) Map(java.util.Map) NotePadMeta(org.pentaho.di.core.NotePadMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) BaseMessages(org.pentaho.di.i18n.BaseMessages) StepMeta(org.pentaho.di.trans.step.StepMeta) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) PropsUI(org.pentaho.di.ui.core.PropsUI) Wizard(org.eclipse.jface.wizard.Wizard) TabItem(org.pentaho.xul.swt.tab.TabItem) Utils(org.pentaho.di.core.util.Utils) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) InvocationTargetException(java.lang.reflect.InvocationTargetException) List(java.util.List) JobEntrySpecial(org.pentaho.di.job.entries.special.JobEntrySpecial) JobEntryDialogInterface(org.pentaho.di.job.entry.JobEntryDialogInterface) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SWT(org.eclipse.swt.SWT) KettleStepException(org.pentaho.di.core.exception.KettleStepException) TransAction(org.pentaho.di.core.undo.TransAction) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ObjectLocationSpecificationMethod(org.pentaho.di.core.ObjectLocationSpecificationMethod) JobHopMeta(org.pentaho.di.job.JobHopMeta) KettleException(org.pentaho.di.core.exception.KettleException) HashMap(java.util.HashMap) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) JobEntryPluginType(org.pentaho.di.core.plugins.JobEntryPluginType) Constructor(java.lang.reflect.Constructor) Spoon(org.pentaho.di.ui.spoon.Spoon) ArrayList(java.util.ArrayList) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) Const(org.pentaho.di.core.Const) XMLHandler(org.pentaho.di.core.xml.XMLHandler) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) Node(org.w3c.dom.Node) JobExecutionConfiguration(org.pentaho.di.job.JobExecutionConfiguration) RipDatabaseWizardPage2(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage2) RipDatabaseWizardPage1(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage1) RipDatabaseWizardPage3(org.pentaho.di.ui.spoon.wizards.RipDatabaseWizardPage3) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Shell(org.eclipse.swt.widgets.Shell) Repository(org.pentaho.di.repository.Repository) JobMeta(org.pentaho.di.job.JobMeta) DefaultLogLevel(org.pentaho.di.core.logging.DefaultLogLevel) TransHopMeta(org.pentaho.di.trans.TransHopMeta) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) MessageBox(org.eclipse.swt.widgets.MessageBox) VisibleForTesting(com.google.common.annotations.VisibleForTesting) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta) JobExecutionConfigurationDialog(org.pentaho.di.ui.job.dialog.JobExecutionConfigurationDialog) ExtensionPointHandler(org.pentaho.di.core.extension.ExtensionPointHandler) JobMeta(org.pentaho.di.job.JobMeta) JobHopMeta(org.pentaho.di.job.JobHopMeta) KettleStepException(org.pentaho.di.core.exception.KettleStepException) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) TableOutputMeta(org.pentaho.di.trans.steps.tableoutput.TableOutputMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) JobEntrySQL(org.pentaho.di.job.entries.sql.JobEntrySQL) StepMeta(org.pentaho.di.trans.step.StepMeta) TableInputMeta(org.pentaho.di.trans.steps.tableinput.TableInputMeta) InvocationTargetException(java.lang.reflect.InvocationTargetException) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleException(org.pentaho.di.core.exception.KettleException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) StepPluginType(org.pentaho.di.core.plugins.StepPluginType) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) NotePadMeta(org.pentaho.di.core.NotePadMeta) TransHopMeta(org.pentaho.di.trans.TransHopMeta)

Example 28 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class SpoonTabsDelegate method tabClose.

public boolean tabClose(TabItem item, boolean force) throws KettleException {
    // Try to find the tab-item that's being closed.
    boolean createPerms = !RepositorySecurityUI.verifyOperations(Spoon.getInstance().getShell(), Spoon.getInstance().getRepository(), false, RepositoryOperation.MODIFY_TRANSFORMATION, RepositoryOperation.MODIFY_JOB);
    boolean close = true;
    boolean canSave = true;
    for (TabMapEntry entry : tabMap) {
        if (item.equals(entry.getTabItem())) {
            final TabItemInterface itemInterface = entry.getObject();
            final Object managedObject = itemInterface.getManagedObject();
            if (!force) {
                if (managedObject != null && AbstractMeta.class.isAssignableFrom(managedObject.getClass())) {
                    canSave = !((AbstractMeta) managedObject).hasMissingPlugins();
                }
                if (canSave) {
                    // Can we close this tab? Only allow users with create content perms to save
                    if (!itemInterface.canBeClosed() && createPerms) {
                        int reply = itemInterface.showChangedWarning();
                        if (reply == SWT.YES) {
                            close = itemInterface.applyChanges();
                        } else {
                            if (reply == SWT.CANCEL) {
                                close = false;
                            } else {
                                close = true;
                            }
                        }
                    }
                }
            }
            String beforeCloseId = null;
            String afterCloseId = null;
            if (itemInterface instanceof TransGraph) {
                beforeCloseId = KettleExtensionPoint.TransBeforeClose.id;
                afterCloseId = KettleExtensionPoint.TransAfterClose.id;
            } else if (itemInterface instanceof JobGraph) {
                beforeCloseId = KettleExtensionPoint.JobBeforeClose.id;
                afterCloseId = KettleExtensionPoint.JobAfterClose.id;
            }
            if (beforeCloseId != null) {
                try {
                    ExtensionPointHandler.callExtensionPoint(log, beforeCloseId, managedObject);
                } catch (KettleException e) {
                    // prevent tab close
                    close = false;
                }
            }
            // 
            if (close) {
                if (itemInterface instanceof TransGraph) {
                    TransMeta transMeta = (TransMeta) managedObject;
                    spoon.delegates.trans.closeTransformation(transMeta);
                    spoon.refreshTree();
                // spoon.refreshCoreObjects();
                } else if (itemInterface instanceof JobGraph) {
                    JobMeta jobMeta = (JobMeta) managedObject;
                    spoon.delegates.jobs.closeJob(jobMeta);
                    spoon.refreshTree();
                // spoon.refreshCoreObjects();
                } else if (itemInterface instanceof SpoonBrowser) {
                    this.removeTab(entry);
                    spoon.refreshTree();
                } else if (itemInterface instanceof Composite) {
                    Composite comp = (Composite) itemInterface;
                    if (comp != null && !comp.isDisposed()) {
                        comp.dispose();
                    }
                }
                if (afterCloseId != null) {
                    try {
                        ExtensionPointHandler.callExtensionPoint(log, afterCloseId, managedObject);
                    } catch (KettleException e) {
                    // fails gracefully... what else could we do?
                    }
                }
            }
            break;
        }
    }
    return close;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) Composite(org.eclipse.swt.widgets.Composite) AbstractMeta(org.pentaho.di.base.AbstractMeta) TransMeta(org.pentaho.di.trans.TransMeta) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) SpoonBrowser(org.pentaho.di.ui.spoon.SpoonBrowser) FileObject(org.apache.commons.vfs2.FileObject) TabItemInterface(org.pentaho.di.ui.spoon.TabItemInterface)

Example 29 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class JobExecutorDialog method loadFileJob.

private void loadFileJob(String fname) throws KettleException {
    executorJobMeta = new JobMeta(transMeta.environmentSubstitute(fname), repository);
    executorJobMeta.clearChanged();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta)

Example 30 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class Spoon method loadObjectFromRepository.

public void loadObjectFromRepository(ObjectId objectId, RepositoryObjectType objectType, String revision) throws Exception {
    // Try to open the selected transformation.
    if (objectType.equals(RepositoryObjectType.TRANSFORMATION)) {
        try {
            TransLoadProgressDialog progressDialog = new TransLoadProgressDialog(shell, rep, objectId, revision);
            TransMeta transMeta = progressDialog.open();
            transMeta.clearChanged();
            if (transMeta != null) {
                if (log.isDetailed()) {
                    log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.LoadToTransformation", transMeta.getName(), transMeta.getRepositoryDirectory().getName()));
                }
                props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, transMeta.getName(), transMeta.getRepositoryDirectory().getPath(), true, rep.getName(), getUsername(), null);
                addMenuLast();
                addTransGraph(transMeta);
            }
            refreshTree();
            refreshGraph();
        } catch (Exception e) {
            if (KettleRepositoryLostException.lookupStackStrace(e) == null) {
                new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), BaseMessages.getString(Spoon.class, "Spoon.Dialog.ErrorOpeningById.Message", objectId), e.getMessage(), e);
            } else {
                throw e;
            }
        }
    } else if (objectType.equals(RepositoryObjectType.JOB)) {
        try {
            JobLoadProgressDialog progressDialog = new JobLoadProgressDialog(shell, rep, objectId, revision);
            JobMeta jobMeta = progressDialog.open();
            jobMeta.clearChanged();
            if (jobMeta != null) {
                props.addLastFile(LastUsedFile.FILE_TYPE_JOB, jobMeta.getName(), jobMeta.getRepositoryDirectory().getPath(), true, rep.getName(), getUsername(), null);
                saveSettings();
                addMenuLast();
                addJobGraph(jobMeta);
            }
            refreshTree();
            refreshGraph();
        } catch (Exception e) {
            if (KettleRepositoryLostException.lookupStackStrace(e) == null) {
                new ErrorDialog(((Spoon) SpoonFactory.getInstance()).getShell(), BaseMessages.getString(Spoon.class, "Spoon.Dialog.ErrorOpeningById.Message", objectId), e.getMessage(), e);
            } else {
                throw e;
            }
        }
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransLoadProgressDialog(org.pentaho.di.ui.trans.dialog.TransLoadProgressDialog) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) JobLoadProgressDialog(org.pentaho.di.ui.job.dialog.JobLoadProgressDialog)

Aggregations

JobMeta (org.pentaho.di.job.JobMeta)254 Test (org.junit.Test)88 TransMeta (org.pentaho.di.trans.TransMeta)69 KettleException (org.pentaho.di.core.exception.KettleException)62 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)48 Job (org.pentaho.di.job.Job)45 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)27 Repository (org.pentaho.di.repository.Repository)25 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)25 Point (org.pentaho.di.core.gui.Point)24 ArrayList (java.util.ArrayList)23 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)22 SlaveServer (org.pentaho.di.cluster.SlaveServer)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 FileObject (org.apache.commons.vfs2.FileObject)16 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)16 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)15 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)15 PrintWriter (java.io.PrintWriter)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)12