Search in sources :

Example 31 with JobMeta

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

the class Spoon method editSelectAll.

public void editSelectAll() {
    TransMeta transMeta = getActiveTransformation();
    if (transMeta != null) {
        transMeta.selectAll();
        getActiveTransGraph().redraw();
    }
    JobMeta jobMeta = getActiveJob();
    if (jobMeta != null) {
        jobMeta.selectAll();
        getActiveJobGraph().redraw();
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta)

Example 32 with JobMeta

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

the class JobGraph method loadReferencedObject.

protected void loadReferencedObject(JobEntryCopy jobEntryCopy, int index) {
    try {
        Object referencedMeta = jobEntryCopy.getEntry().loadReferencedObject(index, spoon.rep, spoon.metaStore, jobMeta);
        if (referencedMeta == null) {
            // Compatible re-try for older plugins.
            referencedMeta = compatibleJobEntryLoadReferencedObject(jobEntryCopy.getEntry(), index, spoon.rep, jobMeta);
        }
        if (referencedMeta != null && (referencedMeta instanceof TransMeta)) {
            TransMeta launchTransMeta = (TransMeta) referencedMeta;
            // Try to see if this transformation is already loaded in another tab...
            // 
            TabMapEntry tabEntry = spoon.delegates.tabs.findTabForTransformation(launchTransMeta);
            if (tabEntry != null) {
                // Switch to this one!
                // 
                spoon.tabfolder.setSelected(tabEntry.getTabItem());
                return;
            }
            copyInternalJobVariables(jobMeta, launchTransMeta);
            spoon.setParametersAsVariablesInUI(launchTransMeta, launchTransMeta);
            launchTransMeta.clearChanged();
            spoon.addTransGraph(launchTransMeta);
            TransGraph transGraph = spoon.getActiveTransGraph();
            attachActiveTrans(transGraph, launchTransMeta, jobEntryCopy);
            spoon.refreshTree();
            spoon.applyVariables();
        }
        if (referencedMeta != null && (referencedMeta instanceof JobMeta)) {
            JobMeta launchJobMeta = (JobMeta) referencedMeta;
            // Try to see if this job is already loaded in another tab...
            // 
            String tabName = spoon.delegates.tabs.makeTabName(launchJobMeta, true);
            TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.JOB_GRAPH);
            if (tabEntry != null) {
                // Switch to this one!
                // 
                spoon.tabfolder.setSelected(tabEntry.getTabItem());
                return;
            }
            spoon.setParametersAsVariablesInUI(launchJobMeta, launchJobMeta);
            launchJobMeta.clearChanged();
            spoon.addJobGraph(launchJobMeta);
            JobGraph jobGraph = spoon.getActiveJobGraph();
            attachActiveJob(jobGraph, launchJobMeta, jobEntryCopy);
            spoon.refreshTree();
            spoon.applyVariables();
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingSpoonCanNotLoadTransformation.Title"), BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingSpoonCanNotLoadTransformation.Message"), e);
    }
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 33 with JobMeta

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

the class JobGraph method openJob.

