Search in sources :

Example 36 with RepositoryObject

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;
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) FileDialogOperation(org.pentaho.di.ui.core.FileDialogOperation)

Example 37 with RepositoryObject

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());
}
Also used : RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryObject(org.pentaho.di.repository.RepositoryObject)

Example 38 with RepositoryObject

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);
}
Also used : Serializable(java.io.Serializable) RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) IUnifiedRepository(org.pentaho.platform.api.repository2.unified.IUnifiedRepository) Test(org.junit.Test)

Example 39 with RepositoryObject

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();
    }
}
Also used : LinkedHashSet(java.util.LinkedHashSet) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) SWTException(org.eclipse.swt.SWTException) KettleRowException(org.pentaho.di.core.exception.KettleRowException) FileSystemException(org.apache.commons.vfs2.FileSystemException) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) KettleValueException(org.pentaho.di.core.exception.KettleValueException) KettleAuthException(org.pentaho.di.core.exception.KettleAuthException) KettleRepositoryLostException(org.pentaho.di.repository.KettleRepositoryLostException) KettleXMLException(org.pentaho.di.core.exception.KettleXMLException) LifecycleException(org.pentaho.di.core.lifecycle.LifecycleException) KettleMissingPluginsException(org.pentaho.di.core.exception.KettleMissingPluginsException) KettleFileException(org.pentaho.di.core.exception.KettleFileException) KettleException(org.pentaho.di.core.exception.KettleException) MalformedURLException(java.net.MalformedURLException) KettlePropertiesFileDialog(org.pentaho.di.ui.core.dialog.KettlePropertiesFileDialog) FileDialog(org.eclipse.swt.widgets.FileDialog) FileDialogOperation(org.pentaho.di.ui.core.FileDialogOperation)

Example 40 with RepositoryObject

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);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryObject(org.pentaho.di.repository.RepositoryObject) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog)

Aggregations

RepositoryObject (org.pentaho.di.repository.RepositoryObject)46 KettleException (org.pentaho.di.core.exception.KettleException)31 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)15 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)11 StringObjectId (org.pentaho.di.repository.StringObjectId)9 ObjectId (org.pentaho.di.repository.ObjectId)7 ArrayList (java.util.ArrayList)6 Date (java.util.Date)6 Test (org.junit.Test)6 KettleFileException (org.pentaho.di.core.exception.KettleFileException)5 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)5 IOException (java.io.IOException)4 FileSystemException (org.apache.commons.vfs2.FileSystemException)4 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)4 FileDialogOperation (org.pentaho.di.ui.core.FileDialogOperation)4 FileObject (org.apache.commons.vfs2.FileObject)3 RowMetaAndData (org.pentaho.di.core.RowMetaAndData)3 RepositoryObjectInterface (org.pentaho.di.repository.RepositoryObjectInterface)3 Serializable (java.io.Serializable)2 List (java.util.List)2