Search in sources :

Example 96 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class Spoon method clearSharedObjectCache.

public void clearSharedObjectCache() throws KettleException {
    if (rep != null) {
        rep.clearSharedObjectCache();
        TransMeta transMeta = getActiveTransformation();
        if (transMeta != null) {
            rep.readTransSharedObjects(transMeta);
        }
        JobMeta jobMeta = getActiveJob();
        if (jobMeta != null) {
            rep.readJobMetaSharedObjects(jobMeta);
        }
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta)

Example 97 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class Spoon method doubleClickedInTree.

/**
 * Reaction to double click
 */
private void doubleClickedInTree(Tree tree, boolean shift) {
    TreeSelection[] objects = getTreeObjects(tree);
    if (objects.length != 1) {
        // not yet supported, we can do this later when the OSX bug
        return;
    // goes away
    }
    TreeSelection object = objects[0];
    final Object selection = object.getSelection();
    final Object parent = object.getParent();
    if (selection instanceof Class<?>) {
        if (selection.equals(TransMeta.class)) {
            newTransFile();
        }
        if (selection.equals(JobMeta.class)) {
            newJobFile();
        }
        if (selection.equals(TransHopMeta.class)) {
            newHop((TransMeta) parent);
        }
        if (selection.equals(DatabaseMeta.class)) {
            delegates.db.newConnection();
        }
        if (selection.equals(PartitionSchema.class)) {
            newPartitioningSchema((TransMeta) parent);
        }
        if (selection.equals(ClusterSchema.class)) {
            newClusteringSchema((TransMeta) parent);
        }
        if (selection.equals(SlaveServer.class)) {
            newSlaveServer((HasSlaveServersInterface) parent);
        }
    } else {
        if (selection instanceof TransMeta) {
            TransGraph.editProperties((TransMeta) selection, this, rep, true);
        }
        if (selection instanceof JobMeta) {
            JobGraph.editProperties((JobMeta) selection, this, rep, true);
        }
        if (selection instanceof PluginInterface) {
            PluginInterface plugin = (PluginInterface) selection;
            if (plugin.getPluginType().equals(StepPluginType.class)) {
                TransGraph transGraph = getActiveTransGraph();
                if (transGraph != null) {
                    transGraph.addStepToChain(plugin, shift);
                }
            }
            if (plugin.getPluginType().equals(JobEntryPluginType.class)) {
                JobGraph jobGraph = getActiveJobGraph();
                if (jobGraph != null) {
                    jobGraph.addJobEntryToChain(object.getItemText(), shift);
                }
            }
        }
        if (selection instanceof DatabaseMeta) {
            DatabaseMeta database = (DatabaseMeta) selection;
            delegates.db.editConnection(database);
        }
        if (selection instanceof StepMeta) {
            StepMeta step = (StepMeta) selection;
            delegates.steps.editStep((TransMeta) parent, step);
            sharedObjectSyncUtil.synchronizeSteps(step);
        }
        if (selection instanceof JobEntryCopy) {
            editJobEntry((JobMeta) parent, (JobEntryCopy) selection);
        }
        if (selection instanceof TransHopMeta) {
            editHop((TransMeta) parent, (TransHopMeta) selection);
        }
        if (selection instanceof PartitionSchema) {
            editPartitionSchema((TransMeta) parent, (PartitionSchema) selection);
        }
        if (selection instanceof ClusterSchema) {
            delegates.clusters.editClusterSchema((TransMeta) parent, (ClusterSchema) selection);
        }
        if (selection instanceof SlaveServer) {
            editSlaveServer((SlaveServer) selection);
        }
        editSelectionTreeExtension(selection);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) PartitionSchema(org.pentaho.di.partition.PartitionSchema) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) RepositoryObject(org.pentaho.di.repository.RepositoryObject) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) FileObject(org.apache.commons.vfs2.FileObject) TransHopMeta(org.pentaho.di.trans.TransHopMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 98 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class Spoon method setMenu.

private synchronized void setMenu(Tree tree) {
    TreeSelection[] objects = getTreeObjects(tree);
    if (objects.length != 1) {
        // not yet supported, we can do this later when the OSX bug
        return;
    // goes away
    }
    TreeSelection object = objects[0];
    selectionObject = object.getSelection();
    Object selection = selectionObject;
    selectionObjectParent = object.getParent();
    // Not clicked on a real object: returns a class
    XulMenupopup spoonMenu = null;
    if (selection instanceof Class<?>) {
        if (selection.equals(TransMeta.class)) {
            // New
            spoonMenu = (XulMenupopup) menuMap.get("trans-class");
        } else if (selection.equals(JobMeta.class)) {
            // New
            spoonMenu = (XulMenupopup) menuMap.get("job-class");
        } else if (selection.equals(TransHopMeta.class)) {
            // New
            spoonMenu = (XulMenupopup) menuMap.get("trans-hop-class");
        } else if (selection.equals(DatabaseMeta.class)) {
            spoonMenu = (XulMenupopup) menuMap.get("database-class");
        } else if (selection.equals(PartitionSchema.class)) {
            // New
            spoonMenu = (XulMenupopup) menuMap.get("partition-schema-class");
        } else if (selection.equals(ClusterSchema.class)) {
            spoonMenu = (XulMenupopup) menuMap.get("cluster-schema-class");
        } else if (selection.equals(SlaveServer.class)) {
            spoonMenu = (XulMenupopup) menuMap.get("slave-cluster-class");
        } else {
            spoonMenu = null;
        }
    } else {
        if (selection instanceof TransMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("trans-inst");
        } else if (selection instanceof JobMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("job-inst");
        } else if (selection instanceof PluginInterface) {
            spoonMenu = (XulMenupopup) menuMap.get("step-plugin");
        } else if (selection instanceof DatabaseMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("database-inst");
            // disable for now if the connection is an SAP ERP type of database...
            // 
            XulMenuitem item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-explore");
            if (item != null) {
                final DatabaseMeta databaseMeta = (DatabaseMeta) selection;
                item.setDisabled(!databaseMeta.isExplorable());
            }
            item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-clear-cache");
            if (item != null) {
                final DatabaseMeta databaseMeta = (DatabaseMeta) selectionObject;
                item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.ClearDBCache") + // Clear
                databaseMeta.getName());
            }
            item = (XulMenuitem) mainSpoonContainer.getDocumentRoot().getElementById("database-inst-share");
            if (item != null) {
                final DatabaseMeta databaseMeta = (DatabaseMeta) selection;
                if (databaseMeta.isShared()) {
                    item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.UnShare"));
                } else {
                    item.setLabel(BaseMessages.getString(PKG, "Spoon.Menu.Popup.CONNECTIONS.Share"));
                }
            }
        } else if (selection instanceof StepMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("step-inst");
        } else if (selection instanceof JobEntryCopy) {
            spoonMenu = (XulMenupopup) menuMap.get("job-entry-copy-inst");
        } else if (selection instanceof TransHopMeta) {
            spoonMenu = (XulMenupopup) menuMap.get("trans-hop-inst");
        } else if (selection instanceof PartitionSchema) {
            spoonMenu = (XulMenupopup) menuMap.get("partition-schema-inst");
        } else if (selection instanceof ClusterSchema) {
            spoonMenu = (XulMenupopup) menuMap.get("cluster-schema-inst");
        } else if (selection instanceof SlaveServer) {
            spoonMenu = (XulMenupopup) menuMap.get("slave-server-inst");
        }
    }
    if (spoonMenu != null) {
        ConstUI.displayMenu(spoonMenu, tree);
    } else {
        tree.setMenu(null);
    }
    createPopUpMenuExtension();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) PartitionSchema(org.pentaho.di.partition.PartitionSchema) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) XulMenupopup(org.pentaho.ui.xul.containers.XulMenupopup) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) RepositoryObject(org.pentaho.di.repository.RepositoryObject) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) FileObject(org.apache.commons.vfs2.FileObject) TransHopMeta(org.pentaho.di.trans.TransHopMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema)

