Search in sources :

Example 46 with RepositoryMeta

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

the class PurRepositoryProxy method setLocationUrl.

public void setLocationUrl(String locationUrl) {
    RepositoryMeta repositoryMeta = this.createPurRepositoryMetaRepositoryMeta(locationUrl);
    this.getDelegate().init(repositoryMeta);
    this.locationUrl = locationUrl;
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta)

Example 47 with RepositoryMeta

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

the class PurRepositoryProxyTest method createPurRepositoryMetaRepositoryMetaTest.

@Test
public void createPurRepositoryMetaRepositoryMetaTest() {
    RepositoryMeta repositoryMeta = null;
    try {
        Mockito.<Class<?>>when(mockClassLoader.loadClass("org.pentaho.di.repository.pur" + ".PurRepositoryLocation")).thenReturn(Class.forName("org.pentaho.di.repository.pur" + ".PurRepositoryLocation"));
        Mockito.<Class<?>>when(mockClassLoader.loadClass("org.pentaho.di.repository.pur.PurRepositoryMeta")).thenReturn(Class.forName("org.pentaho.di.repository.pur.PurRepositoryMeta"));
    } catch (ClassNotFoundException e) {
        e.printStackTrace();
    }
    repositoryMeta = proxy.createPurRepositoryMetaRepositoryMeta("SomeUrl");
    assertNotNull(repositoryMeta);
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) Test(org.junit.Test)

Example 48 with RepositoryMeta

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

the class JobEntryConnectedToRepositoryDialog method getListRepositories.

/**
 * Get a list of repositories defined in this system, allow the user to select from it.
 */
