Search in sources :

Example 6 with EngineMetaInterface

use of org.pentaho.di.core.EngineMetaInterface 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 7 with EngineMetaInterface

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

the class JobFileListener method save.

public boolean save(EngineMetaInterface meta, String fname, boolean export) {
    Spoon spoon = Spoon.getInstance();
    EngineMetaInterface lmeta;
    if (export) {
        lmeta = (JobMeta) ((JobMeta) meta).realClone(false);
    } else {
        lmeta = meta;
    }
    try {
        ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobBeforeSave.id, lmeta);
    } catch (KettleException e) {
    // fails gracefully
    }
    boolean saveStatus = spoon.saveMeta(lmeta, fname);
    if (saveStatus) {
        try {
            ExtensionPointHandler.callExtensionPoint(spoon.getLog(), KettleExtensionPoint.JobAfterSave.id, lmeta);
        } catch (KettleException e) {
        // fails gracefully
        }
    }
    return saveStatus;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) JobMeta(org.pentaho.di.job.JobMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface)

Example 8 with EngineMetaInterface

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

the class RepositoryBrowserController method hasDupeFile.

/**
 * Checks if there is a duplicate file in a given directory (i.e. hidden file)
 * @param path - Path to directory in which we are saving
 * @param name - Name of file to save
 * @param fileName - Possible duplicate file name
 * @param override - True is user wants override file, false otherwise
 * @return - true if a duplicate file is found, false otherwise
 */
private boolean hasDupeFile(String path, String name, String fileName, boolean override) {
    try {
        RepositoryDirectoryInterface repositoryDirectoryInterface = getRepository().findDirectory(path);
        EngineMetaInterface meta = getSpoon().getActiveMeta();
        RepositoryObjectType type = "Trans".equals(meta.getFileType()) ? RepositoryObjectType.TRANSFORMATION : RepositoryObjectType.JOB;
        if (getRepository().exists(name, repositoryDirectoryInterface, type)) {
            return !override || !name.equals(fileName);
        }
    } catch (Exception e) {
        System.out.println(e);
    }
    return false;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) KettleException(org.pentaho.di.core.exception.KettleException) KettleObjectExistsException(org.pentaho.di.core.exception.KettleObjectExistsException) KettleTransException(org.pentaho.di.core.exception.KettleTransException) KettleJobException(org.pentaho.di.core.exception.KettleJobException)

Example 9 with EngineMetaInterface

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

the class Spoon method shareObject.

protected void shareObject(SharedObjectInterface sharedObject) {
    sharedObject.setShared(true);
    EngineMetaInterface meta = getActiveMeta();
    try {
        if (meta != null) {
            SharedObjects sharedObjects = null;
            if (meta instanceof TransMeta) {
                sharedObjects = ((TransMeta) meta).getSharedObjects();
            }
            if (meta instanceof JobMeta) {
                sharedObjects = ((JobMeta) meta).getSharedObjects();
            }
            if (sharedObjects != null) {
                sharedObjects.storeObject(sharedObject);
                sharedObjects.saveToFile();
            }
        }
    } catch (Exception e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorWritingSharedObjects.Message"), e);
    }
    refreshTree();
}
Also used : JobMeta(org.pentaho.di.job.JobMeta) TransMeta(org.pentaho.di.trans.TransMeta) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) SharedObjects(org.pentaho.di.shared.SharedObjects) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException)

Example 10 with EngineMetaInterface

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

the class Spoon method enableMenus.

