Search in sources :

Example 31 with AbstractMeta

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

the class Spoon method saveToFile.

public boolean saveToFile(EngineMetaInterface meta) throws KettleException {
    if (meta == null) {
        return false;
    }
    boolean saved = false;
    ((AbstractMeta) meta).setRepository(rep);
    ((AbstractMeta) meta).setMetaStore(metaStore);
    if (getLog().isDetailed()) {
        // "Save to file or repository...
        getLog().logDetailed(BaseMessages.getString(PKG, "Spoon.Log.SaveToFileOrRepository"));
    }
    SpoonPerspective activePerspective = SpoonPerspectiveManager.getInstance().getActivePerspective();
    // 
    if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
        return ((SpoonPerspectiveOpenSaveInterface) activePerspective).save(meta);
    }
    String activePerspectiveId = activePerspective.getId();
    boolean etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
    if (rep != null && etlPerspective) {
        if (meta.getObjectId() == null) {
            meta.setFilename(null);
        }
        saved = saveToRepository(meta);
    } else {
        if (meta.getFilename() != null) {
            saved = save(meta, meta.getFilename(), false);
        } else {
            if (meta.canSave()) {
                saved = saveFileAs(meta);
            }
        }
    }
    // throws Exception in case anything goes wrong
    meta.saveSharedObjects();
    try {
        if (props.useDBCache() && meta instanceof TransMeta) {
            ((TransMeta) meta).getDbCache().saveCache();
        }
    } catch (KettleException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorSavingDatabaseCache.Title"), // "An error occurred saving the database cache to disk"
        BaseMessages.getString(PKG, "Spoon.Dialog.ErrorSavingDatabaseCache.Message"), e);
    }
    // rename the tab only if the meta was successfully saved
    if (saved) {
        // filename or name of transformation might have changed.
        delegates.tabs.renameTabs();
    }
    refreshTree();
    // Update menu status for the newly saved object
    enableMenus();
    return saved;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) AbstractMeta(org.pentaho.di.base.AbstractMeta) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 32 with AbstractMeta

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

the class RunConfigurationImportExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
    AbstractMeta abstractMeta = (AbstractMeta) o;
    final EmbeddedMetaStore embeddedMetaStore = abstractMeta.getEmbeddedMetaStore();
    RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
    List<RunConfiguration> runConfigurationList = embeddedRunConfigurationManager.load();
    List<String> runConfigurationNames = runConfigurationList.stream().map(RunConfiguration::getName).collect(Collectors.toList());
    runConfigurationNames.addAll(runConfigurationManager.getNames());
    runConfigurationList.addAll(createSlaveServerRunConfigurations(runConfigurationNames, abstractMeta));
    for (RunConfiguration runConfiguration : runConfigurationList) {
        if (!runConfiguration.getName().equals(DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME)) {
            runConfigurationManager.save(runConfiguration);
        }
    }
}
Also used : RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) RunConfigurationManager(org.pentaho.di.engine.configuration.impl.RunConfigurationManager) EmbeddedRunConfigurationManager(org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager) AbstractMeta(org.pentaho.di.base.AbstractMeta) EmbeddedMetaStore(org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)

Example 33 with AbstractMeta

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

