Search in sources :

Example 56 with NotePadMeta

use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.

the class JobGraph method setMenu.

protected synchronized void setMenu(int x, int y) {
    currentMouseX = x;
    currentMouseY = y;
    final JobEntryCopy jobEntry = jobMeta.getJobEntryCopy(x, y, iconsize);
    setJobEntry(jobEntry);
    Document doc = xulDomContainer.getDocumentRoot();
    if (jobEntry != null) {
        // We clicked on a Job Entry!
        XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-entry");
        if (menu != null) {
            List<JobEntryCopy> selection = jobMeta.getSelectedEntries();
            doRightClickSelection(jobEntry, selection);
            int sels = selection.size();
            XulMenuitem item = (XulMenuitem) doc.getElementById("job-graph-entry-newhop");
            item.setDisabled(sels < 2);
            JfaceMenupopup launchMenu = (JfaceMenupopup) doc.getElementById("job-graph-entry-launch-popup");
            String[] referencedObjects = jobEntry.getEntry().getReferencedObjectDescriptions();
            boolean[] enabledObjects = jobEntry.getEntry().isReferencedObjectEnabled();
            launchMenu.setDisabled(Utils.isEmpty(referencedObjects));
            launchMenu.removeChildren();
            if (!Utils.isEmpty(referencedObjects)) {
                for (int i = 0; i < referencedObjects.length; i++) {
                    final int index = i;
                    String referencedObject = referencedObjects[i];
                    Action action = new Action(referencedObject, Action.AS_DROP_DOWN_MENU) {

                        public void run() {
                            loadReferencedObject(jobEntry, index);
                        }
                    };
                    JfaceMenuitem child = new JfaceMenuitem(null, launchMenu, xulDomContainer, referencedObject, i, action);
                    child.setLabel(referencedObject);
                    child.setDisabled(!enabledObjects[i]);
                }
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-align-snap");
            item.setAcceltext("ALT-HOME");
            item.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.JobEntry.AllignDistribute.SnapToGrid"));
            item.setAccesskey("alt-home");
            XulMenu aMenu = (XulMenu) doc.getElementById("job-graph-entry-align");
            if (aMenu != null) {
                aMenu.setDisabled(sels < 1);
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-detach");
            if (item != null) {
                item.setDisabled(!jobMeta.isEntryUsedInHops(jobEntry));
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-hide");
            if (item != null) {
                item.setDisabled(!(jobEntry.isDrawn() && !jobMeta.isEntryUsedInHops(jobEntry)));
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-delete");
            if (item != null) {
                item.setDisabled(!jobEntry.isDrawn());
            }
            item = (XulMenuitem) doc.getElementById("job-graph-entry-parallel");
            if (item != null) {
                item.setSelected(jobEntry.isLaunchingInParallel());
            }
            try {
                JobGraphJobEntryMenuExtension extension = new JobGraphJobEntryMenuExtension(xulDomContainer, doc, jobMeta, jobEntry, this);
                ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.JobGraphJobEntrySetMenu.id, extension);
            } catch (Exception e) {
                log.logError("Error handling menu right click on job entry through extension point", e);
            }
            ConstUI.displayMenu(menu, canvas);
        }
    } else {
        // Clear the menu
        final JobHopMeta hi = findJobHop(x, y);
        setCurrentHop(hi);
        if (hi != null) {
            // We clicked on a HOP!
            XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-hop");
            if (menu != null) {
                XulMenuitem miPopEvalUncond = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-uncond");
                XulMenuitem miPopEvalTrue = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-true");
                XulMenuitem miPopEvalFalse = (XulMenuitem) doc.getElementById("job-graph-hop-evaluation-false");
                XulMenuitem miDisHop = (XulMenuitem) doc.getElementById("job-graph-hop-enabled");
                XulMenuitem miFlipHop = (XulMenuitem) doc.getElementById("job-graph-hop-flip");
                // 
                if (miPopEvalUncond != null && miPopEvalTrue != null && miPopEvalFalse != null) {
                    if (hi.isUnconditional()) {
                        miPopEvalUncond.setSelected(true);
                        miPopEvalTrue.setSelected(false);
                        miPopEvalFalse.setSelected(false);
                    } else {
                        if (hi.getEvaluation()) {
                            miPopEvalUncond.setSelected(false);
                            miPopEvalTrue.setSelected(true);
                            miPopEvalFalse.setSelected(false);
                        } else {
                            miPopEvalUncond.setSelected(false);
                            miPopEvalTrue.setSelected(false);
                            miPopEvalFalse.setSelected(true);
                        }
                    }
                    if (!hi.getFromEntry().evaluates()) {
                        miPopEvalTrue.setDisabled(true);
                        miPopEvalFalse.setDisabled(true);
                    } else {
                        miPopEvalTrue.setDisabled(false);
                        miPopEvalFalse.setDisabled(false);
                    }
                    if (!hi.getFromEntry().isUnconditional()) {
                        miPopEvalUncond.setDisabled(true);
                    } else {
                        miPopEvalUncond.setDisabled(false);
                    }
                    if (hi.getFromEntry().isStart()) {
                        miFlipHop.setDisabled(true);
                    } else {
                        miFlipHop.setDisabled(false);
                    }
                }
                if (miDisHop != null) {
                    if (hi.isEnabled()) {
                        miDisHop.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.Hop.Disable"));
                    } else {
                        miDisHop.setLabel(BaseMessages.getString(PKG, "JobGraph.PopupMenu.Hop.Enable"));
                    }
                }
                ConstUI.displayMenu(menu, canvas);
            }
        } else {
            // Clicked on the background: maybe we hit a note?
            final NotePadMeta ni = jobMeta.getNote(x, y);
            setCurrentNote(ni);
            if (ni != null) {
                XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-note");
                if (menu != null) {
                    ConstUI.displayMenu(menu, canvas);
                }
            } else {
                XulMenupopup menu = (XulMenupopup) doc.getElementById("job-graph-background");
                if (menu != null) {
                    final String clipcontent = spoon.fromClipboard();
                    XulMenuitem item = (XulMenuitem) doc.getElementById("job-graph-note-paste");
                    if (item != null) {
                        item.setDisabled(clipcontent == null);
                    }
                    ConstUI.displayMenu(menu, canvas);
                }
            }
        }
    }
}
Also used : Action(org.eclipse.jface.action.Action) JobHopMeta(org.pentaho.di.job.JobHopMeta) JfaceMenuitem(org.pentaho.ui.xul.jface.tags.JfaceMenuitem) Document(org.pentaho.ui.xul.dom.Document) JfaceMenupopup(org.pentaho.ui.xul.jface.tags.JfaceMenupopup) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) XulException(org.pentaho.ui.xul.XulException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException) XulMenupopup(org.pentaho.ui.xul.containers.XulMenupopup) XulMenu(org.pentaho.ui.xul.containers.XulMenu) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Example 57 with NotePadMeta

use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.

the class JobGraph method editNote.

protected void editNote(NotePadMeta ni) {
    NotePadMeta before = (NotePadMeta) ni.clone();
    String title = BaseMessages.getString(PKG, "JobGraph.Dialog.EditNote.Title");
    NotePadDialog dd = new NotePadDialog(jobMeta, shell, title, ni);
    NotePadMeta n = dd.open();
    if (n != null) {
        ni.setChanged();
        ni.setNote(n.getNote());
        ni.setFontName(n.getFontName());
        ni.setFontSize(n.getFontSize());
        ni.setFontBold(n.isFontBold());
        ni.setFontItalic(n.isFontItalic());
        // font color
        ni.setFontColorRed(n.getFontColorRed());
        ni.setFontColorGreen(n.getFontColorGreen());
        ni.setFontColorBlue(n.getFontColorBlue());
        // background color
        ni.setBackGroundColorRed(n.getBackGroundColorRed());
        ni.setBackGroundColorGreen(n.getBackGroundColorGreen());
        ni.setBackGroundColorBlue(n.getBackGroundColorBlue());
        // border color
        ni.setBorderColorRed(n.getBorderColorRed());
        ni.setBorderColorGreen(n.getBorderColorGreen());
        ni.setBorderColorBlue(n.getBorderColorBlue());
        ni.setDrawShadow(n.isDrawShadow());
        spoon.addUndoChange(jobMeta, new NotePadMeta[] { before }, new NotePadMeta[] { ni }, new int[] { jobMeta.indexOfNote(ni) });
        ni.width = ConstUI.NOTE_MIN_SIZE;
        ni.height = ConstUI.NOTE_MIN_SIZE;
        spoon.refreshGraph();
    }
}
Also used : NotePadDialog(org.pentaho.di.ui.spoon.dialog.NotePadDialog) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Example 58 with NotePadMeta

use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.

the class TransGraph method setMenu.

/**
 * This sets the popup-menu on the background of the canvas based on the xy coordinate of the mouse. This method is
 * called after a mouse-click.
 *
 * @param x X-coordinate on screen
 * @param y Y-coordinate on screen
 */
private synchronized void setMenu(int x, int y) {
    try {
        currentMouseX = x;
        currentMouseY = y;
        final StepMeta stepMeta = transMeta.getStep(x, y, iconsize);
        if (stepMeta != null) {
            // We clicked on a Step!
            setCurrentStep(stepMeta);
            XulMenupopup menu = menuMap.get("trans-graph-entry");
            try {
                ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransStepRightClick.id, new StepMenuExtension(this, menu));
            } catch (Exception ex) {
                LogChannel.GENERAL.logError("Error calling TransStepRightClick extension point", ex);
            }
            if (menu != null) {
                List<StepMeta> selection = transMeta.getSelectedSteps();
                doRightClickSelection(stepMeta, selection);
                int sels = selection.size();
                Document doc = getXulDomContainer().getDocumentRoot();
                // TODO: cache the next line (seems fast enough)?
                // 
                List<PluginInterface> rowDistributionPlugins = PluginRegistry.getInstance().getPlugins(RowDistributionPluginType.class);
                JfaceMenupopup customRowDistMenu = (JfaceMenupopup) doc.getElementById("trans-graph-entry-data-movement-popup");
                customRowDistMenu.setDisabled(false);
                customRowDistMenu.removeChildren();
                // Add the default round robin plugin...
                // 
                Action action = new Action("RoundRobinRowDistribution", Action.AS_CHECK_BOX) {

                    @Override
                    public void run() {
                        // default
                        stepMeta.setRowDistribution(null);
                        stepMeta.setDistributes(true);
                    }
                };
                boolean selected = stepMeta.isDistributes() && stepMeta.getRowDistribution() == null;
                action.setChecked(selected);
                JfaceMenuitem child = new JfaceMenuitem(null, customRowDistMenu, xulDomContainer, "Round Robin row distribution", 0, action);
                child.setLabel(BaseMessages.getString(PKG, "TransGraph.PopupMenu.RoundRobin"));
                child.setDisabled(false);
                child.setSelected(selected);
                for (int p = 0; p < rowDistributionPlugins.size(); p++) {
                    final PluginInterface rowDistributionPlugin = rowDistributionPlugins.get(p);
                    selected = stepMeta.isDistributes() && stepMeta.getRowDistribution() != null && stepMeta.getRowDistribution().getCode().equals(rowDistributionPlugin.getIds()[0]);
                    action = new Action(rowDistributionPlugin.getIds()[0], Action.AS_CHECK_BOX) {

                        @Override
                        public void run() {
                            try {
                                stepMeta.setRowDistribution((RowDistributionInterface) PluginRegistry.getInstance().loadClass(rowDistributionPlugin));
                            } catch (Exception e) {
                                LogChannel.GENERAL.logError("Error loading row distribution plugin class: ", e);
                            }
                        }
                    };
                    action.setChecked(selected);
                    child = new JfaceMenuitem(null, customRowDistMenu, xulDomContainer, rowDistributionPlugin.getName(), p + 1, action);
                    child.setLabel(rowDistributionPlugin.getName());
                    child.setDisabled(false);
                    child.setSelected(selected);
                }
                // Add the default copy rows plugin...
                // 
                action = new Action("CopyRowsDistribution", Action.AS_CHECK_BOX) {

                    @Override
                    public void run() {
                        stepMeta.setDistributes(false);
                    }
                };
                selected = !stepMeta.isDistributes();
                action.setChecked(selected);
                child = new JfaceMenuitem(null, customRowDistMenu, xulDomContainer, "Copy rows distribution", 0, action);
                child.setLabel(BaseMessages.getString(PKG, "TransGraph.PopupMenu.CopyData"));
                child.setDisabled(false);
                child.setSelected(selected);
                JfaceMenupopup launchMenu = (JfaceMenupopup) doc.getElementById("trans-graph-entry-launch-popup");
                String[] referencedObjects = stepMeta.getStepMetaInterface().getReferencedObjectDescriptions();
                boolean[] enabledObjects = stepMeta.getStepMetaInterface().isReferencedObjectEnabled();
                launchMenu.setDisabled(Utils.isEmpty(referencedObjects));
                launchMenu.removeChildren();
                int childIndex = 0;
                // First see if we need to add a special "active" entry (running transformation)
                // 
                StepMetaInterface stepMetaInterface = stepMeta.getStepMetaInterface();
                String activeReferencedObjectDescription = stepMetaInterface.getActiveReferencedObjectDescription();
                if (getActiveSubtransformation(this, stepMeta) != null && activeReferencedObjectDescription != null) {
                    action = new Action(activeReferencedObjectDescription, Action.AS_DROP_DOWN_MENU) {

                        @Override
                        public void run() {
                            // negative by convention
                            openMapping(stepMeta, -1);
                        }
                    };
                    child = new JfaceMenuitem(null, launchMenu, xulDomContainer, activeReferencedObjectDescription, childIndex++, action);
                    child.setLabel(activeReferencedObjectDescription);
                    child.setDisabled(false);
                }
                if (!Utils.isEmpty(referencedObjects)) {
                    for (int i = 0; i < referencedObjects.length; i++) {
                        final int index = i;
                        String referencedObject = referencedObjects[i];
                        action = new Action(referencedObject, Action.AS_DROP_DOWN_MENU) {

                            @Override
                            public void run() {
                                openMapping(stepMeta, index);
                            }
                        };
                        child = new JfaceMenuitem(null, launchMenu, xulDomContainer, referencedObject, childIndex++, action);
                        child.setLabel(referencedObject);
                        child.setDisabled(!enabledObjects[i]);
                    }
                }
                initializeXulMenu(doc, selection, stepMeta);
                ConstUI.displayMenu(menu, canvas);
            }
        } else {
            final TransHopMeta hi = findHop(x, y);
            if (hi != null) {
                // We clicked on a HOP!
                XulMenupopup menu = menuMap.get("trans-graph-hop");
                if (menu != null) {
                    setCurrentHop(hi);
                    XulMenuitem item = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("trans-graph-hop-enabled");
                    if (item != null) {
                        if (hi.isEnabled()) {
                            item.setLabel(BaseMessages.getString(PKG, "TransGraph.PopupMenu.DisableHop"));
                        } else {
                            item.setLabel(BaseMessages.getString(PKG, "TransGraph.PopupMenu.EnableHop"));
                        }
                    }
                    ConstUI.displayMenu(menu, canvas);
                }
            } else {
                // Clicked on the background: maybe we hit a note?
                final NotePadMeta ni = transMeta.getNote(x, y);
                setCurrentNote(ni);
                if (ni != null) {
                    XulMenupopup menu = menuMap.get("trans-graph-note");
                    if (menu != null) {
                        ConstUI.displayMenu(menu, canvas);
                    }
                } else {
                    XulMenupopup menu = menuMap.get("trans-graph-background");
                    if (menu != null) {
                        final String clipcontent = spoon.fromClipboard();
                        XulMenuitem item = (XulMenuitem) getXulDomContainer().getDocumentRoot().getElementById("trans-graph-background-paste");
                        if (item != null) {
                            item.setDisabled(clipcontent == null);
                        }
                        ConstUI.displayMenu(menu, canvas);
                    }
                }
            }
        }
    } catch (Throwable t) {
        // TODO: fix this: log somehow, is IGNORED for now.
        t.printStackTrace();
    }
}
Also used : Action(org.eclipse.jface.action.Action) JfaceMenuitem(org.pentaho.ui.xul.jface.tags.JfaceMenuitem) SpoonUiExtenderPluginInterface(org.pentaho.di.ui.spoon.SpoonUiExtenderPluginInterface) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) StepMetaInterface(org.pentaho.di.trans.step.StepMetaInterface) Document(org.pentaho.ui.xul.dom.Document) JfaceMenupopup(org.pentaho.ui.xul.jface.tags.JfaceMenupopup) StepMeta(org.pentaho.di.trans.step.StepMeta) XulException(org.pentaho.ui.xul.XulException) InvocationTargetException(java.lang.reflect.InvocationTargetException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleStepException(org.pentaho.di.core.exception.KettleStepException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleException(org.pentaho.di.core.exception.KettleException) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) XulMenupopup(org.pentaho.ui.xul.containers.XulMenupopup) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) RowDistributionInterface(org.pentaho.di.trans.step.RowDistributionInterface) TransHopMeta(org.pentaho.di.trans.TransHopMeta) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Example 59 with NotePadMeta

