Search in sources :

Example 1 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class Spoon method exploreRepository.

public void exploreRepository() {
    if (rep != null) {
        final RepositoryExplorerCallback cb = new RepositoryExplorerCallback() {

            @Override
            public boolean open(UIRepositoryContent element, String revision) throws Exception {
                String objName = element.getName();
                if (objName != null) {
                    RepositoryObjectType objectType = element.getRepositoryElementType();
                    RepositoryDirectory repDir = element.getRepositoryDirectory();
                    if (element.getObjectId() != null) {
                        // new way
                        loadObjectFromRepository(element.getObjectId(), objectType, revision);
                    } else {
                        // old way
                        loadObjectFromRepository(objName, objectType, repDir, revision);
                    }
                }
                // do not close explorer
                return false;
            }

            @Override
            public boolean error(String message) throws Exception {
                closeRepository();
                return true;
            }
        };
        try {
            final KettleWaitBox box = (KettleWaitBox) this.mainSpoonContainer.getDocumentRoot().createElement("iconwaitbox");
            box.setIndeterminate(true);
            box.setCanCancel(false);
            box.setIcon("ui/images/kettle_logo_small.svg");
            box.setTitle(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Connection.Wait.Title"));
            box.setMessage(BaseMessages.getString(RepositoryDialogInterface.class, "RepositoryExplorerDialog.Explorer.Wait.Message"));
            box.setDialogParent(shell);
            box.setRunnable(new WaitBoxRunnable(box) {

                @Override
                public void run() {
                    shell.getDisplay().syncExec(new Runnable() {

                        @Override
                        public void run() {
                            RepositoryExplorer explorer;
                            try {
                                try {
                                    explorer = new RepositoryExplorer(shell, rep, cb, Variables.getADefaultVariableSpace(), sharedObjectSyncUtil);
                                } catch (final KettleRepositoryLostException krle) {
                                    handleRepositoryLost(krle);
                                    closeRepository();
                                    return;
                                } finally {
                                    box.stop();
                                }
                                if (explorer.isInitialized()) {
                                    explorer.show();
                                } else {
                                    return;
                                }
                                explorer.dispose();
                            } catch (final Throwable e) {
                                shell.getDisplay().asyncExec(new Runnable() {

                                    @Override
                                    public void run() {
                                        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
                                    }
                                });
                            }
                        }
                    });
                }

                @Override
                public void cancel() {
                }
            });
            box.start();
        } catch (Throwable e) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Error"), e.getMessage(), e);
        }
    }
}
Also used : RepositoryExplorer(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorer) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) UIRepositoryContent(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryContent) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) RepositoryExplorerCallback(org.pentaho.di.ui.repository.repositoryexplorer.RepositoryExplorerCallback) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) WaitBoxRunnable(org.pentaho.ui.xul.components.WaitBoxRunnable) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) RepositoryDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface) KettleWaitBox(org.pentaho.di.ui.xul.KettleWaitBox)

Example 2 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class JobDialog method open.

