Search in sources :

Example 11 with RepositoryMeta

use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryConnectController method setDefaultRepository.

public boolean setDefaultRepository(String name) {
    for (int i = 0; i < repositoriesMeta.nrRepositories(); i++) {
        RepositoryMeta repositoryMeta = repositoriesMeta.getRepository(i);
        repositoryMeta.setDefault(repositoryMeta.getName().equals(name));
    }
    try {
        repositoriesMeta.writeData();
    } catch (KettleException ke) {
        log.logError("Unable to set default repository", ke);
        return false;
    }
    return true;
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) KettleException(org.pentaho.di.core.exception.KettleException)

Example 12 with RepositoryMeta

use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryConnectController method isCompatibleRepositoryEdit.

private boolean isCompatibleRepositoryEdit(RepositoryMeta repositoryMeta) {
    if (repositoryMeta != null && repositoriesMeta.indexOfRepository(currentRepository) >= 0 && connectedRepository != null && repositoryEquals(connectedRepository, currentRepository)) {
        // only name / description / default changed ?
        RepositoryMeta clone = repositoryMeta.clone();
        clone.setName(connectedRepository.getName());
        clone.setDescription(connectedRepository.getDescription());
        clone.setDefault(connectedRepository.isDefault());
        return repositoryEquals(connectedRepository, clone);
    }
    return false;
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta)

Example 13 with RepositoryMeta

use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryConnectController method deleteRepository.

public boolean deleteRepository(String name) {
    RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(name);
    int index = repositoriesMeta.indexOfRepository(repositoryMeta);
    if (index != -1) {
        repositoriesMeta.removeRepository(index);
        save();
        Spoon spoon = spoonSupplier.get();
        Runnable execute = () -> {
            if (spoon.getRepositoryName() != null && spoon.getRepositoryName().equals(repositoryMeta.getName())) {
                spoon.closeRepository();
                setConnectedRepository(null);
            }
            fireListeners();
        };
        if (spoon.getShell() != null) {
            spoon.getShell().getDisplay().asyncExec(execute);
        } else {
            execute.run();
        }
    }
    return true;
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) Spoon(org.pentaho.di.ui.spoon.Spoon)

Example 14 with RepositoryMeta

use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryOpenRecentFileExtensionPoint method callExtensionPoint.

