use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class DialogHelper method selectRepositoryObject.
public static RepositoryObject selectRepositoryObject(String filter, LogChannel log) {
try {
FileDialogOperation fileDialogOperation = new FileDialogOperation(FileDialogOperation.OPEN, FileDialogOperation.ORIGIN_OTHER);
if (!Utils.isEmpty(filter)) {
fileDialogOperation.setFilter(filter);
}
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonOpenSaveRepository.id, fileDialogOperation);
return (RepositoryObject) fileDialogOperation.getRepositoryObject();
} catch (KettleException ke) {
// Ignore
}
return null;
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class PurRepository_GetObjectInformation_IT method testDeletedFlagForObject.
private void testDeletedFlagForObject(Callable<RepositoryElementInterface> elementProvider) throws Exception {
TransDelegate transDelegate = new TransDelegate(purRepository, unifiedRepository);
JobDelegate jobDelegate = new JobDelegate(purRepository, unifiedRepository);
FieldUtils.writeField(purRepository, "transDelegate", transDelegate, true);
FieldUtils.writeField(purRepository, "jobDelegate", jobDelegate, true);
RepositoryElementInterface element = elementProvider.call();
RepositoryDirectoryInterface directory = purRepository.findDirectory(element.getRepositoryDirectory().getPath());
element.setRepositoryDirectory(directory);
purRepository.save(element, null, null);
assertNotNull("Element was saved", element.getObjectId());
RepositoryObject information;
information = purRepository.getObjectInformation(element.getObjectId(), element.getRepositoryElementType());
assertNotNull(information);
assertFalse(information.isDeleted());
purRepository.deleteTransformation(element.getObjectId());
assertNotNull("Element was moved to Trash", unifiedRepository.getFileById(element.getObjectId().getId()));
information = purRepository.getObjectInformation(element.getObjectId(), element.getRepositoryElementType());
assertNotNull(information);
assertTrue(information.isDeleted());
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class PurRepository_GetObjectInformation_IT method getObjectInformation_InvalidRepositoryId_NullIsHandled.
@Test
public void getObjectInformation_InvalidRepositoryId_NullIsHandled() throws Exception {
IUnifiedRepository unifiedRepository = mock(IUnifiedRepository.class);
when(unifiedRepository.getFileById(any(Serializable.class))).thenReturn(null);
purRepository.setTest(unifiedRepository);
RepositoryObject information = purRepository.getObjectInformation(new StringObjectId("invalid id"), RepositoryObjectType.JOB);
assertNull("Should return null if file was not found", information);
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class Spoon method openFile.
public void openFile(boolean importfile) {
try {
SpoonPerspective activePerspective = SpoonPerspectiveManager.getInstance().getActivePerspective();
//
if (!importfile) {
if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
((SpoonPerspectiveOpenSaveInterface) activePerspective).open();
return;
}
}
String activePerspectiveId = activePerspective.getId();
boolean etlPerspective = activePerspectiveId.equals(MainSpoonPerspective.ID);
if (rep == null || importfile || !etlPerspective) {
// Load from XML
FileDialog dialog = new FileDialog(shell, SWT.OPEN);
LinkedHashSet<String> extensions = new LinkedHashSet<>();
LinkedHashSet<String> extensionNames = new LinkedHashSet<>();
StringBuilder allExtensions = new StringBuilder();
for (FileListener l : fileListeners) {
for (String ext : l.getSupportedExtensions()) {
extensions.add("*." + ext);
allExtensions.append("*.").append(ext).append(";");
}
Collections.addAll(extensionNames, l.getFileTypeDisplayNames(Locale.getDefault()));
}
extensions.add("*");
extensionNames.add(BaseMessages.getString(PKG, "Spoon.Dialog.OpenFile.AllFiles"));
String[] exts = new String[extensions.size() + 1];
exts[0] = allExtensions.toString();
System.arraycopy(extensions.toArray(new String[extensions.size()]), 0, exts, 1, extensions.size());
String[] extNames = new String[extensionNames.size() + 1];
extNames[0] = BaseMessages.getString(PKG, "Spoon.Dialog.OpenFile.AllTypes");
System.arraycopy(extensionNames.toArray(new String[extensionNames.size()]), 0, extNames, 1, extensionNames.size());
dialog.setFilterExtensions(exts);
setFilterPath(dialog);
String filename = dialog.open();
if (filename != null) {
if (importfile) {
if (activePerspective instanceof SpoonPerspectiveOpenSaveInterface) {
((SpoonPerspectiveOpenSaveInterface) activePerspective).importFile(filename);
return;
}
}
lastDirOpened = dialog.getFilterPath();
openFile(filename, importfile);
}
} else {
try {
FileDialogOperation fileDialogOperation = new FileDialogOperation(FileDialogOperation.OPEN, FileDialogOperation.ORIGIN_SPOON);
ExtensionPointHandler.callExtensionPoint(log, KettleExtensionPoint.SpoonOpenSaveRepository.id, fileDialogOperation);
if (fileDialogOperation.getRepositoryObject() != null) {
RepositoryObject repositoryObject = (RepositoryObject) fileDialogOperation.getRepositoryObject();
loadObjectFromRepository(repositoryObject.getObjectId(), repositoryObject.getObjectType(), null);
}
} catch (Exception e) {
// Ignore
}
}
} catch (KettleRepositoryLostException krle) {
new ErrorDialog(getShell(), BaseMessages.getString(PKG, "Spoon.Error"), krle.getPrefaceMessage(), krle);
this.closeRepository();
}
}
use of org.pentaho.di.repository.RepositoryObject in project pentaho-kettle by pentaho.
the class BaseStreamingDialog method getByReferenceData.
private void getByReferenceData(ObjectId transObjectId) {
try {
RepositoryObject transInf = repository.getObjectInformation(transObjectId, RepositoryObjectType.TRANSFORMATION);
String path = DialogUtils.getPath(transMeta.getRepositoryDirectory().getPath(), transInf.getRepositoryDirectory().getPath());
String fullPath = Const.NVL(path, "") + "/" + Const.NVL(transInf.getName(), "");
wTransPath.setText(fullPath);
} catch (KettleException e) {
new ErrorDialog(shell, BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Title"), BaseMessages.getString(PKG, "JobEntryTransDialog.Exception.UnableToReferenceObjectId.Message"), e);
}
}
Aggregations