private void getListRepositories() {
    RepositoriesMeta reps_info = null;
    try {
        reps_info = new RepositoriesMeta();
        try {
            reps_info.readData();
            int nrRepositories = reps_info.nrRepositories();
            if (nrRepositories == 0) {
                displayMsg(BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobEntryConnectedToRepositoryDialog.Error.NoRep.DialogMessage"), true);
            } else {
                String[] available = new String[nrRepositories];
                for (int i = 0; i < nrRepositories; i++) {
                    RepositoryMeta ri = reps_info.getRepository(i);
                    available[i] = ri.getName();
                }
                String[] source = new String[1];
                source[0] = wRepName.getText();
                int[] idxSource = Const.indexsOfStrings(source, available);
                EnterSelectionDialog dialog = new EnterSelectionDialog(shell, available, BaseMessages.getString(PKG, "JobEntryConnectedToRepositoryDialog.SelectRepository.Title"), BaseMessages.getString(PKG, "JobEntryConnectedToRepositoryDialog.SelectRepository.Message"));
                dialog.setMulti(false);
                dialog.setAvoidQuickSearch();
                dialog.setSelectedNrs(idxSource);
                if (dialog.open() != null) {
                    int[] idx = dialog.getSelectionIndeces();
                    wRepName.setText(available[idx[0]]);
                }
            }
        } catch (Exception e) {
            displayMsg(BaseMessages.getString(PKG, "JobEntryConnectedToRepositoryDialog.Error.NoRepsDefined"), BaseMessages.getString(PKG, "JobEntryConnectedToRepositoryDialog.Error.NoRepsDefinedMsg"), true);
        }
    } catch (Exception e) {
        displayMsg(BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobEntryConnectedToRepositoryDialog.ErrorGettingRepositories.DialogMessage") + Const.CR + ":" + e.getMessage(), true);
    } finally {
        reps_info.clear();
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta) EnterSelectionDialog(org.pentaho.di.ui.core.dialog.EnterSelectionDialog)

Example 49 with RepositoryMeta

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

the class JobEntryExportRepositoryDialog method displaydirectoryList.

private void displaydirectoryList() {
    RepositoriesMeta repositoriesMeta = null;
    RepositoryMeta repositoryMeta = null;
    Repository repos = null;
    try {
        repositoriesMeta = new RepositoriesMeta();
        repositoriesMeta.readData();
        repositoryMeta = repositoriesMeta.findRepository(jobMeta.environmentSubstitute(wRepositoryname.getText()));
        if (repositoryMeta == null) {
            // Can not find repository
            displayMsg(BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotFindRep"), BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotFindRepMsg", wRepositoryname.getText()), true);
        }
        repos = PluginRegistry.getInstance().loadClass(RepositoryPluginType.class, repositoryMeta, Repository.class);
        repos.init(repositoryMeta);
        try {
            repos.connect(jobMeta.environmentSubstitute(wUserName.getText()), jobMeta.environmentSubstitute(wPassword.getText()));
        } catch (Exception e) {
            displayMsg(BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotConnect"), BaseMessages.getString(PKG, "JobExportRepository.Error.CanNotConnectMsg", wRepositoryname.getText()), true);
        }
        if (repos.isConnected()) {
            try {
                FileDialogOperation fileDialogOperation = new FileDialogOperation(FileDialogOperation.SELECT_FOLDER, FileDialogOperation.ORIGIN_SPOON);
                fileDialogOperation.setTitle(BaseMessages.getString(PKG, "JobExportRepository.SelectDirectoryDialog.Title"));
                fileDialogOperation.setFilter(null);
                fileDialogOperation.setRepository(repos);
                if (!Utils.isEmpty(wFoldername.getText())) {
                    fileDialogOperation.setStartDir(wFoldername.getText());
                }
                ExtensionPointHandler.callExtensionPoint(null, KettleExtensionPoint.SpoonOpenSaveRepository.id, fileDialogOperation);
                if (fileDialogOperation.getRepositoryObject() != null) {
                    String path = ((RepositoryObject) fileDialogOperation.getRepositoryObject()).getRepositoryDirectory().getPath();
                    wFoldername.setText(path);
                }
            } catch (KettleException e) {
            // Do Nothing
            }
        }
    } catch (Exception e) {
        displayMsg(BaseMessages.getString(PKG, "System.Dialog.Error.Title"), BaseMessages.getString(PKG, "JobExportRepository.ErrorGettingFolderds.DialogMessage") + Const.CR + ":" + e.getMessage(), true);
    } finally {
        if (repos != null) {
            repos.disconnect();
            repos = null;
        }
        if (repositoryMeta != null) {
            repositoryMeta = null;
        }
        repositoriesMeta.clear();
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) KettleException(org.pentaho.di.core.exception.KettleException) JobEntryExportRepository(org.pentaho.di.job.entries.exportrepository.JobEntryExportRepository) Repository(org.pentaho.di.repository.Repository) RepositoryPluginType(org.pentaho.di.core.plugins.RepositoryPluginType) RepositoriesMeta(org.pentaho.di.repository.RepositoriesMeta) KettleException(org.pentaho.di.core.exception.KettleException) FileDialogOperation(org.pentaho.di.ui.core.FileDialogOperation)

Example 50 with RepositoryMeta

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

the class RepositoriesHelper method editRepository.

public void editRepository() {
    try {
        PluginInterface plugin = null;
        RepositoryMeta ri = input.searchRepository(model.getSelectedRepository().getName());
        if (ri != null) {
            plugin = PluginRegistry.getInstance().getPlugin(RepositoryPluginType.class, ri.getId());
            if (plugin == null) {
                throw new KettleException(BaseMessages.getString(PKG, "RepositoryLogin.ErrorFindingPlugin", ri.getId()));
            }
        }
        RepositoryDialogInterface dd = getRepositoryDialog(plugin, ri, input, this.shell);
        if (dd.open(MODE.EDIT) != null) {
            fillRepositories();
            int idx = input.indexOfRepository(ri);
            model.setSelectedRepository(input.getRepository(idx));
            writeData();
        }
    } catch (Exception e) {
        log.logDetailed(BaseMessages.getString(PKG, "RepositoryLogin.ErrorEditingRepository", e.getLocalizedMessage()));
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Dialog.Error"), BaseMessages.getString(PKG, "RepositoryLogin.ErrorEditingRepository", e.getLocalizedMessage()), e);
    }
}
Also used : RepositoryMeta(org.pentaho.di.repository.RepositoryMeta) KettleException(org.pentaho.di.core.exception.KettleException) RepositoryPluginType(org.pentaho.di.core.plugins.RepositoryPluginType) PluginInterface(org.pentaho.di.core.plugins.PluginInterface) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) RepositoryDialogInterface(org.pentaho.di.ui.repository.dialog.RepositoryDialogInterface) KettleException(org.pentaho.di.core.exception.KettleException) KettleSecurityException(org.pentaho.di.core.exception.KettleSecurityException)

Aggregations

RepositoryMeta (org.pentaho.di.repository.RepositoryMeta)53 KettleException (org.pentaho.di.core.exception.KettleException)31 Repository (org.pentaho.di.repository.Repository)21 RepositoriesMeta (org.pentaho.di.repository.RepositoriesMeta)16 Test (org.junit.Test)10 RepositoryPluginType (org.pentaho.di.core.plugins.RepositoryPluginType)10 UnknownParamException (org.pentaho.di.core.parameters.UnknownParamException)6 Date (java.util.Date)5 HashMap (java.util.HashMap)5 Matchers.anyString (org.mockito.Matchers.anyString)5 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)5 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)5 PluginRegistry (org.pentaho.di.core.plugins.PluginRegistry)5 KettleFileRepositoryMeta (org.pentaho.di.repository.filerep.KettleFileRepositoryMeta)5 ArrayList (java.util.ArrayList)4 JSONObject (org.json.simple.JSONObject)4 BaseRepositoryMeta (org.pentaho.di.repository.BaseRepositoryMeta)4 IOException (java.io.IOException)3 KettleStepException (org.pentaho.di.core.exception.KettleStepException)3 PluginInterface (org.pentaho.di.core.plugins.PluginInterface)3