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