Search in sources :

Example 1 with MissingEntryDialog

use of org.pentaho.di.ui.job.entries.missing.MissingEntryDialog in project pentaho-kettle by pentaho.

the class JobLoadProgressDialog method open.

public JobMeta open() {
    IRunnableWithProgress op = new IRunnableWithProgress() {

        public void run(IProgressMonitor monitor) throws InvocationTargetException, InterruptedException {
            Spoon spoon = Spoon.getInstance();
            try {
                // Call extension point(s) before the file has been opened
                ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobBeforeOpen.id, (objectId == null) ? jobname : objectId.toString());
                if (objectId != null) {
                    jobInfo = rep.loadJob(objectId, versionLabel);
                } else {
                    jobInfo = rep.loadJob(jobname, repdir, new ProgressMonitorAdapter(monitor), versionLabel);
                }
                // Call extension point(s) now that the file has been opened
                ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobAfterOpen.id, jobInfo);
                if (jobInfo.hasMissingPlugins()) {
                    MissingEntryDialog missingDialog = new MissingEntryDialog(shell, jobInfo.getMissingEntries());
                    if (missingDialog.open() == null) {
                        jobInfo = null;
                    }
                }
            } catch (KettleException e) {
                throw new InvocationTargetException(e, "Error loading job");
            }
        }
    };
    try {
        ProgressMonitorDialog pmd = new ProgressMonitorDialog(shell);
        pmd.run(true, false, op);
    } catch (InvocationTargetException e) {
        KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
        if (krle != null) {
            throw krle;
        }
        new ErrorDialog(shell, "Error loading job", "An error occured loading the job!", e);
        jobInfo = null;
    } catch (InterruptedException e) {
        new ErrorDialog(shell, "Error loading job", "An error occured loading the job!", e);
        jobInfo = null;
    }
    return jobInfo;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) Spoon(org.pentaho.di.ui.spoon.Spoon) ProgressMonitorDialog(org.eclipse.jface.dialogs.ProgressMonitorDialog) ProgressMonitorAdapter(org.pentaho.di.core.ProgressMonitorAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MissingEntryDialog(org.pentaho.di.ui.job.entries.missing.MissingEntryDialog) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) InvocationTargetException(java.lang.reflect.InvocationTargetException) IRunnableWithProgress(org.eclipse.jface.operation.IRunnableWithProgress)

Example 2 with MissingEntryDialog

use of org.pentaho.di.ui.job.entries.missing.MissingEntryDialog in project pentaho-kettle by pentaho.

the class JobFileListener method open.

public boolean open(Node jobNode, String fname, boolean importfile) {
    Spoon spoon = Spoon.getInstance();
    try {
        // Call extension point(s) before the file has been opened
        ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobBeforeOpen.id, fname);
        JobMeta jobMeta = new JobMeta();
        jobMeta.loadXML(jobNode, fname, spoon.getRepository(), spoon.getMetaStore(), false, spoon);
        if (jobMeta.hasMissingPlugins()) {
            MissingEntryDialog missingDialog = new MissingEntryDialog(spoon.getShell(), jobMeta.getMissingEntries());
            if (missingDialog.open() == null) {
                return true;
            }
        }
        jobMeta.setRepositoryDirectory(spoon.getDefaultSaveLocation(jobMeta));
        jobMeta.setRepository(spoon.getRepository());
        jobMeta.setMetaStore(spoon.getMetaStore());
        spoon.setJobMetaVariables(jobMeta);
        spoon.getProperties().addLastFile(LastUsedFile.FILE_TYPE_JOB, fname, null, false, null);
        spoon.addMenuLast();
        // if any exist.
        if (importfile) {
            if (spoon.getRepository() != null) {
                jobMeta = fixLinks(jobMeta);
            }
        } else {
            jobMeta.clearChanged();
        }
        jobMeta.setFilename(fname);
        spoon.delegates.jobs.addJobGraph(jobMeta);
        // Call extension point(s) now that the file has been opened
        ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobAfterOpen.id, jobMeta);
        spoon.refreshTree();
        SpoonPerspectiveManager.getInstance().activatePerspective(MainSpoonPerspective.class);
        return true;
    } catch (KettleException e) {
        new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Message") + fname, e);
    }
    return false;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) MissingEntryDialog(org.pentaho.di.ui.job.entries.missing.MissingEntryDialog)

Aggregations

KettleException (org.pentaho.di.core.exception.KettleException)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 MissingEntryDialog (org.pentaho.di.ui.job.entries.missing.MissingEntryDialog)2 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)1 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)1 ProgressMonitorAdapter (org.pentaho.di.core.ProgressMonitorAdapter)1 JobMeta (org.pentaho.di.job.JobMeta)1 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)1 Spoon (org.pentaho.di.ui.spoon.Spoon)1