Search in sources :

Example 11 with RepositoryDirectory

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

the class KettleDatabaseRepositoryDirectoryDelegate method createRepositoryDirectory.

/**
 * Create a new directory, possibly by creating several sub-directies of / at the same time.
 *
 * @param parentDirectory
 *          the parent directory
 * @param directoryPath
 *          The path to the new Repository Directory, to be created.
 * @return The created sub-directory
 * @throws KettleException
 *           In case something goes wrong
 */
public RepositoryDirectoryInterface createRepositoryDirectory(RepositoryDirectoryInterface parentDirectory, String directoryPath) throws KettleException {
    // RepositoryDirectoryInterface refreshedParentDir =
    // repository.loadRepositoryDirectoryTree().findDirectory(parentDirectory.getPath());
    RepositoryDirectoryInterface refreshedParentDir = parentDirectory;
    String[] path = Const.splitPath(directoryPath, RepositoryDirectory.DIRECTORY_SEPARATOR);
    RepositoryDirectoryInterface parent = refreshedParentDir;
    for (int level = 0; level < path.length; level++) {
        RepositoryDirectoryInterface rd = parent.findChild(path[level]);
        if (rd == null) {
            // This child directory doesn't exists, let's add it!
            // 
            rd = new RepositoryDirectory(parent, path[level]);
            saveRepositoryDirectory(rd);
            // Don't forget to add this directory to the tree!
            // 
            parent.addSubdirectory(rd);
            parent = rd;
        } else {
            parent = rd;
        }
    }
    return parent;
}
Also used : RepositoryDirectoryInterface(org.pentaho.di.repository.RepositoryDirectoryInterface) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString)

Example 12 with RepositoryDirectory

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

the class KettleDatabaseRepositoryDirectoryDelegate method loadRepositoryDirectory.

public void loadRepositoryDirectory(RepositoryDirectory repositoryDirectory, ObjectId id_directory) throws KettleException {
    if (id_directory == null) {
        // This is the root directory, id = OL
        id_directory = new LongObjectId(0L);
    }
    try {
        RowMetaAndData row = getDirectory(id_directory);
        if (row != null) {
            repositoryDirectory.setObjectId(id_directory);
            // Content?
            // 
            repositoryDirectory.setName(row.getString("DIRECTORY_NAME", null));
            // The sub-directories?
            // 
            ObjectId[] subids = repository.getSubDirectoryIDs(repositoryDirectory.getObjectId());
            for (int i = 0; i < subids.length; i++) {
                RepositoryDirectory subdir = new RepositoryDirectory();
                loadRepositoryDirectory(subdir, subids[i]);
                repositoryDirectory.addSubdirectory(subdir);
            }
        }
    } catch (Exception e) {
        throw new KettleException(BaseMessages.getString(PKG, "Repository.LoadRepositoryDirectory.ErrorLoading.Exception"), e);
    }
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RowMetaAndData(org.pentaho.di.core.RowMetaAndData) RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) LongObjectId(org.pentaho.di.repository.LongObjectId) ObjectId(org.pentaho.di.repository.ObjectId) LongObjectId(org.pentaho.di.repository.LongObjectId) KettleException(org.pentaho.di.core.exception.KettleException)

Example 13 with RepositoryDirectory

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

the class KettleFileRepository method loadRepositoryDirectoryTree.

@Override
public RepositoryDirectoryInterface loadRepositoryDirectoryTree() throws KettleException {
    RepositoryDirectory root = new RepositoryDirectory();
    root.setObjectId(new StringObjectId("/"));
    return loadRepositoryDirectoryTree(root);
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) StringObjectId(org.pentaho.di.repository.StringObjectId)

Example 14 with RepositoryDirectory

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

the class KettleFileRepository method getUserHomeDirectory.

@Override
public RepositoryDirectoryInterface getUserHomeDirectory() throws KettleException {
    RepositoryDirectory root = new RepositoryDirectory();
    root.setObjectId(null);
    return loadRepositoryDirectoryTree(root);
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory)

Example 15 with RepositoryDirectory

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

the class UIEETransformationTest method testRename.

@Test
public void testRename() throws Exception {
    final String newName = "newName";
    RepositoryDirectory repDir = mock(RepositoryDirectory.class);
    uiTransformation.renameTransformation(mockObjectId, repDir, newName);
    verify(mockRevisionService, times(1)).getRevisions(mockObjectId);
}
Also used : RepositoryDirectory(org.pentaho.di.repository.RepositoryDirectory) UIRepositoryDirectory(org.pentaho.di.ui.repository.repositoryexplorer.model.UIRepositoryDirectory) Test(org.junit.Test)

Aggregations

RepositoryDirectory (org.pentaho.di.repository.RepositoryDirectory)57 KettleException (org.pentaho.di.core.exception.KettleException)23 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)15 Test (org.junit.Test)14 TransMeta (org.pentaho.di.trans.TransMeta)11 LongObjectId (org.pentaho.di.repository.LongObjectId)10 ObjectId (org.pentaho.di.repository.ObjectId)9 KettleFileException (org.pentaho.di.core.exception.KettleFileException)8 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)8 Repository (org.pentaho.di.repository.Repository)8 RepositoryElementMetaInterface (org.pentaho.di.repository.RepositoryElementMetaInterface)8 ArrayList (java.util.ArrayList)7 StringObjectId (org.pentaho.di.repository.StringObjectId)7 FileSystemException (org.apache.commons.vfs2.FileSystemException)6 KettleXMLException (org.pentaho.di.core.exception.KettleXMLException)6 ErrorDialog (org.pentaho.di.ui.core.dialog.ErrorDialog)6 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)6 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)5 JobMeta (org.pentaho.di.job.JobMeta)5 TreeItem (org.eclipse.swt.widgets.TreeItem)4