public JobMeta open() {
    Shell parent = getParent();
    Display display = parent.getDisplay();
    shell = new Shell(parent, SWT.DIALOG_TRIM | SWT.RESIZE | SWT.MAX | SWT.MIN | SWT.APPLICATION_MODAL);
    props.setLook(shell);
    shell.setImage(GUIResource.getInstance().getImageJobGraph());
    lsMod = new ModifyListener() {

        public void modifyText(ModifyEvent e) {
            changed = true;
        }
    };
    FormLayout formLayout = new FormLayout();
    formLayout.marginWidth = Const.FORM_MARGIN;
    formLayout.marginHeight = Const.FORM_MARGIN;
    shell.setLayout(formLayout);
    shell.setText(BaseMessages.getString(PKG, "JobDialog.JobProperties.ShellText"));
    middle = props.getMiddlePct();
    margin = Const.MARGIN;
    wTabFolder = new CTabFolder(shell, SWT.BORDER);
    props.setLook(wTabFolder, Props.WIDGET_STYLE_TAB);
    // 
    for (LogTableInterface logTable : logTables) {
        // can be null
        logTableUserInterfaces.add(getLogTableUserInterface(logTable, jobMeta, lsMod));
    }
    addJobTab();
    addParamTab();
    addSettingsTab();
    addLogTab();
    // See if there are any other tabs to be added...
    extraTabs = new ArrayList<JobDialogPluginInterface>();
    java.util.List<PluginInterface> jobDialogPlugins = PluginRegistry.getInstance().getPlugins(JobDialogPluginType.class);
    for (PluginInterface jobDialogPlugin : jobDialogPlugins) {
        try {
            JobDialogPluginInterface extraTab = (JobDialogPluginInterface) PluginRegistry.getInstance().loadClass(jobDialogPlugin);
            extraTab.addTab(jobMeta, parent, wTabFolder);
            extraTabs.add(extraTab);
        } catch (Exception e) {
            KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
            if (krle != null) {
                throw krle;
            }
            new ErrorDialog(shell, "Error", "Error loading job dialog plugin with id " + jobDialogPlugin.getIds()[0], e);
        }
    }
    fdTabFolder = new FormData();
    fdTabFolder.left = new FormAttachment(0, 0);
    fdTabFolder.top = new FormAttachment(0, 0);
    fdTabFolder.right = new FormAttachment(100, 0);
    fdTabFolder.bottom = new FormAttachment(100, -50);
    wTabFolder.setLayoutData(fdTabFolder);
    // THE BUTTONS
    wOK = new Button(shell, SWT.PUSH);
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wOK.setText(BaseMessages.getString(PKG, "System.Button.OK"));
    wSQL = new Button(shell, SWT.PUSH);
    wSQL.setText(BaseMessages.getString(PKG, "System.Button.SQL"));
    wCancel = new Button(shell, SWT.PUSH);
    wCancel.setText(BaseMessages.getString(PKG, "System.Button.Cancel"));
    // BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, margin, wSharedObjectsFile);
    BaseStepDialog.positionBottomButtons(shell, new Button[] { wOK, wSQL, wCancel }, Const.MARGIN, null);
    // Add listeners
    lsOK = new Listener() {

        public void handleEvent(Event e) {
            ok();
        }
    };
    lsSQL = new Listener() {

        public void handleEvent(Event e) {
            sql();
        }
    };
    lsCancel = new Listener() {

        public void handleEvent(Event e) {
            cancel();
        }
    };
    wOK.addListener(SWT.Selection, lsOK);
    wSQL.addListener(SWT.Selection, lsSQL);
    wCancel.addListener(SWT.Selection, lsCancel);
    lsDef = new SelectionAdapter() {

        public void widgetDefaultSelected(SelectionEvent e) {
            ok();
        }
    };
    wJobname.addSelectionListener(lsDef);
    // Detect X or ALT-F4 or something that kills this window...
    shell.addShellListener(new ShellAdapter() {

        public void shellClosed(ShellEvent e) {
            cancel();
        }
    });
    wTabFolder.setSelection(0);
    getData();
    BaseStepDialog.setSize(shell);
    changed = false;
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch()) {
            display.sleep();
        }
    }
    return jobMeta;
}
Also used : FormLayout(org.eclipse.swt.layout.FormLayout) FormData(org.eclipse.swt.layout.FormData) ShellAdapter(org.eclipse.swt.events.ShellAdapter) CTabFolder(org.eclipse.swt.custom.CTabFolder) FieldDisabledListener(org.pentaho.di.ui.core.widget.FieldDisabledListener) Listener(org.eclipse.swt.widgets.Listener) ModifyListener(org.eclipse.swt.events.ModifyListener) ModifyListener(org.eclipse.swt.events.ModifyListener) LogTablePluginInterface(org.pentaho.di.core.logging.LogTablePluginInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ShellEvent(org.eclipse.swt.events.ShellEvent) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) DuplicateParamException(org.pentaho.di.core.parameters.DuplicateParamException) UnknownParamException(org.pentaho.di.core.parameters.UnknownParamException) KettleException(org.pentaho.di.core.exception.KettleException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) LogTableInterface(org.pentaho.di.core.logging.LogTableInterface) Shell(org.eclipse.swt.widgets.Shell) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Button(org.eclipse.swt.widgets.Button) SelectionEvent(org.eclipse.swt.events.SelectionEvent) ModifyEvent(org.eclipse.swt.events.ModifyEvent) Event(org.eclipse.swt.widgets.Event) ShellEvent(org.eclipse.swt.events.ShellEvent) SelectionEvent(org.eclipse.swt.events.SelectionEvent) FormAttachment(org.eclipse.swt.layout.FormAttachment) Display(org.eclipse.swt.widgets.Display)

