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