Search in sources :

Example 1 with JobLoadProgressDialog

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

Example 2 with JobLoadProgressDialog

use of org.pentaho.di.ui.job.dialog.JobLoadProgressDialog in project pentaho-kettle by pentaho.

the class Spoon method loadLastUsedFile.

private void loadLastUsedFile(LastUsedFile lastUsedFile, String repositoryName, boolean trackIt, boolean isStartup) throws KettleException {
    boolean useRepository = repositoryName != null;
    // 
    if (lastUsedFile.isSourceRepository()) {
        if (!Utils.isEmpty(lastUsedFile.getRepositoryName())) {
            if (useRepository && !lastUsedFile.getRepositoryName().equalsIgnoreCase(repositoryName)) {
                // We just asked...
                useRepository = false;
            }
        }
    }
    if (useRepository && lastUsedFile.isSourceRepository()) {
        if (rep != null) {
            // load from this repository...
            if (rep.getName().equalsIgnoreCase(lastUsedFile.getRepositoryName())) {
                RepositoryDirectoryInterface rdi = rep.findDirectory(lastUsedFile.getDirectory());
                if (rdi != null) {
                    // does the file exist in the repo?
                    final RepositoryObjectType fileType = lastUsedFile.isJob() ? RepositoryObjectType.JOB : RepositoryObjectType.TRANSFORMATION;
                    if (!rep.exists(lastUsedFile.getFilename(), rdi, fileType)) {
                        // opening this file
                        if (isStartup) {
                            if (log.isDetailed()) {
                                log.logDetailed(BaseMessages.getString(PKG, "Spoon.log.openingMissingFile"));
                            }
                        } else {
                            final Dialog dlg = new SimpleMessageDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.MissingRecentFile.Message", lastUsedFile.getLongFileType().toLowerCase()), MessageDialog.ERROR, BaseMessages.getString(PKG, "System.Button.Close"), MISSING_RECENT_DLG_WIDTH, SimpleMessageDialog.BUTTON_WIDTH);
                            dlg.open();
                        }
                    } else {
                        // Are we loading a transformation or a job?
                        if (lastUsedFile.isTransformation()) {
                            if (log.isDetailed()) {
                                // "Auto loading transformation ["+lastfiles[0]+"] from repository directory ["+lastdirs[0]+"]"
                                log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.AutoLoadingTransformation", lastUsedFile.getFilename(), lastUsedFile.getDirectory()));
                            }
                            TransLoadProgressDialog tlpd = new TransLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
                            TransMeta transMeta = tlpd.open();
                            if (transMeta != null) {
                                if (trackIt) {
                                    props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null);
                                }
                                // transMeta.setFilename(lastUsedFile.getFilename());
                                transMeta.clearChanged();
                                addTransGraph(transMeta);
                                refreshTree();
                            }
                        } else if (lastUsedFile.isJob()) {
                            JobLoadProgressDialog progressDialog = new JobLoadProgressDialog(shell, rep, lastUsedFile.getFilename(), rdi, null);
                            JobMeta jobMeta = progressDialog.open();
                            if (jobMeta != null) {
                                if (trackIt) {
                                    props.addLastFile(LastUsedFile.FILE_TYPE_JOB, lastUsedFile.getFilename(), rdi.getPath(), true, rep.getName(), getUsername(), null);
                                }
                                jobMeta.clearChanged();
                                addJobGraph(jobMeta);
                            }
                        }
                        refreshTree();
                    }
                }
            }
        }
    }
    // open files stored locally, not in the repository
    if (!lastUsedFile.isSourceRepository() && !Utils.isEmpty(lastUsedFile.getFilename())) {
        if (lastUsedFile.isTransformation()) {
            openFile(lastUsedFile.getFilename(), rep != null);
        }
        if (lastUsedFile.isJob()) {
            openFile(lastUsedFile.getFilename(), false);
        }
        refreshTree();
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) SimpleMessageDialog(org.pentaho.di.ui.core.dialog.SimpleMessageDialog) TransLoadProgressDialog(org.pentaho.di.ui.trans.dialog.TransLoadProgressDialog) LogSettingsDialog(org.pentaho.di.ui.spoon.dialog.LogSettingsDialog) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) SubjectDataBrowserDialog(org.pentaho.di.ui.core.dialog.SubjectDataBrowserDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ImportRulesDialog(org.pentaho.di.ui.imp.ImportRulesDialog) RepositoriesDialog(org.pentaho.di.ui.repository.RepositoriesDialog) KettlePropertiesFileDialog(org.pentaho.di.ui.core.dialog.KettlePropertiesFileDialog) EnterMappingDialog(org.pentaho.di.ui.core.dialog.EnterMappingDialog) Dialog(org.eclipse.jface.dialogs.Dialog) CheckTransProgressDialog(org.pentaho.di.ui.spoon.dialog.CheckTransProgressDialog) PreviewRowsDialog(org.pentaho.di.ui.core.dialog.PreviewRowsDialog) ShowMessageDialog(org.pentaho.di.ui.core.dialog.ShowMessageDialog) CapabilityManagerDialog(org.pentaho.di.ui.spoon.dialog.CapabilityManagerDialog) TransHopDialog(org.pentaho.di.ui.trans.dialog.TransHopDialog) TransLoadProgressDialog(org.pentaho.di.ui.trans.dialog.TransLoadProgressDialog) EnterOptionsDialog(org.pentaho.di.ui.core.dialog.EnterOptionsDialog) BrowserEnvironmentWarningDialog(org.pentaho.di.ui.core.dialog.BrowserEnvironmentWarningDialog) AuthProviderDialog(org.pentaho.di.ui.core.auth.AuthProviderDialog) EnterSearchDialog(org.pentaho.di.ui.core.dialog.EnterSearchDialog) EnterStringsDialog(org.pentaho.di.ui.core.dialog.EnterStringsDialog) VfsFileChooserDialog(org.pentaho.vfs.ui.VfsFileChooserDialog) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog) SelectDirectoryDialog(org.pentaho.di.ui.repository.dialog.SelectDirectoryDialog) MetaStoreExplorerDialog(org.pentaho.di.ui.spoon.dialog.MetaStoreExplorerDialog) RepositoryImportProgressDialog(org.pentaho.di.ui.repository.dialog.RepositoryImportProgressDialog) SaveProgressDialog(org.pentaho.di.ui.spoon.dialog.SaveProgressDialog) AnalyseImpactProgressDialog(org.pentaho.di.ui.spoon.dialog.AnalyseImpactProgressDialog) RepositoryExportProgressDialog(org.pentaho.di.ui.repository.dialog.RepositoryExportProgressDialog) AboutDialog(org.pentaho.di.ui.core.dialog.AboutDialog) JobLoadProgressDialog(org.pentaho.di.ui.job.dialog.JobLoadProgressDialog) WizardDialog(org.eclipse.jface.wizard.WizardDialog) SimpleMessageDialog(org.pentaho.di.ui.core.dialog.SimpleMessageDialog) CheckResultDialog(org.pentaho.di.ui.core.dialog.CheckResultDialog) ShowBrowserDialog(org.pentaho.di.ui.core.dialog.ShowBrowserDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) TransMeta(org.pentaho.di.trans.TransMeta) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) JobLoadProgressDialog(org.pentaho.di.ui.job.dialog.JobLoadProgressDialog)

