Search in sources :

Example 16 with RepositoryMeta

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

the class SessionTimeoutHandler method showLoginScreen.

boolean showLoginScreen(RepositoryConnectController repositoryConnectController) {
    String message = BaseMessages.getString(PKG, "Repository.Reconnection.Message");
    RepositoryDialog loginDialog = new RepositoryDialog(getSpoon().getShell(), repositoryConnectController);
    RepositoryMeta repositoryMeta = repositoryConnectController.getConnectedRepository();
    return loginDialog.openRelogin(repositoryMeta, message);
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoryDialog(org.pentaho.di.ui.repo.dialog.RepositoryDialog)

Example 17 with RepositoryMeta

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

the class RepositoriesModel method setSelectedRepository.

public void setSelectedRepository(RepositoryMeta selectedRepository) {
    RepositoryMeta previousValue = this.selectedRepository;
    this.selectedRepository = selectedRepository;
    this.firePropertyChange("selectedRepository", previousValue, selectedRepository);
    checkIfModelValid();
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta)

Example 18 with RepositoryMeta

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

the class RepositoriesHelper method loginToRepository.

public void loginToRepository() throws KettleException, KettleSecurityException {
    if (model != null && model.getSelectedRepository() != null) {
        RepositoryMeta repositoryMeta = input.getRepository(model.getRepositoryIndex(model.getSelectedRepository()));
        repository = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, repositoryMeta.getId(), Repository.class);
        repository.init(repositoryMeta);
        repository.connect(model.getUsername(), model.getPassword());
        props.setLastRepository(repositoryMeta.getName());
        props.setLastRepositoryLogin(model.getUsername());
    } else {
        log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.ErrorLoginToRepository"));
        throw new KettleException(BaseMessages.getString(PKG, "RepositoryLogin.ErrorLoginToRepository"));
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) KettleException(org.pentaho.di.core.exception.KettleException) Repository(org.pentaho.di.repository.Repository) RepositoryPluginType(org.pentaho.di.core.plugins.RepositoryPluginType)

Example 19 with RepositoryMeta

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

the class RepositoriesHelper method deleteRepository.

public void deleteRepository() {
    try {
        XulConfirmBox confirmBox = (XulConfirmBox) document.createElement("confirmbox");
        final RepositoryMeta repositoryMeta = input.searchRepository(model.getSelectedRepository().getName());
        if (repositoryMeta != null) {
            confirmBox.setTitle(BaseMessages.getString(PKG, "RepositoryLogin.ConfirmDeleteRepositoryDialog.Title"));
            confirmBox.setMessage(BaseMessages.getString(PKG, "RepositoryLogin.ConfirmDeleteRepositoryDialog.Message"));
            confirmBox.setAcceptLabel(BaseMessages.getString(PKG, "Dialog.Ok"));
            confirmBox.setCancelLabel(BaseMessages.getString(PKG, "Dialog.Cancel"));
            confirmBox.addDialogCallback(new XulDialogCallback<Object>() {

                public void onClose(XulComponent sender, Status returnCode, Object retVal) {
                    if (returnCode == Status.ACCEPT) {
                        int idx = input.indexOfRepository(repositoryMeta);
                        input.removeRepository(idx);
                        fillRepositories();
                        writeData();
                    }
                }

                public void onError(XulComponent sender, Throwable t) {
                    log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage()));
                    new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", t.getLocalizedMessage()), t);
                }
            });
            confirmBox.open();
        }
    } catch (Exception e) {
        log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", e.getLocalizedMessage()));
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.UnableToDeleteRepository", e.getLocalizedMessage()), e);
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) XulConfirmBox(org.pentaho.ui.xul.components.XulConfirmBox) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) XulComponent(org.pentaho.ui.xul.XulComponent) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Example 20 with RepositoryMeta

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

the class RepositoriesHelper method newRepository.

public void newRepository() {
    PluginRegistry registry = PluginRegistry.getInstance();
    Class<? extends PluginTypeInterface> pluginType = RepositoryPluginType.class;
    List<PluginInterface> plugins = registry.getPlugins(pluginType);
    String[] names = new String[plugins.size()];
    for (int i = 0; i < names.length; i++) {
        PluginInterface plugin = plugins.get(i);
        names[i] = plugin.getName() + " - " + plugin.getDescription();
    }
    // TODO: make this a bit fancier!
    EnterSelectionDialog selectRepositoryType = new EnterSelectionDialog(this.shell, names, BaseMessages.getString(PKG, "RepositoryLogin.SelectRepositoryType"), BaseMessages.getString(PKG, "RepositoryLogin.SelectRepositoryTypeCreate"));
    String choice = selectRepositoryType.openRepoDialog();
    if (choice != null) {
        int index = selectRepositoryType.getSelectionNr();
        PluginInterface plugin = plugins.get(index);
        String id = plugin.getIds()[0];
        try {
            // With this ID we can create a new Repository object...
            // 
            RepositoryMeta repositoryMeta = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, id, RepositoryMeta.class);
            RepositoryDialogInterface dialog = getRepositoryDialog(plugin, repositoryMeta, input, this.shell);
            RepositoryMeta meta = dialog.open(MODE.ADD);
            if (meta != null) {
                // If it does then display a error to the user
                if (meta.getName() != null) {
                    input.addRepository(meta);
                    fillRepositories();
                    model.setSelectedRepository(meta);
                    writeData();
                }
            }
        } catch (Exception e) {
            log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.ErrorCreatingRepository", e.getLocalizedMessage()));
            new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.ErrorCreatingRepository", e.getLocalizedMessage()), e);
        }
    }
}
Also used : RepositoryPluginType(org.pentaho.di.core.plugins.RepositoryPluginType) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException) RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) PluginRegistry(org.pentaho.di.core.plugins.PluginRegistry) RepositoryDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

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