public void openJob(JobEntryJob entry, JobEntryCopy jobEntryCopy) {
    try {
        JobMeta launchJobMeta = null;
        switch(entry.getSpecificationMethod()) {
            case FILENAME:
                // See if this file is already loaded...
                // 
                String exactFilename = jobMeta.environmentSubstitute(entry.getFilename());
                if (Utils.isEmpty(exactFilename)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoFilenameSpecified"));
                }
                // 
                if (KettleVFS.fileExists(exactFilename)) {
                    launchJobMeta = new JobMeta(jobMeta, exactFilename, spoon.rep, spoon.metaStore, null);
                } else {
                    launchJobMeta = new JobMeta();
                }
                launchJobMeta.setFilename(exactFilename);
                break;
            case REPOSITORY_BY_NAME:
                String exactJobname = jobMeta.environmentSubstitute(entry.getJobName());
                String exactDirectory = jobMeta.environmentSubstitute(entry.getDirectory());
                if (Utils.isEmpty(exactJobname)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobNameSpecified"));
                }
                if (Utils.isEmpty(exactDirectory)) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobDirectorySpecified"));
                }
                // Open the job or create a new one...
                // 
                RepositoryDirectoryInterface repDir = spoon.rep.findDirectory(entry.getDirectory());
                boolean exists = spoon.rep.exists(exactJobname, repDir, RepositoryObjectType.JOB);
                if (!exists) {
                    launchJobMeta = new JobMeta();
                    launchJobMeta.setName(exactJobname);
                    launchJobMeta.setRepositoryDirectory(repDir);
                } else {
                    // Always reads last revision
                    launchJobMeta = spoon.rep.loadJob(exactJobname, repDir, null, null);
                }
                break;
            case REPOSITORY_BY_REFERENCE:
                if (entry.getJobObjectId() == null) {
                    throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoJobReferenceSpecified"));
                }
                // Always reads last revision
                launchJobMeta = spoon.rep.loadJob(entry.getJobObjectId(), null);
                break;
            default:
                break;
        }
        // 
        if (launchJobMeta == null) {
            throw new Exception(BaseMessages.getString(PKG, "JobGraph.Exception.NoValidJobSpecified"));
        }
        launchJobMeta.setRepository(spoon.getRepository());
        launchJobMeta.setMetaStore(spoon.getMetaStore());
        // Try to see if this job is already loaded in another tab...
        // 
        String tabName = spoon.delegates.tabs.makeTabName(launchJobMeta, true);
        TabMapEntry tabEntry = spoon.delegates.tabs.findTabMapEntry(tabName, ObjectType.JOB_GRAPH);
        if (tabEntry != null) {
            // Switch to this one!
            // 
            spoon.tabfolder.setSelected(tabEntry.getTabItem());
            return;
        }
        spoon.setParametersAsVariablesInUI(launchJobMeta, launchJobMeta);
        spoon.addJobGraph(launchJobMeta);
        launchJobMeta.clearChanged();
        JobGraph jobGraph = spoon.getActiveJobGraph();
        attachActiveJob(jobGraph, launchJobMeta, jobEntryCopy);
        spoon.refreshTree();
        spoon.applyVariables();
    } catch (Throwable e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingChefCanNotLoadJob.Title"), BaseMessages.getString(PKG, "JobGraph.Dialog.ErrorLaunchingChefCanNotLoadJob.Message"), e);
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) JobMeta(org.pentaho.di.job.JobMeta) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 34 with JobMeta

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

the class JobGraph method editProperties.

public static boolean editProperties(JobMeta jobMeta, Spoon spoon, Repository rep, boolean allowDirectoryChange) {
    if (jobMeta == null) {
        return false;
    }
    JobDialog jd = new JobDialog(spoon.getShell(), SWT.NONE, jobMeta, rep);
    jd.setDirectoryChangeAllowed(allowDirectoryChange);
    JobMeta ji = jd.open();
    // 
    if (jd.isSharedObjectsFileChanged()) {
        try {
            SharedObjects sharedObjects = rep != null ? rep.readJobMetaSharedObjects(jobMeta) : jobMeta.readSharedObjects();
            spoon.sharedObjectsFileMap.put(sharedObjects.getFilename(), sharedObjects);
        } catch (Exception e) {
            new ErrorDialog(spoon.getShell(), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message", spoon.delegates.tabs.makeTabName(jobMeta, true)), e);
        }
    }
    // If we added properties, add them to the variables too, so that they appear in the CTRL-SPACE variable completion.
    // 
    spoon.setParametersAsVariablesInUI(jobMeta, jobMeta);
    if (jd.isSharedObjectsFileChanged() || ji != null) {
        spoon.refreshTree();
        // cheap operation, might as will do it anyway
        spoon.delegates.tabs.renameTabs();
    }
    spoon.setShellText();
    return ji != null;
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) JobDialog(org.pentaho.di.ui.job.dialog.JobDialog) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SharedObjects(org.pentaho.di.shared.SharedObjects) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException)

Example 35 with JobMeta

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

the class JobGraph method enableDisableNextHops.