the class RunConfigurationRunExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface logChannelInterface, Object o) throws KettleException {
    ExecutionConfiguration executionConfiguration = (ExecutionConfiguration) ((Object[]) o)[0];
    AbstractMeta meta = (AbstractMeta) ((Object[]) o)[1];
    VariableSpace variableSpace = (VariableSpace) ((Object[]) o)[2];
    Repository repository = (Repository) ((Object[]) o)[3];
    EmbeddedMetaStore embeddedMetaStore = meta.getEmbeddedMetaStore();
    RunConfiguration runConfiguration = runConfigurationManager.load(executionConfiguration.getRunConfiguration());
    if (runConfiguration == null) {
        RunConfigurationManager embeddedRunConfigurationManager = EmbeddedRunConfigurationManager.build(embeddedMetaStore);
        runConfiguration = embeddedRunConfigurationManager.load(executionConfiguration.getRunConfiguration());
    }
    if (runConfiguration != null) {
        RunConfigurationExecutor runConfigurationExecutor = runConfigurationManager.getExecutor(runConfiguration.getType());
        if (runConfigurationExecutor != null) {
            runConfigurationExecutor.execute(runConfiguration, executionConfiguration, meta, variableSpace, repository);
        }
    } else {
        String name = "";
        if (variableSpace instanceof TransMeta) {
            name = ((TransMeta) variableSpace).getFilename();
        }
        throw new KettleException(BaseMessages.getString(PKG, "RunConfigurationRunExtensionPoint.ConfigNotFound.Error", name, executionConfiguration.getRunConfiguration(), "{0}"));
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) VariableSpace(org.pentaho.di.core.variables.VariableSpace) RunConfigurationManager(org.pentaho.di.engine.configuration.impl.RunConfigurationManager) EmbeddedRunConfigurationManager(org.pentaho.di.engine.configuration.impl.EmbeddedRunConfigurationManager) AbstractMeta(org.pentaho.di.base.AbstractMeta) TransMeta(org.pentaho.di.trans.TransMeta) ExecutionConfiguration(org.pentaho.di.ExecutionConfiguration) RunConfigurationExecutor(org.pentaho.di.engine.configuration.api.RunConfigurationExecutor) EmbeddedMetaStore(org.pentaho.di.core.attributes.metastore.EmbeddedMetaStore)

Example 34 with AbstractMeta

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

the class ConnectionDelegate method delete.

public void delete(String label) {
    ConnectionDeleteDialog connectionDeleteDialog = new ConnectionDeleteDialog(spoonSupplier.get().getShell());
    if (connectionDeleteDialog.open(label) == SWT.YES) {
        ConnectionManager connectionManager = ConnectionManager.getInstance();
        connectionManager.delete(label);
        spoonSupplier.get().getShell().getDisplay().asyncExec(() -> spoonSupplier.get().refreshTree(ConnectionFolderProvider.STRING_VFS_CONNECTIONS));
        EngineMetaInterface engineMetaInterface = spoonSupplier.get().getActiveMeta();
        if (engineMetaInterface instanceof AbstractMeta) {
            ((AbstractMeta) engineMetaInterface).setChanged();
        }
    }
}
Also used : ConnectionManager(org.pentaho.di.connections.ConnectionManager) AbstractMeta(org.pentaho.di.base.AbstractMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface)

Example 35 with AbstractMeta

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

the class ConnectionTreeDelegateExtension method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object extension) throws KettleException {
    SpoonTreeDelegateExtension treeDelExt = (SpoonTreeDelegateExtension) extension;
    int caseNumber = treeDelExt.getCaseNumber();
    AbstractMeta meta = treeDelExt.getTransMeta();
    String[] path = treeDelExt.getPath();
    List<TreeSelection> objects = treeDelExt.getObjects();
    TreeSelection object = null;
    if (path[2].equals(ConnectionFolderProvider.STRING_VFS_CONNECTIONS)) {
        switch(caseNumber) {
            case 3:
                object = new TreeSelection(path[2], VFSConnectionDetails.class, meta);
                break;
            case 4:
                try {
                    final String name = path[3];
                    object = new TreeSelection(name, new ConnectionTreeItem(name), meta);
                } catch (Exception e) {
                // Do Nothing
                }
                break;
        }
    }
    if (object != null) {
        objects.add(object);
    }
}
Also used : TreeSelection(org.pentaho.di.ui.spoon.TreeSelection) AbstractMeta(org.pentaho.di.base.AbstractMeta) SpoonTreeDelegateExtension(org.pentaho.di.ui.spoon.delegates.SpoonTreeDelegateExtension) VFSConnectionDetails(org.pentaho.di.connections.vfs.VFSConnectionDetails) ExtensionPoint(org.pentaho.di.core.extension.ExtensionPoint) KettleException(org.pentaho.di.core.exception.KettleException)

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