use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.

the class TransGraph method selectInRect.

/**
 * Select all the steps in a certain (screen) rectangle
 *
 * @param rect The selection area as a rectangle
 */
public void selectInRect(TransMeta transMeta, org.pentaho.di.core.gui.Rectangle rect) {
    if (rect.height < 0 || rect.width < 0) {
        org.pentaho.di.core.gui.Rectangle rectified = new org.pentaho.di.core.gui.Rectangle(rect.x, rect.y, rect.width, rect.height);
        // Only for people not dragging from left top to right bottom
        if (rectified.height < 0) {
            rectified.y = rectified.y + rectified.height;
            rectified.height = -rectified.height;
        }
        if (rectified.width < 0) {
            rectified.x = rectified.x + rectified.width;
            rectified.width = -rectified.width;
        }
        rect = rectified;
    }
    for (int i = 0; i < transMeta.nrSteps(); i++) {
        StepMeta stepMeta = transMeta.getStep(i);
        Point a = stepMeta.getLocation();
        if (rect.contains(a.x, a.y)) {
            stepMeta.setSelected(true);
        }
    }
    for (int i = 0; i < transMeta.nrNotes(); i++) {
        NotePadMeta ni = transMeta.getNote(i);
        Point a = ni.getLocation();
        Point b = new Point(a.x + ni.width, a.y + ni.height);
        if (rect.contains(a.x, a.y) && rect.contains(b.x, b.y)) {
            ni.setSelected(true);
        }
    }
}
Also used : Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint) NotePadMeta(org.pentaho.di.core.NotePadMeta) StepMeta(org.pentaho.di.trans.step.StepMeta) Point(org.pentaho.di.core.gui.Point) KettleExtensionPoint(org.pentaho.di.core.extension.KettleExtensionPoint)