Example 3 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException 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 4 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class Spoon method setShellText.

public void setShellText() {
    if (shell.isDisposed()) {
        return;
    }
    String filename = null;
    String name = null;
    String version = null;
    ChangedFlagInterface changed = null;
    boolean versioningEnabled = true;
    AbstractMeta meta = getActiveJob() != null ? getActiveJob() : getActiveTransformation();
    if (meta != null) {
        changed = meta;
        filename = meta.getFilename();
        name = meta.getName();
        version = meta.getObjectRevision() == null ? null : meta.getObjectRevision().getName();
        try {
            versioningEnabled = isVersionEnabled(rep, meta);
        } catch (KettleRepositoryLostException krle) {
            handleRepositoryLost(krle);
        }
    }
    String text = "";
    if (rep != null) {
        text += APP_TITLE + " - [" + getRepositoryName() + "] ";
    } else {
        text += APP_TITLE + " - ";
    }
    if (Utils.isEmpty(name)) {
        if (!Utils.isEmpty(filename)) {
            text += filename;
        } else {
            String tab = getActiveTabText();
            if (!Utils.isEmpty(tab)) {
                text += tab;
            } else {
                // "[no name]"
                text += BaseMessages.getString(PKG, "Spoon.Various.NoName");
            }
        }
    } else {
        text += name;
    }
    if (versioningEnabled && !Utils.isEmpty(version)) {
        text += " v" + version;
    }
    if (changed != null && changed.hasChanged()) {
        text += " " + BaseMessages.getString(PKG, "Spoon.Various.Changed");
    }
    shell.setText(text);
    markTabsChanged(false);
}
Also used : ChangedFlagInterface(org.pentaho.di.core.changed.ChangedFlagInterface) AbstractMeta(org.pentaho.di.base.AbstractMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException)

Example 5 with KettleRepositoryLostException

use of org.pentaho.di.repository.KettleRepositoryLostException in project pentaho-kettle by pentaho.

the class Spoon method refreshDbConnectionsSubtree.

@VisibleForTesting
void refreshDbConnectionsSubtree(TreeItem tiRootName, AbstractMeta meta, GUIResource guiResource) {
    TreeItem tiDbTitle = createTreeItem(tiRootName, STRING_CONNECTIONS, guiResource.getImageFolder());
    DatabasesCollector collector = new DatabasesCollector(meta, rep);
    try {
        try {
            collector.collectDatabases();
        } catch (KettleException e) {
            if (e.getCause() instanceof KettleRepositoryLostException) {
                handleRepositoryLost((KettleRepositoryLostException) e.getCause());
                collector = new DatabasesCollector(meta, null);
                collector.collectDatabases();
            } else {
                throw e;
            }
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.ErrorDialog.Title"), BaseMessages.getString(PKG, "Spoon.ErrorDialog.ErrorFetchingFromRepo.DbConnections"), e);
    }
    for (String dbName : collector.getDatabaseNames()) {
        if (!filterMatch(dbName)) {
            continue;
        }
        DatabaseMeta databaseMeta = collector.getMetaFor(dbName);
        TreeItem tiDb = createTreeItem(tiDbTitle, databaseMeta.getDisplayName(), guiResource.getImageConnectionTree());
        if (databaseMeta.isShared()) {
            tiDb.setFont(guiResource.getFontBold());
        }
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) TreeItem(org.eclipse.swt.widgets.TreeItem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) VisibleForTesting(com.google.common.annotations.VisibleForTesting)

Aggregations

KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)10 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)9 KettleException (org.pentaho.di.core.exception.KettleException)8 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 MalformedURLException (java.net.MalformedURLException)3 FileSystemException (org.apache.commons.vfs2.FileSystemException)3 SWTException (org.eclipse.swt.SWTException)3 AbstractMeta (org.pentaho.di.base.AbstractMeta)3 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)3 KettleFileException (org.pentaho.di.core.exception.KettleFileException)3 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)3 KettleRowException (org.pentaho.di.core.exception.KettleRowException)3 KettleValueException (org.pentaho.di.core.exception.KettleValueException)3 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)3 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)3 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)3 InvocationTargetException (java.lang.reflect.InvocationTargetException)2 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)2 ProgressMonitorDialog (org.eclipse.jface.dialogs.ProgressMonitorDialog)2 IRunnableWithProgress (org.eclipse.jface.operation.IRunnableWithProgress)2