public void enableMenus() {
    boolean disableTransMenu = getActiveTransformation() == null;
    boolean disableJobMenu = getActiveJob() == null;
    boolean disableMetaMenu = getActiveMeta() == null;
    boolean isRepositoryRunning = rep != null;
    boolean disablePreviewButton = true;
    String activePerspectiveId = null;
    SpoonPerspectiveManager manager = SpoonPerspectiveManager.getInstance();
    if (manager != null && manager.getActivePerspective() != null) {
        activePerspectiveId = manager.getActivePerspective().getId();
    }
    boolean etlPerspective = false;
    if (activePerspectiveId != null && activePerspectiveId.length() > 0) {
        etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
    }
    TransGraph transGraph = getActiveTransGraph();
    if (transGraph != null) {
        disablePreviewButton = !(transGraph.isRunning() && !transGraph.isHalting());
    }
    boolean disableSave = true;
    boolean disableDatabaseExplore = true;
    TabItemInterface currentTab = getActiveTabitem();
    if (currentTab != null && currentTab.canHandleSave()) {
        disableSave = !currentTab.hasContentChanged();
    }
    EngineMetaInterface meta = getActiveMeta();
    if (meta != null) {
        disableSave = !meta.canSave();
        disableDatabaseExplore = false;
    }
    org.pentaho.ui.xul.dom.Document doc;
    if (mainSpoonContainer != null) {
        doc = mainSpoonContainer.getDocumentRoot();
        if (doc != null) {
            if (etlPerspective) {
                doc.getElementById("file").setVisible(etlPerspective);
                doc.getElementById("edit").setVisible(etlPerspective);
                doc.getElementById("view").setVisible(etlPerspective);
                doc.getElementById("action").setVisible(etlPerspective);
                doc.getElementById("tools").setVisible(etlPerspective);
                doc.getElementById("help").setVisible(etlPerspective);
                doc.getElementById("help-welcome").setVisible(etlPerspective);
                doc.getElementById("help-plugins").setVisible(true);
            }
            // Only enable certain menu-items if we need to.
            disableMenuItem(doc, "file-new-database", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "menubar-new-database", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "file-save", disableTransMenu && disableJobMenu && disableMetaMenu || disableSave);
            disableMenuItem(doc, "toolbar-file-save", disableTransMenu && disableJobMenu && disableMetaMenu || disableSave);
            disableMenuItem(doc, "file-save-as", disableTransMenu && disableJobMenu && disableMetaMenu || disableSave);
            disableMenuItem(doc, "toolbar-file-save-as", disableTransMenu && disableJobMenu && disableMetaMenu || disableSave);
            disableMenuItem(doc, "file-save-as-vfs", disableTransMenu && disableJobMenu && disableMetaMenu);
            disableMenuItem(doc, "file-close", disableTransMenu && disableJobMenu && disableMetaMenu);
            disableMenuItem(doc, "file-print", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "file-export-to-xml", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "file-export-all-to-xml", disableTransMenu && disableJobMenu);
            // Disable the undo and redo menus if there is no active transformation
            // or active job
            // DO NOT ENABLE them otherwise ... leave that to the undo/redo settings
            // 
            disableMenuItem(doc, UNDO_MENU_ITEM, disableTransMenu && disableJobMenu);
            disableMenuItem(doc, REDO_MENU_ITEM, disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "edit-clear-selection", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "edit-select-all", disableTransMenu && disableJobMenu);
            updateSettingsMenu(doc, disableTransMenu, disableJobMenu);
            disableMenuItem(doc, "edit-settings", disableTransMenu && disableJobMenu && disableMetaMenu);
            // View Menu
            ((XulMenuitem) doc.getElementById("view-results")).setSelected(isExecutionResultsPaneVisible());
            disableMenuItem(doc, "view-results", transGraph == null && disableJobMenu);
            disableMenuItem(doc, "view-zoom-in", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "view-zoom-out", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "view-zoom-100pct", disableTransMenu && disableJobMenu);
            // Transformations
            disableMenuItem(doc, "process-run", disableTransMenu && disablePreviewButton && disableJobMenu);
            disableMenuItem(doc, "process-run-options", disableTransMenu && disablePreviewButton && disableJobMenu);
            disableMenuItem(doc, "trans-replay", disableTransMenu && disablePreviewButton);
            disableMenuItem(doc, "trans-preview", disableTransMenu && disablePreviewButton);
            disableMenuItem(doc, "trans-debug", disableTransMenu && disablePreviewButton);
            disableMenuItem(doc, "trans-verify", disableTransMenu);
            disableMenuItem(doc, "trans-impact", disableTransMenu);
            disableMenuItem(doc, "trans-get-sql", disableTransMenu);
            disableMenuItem(doc, "trans-last-impact", disableTransMenu);
            // Tools
            disableMenuItem(doc, "repository-explore", !isRepositoryRunning);
            disableMenuItem(doc, "tools-dabase-explore", !isRepositoryRunning && disableDatabaseExplore);
            disableMenuItem(doc, "repository-clear-shared-object-cache", !isRepositoryRunning);
            disableMenuItem(doc, "toolbar-expore-repository", !isRepositoryRunning);
            disableMenuItem(doc, "repository-export-all", !isRepositoryRunning);
            disableMenuItem(doc, "repository-import-directory", !isRepositoryRunning);
            disableMenuItem(doc, "trans-last-preview", !isRepositoryRunning || disableTransMenu);
            // Wizard
            disableMenuItem(doc, "wizard-connection", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "wizard-copy-table", disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "wizard-copy-tables", isRepositoryRunning && disableTransMenu && disableJobMenu);
            disableMenuItem(doc, "database-inst-dependancy", !isRepositoryRunning);
            SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifeCycleEvent.MENUS_REFRESHED);
            MenuManager menuManager = getMenuBarManager();
            menuManager.updateAll(true);
            // What steps & plugins to show?
            refreshCoreObjects();
            fireMenuControlers();
        }
    }
}
Also used : XulMenuitem(org.pentaho.ui.xul.components.XulMenuitem) MenuManager(org.eclipse.jface.action.MenuManager) EngineMetaInterface(org.pentaho.di.core.EngineMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) TransGraph(org.pentaho.di.ui.spoon.trans.TransGraph)

Aggregations

EngineMetaInterface (org.pentaho.di.core.EngineMetaInterface)21 KettleException (org.pentaho.di.core.exception.KettleException)9 TransMeta (org.pentaho.di.trans.TransMeta)7 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)5 TransGraph (org.pentaho.di.ui.spoon.trans.TransGraph)5 MalformedURLException (java.net.MalformedURLException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 SWTException (org.eclipse.swt.SWTException)4 Test (org.junit.Test)4 KettleAuthException (org.pentaho.di.core.exception.KettleAuthException)4 KettleFileException (org.pentaho.di.core.exception.KettleFileException)4 KettleMissingPluginsException (org.pentaho.di.core.exception.KettleMissingPluginsException)4 KettleRowException (org.pentaho.di.core.exception.KettleRowException)4 KettleValueException (org.pentaho.di.core.exception.KettleValueException)4 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)4 LifecycleException (org.pentaho.di.core.lifecycle.LifecycleException)4 JobMeta (org.pentaho.di.job.JobMeta)4 KettleRepositoryLostException (org.pentaho.di.repository.KettleRepositoryLostException)4 Repository (org.pentaho.di.repository.Repository)4 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)4