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;
}
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);
}
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();
}
}
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();
}
}
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);
}
}
Aggregations