Example 99 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class Spoon method handleStartOptions.

public void handleStartOptions(CommandLineOption[] options) {
    // note that at this point the rep object is populated by previous calls
    StringBuilder optionRepname = getCommandLineOption(options, "rep").getArgument();
    StringBuilder optionFilename = getCommandLineOption(options, "file").getArgument();
    StringBuilder optionDirname = getCommandLineOption(options, "dir").getArgument();
    StringBuilder optionTransname = getCommandLineOption(options, "trans").getArgument();
    StringBuilder optionJobname = getCommandLineOption(options, "job").getArgument();
    try {
        // Read kettle transformation specified on command-line?
        if (!Utils.isEmpty(optionRepname) || !Utils.isEmpty(optionFilename)) {
            if (!Utils.isEmpty(optionRepname)) {
                if (rep != null) {
                    if (Utils.isEmpty(optionDirname)) {
                        optionDirname = new StringBuilder(RepositoryDirectory.DIRECTORY_SEPARATOR);
                    }
                    // Options /file, /job and /trans are mutually
                    // exclusive
                    int t = (Utils.isEmpty(optionFilename) ? 0 : 1) + (Utils.isEmpty(optionJobname) ? 0 : 1) + (Utils.isEmpty(optionTransname) ? 0 : 1);
                    if (t > 1) {
                        // "More then one mutually exclusive options /file, /job and /trans are specified."
                        log.logError(BaseMessages.getString(PKG, "Spoon.Log.MutuallyExcusive"));
                    } else if (t == 1) {
                        if (!Utils.isEmpty(optionFilename)) {
                            openFile(optionFilename.toString(), false);
                        } else {
                            // OK, if we have a specified job or
                            // transformation, try to load it...
                            // If not, keep the repository logged
                            // in.
                            RepositoryDirectoryInterface rdi = rep.findDirectory(optionDirname.toString());
                            if (rdi == null) {
                                log.logError(BaseMessages.getString(PKG, "Spoon.Log.UnableFindDirectory", optionDirname.toString()));
                            } else {
                                if (!Utils.isEmpty(optionTransname)) {
                                    TransMeta transMeta = // reads
                                    rep.loadTransformation(optionTransname.toString(), rdi, null, true, null);
                                    // last
                                    // version
                                    transMeta.clearChanged();
                                    transMeta.setInternalKettleVariables();
                                    addTransGraph(transMeta);
                                } else {
                                    // Try to load a specified job
                                    // if any
                                    // reads
                                    JobMeta jobMeta = rep.loadJob(optionJobname.toString(), rdi, null, null);
                                    // last
                                    // version
                                    jobMeta.clearChanged();
                                    jobMeta.setInternalKettleVariables();
                                    addJobGraph(jobMeta);
                                }
                            }
                        }
                    }
                } else {
                    // "No repositories defined on this system."
                    log.logError(BaseMessages.getString(PKG, "Spoon.Log.NoRepositoriesDefined"));
                }
            } else if (!Utils.isEmpty(optionFilename)) {
                openFile(optionFilename.toString(), false);
            }
        }
    } catch (KettleException ke) {
        hideSplash();
        log.logError(BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred") + Const.CR + ke.getMessage());
        log.logError(Const.getStackTracker(ke));
        // do not just eat the exception
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred"), BaseMessages.getString(PKG, "Spoon.Log.ErrorOccurred") + Const.CR + ke.getMessage(), ke);
        rep = null;
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 100 with JobMeta

use of org.pentaho.di.job.JobMeta in project pentaho-kettle by pentaho.

the class Spoon method fillVariables.

private void fillVariables(RowMetaAndData vars) {
    TransMeta[] transMetas = getLoadedTransformations();
    JobMeta[] jobMetas = getLoadedJobs();
    if ((transMetas == null || transMetas.length == 0) && (jobMetas == null || jobMetas.length == 0)) {
        return;
    }
    Properties sp = new Properties();
    sp.putAll(System.getProperties());
    VariableSpace space = Variables.getADefaultVariableSpace();
    String[] keys = space.listVariables();
    for (String key : keys) {
        sp.put(key, space.getVariable(key));
    }
    for (TransMeta transMeta : transMetas) {
        List<String> list = transMeta.getUsedVariables();
        for (String varName : list) {
            String varValue = sp.getProperty(varName, "");
            if (vars.getRowMeta().indexOfValue(varName) < 0 && !varName.startsWith(Const.INTERNAL_VARIABLE_PREFIX)) {
                vars.addValue(new ValueMetaString(varName), varValue);
            }
        }
    }
    for (JobMeta jobMeta : jobMetas) {
        List<String> list = jobMeta.getUsedVariables();
        for (String varName : list) {
            String varValue = sp.getProperty(varName, "");
            if (vars.getRowMeta().indexOfValue(varName) < 0 && !varName.startsWith(Const.INTERNAL_VARIABLE_PREFIX)) {
                vars.addValue(new ValueMetaString(varName), varValue);
            }
        }
    }
}
Also used : ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) JobMeta(org.pentaho.di.job.JobMeta) VariableSpace(org.pentaho.di.core.variables.VariableSpace) TransMeta(org.pentaho.di.trans.TransMeta) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) Properties(java.util.Properties)

Aggregations

JobMeta (org.pentaho.di.job.JobMeta)254 Test (org.junit.Test)88 TransMeta (org.pentaho.di.trans.TransMeta)69 KettleException (org.pentaho.di.core.exception.KettleException)62 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)48 Job (org.pentaho.di.job.Job)45 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)27 Repository (org.pentaho.di.repository.Repository)25 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)25 Point (org.pentaho.di.core.gui.Point)24 ArrayList (java.util.ArrayList)23 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)22 SlaveServer (org.pentaho.di.cluster.SlaveServer)17 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)17 FileObject (org.apache.commons.vfs2.FileObject)16 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)16 LogChannelInterface (org.pentaho.di.core.logging.LogChannelInterface)15 SimpleLoggingObject (org.pentaho.di.core.logging.SimpleLoggingObject)15 PrintWriter (java.io.PrintWriter)12 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)12