Search in sources :

Example 11 with TransGraph

use of org.pentaho.di.ui.spoon.trans.TransGraph 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 12 with TransGraph

use of org.pentaho.di.ui.spoon.trans.TransGraph in project pentaho-kettle by pentaho.

the class SpoonMenuABSController method updateMenu.

public void updateMenu(Document doc) {
    try {
        Spoon spoon = Spoon.getInstance();
        boolean createPermitted = true;
        boolean executePermitted = true;
        // If we are working with an Enterprise Repository
        if ((spoon != null) && (spoon.getRepository() != null) && (spoon.getRepository() instanceof PurRepository)) {
            Repository repo = spoon.getRepository();
            // Check for ABS Security
            if (repo.hasService(IAbsSecurityProvider.class)) {
                IAbsSecurityProvider securityProvider = (IAbsSecurityProvider) repo.getService(IAbsSecurityProvider.class);
                // Get create & execute permission
                createPermitted = securityProvider.isAllowed(IAbsSecurityProvider.CREATE_CONTENT_ACTION);
                executePermitted = securityProvider.isAllowed(IAbsSecurityProvider.EXECUTE_CONTENT_ACTION);
                EngineMetaInterface meta = spoon.getActiveMeta();
                // If (meta is not null) and (meta is either a Transformation or Job)
                if ((meta != null) && ((meta instanceof JobMeta) || (meta instanceof TransMeta))) {
                    // Main spoon toolbar
                    // $NON-NLS-1$
                    ((XulToolbarbutton) doc.getElementById("toolbar-file-new")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulToolbarbutton) doc.getElementById("toolbar-file-save")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulToolbarbutton) doc.getElementById("toolbar-file-save-as")).setDisabled(!createPermitted);
                    // Popup menus
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("trans-class-new")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("job-class-new")).setDisabled(!createPermitted);
                    // Main spoon menu
                    // $NON-NLS-1$
                    ((XulMenu) doc.getElementById("file-new")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("file-save")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("file-save-as")).setDisabled(!createPermitted);
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("file-close")).setDisabled(!createPermitted);
                }
                // Handle Execute permissions
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("process-run")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-preview")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-debug")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-replay")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-verify")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-impact")).setDisabled(!executePermitted);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("trans-get-sql")).setDisabled(!executePermitted);
                // Disable Show Last menu under the Action menu. Disable without execute permissions.
                // $NON-NLS-1$
                ((XulMenu) doc.getElementById("trans-last")).setDisabled(!executePermitted);
                boolean exportAllowed = createPermitted && executePermitted;
                // $NON-NLS-1$
                ((XulMenu) doc.getElementById("file-export")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("repository-export-all")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("file-save-as-vfs")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("edit-cut-steps")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("edit-copy-steps")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("edit.copy-file")).setDisabled(!exportAllowed);
                // $NON-NLS-1$
                ((XulMenuitem) doc.getElementById("edit-paste-steps")).setDisabled(!exportAllowed);
                // Schedule is a plugin
                if (doc.getElementById("trans-schedule") != null) {
                    // $NON-NLS-1$
                    ((XulMenuitem) doc.getElementById("trans-schedule")).setDisabled(!executePermitted);
                }
                TransGraph transGraph = Spoon.getInstance().getActiveTransGraph();
                if (transGraph != null) {
                    XulToolbar toolbar = transGraph.getToolbar();
                    XulToolbarbutton runButton = (XulToolbarbutton) toolbar.getElementById("trans-run");
                    XulToolbarbutton debugButton = (XulToolbarbutton) toolbar.getElementById("trans-debug");
                    XulToolbarbutton previewButton = (XulToolbarbutton) toolbar.getElementById("trans-preview");
                    XulToolbarbutton replayButton = (XulToolbarbutton) toolbar.getElementById("trans-replay");
                    XulToolbarbutton verifyButton = (XulToolbarbutton) toolbar.getElementById("trans-verify");
                    XulToolbarbutton impactButton = (XulToolbarbutton) toolbar.getElementById("trans-impact");
                    XulToolbarbutton generateSqlButton = (XulToolbarbutton) toolbar.getElementById("trans-get-sql");
                    if ((runButton != null) && (runButton.isDisabled() ^ !executePermitted)) {
                        runButton.setDisabled(!executePermitted);
                    }
                    if ((debugButton != null) && (debugButton.isDisabled() ^ !executePermitted)) {
                        debugButton.setDisabled(!executePermitted);
                    }
                    if ((previewButton != null) && (previewButton.isDisabled() ^ !executePermitted)) {
                        previewButton.setDisabled(!executePermitted);
                    }
                    if ((replayButton != null) && (replayButton.isDisabled() ^ !executePermitted)) {
                        replayButton.setDisabled(!executePermitted);
                    }
                    if ((verifyButton != null) && (verifyButton.isDisabled() ^ !executePermitted)) {
                        verifyButton.setDisabled(!executePermitted);
                    }
                    if ((impactButton != null) && (impactButton.isDisabled() ^ !executePermitted)) {
                        impactButton.setDisabled(!executePermitted);
                    }
                    if ((generateSqlButton != null) && (generateSqlButton.isDisabled() ^ !executePermitted)) {
                        generateSqlButton.setDisabled(!executePermitted);
                    }
                }
                JobGraph jobGraph = Spoon.getInstance().getActiveJobGraph();
                if (jobGraph != null) {
                    XulToolbar toolbar = jobGraph.getToolbar();
                    XulToolbarbutton runButton = (XulToolbarbutton) toolbar.getElementById("job-run");
                    XulToolbarbutton generateSqlButton = (XulToolbarbutton) toolbar.getElementById("job-get-sql");
                    if ((runButton != null) && (runButton.isDisabled() ^ !executePermitted)) {
                        runButton.setDisabled(!executePermitted);
                    }
                    if ((generateSqlButton != null) && (generateSqlButton.isDisabled() ^ !executePermitted)) {
                        generateSqlButton.setDisabled(!executePermitted);
                    }
                }
            }
        }
        EESpoonPlugin.updateChangedWarningDialog(createPermitted);
    } catch (Exception e) {
        // don't let this bomb all the way out, otherwise we'll get stuck: PDI-4670
        log.logError(e.getMessage(), e);
    }
}
Also used : IAbsSecurityProvider(org.pentaho.di.ui.repository.pur.services.IAbsSecurityProvider) JobMeta(org.pentaho.di.job.JobMeta) XulToolbar(org.pentaho.ui.xul.containers.XulToolbar) PurRepository(org.pentaho.di.repository.pur.PurRepository) TransMeta(org.pentaho.di.trans.TransMeta) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph) XulToolbarbutton(org.pentaho.ui.xul.components.XulToolbarbutton) XulMenu(org.pentaho.ui.xul.containers.XulMenu) Repository(org.pentaho.di.repository.Repository) PurRepository(org.pentaho.di.repository.pur.PurRepository) JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) Spoon(org.pentaho.di.ui.spoon.Spoon) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface)