Example 3 with JobLoadProgressDialog

use of org.pentaho.di.ui.job.dialog.JobLoadProgressDialog in project pentaho-kettle by pentaho.

the class Spoon method loadObjectFromRepository.

public void loadObjectFromRepository(String objName, RepositoryObjectType objectType, RepositoryDirectoryInterface repDir, String versionLabel) throws Exception {
    // Try to open the selected transformation.
    if (objectType.equals(RepositoryObjectType.TRANSFORMATION)) {
        try {
            TransLoadProgressDialog progressDialog = new TransLoadProgressDialog(shell, rep, objName, repDir, versionLabel);
            TransMeta transMeta = progressDialog.open();
            transMeta.clearChanged();
            if (transMeta != null) {
                if (log.isDetailed()) {
                    log.logDetailed(BaseMessages.getString(PKG, "Spoon.Log.LoadToTransformation", objName, repDir.getName()));
                }
                props.addLastFile(LastUsedFile.FILE_TYPE_TRANSFORMATION, objName, repDir.getPath(), true, rep.getName(), getUsername(), null);
                addMenuLast();
                addTransGraph(transMeta);
            }
            refreshTree();
            refreshGraph();
        } catch (Exception e) {
            if (KettleRepositoryLostException.lookupStackStrace(e) == null) {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Message") + objName + Const.CR + // "Error opening : "
                e.getMessage());
                mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Title"));
                mb.open();
            } else {
                throw e;
            }
        }
    } else if (objectType.equals(RepositoryObjectType.JOB)) {
        // Try to open the selected job.
        try {
            JobLoadProgressDialog progressDialog = new JobLoadProgressDialog(shell, rep, objName, repDir, versionLabel);
            JobMeta jobMeta = progressDialog.open();
            jobMeta.clearChanged();
            if (jobMeta != null) {
                props.addLastFile(LastUsedFile.FILE_TYPE_JOB, objName, repDir.getPath(), true, rep.getName(), getUsername(), null);
                saveSettings();
                addMenuLast();
                addJobGraph(jobMeta);
            }
            refreshTree();
            refreshGraph();
        } catch (Exception e) {
            if (KettleRepositoryLostException.lookupStackStrace(e) == null) {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Message") + objName + Const.CR + // "Error opening : "
                e.getMessage());
                mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.ErrorOpening.Title"));
                mb.open();
            } 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) 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) MessageBox(org.eclipse.swt.widgets.MessageBox)

Aggregations

JobMeta (org.pentaho.di.job.JobMeta)3 TransMeta (org.pentaho.di.trans.TransMeta)3 JobLoadProgressDialog (org.pentaho.di.ui.job.dialog.JobLoadProgressDialog)3 TransLoadProgressDialog (org.pentaho.di.ui.trans.dialog.TransLoadProgressDialog)3 MalformedURLException (java.net.MalformedURLException)2 FileSystemException (org.apache.commons.vfs2.FileSystemException)2 SWTException (org.eclipse.swt.SWTException)2 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)2 KettleException (org.pentaho.di.core.exception.KettleException)2 KettleFileException (org.pentaho.di.core.exception.KettleFileException)2 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)2 KettleRowException (org.pentaho.di.core.exception.KettleRowException)2 KettleValueException (org.pentaho.di.core.exception.KettleValueException)2 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)2 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)2 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)2 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)2 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)2 Dialog (org.eclipse.jface.dialogs.Dialog)1 MessageDialog (org.eclipse.jface.dialogs.MessageDialog)1