Example 60 with NotePadMeta

use of org.pentaho.di.core.NotePadMeta in project pentaho-kettle by pentaho.

the class JobDelegate method elementToDataNode.

public DataNode elementToDataNode(final RepositoryElementInterface element) throws KettleException {
    JobMeta jobMeta = (JobMeta) element;
    DataNode rootNode = new DataNode(NODE_JOB);
    if (jobMeta.getPrivateDatabases() != null) {
        // save all private database names http://jira.pentaho.com/browse/PPP-3413
        String privateDatabaseNames = StringUtils.join(jobMeta.getPrivateDatabases(), JOB_PRIVATE_DATABASE_DELIMITER);
        DataNode privateDatabaseNode = rootNode.addNode(NODE_JOB_PRIVATE_DATABASES);
        privateDatabaseNode.setProperty(PROP_JOB_PRIVATE_DATABASE_NAMES, privateDatabaseNames);
    }
    // Save the notes
    // 
    DataNode notesNode = rootNode.addNode(NODE_NOTES);
    notesNode.setProperty(PROP_NR_NOTES, jobMeta.nrNotes());
    for (int i = 0; i < jobMeta.nrNotes(); i++) {
        NotePadMeta note = jobMeta.getNote(i);
        DataNode noteNode = notesNode.addNode(NOTE_PREFIX + i);
        noteNode.setProperty(PROP_XML, note.getXML());
    }
    // 
    if (log.isDetailed()) {
        // $NON-NLS-1$ //$NON-NLS-2$
        log.logDetailed(toString(), "Saving " + jobMeta.nrJobEntries() + " Job enty copies to repository...");
    }
    DataNode entriesNode = rootNode.addNode(NODE_ENTRIES);
    entriesNode.setProperty(PROP_NR_JOB_ENTRY_COPIES, jobMeta.nrJobEntries());
    for (int i = 0; i < jobMeta.nrJobEntries(); i++) {
        JobEntryCopy copy = jobMeta.getJobEntry(i);
        JobEntryInterface entry = copy.getEntry();
        // Create a new node for each entry...
        // 
        DataNode copyNode = entriesNode.addNode(// $NON-NLS-1$
        sanitizeNodeName(copy.getName()) + "_" + (i + 1) + EXT_JOB_ENTRY_COPY);
        copyNode.setProperty(PROP_NAME, copy.getName());
        copyNode.setProperty(PROP_DESCRIPTION, copy.getDescription());
        copyNode.setProperty(PROP_NR, copy.getNr());
        copyNode.setProperty(PROP_GUI_LOCATION_X, copy.getLocation().x);
        copyNode.setProperty(PROP_GUI_LOCATION_Y, copy.getLocation().y);
        copyNode.setProperty(PROP_GUI_DRAW, copy.isDrawn());
        copyNode.setProperty(PROP_PARALLEL, copy.isLaunchingInParallel());
        // 
        if (entry instanceof JobEntryBase) {
            AttributesMapUtil.saveAttributesMap(copyNode, (JobEntryBase) entry);
        }
        AttributesMapUtil.saveAttributesMap(copyNode, copy);
        // Save the entry information here as well, for completeness.
        // TODO: since this slightly stores duplicate information, figure out how to store this separately.
        // 
        copyNode.setProperty(PROP_JOBENTRY_TYPE, entry.getPluginId());
        DataNode customNode = new DataNode(NODE_CUSTOM);
        RepositoryProxy proxy = new RepositoryProxy(customNode);
        entry.saveRep(proxy, proxy.getMetaStore(), null);
        compatibleEntrySaveRep(entry, proxy, null);
        copyNode.addNode(customNode);
    }
    // Finally, save the hops
    // 
    DataNode hopsNode = rootNode.addNode(NODE_HOPS);
    hopsNode.setProperty(PROP_NR_HOPS, jobMeta.nrJobHops());
    for (int i = 0; i < jobMeta.nrJobHops(); i++) {
        JobHopMeta hop = jobMeta.getJobHop(i);
        DataNode hopNode = hopsNode.addNode(JOB_HOP_PREFIX + i);
        hopNode.setProperty(JOB_HOP_FROM, hop.getFromEntry().getName());
        hopNode.setProperty(JOB_HOP_FROM_NR, hop.getFromEntry().getNr());
        hopNode.setProperty(JOB_HOP_TO, hop.getToEntry().getName());
        hopNode.setProperty(JOB_HOP_TO_NR, hop.getToEntry().getNr());
        hopNode.setProperty(JOB_HOP_ENABLED, hop.isEnabled());
        hopNode.setProperty(JOB_HOP_EVALUATION, hop.getEvaluation());
        hopNode.setProperty(JOB_HOP_UNCONDITIONAL, hop.isUnconditional());
    }
    String[] paramKeys = jobMeta.listParameters();
    DataNode paramsNode = rootNode.addNode(NODE_PARAMETERS);
    paramsNode.setProperty(PROP_NR_PARAMETERS, paramKeys == null ? 0 : paramKeys.length);
    for (int idx = 0; idx < paramKeys.length; idx++) {
        DataNode paramNode = paramsNode.addNode(PARAM_PREFIX + idx);
        String key = paramKeys[idx];
        String description = jobMeta.getParameterDescription(paramKeys[idx]);
        String defaultValue = jobMeta.getParameterDefault(paramKeys[idx]);
        // $NON-NLS-1$
        paramNode.setProperty(PARAM_KEY, key != null ? key : "");
        // $NON-NLS-1$
        paramNode.setProperty(PARAM_DEFAULT, defaultValue != null ? defaultValue : "");
        // $NON-NLS-1$
        paramNode.setProperty(PARAM_DESC, description != null ? description : "");
    }
    // Let's not forget to save the details of the transformation itself.
    // This includes logging information, parameters, etc.
    // 
    saveJobDetails(rootNode, jobMeta);
    return rootNode;
}
Also used : JobEntryBase(org.pentaho.di.job.entry.JobEntryBase) JobMeta(org.pentaho.di.job.JobMeta) JobEntryCopy(org.pentaho.di.job.entry.JobEntryCopy) JobHopMeta(org.pentaho.di.job.JobHopMeta) JobEntryInterface(org.pentaho.di.job.entry.JobEntryInterface) DataNode(org.pentaho.platform.api.repository2.unified.data.node.DataNode) NotePadMeta(org.pentaho.di.core.NotePadMeta)

Aggregations

NotePadMeta (org.pentaho.di.core.NotePadMeta)63 Point (org.pentaho.di.core.gui.Point)39 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)34 StepMeta (org.pentaho.di.trans.step.StepMeta)26 KettleException (org.pentaho.di.core.exception.KettleException)25 JobEntryCopy (org.pentaho.di.job.entry.JobEntryCopy)23 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)15 TransHopMeta (org.pentaho.di.trans.TransHopMeta)14 JobHopMeta (org.pentaho.di.job.JobHopMeta)11 ArrayList (java.util.ArrayList)10 KettleDatabaseException (org.pentaho.di.core.exception.KettleDatabaseException)10 SlaveServer (org.pentaho.di.cluster.SlaveServer)9 KettleStepException (org.pentaho.di.core.exception.KettleStepException)8 StepMetaInterface (org.pentaho.di.trans.step.StepMetaInterface)8 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)7 TransMeta (org.pentaho.di.trans.TransMeta)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)6 KettleFileException (org.pentaho.di.core.exception.KettleFileException)6 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)6 StepErrorMeta (org.pentaho.di.trans.step.StepErrorMeta)6