Example 13 with TransGraph

use of org.pentaho.di.ui.spoon.trans.TransGraph in project pentaho-kettle by pentaho.

the class Spoon method analyseImpact.

public void analyseImpact(TransMeta transMeta) {
    if (transMeta == null) {
        return;
    }
    TransGraph transGraph = delegates.trans.findTransGraphOfTransformation(transMeta);
    if (transGraph == null) {
        return;
    }
    AnalyseImpactProgressDialog aipd = new AnalyseImpactProgressDialog(shell, transMeta, transGraph.getImpact());
    transGraph.setImpactFinished(aipd.open());
    if (transGraph.isImpactFinished()) {
        showLastImpactAnalyses(transMeta);
    }
}
Also used : AnalyseImpactProgressDialog(org.pentaho.di.ui.spoon.dialog.AnalyseImpactProgressDialog) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph)

Example 14 with TransGraph

use of org.pentaho.di.ui.spoon.trans.TransGraph in project pentaho-kettle by pentaho.

the class Spoon method browseVersionHistory.

public void browseVersionHistory() {
    if (rep == null) {
        return;
    }
    TransGraph transGraph = getActiveTransGraph();
    if (transGraph != null) {
        transGraph.browseVersionHistory();
    }
    JobGraph jobGraph = getActiveJobGraph();
    if (jobGraph != null) {
        jobGraph.browseVersionHistory();
    }
}
Also used : JobGraph(org.pentaho.di.ui.spoon.job.JobGraph) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph)

Example 15 with TransGraph

use of org.pentaho.di.ui.spoon.trans.TransGraph 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)

Aggregations

TransGraph (org.pentaho.di.ui.spoon.trans.TransGraph)37 JobGraph (org.pentaho.di.ui.spoon.job.JobGraph)15 TransMeta (org.pentaho.di.trans.TransMeta)10 Test (org.junit.Test)8 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)7 ArrayList (java.util.ArrayList)6 Point (org.pentaho.di.core.gui.Point)6 JobMeta (org.pentaho.di.job.JobMeta)6 StepMeta (org.pentaho.di.trans.step.StepMeta)6 EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)5 KettleException (org.pentaho.di.core.exception.KettleException)5 TabMapEntry (org.pentaho.di.ui.spoon.TabMapEntry)5 Browser (org.eclipse.swt.browser.Browser)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 FileObject (org.apache.commons.vfs2.FileObject)3 SashForm (org.eclipse.swt.custom.SashForm)3 Composite (org.eclipse.swt.widgets.Composite)3 MessageBox (org.eclipse.swt.widgets.MessageBox)3 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)3 TabItem (org.pentaho.xul.swt.tab.TabItem)3