Search in sources :

Example 26 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class Spoon method saveFileAs.

public boolean saveFileAs(EngineMetaInterface meta) throws KettleException {
    boolean saved;
    if (getLog().isBasic()) {
        // "Save as..."
        getLog().logBasic(BaseMessages.getString(PKG, "Spoon.Log.SaveAs"));
    }
    ((AbstractMeta) meta).setRepository(rep);
    ((AbstractMeta) meta).setMetaStore(metaStore);
    String activePerspectiveId = SpoonPerspectiveManager.getInstance().getActivePerspective().getId();
    boolean etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
    if (rep != null && etlPerspective) {
        meta.setObjectId(null);
        meta.setFilename(null);
        saved = saveToRepository(meta, true);
    } else {
        saved = saveXMLFile(meta, false);
    }
    // rename the tab only if the meta was successfully saved
    if (saved) {
        // filename or name of transformation might have changed.
        delegates.tabs.renameTabs();
    }
    refreshTree();
    if (saved && (meta instanceof TransMeta || meta instanceof JobMeta)) {
        TabMapEntry tabEntry = delegates.tabs.findTabMapEntry(meta);
        TabItem tabItem = tabEntry.getTabItem();
        if (meta.getFileType().equals(LastUsedFile.FILE_TYPE_TRANSFORMATION)) {
            tabItem.setImage(GUIResource.getInstance().getImageTransGraph());
        } else if (meta.getFileType().equals(LastUsedFile.FILE_TYPE_JOB)) {
            tabItem.setImage(GUIResource.getInstance().getImageJobGraph());
        }
    }
    // Update menu status for the newly saved object
    enableMenus();
    return saved;
}
Also used : TabItem(org.pentaho.xul.swt.tab.TabItem) CTabItem(org.eclipse.swt.custom.CTabItem) JobMeta(org.pentaho.di.job.JobMeta) AbstractMeta(org.pentaho.di.base.AbstractMeta) TransMeta(org.pentaho.di.trans.TransMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 27 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class Spoon method saveFileAs.

public boolean saveFileAs() throws KettleException {
    try {
        EngineMetaInterface meta = getActiveMeta();
        if (meta != null && AbstractMeta.class.isAssignableFrom(meta.getClass())) {
            if (((AbstractMeta) meta).hasMissingPlugins()) {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Error"));
                mb.setText(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Title"));
                mb.open();
                return false;
            }
        }
        if (meta != null) {
            if (meta.canSave()) {
                return saveFileAs(meta);
            }
        }
    } catch (Exception e) {
        KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
        if (krle != null) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), krle.getPrefaceMessage(), krle);
            closeRepository();
        } else {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Message"), e);
        }
    }
    return false;
}
Also used : AbstractMeta(org.pentaho.di.base.AbstractMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) 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) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 28 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class Spoon method saveFile.

public boolean saveFile() {
    try {
        EngineMetaInterface meta = getActiveMeta();
        if (meta != null) {
            if (AbstractMeta.class.isAssignableFrom(meta.getClass()) && ((AbstractMeta) meta).hasMissingPlugins()) {
                MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_ERROR);
                mb.setMessage(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Error"));
                mb.setText(BaseMessages.getString(PKG, "Spoon.ErrorDialog.MissingPlugin.Title"));
                mb.open();
                return false;
            }
            if (meta != null) {
                return saveToFile(meta);
            }
        }
    } catch (Exception e) {
        KettleRepositoryLostException krle = KettleRepositoryLostException.lookupStackStrace(e);
        if (krle != null) {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), krle.getPrefaceMessage(), krle);
            closeRepository();
        } else {
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Title"), BaseMessages.getString(PKG, "Spoon.File.Save.Fail.Message"), e);
        }
    }
    return false;
}
Also used : AbstractMeta(org.pentaho.di.base.AbstractMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) 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) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 29 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class Spoon method markTabsChanged.

private void markTabsChanged(boolean force) {
    for (TabMapEntry entry : delegates.tabs.getTabs()) {
        if (entry.getTabItem().isDisposed()) {
            continue;
        }
        boolean changed = force || entry.getObject().hasContentChanged();
        if (changed) {
            // Call extension point to alert plugins that a transformation or job has changed
            Object tabObject = entry.getObject().getManagedObject();
            String changedId = null;
            if (tabObject instanceof TransMeta) {
                changedId = KettleExtensionPoint.TransChanged.id;
            } else if (tabObject instanceof JobMeta) {
                changedId = KettleExtensionPoint.JobChanged.id;
            } else {
                changed = false;
            }
            if (changedId != null) {
                try {
                    if (force) {
                        ((AbstractMeta) tabObject).setChanged();
                    }
                    ExtensionPointHandler.callExtensionPoint(log, changedId, tabObject);
                } catch (KettleException e) {
                // fails gracefully
                }
            }
        }
        entry.getTabItem().setChanged(changed);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) AbstractMeta(org.pentaho.di.base.AbstractMeta) TransMeta(org.pentaho.di.trans.TransMeta) RepositoryObject(org.pentaho.di.repository.RepositoryObject) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) FileObject(org.apache.commons.vfs2.FileObject) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 30 with AbstractMeta

use of org.pentaho.di.base.AbstractMeta in project pentaho-kettle by pentaho.

the class Spoon method clearRepositoryDirectory.

/**
 * PDI-18997 - clear specific repository directory when connect and or disconnect from server
 */
public void clearRepositoryDirectory() {
    for (TabMapEntry entry : delegates.tabs.getTabs()) {
        Object managedObject = entry.getObject().getManagedObject();
        if (managedObject instanceof AbstractMeta) {
            AbstractMeta abstractMeta = (AbstractMeta) managedObject;
            abstractMeta.setRepositoryDirectory(new RepositoryDirectory());
            abstractMeta.setFilename(null);
        }
    }
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) AbstractMeta(org.pentaho.di.base.AbstractMeta) RepositoryObject(org.pentaho.di.repository.RepositoryObject) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) FileObject(org.apache.commons.vfs2.FileObject)

Aggregations

AbstractMeta (org.pentaho.di.base.AbstractMeta)50 Test (org.junit.Test)18 KettleException (org.pentaho.di.core.exception.KettleException)10 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)7 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)6 JobMeta (org.pentaho.di.job.JobMeta)6 TransMeta (org.pentaho.di.trans.TransMeta)6 FileObject (org.apache.commons.vfs2.FileObject)5 ExtensionPointWrapper (org.pentaho.di.ui.core.events.dialog.extension.ExtensionPointWrapper)5 SlaveServer (org.pentaho.di.cluster.SlaveServer)4 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 RunConfiguration (org.pentaho.di.engine.configuration.api.RunConfiguration)4 SelectionEvent (org.eclipse.swt.events.SelectionEvent)3 EmbeddedMetaStore (org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)3 ExtensionPoint (org.pentaho.di.core.extension.ExtensionPoint)3 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)3 EmbeddedRunConfigurationManager (org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager)3 RunConfigurationManager (org.pentaho.di.engine.configuration.impl.RunConfigurationManager)3 RepositoryObject (org.pentaho.di.repository.RepositoryObject)3