Search in sources :

Example 26 with RepositoryDirectoryInterface

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

the class UIEERepositoryDirectoryIT method testUiDeleteNotEmpty.

@Test
public void testUiDeleteNotEmpty() throws Exception {
    RepositoryDirectoryInterface rootDir = repository.loadRepositoryDirectoryTree();
    final String startDirName = "home";
    final String testDirName = "testdir";
    final String testDir2Name = "testdir2";
    final String startDirPath = "/" + startDirName;
    final String testDirPath = startDirPath + "/" + testDirName;
    final String testDir2Path = testDirPath + "/" + testDir2Name;
    RepositoryDirectoryInterface startDir = rootDir.findDirectory(startDirName);
    final RepositoryDirectoryInterface testDirCreated = repository.createRepositoryDirectory(startDir, testDirName);
    final RepositoryDirectoryInterface testDir2Created = repository.createRepositoryDirectory(testDirCreated, testDir2Name);
    assertNotNull(testDirCreated);
    assertNotNull(testDirCreated.getObjectId());
    assertNotNull(testDir2Created);
    rootDir = repository.loadRepositoryDirectoryTree();
    startDir = rootDir.findDirectory(startDirName);
    final RepositoryDirectoryInterface startDirFound = repository.findDirectory(startDirPath);
    final RepositoryDirectoryInterface testDirFound = repository.findDirectory(testDirPath);
    Assert.assertNotNull(testDirFound);
    final RepositoryDirectoryInterface testDir2Found = repository.findDirectory(testDir2Path);
    Assert.assertNotNull(testDir2Found);
    final UIEERepositoryDirectory startDirUi = new UIEERepositoryDirectory(startDirFound, null, repository);
    final UIEERepositoryDirectory testDirUi = new UIEERepositoryDirectory(testDirFound, startDirUi, repository);
    testDirUi.delete(true);
    RepositoryDirectoryInterface testDirFound2 = repository.findDirectory(testDirPath);
    Assert.assertNull(testDirFound2);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Test(org.junit.Test)

Example 27 with RepositoryDirectoryInterface

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

the class PurRepositoryIT method loadStartDirectory.

@Override
protected RepositoryDirectoryInterface loadStartDirectory() throws Exception {
    RepositoryDirectoryInterface rootDir = repository.loadRepositoryDirectoryTree();
    RepositoryDirectoryInterface startDir = rootDir.findDirectory("public");
    assertNotNull(startDir);
    return startDir;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface)

Example 28 with RepositoryDirectoryInterface

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

the class PurRepositoryIT method testCreateRepositoryDirectory.

@Test
public void testCreateRepositoryDirectory() throws KettleException {
    RepositoryDirectoryInterface tree = repository.loadRepositoryDirectoryTree();
    repository.createRepositoryDirectory(tree.findDirectory("home"), "/admin1");
    repository.createRepositoryDirectory(tree, "/home/admin2");
    repository.createRepositoryDirectory(tree, "/home/admin2/new1");
    RepositoryDirectoryInterface repositoryDirectory = repository.createRepositoryDirectory(tree, "/home/admin2/new1");
    repository.getJobAndTransformationObjects(repositoryDirectory.getObjectId(), false);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Test(org.junit.Test)

Example 29 with RepositoryDirectoryInterface

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

the class JobGeneratorTest method setUp.

@Before
public void setUp() throws Exception {
    final StarDomain starDomain = mock(StarDomain.class);
    final Domain domain = mock(Domain.class);
    when(domain.getProperty(eq(DefaultIDs.DOMAIN_TARGET_DATABASE))).thenReturn("test_domain_target_db");
    when(starDomain.getDomain()).thenReturn(domain);
    final Repository repository = mock(Repository.class);
    final RepositoryDirectoryInterface targetDirectory = mock(RepositoryDirectoryInterface.class);
    final DatabaseMeta meta = Mockito.mock(DatabaseMeta.class);
    Mockito.when(meta.getName()).thenReturn("test_domain_target_db");
    final LinkedList<DatabaseMeta> databases = new LinkedList<DatabaseMeta>() {

        {
            add(meta);
        }
    };
    final String locale = Locale.US.toString();
    jobGenerator = new JobGenerator(starDomain, repository, targetDirectory, databases, locale);
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) Repository(org.pentaho.di.repository.Repository) StarDomain(org.pentaho.di.starmodeler.StarDomain) Domain(org.pentaho.metadata.model.Domain) StarDomain(org.pentaho.di.starmodeler.StarDomain) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) LinkedList(java.util.LinkedList) Before(org.junit.Before)

Example 30 with RepositoryDirectoryInterface

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

the class TrashBrowseController method undelete.

public void undelete() {
    // make a copy because the selected trash items changes as soon as trashService.undelete is called
    List<UIDeletedObject> selectedTrashFileItemsSnapshot = new ArrayList<UIDeletedObject>(selectedTrashFileItems);
    if (selectedTrashFileItemsSnapshot != null && selectedTrashFileItemsSnapshot.size() > 0) {
        List<ObjectId> ids = new ArrayList<ObjectId>();
        for (UIDeletedObject uiObj : selectedTrashFileItemsSnapshot) {
            ids.add(uiObj.getId());
        }
        try {
            trashService.undelete(ids);
            setTrash(trashService.getTrash());
            for (UIDeletedObject uiObj : selectedTrashFileItemsSnapshot) {
                // find the closest UIRepositoryDirectory that is in the dirMap
                RepositoryDirectoryInterface dir = repository.findDirectory(uiObj.getOriginalParentPath());
                while (dir != null && dirMap.get(dir.getObjectId()) == null) {
                    dir = dir.getParent();
                }
                // now refresh that UIRepositoryDirectory so that the file/folders deck instantly refreshes on undelete
                if (dir != null) {
                    dirMap.get(dir.getObjectId()).refresh();
                }
                // if transformation or directory with transformations call extension to restore data services references.
                if (RepositoryObjectType.TRANSFORMATION.name().equals(uiObj.getType())) {
                    TransMeta transMeta = repository.loadTransformation(uiObj.getId(), null);
                    ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta);
                    transMeta.clearChanged();
                } else if (!RepositoryObjectType.JOB.name().equals(uiObj.getType())) {
                    // if not a transformation and not a job then is a Directory
                    RepositoryDirectoryInterface actualDir = repository.findDirectory(uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName());
                    if (actualDir != null) {
                        List<RepositoryElementMetaInterface> transformations = new ArrayList<>();
                        getAllTransformations(actualDir, transformations);
                        for (RepositoryElementMetaInterface repositoryElementMetaInterface : transformations) {
                            TransMeta transMeta = repository.loadTransformation(repositoryElementMetaInterface.getObjectId(), null);
                            ExtensionPointHandler.callExtensionPoint(LogChannel.GENERAL, KettleExtensionPoint.TransAfterOpen.id, transMeta);
                            transMeta.clearChanged();
                        }
                    } else {
                        displayExceptionMessage(BaseMessages.getString(PKG, "TrashBrowseController.UnableToRestoreDirectory", uiObj.getOriginalParentPath() + RepositoryDirectory.DIRECTORY_SEPARATOR + uiObj.getName()));
                    }
                }
            }
            deck.setSelectedIndex(1);
        } catch (Throwable th) {
            if (mainController == null || !mainController.handleLostRepository(th)) {
                displayExceptionMessage(BaseMessages.getString(PKG, "TrashBrowseController.UnableToRestoreFile", // $NON-NLS-1$
                th.getLocalizedMessage()));
            }
        }
    } else {
        // ui probably allowed the button to be enabled when it shouldn't have been enabled
        throw new RuntimeException();
    }
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) ObjectId(org.pentaho.di.repository.ObjectId) ArrayList(java.util.ArrayList) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) List(java.util.List) RepositoryElementMetaInterface(org.pentaho.di.repository.RepositoryElementMetaInterface)

Aggregations

RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)163 KettleException (org.pentaho.di.core.exception.KettleException)68 Test (org.junit.Test)32 TransMeta (org.pentaho.di.trans.TransMeta)30 ObjectId (org.pentaho.di.repository.ObjectId)27 JobMeta (org.pentaho.di.job.JobMeta)23 Repository (org.pentaho.di.repository.Repository)22 ArrayList (java.util.ArrayList)17 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)17 RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)15 IOException (java.io.IOException)14 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)13 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)11 RepositoryObject (org.pentaho.di.repository.RepositoryObject)11 FileObject (org.apache.commons.vfs2.FileObject)10 List (java.util.List)8 TreeItem (org.eclipse.swt.widgets.TreeItem)8 KettleFileException (org.pentaho.di.core.exception.KettleFileException)8 Date (java.util.Date)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)7