private Set<JobEntryCopy> enableDisableNextHops(JobEntryCopy from, boolean enabled, Set<JobEntryCopy> checkedEntries) {
    checkedEntries.add(from);
    jobMeta.getJobhops().stream().filter(hop -> from.equals(hop.getFromEntry())).forEach(hop -> {
        if (hop.isEnabled() != enabled) {
            JobHopMeta before = (JobHopMeta) hop.clone();
            hop.setEnabled(enabled);
            JobHopMeta after = (JobHopMeta) hop.clone();
            spoon.addUndoChange(jobMeta, new JobHopMeta[] { before }, new JobHopMeta[] { after }, new int[] { jobMeta.indexOfJobHop(hop) });
        }
        if (!checkedEntries.contains(hop.getToEntry())) {
            enableDisableNextHops(hop.getToEntry(), enabled, checkedEntries);
        }
    });
    return checkedEntries;
}
Also used : RepositoryExplorerDialog(org.pentaho.di.ui.repository.dialog.RepositoryExplorerDialog) SashForm(org.eclipse.swt.custom.SashForm) MouseMoveListener(org.eclipse.swt.events.MouseMoveListener) XulException(org.pentaho.ui.xul.XulException) DefaultToolTip(org.eclipse.jface.window.DefaultToolTip) AbstractGraph(org.pentaho.di.ui.spoon.AbstractGraph) Point(org.pentaho.di.core.gui.Point) DND(org.eclipse.swt.dnd.DND) RepositorySecurityUI(org.pentaho.di.ui.repository.RepositorySecurityUI) XulToolbarbutton(org.pentaho.ui.xul.components.XulToolbarbutton) DropTargetEvent(org.eclipse.swt.dnd.DropTargetEvent) JobAdapter(org.pentaho.di.job.JobAdapter) XulSpoonResourceBundle(org.pentaho.di.ui.spoon.XulSpoonResourceBundle) TabMapEntry(org.pentaho.di.ui.spoon.TabMapEntry) Composite(org.eclipse.swt.widgets.Composite) Map(java.util.Map) KeyEvent(org.eclipse.swt.events.KeyEvent) Job(org.pentaho.di.job.Job) ConstUI(org.pentaho.di.ui.core.ConstUI) TabItemInterface(org.pentaho.di.ui.spoon.TabItemInterface) TimerTask(java.util.TimerTask) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) MessageDialog(org.eclipse.jface.dialogs.MessageDialog) KeyAdapter(org.eclipse.swt.events.KeyAdapter) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) LogParentProvidedInterface(org.pentaho.di.core.logging.LogParentProvidedInterface) CTabFolder(org.eclipse.swt.custom.CTabFolder) Device(org.eclipse.swt.graphics.Device) JobEntryResult(org.pentaho.di.job.JobEntryResult) JfaceMenupopup(org.pentaho.ui.xul.jface.tags.JfaceMenupopup) Set(java.util.Set) PropsUI(org.pentaho.di.ui.core.PropsUI) CheckBoxToolTipListener(org.pentaho.di.ui.core.widget.CheckBoxToolTipListener) ToolItem(org.eclipse.swt.widgets.ToolItem) Utils(org.pentaho.di.core.util.Utils) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) Transfer(org.eclipse.swt.dnd.Transfer) LogChannel(org.pentaho.di.core.logging.LogChannel) MouseEvent(org.eclipse.swt.events.MouseEvent) Redrawable(org.pentaho.di.core.gui.Redrawable) JobEntryListener(org.pentaho.di.job.JobEntryListener) MenuItem(org.eclipse.swt.widgets.MenuItem) SWT(org.eclipse.swt.SWT) JfaceMenuitem(org.pentaho.ui.xul.jface.tags.JfaceMenuitem) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SWTGC(org.pentaho.di.ui.spoon.SWTGC) PaintListener(org.eclipse.swt.events.PaintListener) NotePadDialog(org.pentaho.di.ui.spoon.dialog.NotePadDialog) JobHopMeta(org.pentaho.di.job.JobHopMeta) SnapAllignDistribute(org.pentaho.di.core.gui.SnapAllignDistribute) Callable(java.util.concurrent.Callable) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) DragAndDropContainer(org.pentaho.di.core.dnd.DragAndDropContainer) ArrayList(java.util.ArrayList) Spoon(org.pentaho.di.ui.spoon.Spoon) AreaType(org.pentaho.di.core.gui.AreaOwner.AreaType) LoggingObjectType(org.pentaho.di.core.logging.LoggingObjectType) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) ResourceBundle(java.util.ResourceBundle) Const(org.pentaho.di.core.Const) GCInterface(org.pentaho.di.core.gui.GCInterface) JobExecutionConfiguration(org.pentaho.di.job.JobExecutionConfiguration) Document(org.pentaho.ui.xul.dom.Document) GridData(org.eclipse.swt.layout.GridData) EnterTextDialog(org.pentaho.di.ui.core.dialog.EnterTextDialog) XulEventHandler(org.pentaho.ui.xul.impl.XulEventHandler) JobDialog(org.pentaho.di.ui.job.dialog.JobDialog) Shell(org.eclipse.swt.widgets.Shell) SimpleLoggingObject(org.pentaho.di.core.logging.SimpleLoggingObject) FormLayout(org.eclipse.swt.layout.FormLayout) Repository(org.pentaho.di.repository.Repository) SharedObjects(org.pentaho.di.shared.SharedObjects) FormData(org.eclipse.swt.layout.FormData) JobMeta(org.pentaho.di.job.JobMeta) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) LogChannelInterface(org.pentaho.di.core.logging.LogChannelInterface) SpoonPluginManager(org.pentaho.di.ui.spoon.SpoonPluginManager) RepositoryRevisionBrowserDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryRevisionBrowserDialogInterface) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) Color(org.eclipse.swt.graphics.Color) MessageBox(org.eclipse.swt.widgets.MessageBox) ToolTip(org.eclipse.jface.window.ToolTip) JobEntryTrans(org.pentaho.di.job.entries.trans.JobEntryTrans) XulDomContainer(org.pentaho.ui.xul.XulDomContainer) ExtensionPointHandler(org.pentaho.di.core.extension.ExtensionPointHandler) ObjectType(org.pentaho.di.ui.spoon.TabMapEntry.ObjectType) Trans(org.pentaho.di.trans.Trans) DisposeEvent(org.eclipse.swt.events.DisposeEvent) KettleLogStore(org.pentaho.di.core.logging.KettleLogStore) XulToolbar(org.pentaho.ui.xul.containers.XulToolbar) DisposeListener(org.eclipse.swt.events.DisposeListener) ToolBar(org.eclipse.swt.widgets.ToolBar) GUIResource(org.pentaho.di.ui.core.gui.GUIResource) Timer(java.util.Timer) KettleVFS(org.pentaho.di.core.vfs.KettleVFS) GC(org.eclipse.swt.graphics.GC) JobEntryJob(org.pentaho.di.job.entries.job.JobEntryJob) PaintEvent(org.eclipse.swt.events.PaintEvent) TransMeta(org.pentaho.di.trans.TransMeta) NotePadMeta(org.pentaho.di.core.NotePadMeta) Widget(org.eclipse.swt.widgets.Widget) BaseMessages(org.pentaho.di.i18n.BaseMessages) TransPainter(org.pentaho.di.trans.TransPainter) DropTarget(org.eclipse.swt.dnd.DropTarget) JobPainter(org.pentaho.di.job.JobPainter) MouseWheelListener(org.eclipse.swt.events.MouseWheelListener) UUID(java.util.UUID) Display(org.eclipse.swt.widgets.Display) CheckBoxToolTip(org.pentaho.di.ui.core.widget.CheckBoxToolTip) AreaOwner(org.pentaho.di.core.gui.AreaOwner) List(java.util.List) MouseListener(org.eclipse.swt.events.MouseListener) MouseTrackListener(org.eclipse.swt.events.MouseTrackListener) SwtScrollBar(org.pentaho.di.ui.spoon.SwtScrollBar) ResultFile(org.pentaho.di.core.ResultFile) MouseAdapter(org.eclipse.swt.events.MouseAdapter) Label(org.eclipse.swt.widgets.Label) Result(org.pentaho.di.core.Result) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) HasLogChannelInterface(org.pentaho.di.core.logging.HasLogChannelInterface) KettleException(org.pentaho.di.core.exception.KettleException) Image(org.eclipse.swt.graphics.Image) Rectangle(org.eclipse.swt.graphics.Rectangle) HashMap(java.util.HashMap) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) HashSet(java.util.HashSet) XulMenu(org.pentaho.ui.xul.containers.XulMenu) XulSpoonSettingsManager(org.pentaho.di.ui.spoon.XulSpoonSettingsManager) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle) Canvas(org.eclipse.swt.widgets.Canvas) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) FillLayout(org.eclipse.swt.layout.FillLayout) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) KettleXulLoader(org.pentaho.di.ui.xul.KettleXulLoader) Props(org.pentaho.di.core.Props) Combo(org.eclipse.swt.widgets.Combo) Iterator(java.util.Iterator) DropTargetListener(org.eclipse.swt.dnd.DropTargetListener) XulMenupopup(org.pentaho.ui.xul.containers.XulMenupopup) Action(org.eclipse.jface.action.Action) FormAttachment(org.eclipse.swt.layout.FormAttachment) CTabItem(org.eclipse.swt.custom.CTabItem) DelayListener(org.pentaho.di.ui.spoon.trans.DelayListener) RepositoryOperation(org.pentaho.di.repository.RepositoryOperation) XMLTransfer(org.pentaho.di.core.dnd.XMLTransfer) DelayTimer(org.pentaho.di.ui.spoon.trans.DelayTimer) KeyListener(org.eclipse.swt.events.KeyListener) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) Control(org.eclipse.swt.widgets.Control) JobHopMeta(org.pentaho.di.job.JobHopMeta)

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