Search in sources :

Example 6 with JobEntryCopy

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

the class SpoonJobDelegate method undoJobAction.

public void undoJobAction(JobMeta jobMeta, TransAction transAction) {
    switch(transAction.getType()) {
        // We created a new entry : undo this...
        case TransAction.TYPE_ACTION_NEW_JOB_ENTRY:
            // Delete the entry at correct location:
            int[] idx = transAction.getCurrentIndex();
            for (int i = idx.length - 1; i >= 0; i--) {
                jobMeta.removeJobEntry(idx[i]);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We created a new note : undo this...
        case TransAction.TYPE_ACTION_NEW_NOTE:
            // Delete the note at correct location:
            idx = transAction.getCurrentIndex();
            for (int i = idx.length - 1; i >= 0; i--) {
                jobMeta.removeNote(idx[i]);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We created a new hop : undo this...
        case TransAction.TYPE_ACTION_NEW_JOB_HOP:
            // Delete the hop at correct location:
            idx = transAction.getCurrentIndex();
            for (int i = idx.length - 1; i >= 0; i--) {
                jobMeta.removeJobHop(idx[i]);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We delete an entry : undo this...
        case TransAction.TYPE_ACTION_DELETE_JOB_ENTRY:
            // un-Delete the entry at correct location: re-insert
            JobEntryCopy[] ce = (JobEntryCopy[]) transAction.getCurrent();
            idx = transAction.getCurrentIndex();
            for (int i = 0; i < ce.length; i++) {
                jobMeta.addJobEntry(idx[i], ce[i]);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We delete new note : undo this...
        case TransAction.TYPE_ACTION_DELETE_NOTE:
            // re-insert the note at correct location:
            NotePadMeta[] ni = (NotePadMeta[]) transAction.getCurrent();
            idx = transAction.getCurrentIndex();
            for (int i = 0; i < idx.length; i++) {
                jobMeta.addNote(idx[i], ni[i]);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We deleted a new hop : undo this...
        case TransAction.TYPE_ACTION_DELETE_JOB_HOP:
            // re-insert the hop at correct location:
            JobHopMeta[] hi = (JobHopMeta[]) transAction.getCurrent();
            idx = transAction.getCurrentIndex();
            for (int i = 0; i < hi.length; i++) {
                jobMeta.addJobHop(idx[i], hi[i]);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We changed a job entry: undo this...
        case TransAction.TYPE_ACTION_CHANGE_JOB_ENTRY:
            // Delete the current job entry, insert previous version.
            for (int i = 0; i < transAction.getPrevious().length; i++) {
                JobEntryCopy copy = (JobEntryCopy) ((JobEntryCopy) transAction.getPrevious()[i]).clone();
                jobMeta.getJobEntry(transAction.getCurrentIndex()[i]).replaceMeta(copy);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We changed a note : undo this...
        case TransAction.TYPE_ACTION_CHANGE_NOTE:
            // Delete & re-insert
            NotePadMeta[] prev = (NotePadMeta[]) transAction.getPrevious();
            idx = transAction.getCurrentIndex();
            for (int i = 0; i < idx.length; i++) {
                jobMeta.removeNote(idx[i]);
                jobMeta.addNote(idx[i], prev[i]);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // We changed a hop : undo this...
        case TransAction.TYPE_ACTION_CHANGE_JOB_HOP:
            // Delete & re-insert
            JobHopMeta[] prevHops = (JobHopMeta[]) transAction.getPrevious();
            idx = transAction.getCurrentIndex();
            for (int i = 0; i < idx.length; i++) {
                jobMeta.removeJobHop(idx[i]);
                jobMeta.addJobHop(idx[i], prevHops[i]);
            }
            spoon.refreshTree();
            spoon.refreshGraph();
            break;
        // The position of a step has changed: undo this...
        case TransAction.TYPE_ACTION_POSITION_JOB_ENTRY:
            // Find the location of the step:
            idx = transAction.getCurrentIndex();
            Point[] p = transAction.getPreviousLocation();
            for (int i = 0; i < p.length; i++) {
                JobEntryCopy entry = jobMeta.getJobEntry(idx[i]);
                entry.setLocation(p[i]);
            }
            spoon.refreshGraph();
            break;
        // The position of a note has changed: undo this...
        case TransAction.TYPE_ACTION_POSITION_NOTE:
            idx = transAction.getCurrentIndex();
            Point[] prevLoc = transAction.getPreviousLocation();
            for (int i = 0; i < idx.length; i++) {
                NotePadMeta npi = jobMeta.getNote(idx[i]);
                npi.setLocation(prevLoc[i]);
            }
            spoon.refreshGraph();
            break;
        default:
            break;
    }
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobHopMeta(org.pentaho.di.job.JobHopMeta) NotePadMeta(org.pentaho.di.core.NotePadMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 7 with JobEntryCopy

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

the class SpoonTreeDelegate method addDragSourceToTree.

public void addDragSourceToTree(final Tree tree, final Tree selectionTree, final Tree coreObjectsTree) {
    // Drag & Drop for steps
    Transfer[] ttypes = new Transfer[] { XMLTransfer.getInstance() };
    DragSource ddSource = new DragSource(tree, DND.DROP_MOVE);
    ddSource.setTransfer(ttypes);
    ddSource.addDragListener(new DragSourceListener() {

        public void dragStart(DragSourceEvent event) {
            TreeSelection[] treeObjects = getTreeObjects(tree, selectionTree, coreObjectsTree);
            if (treeObjects.length == 0) {
                event.doit = false;
                return;
            }
            spoon.hideToolTips();
            TreeSelection treeObject = treeObjects[0];
            Object object = treeObject.getSelection();
            TransMeta transMeta = spoon.getActiveTransformation();
            if (object instanceof StepMeta || object instanceof PluginInterface || (object instanceof DatabaseMeta && transMeta != null) || object instanceof TransHopMeta || object instanceof JobEntryCopy) {
                event.doit = true;
            } else {
                event.doit = false;
            }
        }

        public void dragSetData(DragSourceEvent event) {
            TreeSelection[] treeObjects = getTreeObjects(tree, selectionTree, coreObjectsTree);
            if (treeObjects.length == 0) {
                event.doit = false;
                return;
            }
            int type = 0;
            String id = null;
            String data = null;
            TreeSelection treeObject = treeObjects[0];
            Object object = treeObject.getSelection();
            if (object instanceof StepMeta) {
                StepMeta stepMeta = (StepMeta) object;
                type = DragAndDropContainer.TYPE_STEP;
                // name of the step.
                data = stepMeta.getName();
            } else if (object instanceof PluginInterface) {
                PluginInterface plugin = (PluginInterface) object;
                Class<? extends PluginTypeInterface> pluginType = plugin.getPluginType();
                if (Const.classIsOrExtends(pluginType, StepPluginType.class)) {
                    type = DragAndDropContainer.TYPE_BASE_STEP_TYPE;
                    id = plugin.getIds()[0];
                    // Step type name
                    data = plugin.getName();
                } else {
                    type = DragAndDropContainer.TYPE_BASE_JOB_ENTRY;
                    // job entry type name
                    data = plugin.getName();
                    if (treeObject.getItemText().equals(JobMeta.createStartEntry().getName())) {
                        data = treeObject.getItemText();
                    } else if (treeObject.getItemText().equals(JobMeta.createDummyEntry().getName())) {
                        data = treeObject.getItemText();
                    }
                }
            } else if (object instanceof DatabaseMeta) {
                DatabaseMeta databaseMeta = (DatabaseMeta) object;
                type = DragAndDropContainer.TYPE_DATABASE_CONNECTION;
                data = databaseMeta.getName();
            } else if (object instanceof TransHopMeta) {
                TransHopMeta hop = (TransHopMeta) object;
                type = DragAndDropContainer.TYPE_TRANS_HOP;
                // nothing for really ;-)
                data = hop.toString();
            } else if (object instanceof JobEntryCopy) {
                JobEntryCopy jobEntryCopy = (JobEntryCopy) object;
                type = DragAndDropContainer.TYPE_JOB_ENTRY;
                // name of the job entry.
                data = jobEntryCopy.getName();
            } else {
                event.doit = false;
                // ignore anything else you drag.
                return;
            }
            event.data = new DragAndDropContainer(type, data, id);
        }

        public void dragFinished(DragSourceEvent event) {
        }
    });
}
Also used : PluginInterface(org.pentaho.di.core.plugins.PluginInterface) TransMeta(org.pentaho.di.trans.TransMeta) DragSource(org.eclipse.swt.dnd.DragSource) DragSourceListener(org.eclipse.swt.dnd.DragSourceListener) StepMeta(org.pentaho.di.trans.step.StepMeta) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) DragSourceEvent(org.eclipse.swt.dnd.DragSourceEvent) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) TreeSelection(org.pentaho.di.ui.spoon.TreeSelection) Transfer(org.eclipse.swt.dnd.Transfer) XMLTransfer(org.pentaho.di.core.dnd.XMLTransfer) DragAndDropContainer(org.pentaho.di.core.dnd.DragAndDropContainer) TransHopMeta(org.pentaho.di.trans.TransHopMeta)

Example 8 with JobEntryCopy

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

the class JobGraph method renameJobEntry.

/**
 * Method gets called, when the user wants to change a job entries name and he indeed entered a different name then
 * the old one. Make sure that no other job entry matches this name and rename in case of uniqueness.
 *
 * @param jobEntry
 * @param newName
 */
public void renameJobEntry(JobEntryCopy jobEntry, String newName) {
    JobEntryCopy[] jobs = jobMeta.getAllJobGraphEntries(newName);
    if (jobs != null && jobs.length > 0) {
        MessageBox mb = new MessageBox(shell, SWT.OK | SWT.ICON_INFORMATION);
        mb.setMessage(BaseMessages.getString(PKG, "Spoon.Dialog.JobEntryNameExists.Message", newName));
        mb.setText(BaseMessages.getString(PKG, "Spoon.Dialog.JobEntryNameExists.Title"));
        mb.open();
    } else {
        jobEntry.setName(newName);
        jobEntry.setChanged();
        // to reflect the new name
        spoon.refreshTree();
        spoon.refreshGraph();
    }
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) MessageBox(org.eclipse.swt.widgets.MessageBox)

Example 9 with JobEntryCopy

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

the class JobGraph method editEntryParallel.

/**
 * Go from serial to parallel to serial execution
 */
public void editEntryParallel() {
    JobEntryCopy je = getJobEntry();
    JobEntryCopy jeOld = (JobEntryCopy) je.clone_deep();
    je.setLaunchingInParallel(!je.isLaunchingInParallel());
    JobEntryCopy jeNew = (JobEntryCopy) je.clone_deep();
    spoon.addUndoChange(jobMeta, new JobEntryCopy[] { jeOld }, new JobEntryCopy[] { jeNew }, new int[] { jobMeta.indexOfJobEntry(jeNew) });
    jobMeta.setChanged();
    if (getJobEntry().isLaunchingInParallel()) {
        // 
        if ("Y".equalsIgnoreCase(spoon.props.getCustomParameter(STRING_PARALLEL_WARNING_PARAMETER, "Y"))) {
            MessageDialogWithToggle md = new MessageDialogWithToggle(shell, BaseMessages.getString(PKG, "JobGraph.ParallelJobEntriesWarning.DialogTitle"), null, BaseMessages.getString(PKG, "JobGraph.ParallelJobEntriesWarning.DialogMessage", Const.CR) + Const.CR, MessageDialog.WARNING, new String[] { BaseMessages.getString(PKG, "JobGraph.ParallelJobEntriesWarning.Option1") }, 0, BaseMessages.getString(PKG, "JobGraph.ParallelJobEntriesWarning.Option2"), "N".equalsIgnoreCase(spoon.props.getCustomParameter(STRING_PARALLEL_WARNING_PARAMETER, "Y")));
            MessageDialogWithToggle.setDefaultImage(GUIResource.getInstance().getImageSpoon());
            md.open();
            spoon.props.setCustomParameter(STRING_PARALLEL_WARNING_PARAMETER, md.getToggleState() ? "N" : "Y");
            spoon.props.saveProps();
        }
    }
    spoon.refreshGraph();
}
Also used : JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) MessageDialogWithToggle(org.eclipse.jface.dialogs.MessageDialogWithToggle)

Example 10 with JobEntryCopy

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

the class JobGraph method findHop.

/**
 * See if location (x,y) is on a line between two steps: the hop!
 *
 * @param x
 * @param y
 * @param exclude
 *          the step to exclude from the hops (from or to location). Specify null if no step is to be excluded.
 * @return the transformation hop on the specified location, otherwise: null
 */
private JobHopMeta findHop(int x, int y, JobEntryCopy exclude) {
    int i;
    JobHopMeta online = null;
    for (i = 0; i < jobMeta.nrJobHops(); i++) {
        JobHopMeta hi = jobMeta.getJobHop(i);
        JobEntryCopy fs = hi.getFromEntry();
        JobEntryCopy ts = hi.getToEntry();
        if (fs == null || ts == null) {
            return null;
        }
        // 
        if (exclude != null && (exclude.equals(fs) || exclude.equals(ts))) {
            continue;
        }
        int[] line = getLine(fs, ts);
        if (pointOnLine(x, y, line)) {
            online = hi;
        }
    }
    return online;
}
Also used : JobHopMeta(org.pentaho.di.job.JobHopMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Aggregations

JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)149 Point (org.pentaho.di.core.gui.Point)54 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)51 JobMeta (org.pentaho.di.job.JobMeta)47 KettleException (org.pentaho.di.core.exception.KettleException)30 Test (org.junit.Test)28 JobEntryInterface (org.pentaho.di.job.entry.JobEntryInterface)28 NotePadMeta (org.pentaho.di.core.NotePadMeta)24 JobHopMeta (org.pentaho.di.job.JobHopMeta)24 ArrayList (java.util.ArrayList)18 Job (org.pentaho.di.job.Job)18 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)16 JobEntryTrans (org.pentaho.di.job.entries.trans.JobEntryTrans)15 MessageBox (org.eclipse.swt.widgets.MessageBox)13 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)10 Result (org.pentaho.di.core.Result)8 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)8 AreaOwner (org.pentaho.di.core.gui.AreaOwner)8 JobEntrySpecial (org.pentaho.di.job.entries.special.JobEntrySpecial)8 Before (org.junit.Before)7