@Override
public void callExtensionPoint(LogChannelInterface log, Object object) throws KettleException {
    if (!(object instanceof LastUsedFile)) {
        return;
    }
    LastUsedFile recentFile = (LastUsedFile) object;
    if (recentFile.isSourceRepository() && !repositoryConnectController.isConnected(recentFile.getRepositoryName())) {
        if (getSpoon().promptForSave()) {
            RepositoryMeta repositoryMeta = repositoryConnectController.getRepositoryMetaByName(recentFile.getRepositoryName());
            if (repositoryMeta != null) {
                if (repositoryMeta.getId().equals("KettleFileRepository")) {
                    getSpoon().closeRepository();
                    repositoryConnectController.connectToRepository(repositoryMeta);
                } else {
                    new RepositoryDialog(getSpoon().getShell(), repositoryConnectController).openLogin(repositoryMeta);
                }
                if (repositoryConnectController.isConnected(repositoryMeta.getName())) {
                    getSpoon().loadLastUsedFile(recentFile, repositoryMeta.getName());
                    getSpoon().addMenuLast();
                }
            }
        }
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog) LastUsedFile(org.pentaho.di.core.LastUsedFile)

Example 15 with RepositoryMeta

use of org.pentaho.di.repository.RepositoryMeta in project pentaho-kettle by pentaho.

the class RepositoryConnectMenu method renderConnectDropdown.

private void renderConnectDropdown() {
    connectDropdown = new ToolItem(toolBar, SWT.DROP_DOWN, toolBar.getItems().length);
    connectDropdown.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.Connect"));
    connectDropdown.addSelectionListener(new SelectionAdapter() {

        @Override
        public void widgetSelected(SelectionEvent event) {
            final Menu connectionMenu = new Menu(toolBar.getShell());
            if (repositoriesMeta != null) {
                for (int i = 0; i < repositoriesMeta.nrRepositories(); i++) {
                    MenuItem item = new MenuItem(connectionMenu, SWT.CHECK);
                    String truncatedName = truncateName(repositoriesMeta.getRepository(i).getName());
                    item.setText(truncatedName);
                    item.setData(repositoriesMeta.getRepository(i).getName());
                    if (spoon.rep != null && spoon.getRepositoryName().equals(repositoriesMeta.getRepository(i).getName())) {
                        item.setSelection(true);
                        continue;
                    }
                    item.addSelectionListener(new SelectionAdapter() {

                        @Override
                        public void widgetSelected(SelectionEvent selectionEvent) {
                            String repoName = (String) (selectionEvent.widget).getData();
                            RepositoryMeta repositoryMeta = repositoriesMeta.findRepository(repoName);
                            if (repositoryMeta != null) {
                                try {
                                    if (!spoon.promptForSave()) {
                                        return;
                                    }
                                } catch (KettleException ke) {
                                    log.logError("Error prompting for save", ke);
                                }
                                if (repositoryMeta.getId().equals("KettleFileRepository")) {
                                    try {
                                        repoConnectController.connectToRepository(repositoryMeta);
                                    } catch (KettleException ke) {
                                        log.logError("Error connecting to repository", ke);
                                    }
                                } else {
                                    new RepositoryDialog(spoon.getShell(), repoConnectController).openLogin(repositoryMeta);
                                }
                                renderAndUpdate();
                            }
                        }
                    });
                }
            }
            new MenuItem(connectionMenu, SWT.SEPARATOR);
            MenuItem managerItem = new MenuItem(connectionMenu, SWT.NONE);
            managerItem.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.RepositoryManager"));
            managerItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent selectionEvent) {
                    new RepositoryDialog(spoon.getShell(), repoConnectController).openManager();
                    RepositoryMeta current = repoConnectController.getCurrentRepository();
                    if (current != null) {
                        spoon.setRepositoryName(current.getName());
                    }
                    renderAndUpdate();
                }
            });
            new MenuItem(connectionMenu, SWT.SEPARATOR);
            MenuItem disconnectItem = new MenuItem(connectionMenu, SWT.NONE);
            disconnectItem.setEnabled(spoon.rep != null);
            disconnectItem.setText(BaseMessages.getString(PKG, "RepositoryConnectMenu.Disconnect"));
            disconnectItem.addSelectionListener(new SelectionAdapter() {

                @Override
                public void widgetSelected(SelectionEvent selectionEvent) {
                    boolean cancelled = false;
                    try {
                        cancelled = !spoon.promptForSave();
                    } catch (KettleException e) {
                        log.logError("Error saving Job or Transformation", e);
                    }
                    if (!cancelled) {
                        spoon.closeRepository();
                        repoConnectController.setConnectedRepository(null);
                        renderAndUpdate();
                    }
                }
            });
            ToolItem item = (ToolItem) event.widget;
            Rectangle rect = item.getBounds();
            org.eclipse.swt.graphics.Point pt = item.getParent().toDisplay(new org.eclipse.swt.graphics.Point(rect.x, rect.y + rect.height));
            connectionMenu.setLocation(pt.x, pt.y);
            connectionMenu.setVisible(true);
        }
    });
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) SelectionAdapter(org.eclipse.swt.events.SelectionAdapter) Rectangle(org.eclipse.swt.graphics.Rectangle) MenuItem(org.eclipse.swt.widgets.MenuItem) Point(org.eclipse.swt.graphics.Point) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog) SelectionEvent(org.eclipse.swt.events.SelectionEvent) Menu(org.eclipse.swt.widgets.Menu) ToolItem(org.eclipse.swt.widgets.ToolItem)

Aggregations

RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)44 KettleException (org.pentaho.di.core.exception.KettleException)27 Repository (org.pentaho.di.repository.Repository)16 RepositoriesMeta (org.pentaho.di.repository.RepositoriesMeta)14 RepositoryPluginType (org.pentaho.di.core.plugins.RepositoryPluginType)10 Test (org.junit.Test)4 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)4 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)4 IOException (java.io.IOException)3 ArrayList (java.util.ArrayList)3 Date (java.util.Date)3 Map (java.util.Map)3 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)3 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)3 RepositoryDialog (org.pentaho.di.ui.repo.dialog.RepositoryDialog)3 ByteArrayInputStream (java.io.ByteArrayInputStream)2 FileNotFoundException (java.io.FileNotFoundException)2 StringBufferInputStream (java.io.StringBufferInputStream)2 HashMap (java.util.HashMap)2 ExecutionException (java.util.concurrent.ExecutionException)2